Class: Specinfra::Backend::Exec
- Defined in:
- lib/specinfra/backend/exec.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#build_command(cmd) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/specinfra/backend/exec.rb', line 28 def build_command(cmd) shell = Specinfra.configuration.shell || '/bin/sh' cmd = cmd.shelljoin if cmd.is_a?(Array) cmd = "#{shell.shellescape} -c #{cmd.shellescape}" path = Specinfra.configuration.path if path cmd = %Q{env PATH="#{path}" #{cmd}} end cmd end |
#run_command(cmd, opts = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/specinfra/backend/exec.rb', line 7 def run_command(cmd, opts={}) cmd = build_command(cmd) cmd = add_pre_command(cmd) stdout = with_env do `#{build_command(cmd)} 2>&1` end # In ruby 1.9, it is possible to use Open3.capture3, but not in 1.8 # stdout, stderr, status = Open3.capture3(cmd) if @example @example.[:command] = cmd @example.[:stdout] = stdout end CommandResult.new :stdout => stdout, :exit_status => $?.exitstatus end |
#send_file(from, to) ⇒ Object
24 25 26 |
# File 'lib/specinfra/backend/exec.rb', line 24 def send_file(from, to) FileUtils.cp(from, to) end |