diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-12 09:52:40 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-12 09:52:40 -0700 |
commit | d08b89fa4b422c66b4e408d87e5d8e198299a2bd (patch) | |
tree | d12679e4d8a93d66ba120eb1cf61e2d8c4856f6c /railties | |
parent | 168df24ac87c2f8a07b05489140bf337ddab440a (diff) | |
parent | 06129c0e3fb0f20df6c0aa1509b151c51e71d180 (diff) | |
download | rails-d08b89fa4b422c66b4e408d87e5d8e198299a2bd.tar.gz rails-d08b89fa4b422c66b4e408d87e5d8e198299a2bd.tar.bz2 rails-d08b89fa4b422c66b4e408d87e5d8e198299a2bd.zip |
Merge pull request #7871 from bjnord/master
Support another file type .rake in `rake notes`
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 2 | ||||
-rw-r--r-- | railties/lib/rails/source_annotation_extractor.rb | 14 | ||||
-rw-r--r-- | railties/test/application/rake/notes_test.rb | 4 |
3 files changed, 12 insertions, 8 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index c9fa541db8..2ecdfdcb22 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,5 +1,7 @@ ## Rails 4.0.0 (unreleased) ## +* Add `.rake` to list of file extensions included by `rake notes` and `rake notes:custom`. *Brent J. Nordquist* + * New test locations `test/models`, `test/helpers`, `test/controllers`, and `test/mailers`. Corresponding rake tasks added as well. *Mike Moore* diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 31e34023c0..3474b02af4 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -32,9 +32,9 @@ class SourceAnnotationExtractor end # Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+, - # +script+, and +test+ (recursively). Only filenames with extension - # +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, +.scss+, +.js+, and - # +.coffee+ are taken into account. The +options+ hash is passed to each + # +script+, and +test+ (recursively). Filenames with extension + # +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, +.scss+, +.js+, + # +.coffee+, and +.rake+ are taken into account. The +options+ hash is passed to each # annotation's +to_s+. # # This class method is the single entry point for the rake tasks. @@ -56,9 +56,9 @@ class SourceAnnotationExtractor end # Returns a hash that maps filenames under +dir+ (recursively) to arrays - # with their annotations. Only files with annotations are included, and only - # those with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, - # +.scss+, +.js+, and +.coffee+ + # with their annotations. Only files with annotations are included. Files + # with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, + # +.scss+, +.js+, +.coffee+, and +.rake+ # are taken into account. def find_in(dir) results = {} @@ -68,7 +68,7 @@ class SourceAnnotationExtractor if File.directory?(item) results.update(find_in(item)) - elsif item =~ /\.(builder|rb|coffee)$/ + elsif item =~ /\.(builder|rb|coffee|rake)$/ results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/)) elsif item =~ /\.(css|scss|js)$/ results.update(extract_annotations_from(item, /\/\/\s*(#{tag}):?\s*(.*)$/)) diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb index 27de75b63b..7a227098ba 100644 --- a/railties/test/application/rake/notes_test.rb +++ b/railties/test/application/rake/notes_test.rb @@ -25,6 +25,7 @@ module ApplicationTests app_file "app/assets/stylesheets/application.css", "// TODO: note in css" app_file "app/assets/stylesheets/application.css.scss", "// TODO: note in scss" app_file "app/controllers/application_controller.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in ruby" + app_file "lib/tasks/task.rake", "# TODO: note in rake" boot_rails require 'rake' @@ -45,8 +46,9 @@ module ApplicationTests assert_match(/note in js/, output) assert_match(/note in css/, output) assert_match(/note in scss/, output) + assert_match(/note in rake/, output) - assert_equal 8, lines.size + assert_equal 9, lines.size lines.each do |line| assert_equal 4, line[0].size |