Class: Tara::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/tara/shell.rb

Class Method Summary collapse

Class Method Details

.exec(command) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/tara/shell.rb', line 6

def self.exec(command)
  output = %x(#{command})
  $stderr.puts(%(#{command}: #{output})) if ENV['TARA_DEBUG']
  unless $?.success?
    raise ExecError, %(Command `#{command}` failed with output: #{output})
  end
  output
rescue Errno::ENOENT => e
  raise ExecError, %(Command `#{command}` failed with output: #{e.message})
end

.exec_with_env(command, env) ⇒ Object



17
18
19
# File 'lib/tara/shell.rb', line 17

def self.exec_with_env(command, env)
  self.exec(env.map { |k, v| [k, v].join('=') }.join(' ') << ' ' << command)
end