Sha256: 5f4db4ce6b7b48fc9c0d7ace6aa5dfa995893395e315eddf2b7e18c9bbd066a5

Contents?: true

Size: 896 Bytes

Versions: 2

Compression:

Stored size: 896 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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
predrags_dummy_pipelines-0.4.1 lib/predrags_dummy_pipelines/exec.rb
predrags_dummy_pipelines-0.4.0 lib/predrags_dummy_pipelines/exec.rb