homecoming 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/README.md +22 -20
- data/lib/homecoming.rb +1 -1
- data/lib/homecoming/find.rb +4 -6
- data/lib/homecoming/traversal.rb +6 -7
- data/lib/homecoming/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2580ae9366630dbaa636d4ee14806e5ee0efd76b
|
4
|
+
data.tar.gz: 7e49b3795b9c7900a0c3598b4460a7f010c1c39f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcf8c13ef15c204a946f8ef8c9c8054db5c8cedfc2b3c2b53bb912c41fcdb47a61ce08286119a7eb59a009a77d189ff31dc24c4663d8531ecb3f91ef45d30123
|
7
|
+
data.tar.gz: 418d852ebdf000c238929e77c8bfd3955dc8991600dc27201892a1cd0c92d8407037e5915971d031361cbe42aef14dc7230caccea466ddb0c74d64792b721126
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
homecoming
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Homecoming
|
2
2
|
|
3
|
+
[](https://travis-ci.org/rrrene/homecoming)
|
4
|
+
|
3
5
|
Homecoming let's you easily traverse all parent directories of a given or
|
4
6
|
the current directory.
|
5
7
|
|
@@ -30,19 +32,19 @@ Or install it yourself as:
|
|
30
32
|
`Homecoming.find` searches for a given filename in the current and all parent
|
31
33
|
directories.
|
32
34
|
|
33
|
-
|
35
|
+
# Given the following directory structure:
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
/
|
38
|
+
home/
|
39
|
+
rrrene/
|
40
|
+
projects/
|
41
|
+
your_project/
|
42
|
+
.yourconfig
|
43
|
+
.yourconfig
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
Homecoming.find(".yourconfig", "/home/rrrene/projects/your_project")
|
46
|
+
# => ["/home/rrrene/.yourconfig",
|
47
|
+
"/home/rrrene/projects/your_project/.yourconfig"]
|
46
48
|
|
47
49
|
If no path is given as second parameter, the current directory is the
|
48
50
|
starting point of the traversal.
|
@@ -52,9 +54,9 @@ starting point of the traversal.
|
|
52
54
|
`Homecoming.each` traverses and yields the given and all parent
|
53
55
|
directories.
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
Homecoming.each("/home/rrrene/projects/your_project") do |dir|
|
58
|
+
# ...
|
59
|
+
end
|
58
60
|
|
59
61
|
If no path is given, the current directory is the starting point of the
|
60
62
|
traversal.
|
@@ -62,16 +64,16 @@ traversal.
|
|
62
64
|
In our example, this would yield the following directories beginning with the
|
63
65
|
given/current one:
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
"/home/rrrene/projects/your_project"
|
68
|
+
"/home/rrrene/projects"
|
69
|
+
"/home/rrrene"
|
70
|
+
"/home"
|
71
|
+
"/"
|
70
72
|
|
71
73
|
|
72
74
|
## Contributing
|
73
75
|
|
74
|
-
1. Fork it ( http://github.com
|
76
|
+
1. Fork it ( http://github.com/rrrene/homecoming/fork )
|
75
77
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
76
78
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
77
79
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/homecoming.rb
CHANGED
data/lib/homecoming/find.rb
CHANGED
@@ -23,12 +23,10 @@ module Homecoming
|
|
23
23
|
# "/home/rrrene/projects/your_project/.yourconfig"]
|
24
24
|
#
|
25
25
|
def files
|
26
|
-
|
27
|
-
Traversal.new(@start_dir) do |dir|
|
26
|
+
Traversal.new(@start_dir).map do |dir|
|
28
27
|
filename = File.join(dir, @filename)
|
29
|
-
|
30
|
-
end
|
31
|
-
found_files
|
28
|
+
File.exist?(filename) ? filename : nil
|
29
|
+
end.compact.reverse
|
32
30
|
end
|
33
31
|
end
|
34
|
-
end
|
32
|
+
end
|
data/lib/homecoming/traversal.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Homecoming
|
2
|
-
class Traversal
|
4
|
+
class Traversal < Enumerator
|
3
5
|
def initialize(dir = Dir.pwd, &block)
|
4
|
-
|
5
|
-
|
6
|
-
yield dir
|
7
|
-
old_length = dir.length
|
8
|
-
dir = File.dirname(dir)
|
6
|
+
super() do |y|
|
7
|
+
Pathname(dir).ascend { |p| y.yield p.to_s }
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
12
|
-
end
|
11
|
+
end
|
data/lib/homecoming/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: homecoming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- René Föhring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,9 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
|
+
- .ruby-gemset
|
50
|
+
- .ruby-version
|
51
|
+
- .travis.yml
|
49
52
|
- Gemfile
|
50
53
|
- LICENSE.txt
|
51
54
|
- README.md
|