From 6dc3587e463ce21978f82f43a2a9743b74e9d5ec Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Sat, 19 Mar 2016 18:39:57 +0100 Subject: [PATCH] Make Cangallo a class instead of a module --- bin/canga | 10 ++++------ lib/cangallo/cangafile.rb | 2 +- lib/cangallo/config.rb | 4 ++-- lib/cangallo/keybase.rb | 2 +- lib/cangallo/libguestfs.rb | 2 +- lib/cangallo/qcow2.rb | 2 +- lib/cangallo/repo.rb | 2 +- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/bin/canga b/bin/canga index aa29632..ee86cd3 100755 --- a/bin/canga +++ b/bin/canga @@ -13,9 +13,7 @@ require "tempfile" require "pp" -include Cangallo - -$config = Config.new +$config = Cangallo::Config.new class Canga < Thor class_option :repo, :desc => 'repository to use' @@ -24,7 +22,7 @@ class Canga < Thor option :parent, :desc => "id of the parent image" def create(file, size=nil) puts [file, size] - Qcow2.create(file, options[:parent], size) + Cangallo::Qcow2.create(file, options[:parent], size) end desc "add FILE", "add a new file to the repository" @@ -113,7 +111,7 @@ class Canga < Thor path = File.expand_path(repo.image_path(sha256)) - Qcow2.create_from_base(path, file) + Cangallo::Qcow2.create_from_base(path, file) end desc "build CANGAFILE", "create a new image using a Cangafile" @@ -136,7 +134,7 @@ class Canga < Thor temp_image = Tempfile.new([File.basename(file), '.qcow2'], repo.path) temp_image.close - Qcow2.create_from_base(parent_path, temp_image.path) + Cangallo::Qcow2.create_from_base(parent_path, temp_image.path) rc = LibGuestfs.virt_customize(temp_image.path, cangafile.libguestfs_commands) exit(-1) if !rc diff --git a/lib/cangallo/cangafile.rb b/lib/cangallo/cangafile.rb index 8d7a743..4d42d12 100644 --- a/lib/cangallo/cangafile.rb +++ b/lib/cangallo/cangafile.rb @@ -7,7 +7,7 @@ require 'fileutils' require 'yaml' -module Cangallo +class Cangallo class Cangafile attr_accessor :data diff --git a/lib/cangallo/config.rb b/lib/cangallo/config.rb index 68678f3..713bf9a 100644 --- a/lib/cangallo/config.rb +++ b/lib/cangallo/config.rb @@ -2,7 +2,7 @@ require 'fileutils' require 'yaml' -module Cangallo +class Cangallo class Config CONFIG_DIR = '.cangallo' CONFIG_FILE = 'config.yaml' @@ -17,7 +17,7 @@ class Config def initialize create_config_dir - create_default_config + create_default_config load_conf end diff --git a/lib/cangallo/keybase.rb b/lib/cangallo/keybase.rb index e48ba5f..c227f86 100644 --- a/lib/cangallo/keybase.rb +++ b/lib/cangallo/keybase.rb @@ -1,7 +1,7 @@ # vim:tabstop=2:sw=2:et: -module Cangallo +class Cangallo module Keybase def self.sign(file) diff --git a/lib/cangallo/libguestfs.rb b/lib/cangallo/libguestfs.rb index 7317ca3..7eb2958 100644 --- a/lib/cangallo/libguestfs.rb +++ b/lib/cangallo/libguestfs.rb @@ -6,7 +6,7 @@ require 'tempfile' require 'fileutils' -module Cangallo +class Cangallo class LibGuestfs def self.virt_customize(image, commands) diff --git a/lib/cangallo/qcow2.rb b/lib/cangallo/qcow2.rb index 515628f..6e33ccc 100644 --- a/lib/cangallo/qcow2.rb +++ b/lib/cangallo/qcow2.rb @@ -6,7 +6,7 @@ require 'tempfile' require 'fileutils' -module Cangallo +class Cangallo class Qcow2 attr_reader :path diff --git a/lib/cangallo/repo.rb b/lib/cangallo/repo.rb index 1b0e38d..207ed53 100644 --- a/lib/cangallo/repo.rb +++ b/lib/cangallo/repo.rb @@ -5,7 +5,7 @@ # vim:ts=2:sw=2 -module Cangallo +class Cangallo class Repo attr_reader :images, :tags, :path, :name