Sha256: e9dd6bf74400cfbdb26de3074838237b0004843d5318bcfd37189a72b756bed6

Contents?: true

Size: 777 Bytes

Versions: 4

Compression:

Stored size: 777 Bytes

Contents

require 'escape'

module Wordmove
  class LocalHost

    attr_reader :options
    attr_reader :logger

    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

4 entries across 4 versions & 1 rubygems

Version Path
wordmove-0.0.4 lib/wordmove/hosts/local_host.rb
wordmove-0.0.3 lib/wordmove/hosts/local_host.rb
wordmove-0.0.2 lib/wordmove/hosts/local_host.rb
wordmove-0.0.1 lib/wordmove/hosts/local_host.rb