Class: Papa::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue) ⇒ Runner

Returns a new instance of Runner.



5
6
7
# File 'lib/papa/runner.rb', line 5

def initialize(queue)
  @queue = queue || []
end

Instance Attribute Details

#last_commandObject

Returns the value of attribute last_command.



3
4
5
# File 'lib/papa/runner.rb', line 3

def last_command
  @last_command
end

#last_errorObject

Returns the value of attribute last_error.



3
4
5
# File 'lib/papa/runner.rb', line 3

def last_error
  @last_error
end

#queueObject

Returns the value of attribute queue.



3
4
5
# File 'lib/papa/runner.rb', line 3

def queue
  @queue
end

#successObject

Returns the value of attribute success.



3
4
5
# File 'lib/papa/runner.rb', line 3

def success
  @success
end

Instance Method Details

#runObject



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

def run
  @success = true
  message = nil
  @queue.each do |command|
    if command.run.failed?
      @success = false
      command.cleanup
      @last_error = command.failure_message
      break
    end
  end
  @success
end