Class: Dramaturg::Runner::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dramaturg/runner/base.rb

Direct Known Subclasses

Print, Shell, Thor

Instance Method Summary collapse

Constructor Details

#initialize(script, config = {}) ⇒ Base

Returns a new instance of Base.



3
4
5
6
# File 'lib/dramaturg/runner/base.rb', line 3

def initialize(script,config={})
  @script = script
  @last_success = true
end

Instance Method Details

#call(cmd) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dramaturg/runner/base.rb', line 8

def call(cmd)
  unless cmd.skipped?
    line = cmd.map { |v| v.for_run }.join('')

    cmd.ran = line
    _call(line, cmd)

    if !cmd.ok? && !cmd.fail_ok
      handle_fail(cmd)
    end
  end

  @last_success = (cmd.success? && !cmd.skipped?)
end

#handle_fail(cmd) ⇒ Object

Raises:

  • (RuntimeError)


28
29
30
# File 'lib/dramaturg/runner/base.rb', line 28

def handle_fail(cmd)
  raise RuntimeError, "#{cmd.ran} failed"
end

#last_success?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/dramaturg/runner/base.rb', line 23

def last_success?
  @last_success
end