parent_paths 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parent_paths/version.rb +1 -1
- data/lib/parent_paths.rb +3 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6783c3c77067649617f46ba80b6637024586f0f8
|
4
|
+
data.tar.gz: 8e62049d650768895aa289369bdaf313d64d7333
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ff27cdefafbd639daea65a8091ea9196ce9770d580a8d7f3420416760017cdea5324d43daf782a1564facf2de879f9a3bb53ca553a1ed6675334e340c4c24ba
|
7
|
+
data.tar.gz: dccc5a2999243a4f73d8c10fc103192af2530b886ec13fa791fc53d53a0b25999ccf91b0f6ae0d1f7c58691084c4b78623c2ef94e38a3b6b42cbede9aa585b8a
|
data/lib/parent_paths/version.rb
CHANGED
data/lib/parent_paths.rb
CHANGED
@@ -10,11 +10,10 @@ module ParentPaths
|
|
10
10
|
# file that calls this method.
|
11
11
|
def self.scan(start = nil, &criteria)
|
12
12
|
start ||= caller_path
|
13
|
-
start = Pathname.new(start)
|
14
13
|
if criteria.call(start)
|
15
14
|
return start
|
16
15
|
else
|
17
|
-
parent = start.parent
|
16
|
+
parent = Pathname.new(start).parent.to_s
|
18
17
|
if start == parent
|
19
18
|
nil
|
20
19
|
else
|
@@ -30,7 +29,7 @@ module ParentPaths
|
|
30
29
|
# file that calls this method.
|
31
30
|
def self.scan_for_owner(filename, start = nil)
|
32
31
|
start ||= caller_path
|
33
|
-
scan(start) { |
|
32
|
+
scan(start) { |path| File.exist?(File.join(path, filename)) }
|
34
33
|
end
|
35
34
|
|
36
35
|
private
|
@@ -40,7 +39,7 @@ module ParentPaths
|
|
40
39
|
# the current file.
|
41
40
|
def self.caller_path
|
42
41
|
matches = caller(2).first.match(/(.*):\d+:in `/)
|
43
|
-
|
42
|
+
File.expand_path(matches[1])
|
44
43
|
end
|
45
44
|
|
46
45
|
end
|