Class: Gitlab::Popen::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.


8
9
10
# File 'lib/gitlab/popen/runner.rb', line 8

def initialize
  @results = []
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results


6
7
8
# File 'lib/gitlab/popen/runner.rb', line 6

def results
  @results
end

Instance Method Details

#all_stderr_empty?Boolean

Returns:

  • (Boolean)

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

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

#all_success?Boolean

Returns:

  • (Boolean)

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

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

#all_success_and_clean?Boolean

Returns:

  • (Boolean)

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

def all_success_and_clean?
  all_success? && all_stderr_empty?
end

#failed_resultsObject


37
38
39
# File 'lib/gitlab/popen/runner.rb', line 37

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

#run(commands, &block) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/popen/runner.rb', line 12

def run(commands, &block)
  commands.each do |cmd|
    # yield doesn't support blocks, so we need to use a block variable
    block.call(cmd) do # rubocop:disable Performance/RedundantBlockCall
      cmd_result = Gitlab::Popen.popen_with_detail(cmd)

      results << cmd_result

      cmd_result
    end
  end
end

#warned_resultsObject


41
42
43
44
45
# File 'lib/gitlab/popen/runner.rb', line 41

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