Sha256: 9af92b739b25cbac15bf797d5062bb7917205f6a5e53a0edccb869f42ebc3f4c

Contents?: true

Size: 1002 Bytes

Versions: 11

Compression:

Stored size: 1002 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.key?('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

11 entries across 11 versions & 1 rubygems

Version Path
foreplay-0.15.2 lib/foreplay/engine/remote/step.rb
foreplay-0.15.1 lib/foreplay/engine/remote/step.rb
foreplay-0.15.0 lib/foreplay/engine/remote/step.rb
foreplay-0.13.5 lib/foreplay/engine/remote/step.rb
foreplay-0.13.4 lib/foreplay/engine/remote/step.rb
foreplay-0.13.3 lib/foreplay/engine/remote/step.rb
foreplay-0.13.2 lib/foreplay/engine/remote/step.rb
foreplay-0.13.1 lib/foreplay/engine/remote/step.rb
foreplay-0.13.0 lib/foreplay/engine/remote/step.rb
foreplay-0.11.2 lib/foreplay/engine/remote/step.rb
foreplay-0.11.1 lib/foreplay/engine/remote/step.rb