Class: WIP::Runner::Shell::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/wip/runner/shell/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, &block) ⇒ Task

Returns a new instance of Task.



7
8
9
10
11
12
13
# File 'lib/wip/runner/shell/task.rb', line 7

def initialize(command, &block)
  @command  = command
  @configs  = []
  @shells   = []
  @children = []
  @block    = block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (protected)



33
34
35
36
37
38
39
40
41
42
# File 'lib/wip/runner/shell/task.rb', line 33

def method_missing(method_name, *args, &block)
  if @command.respond_to?(method_name)
    @command.send(method_name, *args, &block)
  else
    # super
    @command.instance_eval {
      method_missing(method_name, *args, &block)
    }
  end
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



5
6
7
# File 'lib/wip/runner/shell/task.rb', line 5

def children
  @children
end

#configsObject (readonly)

Returns the value of attribute configs.



5
6
7
# File 'lib/wip/runner/shell/task.rb', line 5

def configs
  @configs
end

#shellsObject (readonly)

Returns the value of attribute shells.



5
6
7
# File 'lib/wip/runner/shell/task.rb', line 5

def shells
  @shells
end

Instance Method Details

#build(arguments, options) ⇒ Object



15
16
17
# File 'lib/wip/runner/shell/task.rb', line 15

def build(arguments, options)
  self.instance_exec(arguments, options, &@block) ; self
end

#config(term, options = {}) ⇒ Object



19
20
21
# File 'lib/wip/runner/shell/task.rb', line 19

def config(term, options = {})
  @configs << [term.to_s, options] # Config.new(...)
end

#shell(handler, content, &block) ⇒ Object



23
24
25
# File 'lib/wip/runner/shell/task.rb', line 23

def shell(handler, content, &block)
  shells << Handlers.locate(handler).new(content, &block)
end

#task(&block) ⇒ Object



27
28
29
# File 'lib/wip/runner/shell/task.rb', line 27

def task(&block)
  children << Task.new(@command, &block)
end