Class: Honkdo::Commander
- Inherits:
-
Object
- Object
- Honkdo::Commander
- Defined in:
- lib/honkdo/commander.rb
Instance Method Summary collapse
- #extend_step(name, &blk) ⇒ Object
-
#initialize ⇒ Commander
constructor
A new instance of Commander.
- #load_user_file ⇒ Object
- #load_workflow_files ⇒ Object
- #run ⇒ Object
- #step(name, &blk) ⇒ Object
Constructor Details
#initialize ⇒ Commander
Returns a new instance of Commander.
5 6 7 8 9 10 11 |
# File 'lib/honkdo/commander.rb', line 5 def initialize @closures = {} @workflow = [:grep, :extract, :prune, :sanitize, :tag, :prioritize, :sort, :print] load_workflow_files load_user_file end |
Instance Method Details
#extend_step(name, &blk) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/honkdo/commander.rb', line 17 def extend_step name, &blk old_step = @closures[name] step(name) do |values| blk.call(values, old_step) end end |
#load_user_file ⇒ Object
37 38 39 40 |
# File 'lib/honkdo/commander.rb', line 37 def load_user_file user_file = ".honkdo" load_file user_file if File.exists? user_file end |
#load_workflow_files ⇒ Object
30 31 32 33 34 35 |
# File 'lib/honkdo/commander.rb', line 30 def load_workflow_files path = File.dirname(__FILE__) @workflow.each do |step| load_file(path + "/steps/#{step}.rb") end end |
#run ⇒ Object
24 25 26 27 28 |
# File 'lib/honkdo/commander.rb', line 24 def run @workflow.inject([]) do |values, closure| @closures[closure].call(values) end end |
#step(name, &blk) ⇒ Object
13 14 15 |
# File 'lib/honkdo/commander.rb', line 13 def step name, &blk @closures[name] = blk end |