Sha256: d5b49ab7530f4621ea9eeb8117b3e1b7fdad235e3d8261f4b8f08f19cd43668f

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

require 'escape'

module Wordmove
  class LocalHost

    attr_reader :options
    attr_reader :logger
    attr_reader :ssh_extras

    def initialize(options = {})
      @options = Hashie::Mash.new(options)
      @logger = @options[:logger]
    end

    def run(*args)
      command = shell_command(*args)
      logger.verbose "Executing locally #{command}"
      unless system(command)
        raise Thor::Error, "Error executing \"#{command}\""
      end
    end

    def close
    end

    protected

    def shell_command(*args)
      options = args.extract_options!
      command = Escape.shell_command(args)
      if options[:stdin]
        command += " < #{options[:stdin]}"
      end
      if options[:stdout]
        command += " > #{options[:stdout]}"
      end
      command
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wordmove-0.1.0.alpha lib/wordmove/hosts/local_host.rb
wordmove-0.0.8 lib/wordmove/hosts/local_host.rb