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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 984f5b31cb94ef8c040a44eab2e393bbecfe1917
4
- data.tar.gz: fe029bcac9fd794eae77280f6e7fc2267bf97099
3
+ metadata.gz: 2580ae9366630dbaa636d4ee14806e5ee0efd76b
4
+ data.tar.gz: 7e49b3795b9c7900a0c3598b4460a7f010c1c39f
5
5
  SHA512:
6
- metadata.gz: 042a0d9c8334afc1310697e7e4612fe2c8659f777159dc1edc41232a7bd74606de206748c3767a58b5e3efdd46407a97585fe8463b31f26c7136f632d0dc90af
7
- data.tar.gz: 80365a5a23eca9fe34f472e67cc488430c36fb1d2b0f8a69d2785176b2ac99f37a529aaefda5b6343eb76205f8012c639f96674a020cb24a4cfb72b23251c489
6
+ metadata.gz: dcf8c13ef15c204a946f8ef8c9c8054db5c8cedfc2b3c2b53bb912c41fcdb47a61ce08286119a7eb59a009a77d189ff31dc24c4663d8531ecb3f91ef45d30123
7
+ data.tar.gz: 418d852ebdf000c238929e77c8bfd3955dc8991600dc27201892a1cd0c92d8407037e5915971d031361cbe42aef14dc7230caccea466ddb0c74d64792b721126
@@ -0,0 +1 @@
1
+ homecoming
@@ -0,0 +1 @@
1
+ ruby-2.0.0
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Homecoming
2
2
 
3
+ [![Build Status](https://travis-ci.org/rrrene/homecoming.png?branch=master)](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
- # Given the following directory structure:
35
+ # Given the following directory structure:
34
36
 
35
- /
36
- home/
37
- rrrene/
38
- projects/
39
- your_project/
40
- .yourconfig
41
- .yourconfig
37
+ /
38
+ home/
39
+ rrrene/
40
+ projects/
41
+ your_project/
42
+ .yourconfig
43
+ .yourconfig
42
44
 
43
- Homecoming.find(".yourconfig", "/home/rrrene/projects/your_project")
44
- # => ["/home/rrrene/.yourconfig",
45
- "/home/rrrene/projects/your_project/.yourconfig"]
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
- Homecoming.each("/home/rrrene/projects/your_project") do |dir|
56
- # ...
57
- end
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
- "/home/rrrene/projects/your_project"
66
- "/home/rrrene/projects"
67
- "/home/rrrene"
68
- "/home"
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/<my-github-username>/homecoming/fork )
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`)
@@ -28,6 +28,6 @@ module Homecoming
28
28
  end
29
29
 
30
30
  def self.each(path = Dir.pwd, &block)
31
- Homecoming::Traversal.new(path, &block)
31
+ Homecoming::Traversal.new(path).each(&block)
32
32
  end
33
33
  end
@@ -23,12 +23,10 @@ module Homecoming
23
23
  # "/home/rrrene/projects/your_project/.yourconfig"]
24
24
  #
25
25
  def files
26
- found_files = []
27
- Traversal.new(@start_dir) do |dir|
26
+ Traversal.new(@start_dir).map do |dir|
28
27
  filename = File.join(dir, @filename)
29
- found_files.unshift filename if File.exist?(filename)
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
@@ -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
- old_length = nil
5
- while dir != '.' && dir.length != old_length
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
@@ -1,3 +1,3 @@
1
1
  module Homecoming
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-20 00:00:00.000000000 Z
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