提交 55ceced1 编写于 作者: T Teng Siong Ong

`rake notes` and `rake notes:custom` now support

css, scss and css.
上级 90269802
...@@ -30,8 +30,9 @@ def to_s(options={}) ...@@ -30,8 +30,9 @@ def to_s(options={})
# Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+, # Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+,
# +script+, and +test+ (recursively). Only filenames with extension # +script+, and +test+ (recursively). Only filenames with extension
# +.builder+, +.rb+, and +.erb+ are taken into account. The +options+ # +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, +.scss+, +.js+, and
# hash is passed to each annotation's +to_s+. # +.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. # This class method is the single entry point for the rake tasks.
def self.enumerate(tag, options={}) def self.enumerate(tag, options={})
...@@ -53,7 +54,8 @@ def find(dirs=%w(app config lib script test)) ...@@ -53,7 +54,8 @@ def find(dirs=%w(app config lib script test))
# Returns a hash that maps filenames under +dir+ (recursively) to arrays # Returns a hash that maps filenames under +dir+ (recursively) to arrays
# with their annotations. Only files with annotations are included, and only # 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. # are taken into account.
def find_in(dir) def find_in(dir)
results = {} results = {}
...@@ -65,6 +67,8 @@ def find_in(dir) ...@@ -65,6 +67,8 @@ def find_in(dir)
results.update(find_in(item)) results.update(find_in(item))
elsif item =~ /\.(builder|rb|coffee)$/ elsif item =~ /\.(builder|rb|coffee)$/
results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/)) 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$/ elsif item =~ /\.erb$/
results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/)) results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
elsif item =~ /\.haml$/ elsif item =~ /\.haml$/
......
...@@ -17,6 +17,9 @@ def teardown ...@@ -17,6 +17,9 @@ def teardown
app_file "app/views/home/index.html.haml", "-# TODO: note in haml" 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/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.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" app_file "app/controllers/application_controller.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in ruby"
boot_rails boot_rails
...@@ -35,8 +38,11 @@ def teardown ...@@ -35,8 +38,11 @@ def teardown
assert_match /note in slim/, output assert_match /note in slim/, output
assert_match /note in ruby/, output assert_match /note in ruby/, output
assert_match /note in coffee/, 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| lines.each do |line|
assert_equal 4, line[0].size assert_equal 4, line[0].size
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册