diff options
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/paths.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 4ac3d88dc2..c24940816d 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -87,14 +87,15 @@ module Rails protected def filter_by(constraint) - all = [] + yes = [] + no = [] + all_paths.each do |path| - if path.send(constraint) - paths = path.existent - paths -= path.children.map { |p| p.send(constraint) ? [] : p.existent }.flatten - all.concat(paths) - end + paths = path.existent + path.existent_base_paths + path.send(constraint) ? yes.concat(paths) : no.concat(paths) end + + all = yes - no all.uniq! all end @@ -123,6 +124,7 @@ module Rails keys.delete(@current) @root.values_at(*keys.sort) end + deprecate :children def first expanded.first @@ -194,6 +196,10 @@ module Rails expanded.select { |d| File.directory?(d) } end + def existent_base_paths + map { |p| File.expand_path(p, @root.path) }.select{ |f| File.exist? f } + end + alias to_a expanded private |