push_dir 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +5 -2
- data/README.txt +2 -1
- data/lib/push_dir.rb +23 -8
- data/test/test_push_dir.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/README.txt
CHANGED
data/lib/push_dir.rb
CHANGED
@@ -1,10 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# Include this to get push_dir, or call PushDir.push_dir
|
2
|
+
module PushDir
|
3
|
+
# Current PushDir version number
|
4
|
+
VERSION = '1.0.1'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
# Simplifies directory management
|
7
|
+
# Dir.pwd => '/var/'
|
8
|
+
# push_dir '/' do
|
9
|
+
# # Dir.pwd => '/'
|
10
|
+
# push_dir '/home/' do
|
11
|
+
# # Dir.pwd => '/home/'
|
12
|
+
# end
|
13
|
+
# # Dir.pwd => '/'
|
14
|
+
# end
|
15
|
+
# # Dir.pwd => '/var/'
|
16
|
+
#
|
17
|
+
# The code is very simple, and consists of saving the old pwd, moving
|
18
|
+
# to the new pwd, yielding, then changing back to the old pwd.
|
19
|
+
def push_dir path
|
20
|
+
old_pwd = Dir.pwd
|
21
|
+
Dir.chdir(path)
|
22
|
+
yield
|
23
|
+
Dir.chdir(old_pwd)
|
24
|
+
end
|
10
25
|
end
|
data/test/test_push_dir.rb
CHANGED