Sha256: 4de0b99526b48849d1f4407ff6bc24abf5b1232bfe3f235ffb37377bf7bb6edb

Contents?: true

Size: 936 Bytes

Versions: 4

Compression:

Stored size: 936 Bytes

Contents

class Foreplay::Engine::Remote::Step
  include Foreplay
  attr_reader :host, :shell, :step, :instructions

  def initialize(h, sh, st, i)
    @host = h
    @shell = sh
    @step = st
    @instructions = i
  end

  def deploy
    puts "#{host}#{INDENT}#{(step['commentary'] || step['command']).yellow}" unless step['silent'] == true

    # Output from this step
    output    = ''
    previous  = '' # We don't need or want the final CRLF
    commands  = Foreplay::Engine::Step.new(step, instructions).build

    commands.each do |command|
      process = shell.execute command

      process.on_output do |_, o|
        previous = o
        output += previous
      end

      shell.wait!

      if step['ignore_error'] == true || process.exit_status == 0
        print output.gsub!(/^/, "#{host}#{INDENT * 2}") unless step['silent'] == true || output.blank?
      else
        terminate(output)
      end
    end

    output
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreplay-0.9.8 lib/foreplay/engine/remote/step.rb
foreplay-0.9.7 lib/foreplay/engine/remote/step.rb
foreplay-0.9.2 lib/foreplay/engine/remote/step.rb
foreplay-0.9.1 lib/foreplay/engine/remote/step.rb