Sha256: cdaf0f1973cc3ec8997624e864915ca8a0de08aabb91d2d0921cb03431ebb312
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
require 'yaml' require 'English' require 'fileutils' ## # Dock0 provides an interface for building Arch images module Dock0 class << self ## # Insert a helper .new() method for creating a new Dock0 object def new(*args) Dock0::Image.new(*args) end ## # Helper for simplifying object creation def easy_mode(type, args) Dir.chdir File.dirname(args.first) const_get(type).new(*args).easy_mode end end ## # Base class for common methods class Base attr_reader :config def initialize(*configs) @config = configs.each_with_object(default_config) do |path, obj| new = YAML.load(File.read(path)) next unless new obj.merge! new end @paths = @config['paths'] end def default_config { 'paths' => { 'scripts' => './scripts' } } end def run(cmd) results = `#{cmd} 2>&1` return results if $CHILD_STATUS.success? fail "Failed running #{cmd}:\n#{results}" end def run_script(script) Dir.chdir('.') { instance_eval File.read(script), script, 0 } end def run_scripts Dir.glob(@paths['scripts'] + '/*.rb').sort.each do |script| puts "Running #{script}" run_script script end end def cleanup(list) puts "Removing: #{list.join(', ')}" FileUtils.rm_rf list end end end require 'dock0/version' require 'dock0/image' require 'dock0/config'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dock0-0.2.2 | lib/dock0.rb |
dock0-0.2.1 | lib/dock0.rb |