Class: ChdirRunner
- Inherits:
-
Object
- Object
- ChdirRunner
- Defined in:
- app/ports/chdir_runner.rb
Instance Method Summary collapse
-
#initialize(dir, runner = Runner.new) ⇒ ChdirRunner
constructor
A new instance of ChdirRunner.
- #run(command, input = '', env = {}) ⇒ Object
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 |