Class: Dply::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/dply/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(command, env: {}, shell: false) ⇒ Command

Returns a new instance of Command.



7
8
9
10
11
12
# File 'lib/dply/command.rb', line 7

def initialize(command, env: {}, shell: false)
  @command = command
  @env = env
  @shell = shell
  validate!
end

Instance Method Details

#captureObject



18
19
20
# File 'lib/dply/command.rb', line 18

def capture
  assert_success { IO.popen(@env, command, unsetenv_others: true) { |f| f.read } }
end

#runObject



14
15
16
# File 'lib/dply/command.rb', line 14

def run
  assert_success { system(@env, *command, unsetenv_others: true, 2 => 1) }
end