diff options
author | Teng Siong Ong <siong1987@gmail.com> | 2012-04-22 18:45:13 -0500 |
---|---|---|
committer | Teng Siong Ong <siong1987@gmail.com> | 2012-04-22 18:45:13 -0500 |
commit | 55ceced1fbebff2491c282308bcd8c7b2aef5bba (patch) | |
tree | 8bbef856e8039d0b7cc9efeb0080b7e502ec050a /railties | |
parent | 90269802dbf690fbe8be0cd01e3b387a51f02b70 (diff) | |
download | rails-55ceced1fbebff2491c282308bcd8c7b2aef5bba.tar.gz rails-55ceced1fbebff2491c282308bcd8c7b2aef5bba.tar.bz2 rails-55ceced1fbebff2491c282308bcd8c7b2aef5bba.zip |
`rake notes` and `rake notes:custom` now support
css, scss and css.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/source_annotation_extractor.rb | 10 | ||||
-rw-r--r-- | railties/test/application/rake/notes_test.rb | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 4cd60fdc39..a443c73962 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -30,8 +30,9 @@ class SourceAnnotationExtractor # Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+, # +script+, and +test+ (recursively). Only filenames with extension - # +.builder+, +.rb+, and +.erb+ are taken into account. The +options+ - # hash is passed to each annotation's +to_s+. + # +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, +.scss+, +.js+, and + # +.coffee+ 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. def self.enumerate(tag, options={}) @@ -53,7 +54,8 @@ class SourceAnnotationExtractor # 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+ and +.coffee+ + # those with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, + # +.scss+, +.js+, and +.coffee+ # are taken into account. def find_in(dir) results = {} @@ -65,6 +67,8 @@ class SourceAnnotationExtractor results.update(find_in(item)) elsif item =~ /\.(builder|rb|coffee)$/ results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/)) + elsif item =~ /\.(css|scss|js)$/ + results.update(extract_annotations_from(item, /\/\/\s*(#{tag}):?\s*(.*)$/)) elsif item =~ /\.erb$/ results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/)) elsif item =~ /\.haml$/ diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb index 04abf9e3a1..d069703d30 100644 --- a/railties/test/application/rake/notes_test.rb +++ b/railties/test/application/rake/notes_test.rb @@ -17,6 +17,9 @@ module ApplicationTests app_file "app/views/home/index.html.haml", "-# TODO: note in haml" app_file "app/views/home/index.html.slim", "/ TODO: note in slim" app_file "app/assets/javascripts/application.js.coffee", "# TODO: note in coffee" + app_file "app/assets/javascripts/application.js", "// TODO: note in js" + 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" boot_rails @@ -35,8 +38,11 @@ module ApplicationTests assert_match /note in slim/, output assert_match /note in ruby/, output assert_match /note in coffee/, output + assert_match /note in js/, output + assert_match /note in css/, output + assert_match /note in scss/, output - assert_equal 5, lines.size + assert_equal 8, lines.size lines.each do |line| assert_equal 4, line[0].size |