Sha256: 5f700ffc8add6121fe87adf29d4af228fb18604ae135152f0e915a401f7646e7

Contents?: true

Size: 957 Bytes

Versions: 1

Compression:

Stored size: 957 Bytes

Contents

module PredragsDummyPipelines

  class Exec
    def initialize(actions, name)
      @name = name
      @cmd  = actions.select {|a| a.key? "cmd"}.first["cmd"]
      @test = actions.select {|a| a.key? "test"}.first["test"]
      @cmd_results = []
      @test_results = []
    end

    def cmd
      @cmd
    end

    def run
      run_cmd(@cmd, @cmd_results, true)
      return if @cmd_results.last.last != 0
      run_cmd(@test, @test_results, false)
    end

    def run_cmd(commands, results, should_break)
      commands.each {|c|
        begin
          results << [%x[#{c}], $?.exitstatus]
          break if should_break and $?.exitstatus != 0
        rescue => e
          results << [e, $?.exitstatus]
          break if should_break
        end
      }
      @results
    end

    def show
      [{exec_name: @name, cmd: @cmd, test: @test}, @cmd_results, @test_results]
    end

    def results
      [@cmd_results, @test_results]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
predrags_dummy_pipelines-0.5.1 lib/predrags_dummy_pipelines/exec.rb