lib/facet/pathname/descend.rb in facets-0.9.0 vs lib/facet/pathname/descend.rb in facets-1.0.0
- old
+ new
@@ -1,19 +1,38 @@
-require 'nano/pathname/descend.rb'
\ No newline at end of file
+require 'pathname'
+
+class Pathname
+
+ # Already included in 1.8.4+ version of Ruby
+ if ! instance_methods.include?(:descend)
+
+ # Calls the _block_ for every successive subdirectory of the
+ # directory path from the root (absolute path) unitl +.+
+ # (relative path) is reached.
+ def descend()
+ @path.scan(%r{[^/]*/?})[0...-1].inject('') do |path, dir|
+ yield Pathname.new(path << dir)
+ path
+ end
+ end
+
+ end
+
+end