diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-05 12:07:16 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-05 12:07:16 -0300 |
commit | a0613ad8a9773c76a9b0a256f7099fde35823674 (patch) | |
tree | ac866e7a5c8fa4c15f025759dd0ed1dccb54d311 /railties/lib | |
parent | abf8de85519141496a6773310964ec03f6106f3f (diff) | |
download | rails-a0613ad8a9773c76a9b0a256f7099fde35823674.tar.gz rails-a0613ad8a9773c76a9b0a256f7099fde35823674.tar.bz2 rails-a0613ad8a9773c76a9b0a256f7099fde35823674.zip |
Revert "Use flat_map { } instead of map {}.flatten"
This reverts commit abf8de85519141496a6773310964ec03f6106f3f.
We should take a deeper look to those cases flat_map doesn't do deep
flattening.
irb(main):002:0> [[[1,3], [1,2]]].map{|i| i}.flatten
=> [1, 3, 1, 2]
irb(main):003:0> [[[1,3], [1,2]]].flat_map{|i| i}
=> [[1, 3], [1, 2]]
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/paths.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/source_annotation_extractor.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/testing.rake | 4 |
4 files changed, 5 insertions, 5 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 735a1972fe..c41acc7841 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -184,7 +184,7 @@ module Rails # generate(:authenticated, "user session") def generate(what, *args) log :generate, what - argument = args.flat_map {|arg| arg.to_s }.join(" ") + argument = args.map {|arg| arg.to_s }.flatten.join(" ") in_root { run_ruby_script("script/rails generate #{what} #{argument}", :verbose => false) } end diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 30482fba5d..3c2210aaf9 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -103,7 +103,7 @@ module Rails all_paths.each do |path| if path.send(constraint) paths = path.existent - paths -= path.children.flat_map { |p| p.send(constraint) ? [] : p.existent } + paths -= path.children.map { |p| p.send(constraint) ? [] : p.existent }.flatten all.concat(paths) end end diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 6a8b09dbb7..31e34023c0 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -100,7 +100,7 @@ class SourceAnnotationExtractor # Prints the mapping from filenames to annotations in +results+ ordered by filename. # The +options+ hash is passed to each annotation's +to_s+. def display(results, options={}) - options[:indent] = results.flat_map { |f, a| a.map(&:line) }.max.to_s.size + options[:indent] = results.map { |f, a| a.map(&:line) }.flatten.max.to_s.size results.keys.sort.each do |file| puts "#{file}:" results[file].each do |note| diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index d1d4230132..0de4afe905 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -6,7 +6,7 @@ TEST_CHANGES_SINCE = Time.now - 600 # Look up tests for recently modified sources. def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago) - FileList[source_pattern].flat_map do |path| + FileList[source_pattern].map do |path| if File.mtime(path) > touched_since tests = [] source_dir = File.dirname(path).split("/") @@ -26,7 +26,7 @@ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago) return tests end - end.compact + end.flatten.compact end |