lib/aruba/platform.rb in aruba-0.8.0.pre2 vs lib/aruba/platform.rb in aruba-0.8.0.pre3

- old
+ new

@@ -52,15 +52,32 @@ paths = Array(paths).map { |p| ::File.expand_path(p) } FileUtils.rm_r(paths, options) end + def getwd + Dir.getwd + end + # Change to directory def chdir(dir_name, &block) dir_name = ::File.expand_path(dir_name.to_s) - ::Dir.chdir(dir_name, &block) + begin + if RUBY_VERSION <= '1.9.3' + old_env = ENV.to_hash + else + old_env = ENV.to_h + end + + ENV['OLDPWD'] = getwd + ENV['PWD'] = dir_name + ::Dir.chdir(dir_name, &block) + ensure + ENV.clear + ENV.update old_env + end end # Touch file, directory def touch(args, options) FileUtils.touch(args, options) @@ -222,9 +239,10 @@ :expand_path, \ :absolute_path?, \ :relative_command?, \ :executable_file?, \ :unescape, \ + :getwd, \ :which, \ :write_file end end