Sha256: 91a18e9cb8650a46c0f1e0a69b4d228a88314be4e0b08b4b881e18b02448b1d7
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
module Shaddox class Config # Init ============================================== attr_accessor :tasks def initialize(doxfile) doxfile = './Doxfile' unless doxfile if !File.exists?(doxfile) puts "Doxfile could not be found.".red exit(1) end @tasks = Hash.new instance_eval(File.read(doxfile), doxfile) end # Methods ============================================ def invoke(task_key, opts) begin task = @tasks[task_key.to_sym] return if task.done task.deps.each { |dep| invoke(dep, opts) } info "[#{task_key}] Starting..." Provisioner.new(task.block, opts) task.done = true info "[#{task_key}] Done".green rescue => e err "[#{task_key}] Failed".red puts e.message.red e.backtrace.each { |line| puts line } end end ## DSL Methods ## # ### Add a task # key can be bound to a list to define dependencies, like with Rake # task :example => :some_dep do ... # task :example => [:dep1, :dep2] do ... def task(arg, &block) if arg.is_a? Hash fail "Task Argument Error" if arg.size != 1 key, deps = arg.map { |k, v| [k, v] }.first @tasks[key] = Task.new(block, deps) else fail "Task Argument Error" if !arg.is_a? Symbol @tasks[arg] = Task.new(block, []) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shaddox-0.1.0 | lib/shaddox/config.rb |