Class: Honkdo::Commander

Inherits:
Object
  • Object
show all
Defined in:
lib/honkdo/commander.rb

Instance Method Summary collapse

Constructor Details

#initializeCommander

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_fileObject



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_filesObject



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

#runObject



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