Module: PushDir

Defined in:
lib/push_dir.rb

Overview

Include this to get push_dir, or call PushDir.push_dir

Constant Summary collapse

VERSION =

Current PushDir version number

'1.0.1'

Instance Method Summary collapse

Instance Method Details

#push_dir(path) ⇒ Object

Simplifies directory management Dir.pwd => ‘/var/’ push_dir ‘/’ do

	# Dir.pwd => '/'

push_dir ‘/home/’ do # Dir.pwd => ‘/home/’ end # Dir.pwd => ‘/’ end # Dir.pwd => ‘/var/’

The code is very simple, and consists of saving the old pwd, moving to the new pwd, yielding, then changing back to the old pwd.



19
20
21
22
23
24
# File 'lib/push_dir.rb', line 19

def push_dir path
	old_pwd = Dir.pwd
	Dir.chdir(path)
	yield
	Dir.chdir(old_pwd)
end