Sha256: 014173dbb00efbbdc2cce0a1a82fca256b52c23f88a6a9d8d7b732aa477915fe

Contents?: true

Size: 995 Bytes

Versions: 4

Compression:

Stored size: 995 Bytes

Contents

module Foreplay
  class Engine
    class Remote
      class 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 execute
          s = Foreplay::Engine::Step.new(host, step, instructions)
          s.announce
          output s.commands.map { |command| execute_command(command) }.join
        end

        def execute_command(command)
          o = ''
          process = shell.execute command
          process.on_output { |_, po| o += po }
          shell.wait!
          terminate(o) unless step['ignore_error'] == true || process.exit_status == 0
          o
        end

        def silent
          @silent ||= instructions['verbose'] ? false : step['silent']
        end

        def output(o)
          log o, host: host, silent: silent, indent: 1
          o
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreplay-0.11.0 lib/foreplay/engine/remote/step.rb
foreplay-0.10.3 lib/foreplay/engine/remote/step.rb
foreplay-0.10.2 lib/foreplay/engine/remote/step.rb
foreplay-0.10.1 lib/foreplay/engine/remote/step.rb