From 64878bfc23b348664e5a5ab6abc01c176eb88928 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 4 May 2013 10:56:38 -0700 Subject: [PATCH] Replace all_files_under with method that doesn't modify in-place --- middleman-core/lib/middleman-core/util.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 23d6f23e..ba5e72d5 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -136,13 +136,15 @@ module Middleman # @param paths Some paths string or Pathname # @return [Array] An array of filenames def self.all_files_under(*paths) - paths.flatten! - paths.map! { |p| Pathname(p) } - files = paths.select { |p| p.file? } - paths.select {|p| p.directory? }.each do |dir| - files << all_files_under(dir.children) - end - files.flatten + # when we drop 1.8, replace this with flat_map + paths.map do |p| + path = Pathname(p) + if path.directory? + all_files_under(*path.children) + elsif path.file? + path + end + end.flatten.compact end # Simple shared cache implementation