Class: ChdirRunner

Inherits:
Object
  • Object
show all
Defined in:
app/ports/chdir_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir, runner = Runner.new) ⇒ ChdirRunner

Returns a new instance of ChdirRunner.



21
22
23
# File 'app/ports/chdir_runner.rb', line 21

def initialize(dir, runner=Runner.new)
  @dir, @runner = dir, runner
end

Instance Method Details

#run(command, input = '', env = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'app/ports/chdir_runner.rb', line 25

def run(command, input='', env={})
  prevdir = Dir.pwd
  begin
    Dir.chdir(@dir)
    @runner.run(command, input, env)
  ensure
    Dir.chdir(prevdir)
  end
end