lib/sprockets/base.rb in sprockets-2.0.0 vs lib/sprockets/base.rb in sprockets-2.0.1
- old
+ new
@@ -108,14 +108,37 @@
#
def [](*args)
find_asset(*args)
end
+ def each_entry(root, &block)
+ return to_enum(__method__, root) unless block_given?
+ root = Pathname.new(root) unless root.is_a?(Pathname)
+
+ paths = []
+ entries(root).sort.each do |filename|
+ path = root.join(filename)
+ paths << path
+
+ if stat(path).directory?
+ each_entry(path) do |subpath|
+ paths << subpath
+ end
+ end
+ end
+
+ paths.sort_by(&:to_s).each(&block)
+
+ nil
+ end
+
def each_file
return to_enum(__method__) unless block_given?
- paths.each do |base_path|
- Dir["#{base_path}/**/*"].each do |filename|
- yield filename unless File.directory?(filename)
+ paths.each do |root|
+ each_entry(root) do |path|
+ if !stat(path).directory?
+ yield path
+ end
end
end
nil
end