lib/homecoming/traversal.rb in homecoming-0.1.0 vs lib/homecoming/traversal.rb in homecoming-0.1.1
- old
+ new
@@ -1,12 +1,11 @@
+require 'pathname'
+
module Homecoming
- class Traversal
+ class Traversal < Enumerator
def initialize(dir = Dir.pwd, &block)
- old_length = nil
- while dir != '.' && dir.length != old_length
- yield dir
- old_length = dir.length
- dir = File.dirname(dir)
+ super() do |y|
+ Pathname(dir).ascend { |p| y.yield p.to_s }
end
end
end
-end
\ No newline at end of file
+end