Class: Jive::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



7
8
9
# File 'lib/jive/runner.rb', line 7

def initialize
  @results = []
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

Instance Method Details

#all_stderr_empty?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/jive/runner.rb', line 29

def all_stderr_empty?
  results.all? { |result| result.stderr.empty? }
end

#all_success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/jive/runner.rb', line 25

def all_success?
  results.all? { |result| result.status.success? }
end

#all_success_and_clean?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/jive/runner.rb', line 21

def all_success_and_clean?
  all_success? && all_stderr_empty?
end

#failed_resultsObject



33
34
35
# File 'lib/jive/runner.rb', line 33

def failed_results
  results.reject { |result| result.status.success? }
end

#run(commands, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/jive/runner.rb', line 11

def run(commands, &block)
  commands.each do |command|
    block.call(command) do
      cmd_result = Popen.popen_with_detail(command)
      results << cmd_result
      cmd_result
    end
  end
end

#warned_resultsObject



37
38
39
40
41
# File 'lib/jive/runner.rb', line 37

def warned_results
  results.select do |result|
    result.status.success? && !result.stderr.empty?
  end
end