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, *args, &block) ⇒ Task

Returns a new instance of Task.



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

def initialize(command, *args, &block)
  @command = command
  @configs = []
  @shells  = []
  @steps   = []
  @heading = args.first unless args.empty?
  @block   = block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



38
39
40
41
42
43
44
45
46
# File 'lib/wip/runner/shell/task.rb', line 38

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

Instance Attribute Details

#configsObject (readonly)

Returns the value of attribute configs.



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

def configs
  @configs
end

#headingObject (readonly)

Returns the value of attribute heading.



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

def heading
  @heading
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

#stepsObject (readonly)

Returns the value of attribute steps.



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

def steps
  @steps
end

Instance Method Details

#build(arguments, options) ⇒ Object



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

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

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



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

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

#heading?Boolean

Returns:

  • (Boolean)


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

def heading?
  !! @heading
end

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



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

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

#task(*args, &block) ⇒ Object



32
33
34
# File 'lib/wip/runner/shell/task.rb', line 32

def task(*args, &block)
  steps << Task.new(@command, *args, &block)
end