push_dir 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2011-02-01
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/push_dir.rb
7
+ test/test_push_dir.rb
data/README.txt ADDED
@@ -0,0 +1,65 @@
1
+ = push_dir
2
+
3
+ * http://geeklob.wordpress.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ Push_dir allows for easy working directory management. No more old_pwd = Dir.pwd!
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Simplify working directory management
12
+
13
+ == SYNOPSIS:
14
+
15
+ # Dir.pwd => '/var/'
16
+ push_dir '/' do
17
+ # Dir.pwd => '/'
18
+ push_dir '/home/' do
19
+ # Dir.pwd => '/home/'
20
+ end
21
+ # Dir.pwd => '/'
22
+ end
23
+ # Dir.pwd => '/var/'
24
+
25
+ == REQUIREMENTS:
26
+
27
+ * none
28
+
29
+ == INSTALL:
30
+
31
+ * sudo gem install push_dir # not tested
32
+
33
+ == DEVELOPERS:
34
+
35
+ After checking out the source, run:
36
+
37
+ $ rake newb
38
+
39
+ This task will install any missing dependencies, run the tests/specs,
40
+ and generate the RDoc.
41
+
42
+ == LICENSE:
43
+
44
+ (The MIT License)
45
+
46
+ Copyright (c) 2011 FIX
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of this software and associated documentation files (the
50
+ 'Software'), to deal in the Software without restriction, including
51
+ without limitation the rights to use, copy, modify, merge, publish,
52
+ distribute, sublicense, and/or sell copies of the Software, and to
53
+ permit persons to whom the Software is furnished to do so, subject to
54
+ the following conditions:
55
+
56
+ The above copyright notice and this permission notice shall be
57
+ included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
60
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
63
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
64
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
65
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.spec 'push_dir' do
7
+ developer('Indigo Casson', 'atamiser@gmail.com')
8
+
9
+ # self.rubyforge_name = 'push_dirx' # if different than 'push_dir'
10
+ end
11
+
12
+ # vim: syntax=ruby
data/lib/push_dir.rb ADDED
@@ -0,0 +1,10 @@
1
+ class PushDir
2
+ VERSION = '1.0.0'
3
+ end
4
+
5
+ def push_dir path
6
+ old_pwd = Dir.pwd
7
+ Dir.chdir(path)
8
+ yield
9
+ Dir.chdir(old_pwd)
10
+ end
@@ -0,0 +1,27 @@
1
+ require "test/unit"
2
+ require "push_dir"
3
+
4
+ #include PushDir
5
+
6
+ class TestPushDir < Test::Unit::TestCase
7
+ def test_change_dir
8
+ old_pwd = Dir.pwd
9
+ push_dir '/' do
10
+ assert_equal('/', Dir.pwd)
11
+ end
12
+ assert_equal(old_pwd, Dir.pwd)
13
+ end
14
+
15
+ def test_nesting
16
+ old_pwd = Dir.pwd
17
+ push_dir '/' do
18
+ assert_equal('/', Dir.pwd)
19
+ push_dir '/var' do
20
+ assert_equal('/var', Dir.pwd)
21
+ end
22
+ assert_equal('/', Dir.pwd)
23
+ end
24
+ assert_equal(old_pwd, Dir.pwd)
25
+
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: push_dir
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Indigo Casson
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-01 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: hoe
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 8
31
+ - 0
32
+ version: 2.8.0
33
+ type: :development
34
+ version_requirements: *id001
35
+ description: Push_dir allows for easy working directory management. No more old_pwd = Dir.pwd!
36
+ email:
37
+ - atamiser@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - README.txt
46
+ files:
47
+ - .autotest
48
+ - History.txt
49
+ - Manifest.txt
50
+ - README.txt
51
+ - Rakefile
52
+ - lib/push_dir.rb
53
+ - test/test_push_dir.rb
54
+ has_rdoc: true
55
+ homepage: http://geeklob.wordpress.com
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options:
60
+ - --main
61
+ - README.txt
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project: push_dir
83
+ rubygems_version: 1.3.7
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Push_dir allows for easy working directory management
87
+ test_files:
88
+ - test/test_push_dir.rb