mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
rake notes
and rake notes:custom
now support
css, scss and css.
This commit is contained in:
parent
90269802db
commit
55ceced1fb
2 changed files with 14 additions and 4 deletions
|
@ -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$/
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue