Skip to content

Commit

Permalink
Merge pull request rails#6519 from oscardelben/3-2-stable
Browse files Browse the repository at this point in the history
Display annotations in coffee files
  • Loading branch information
carlosantoniodasilva committed May 30, 2012
2 parents 12e5c72 + 2f71d40 commit f09ae85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions railties/lib/rails/source_annotation_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def find(dirs=%w(app config lib script test))

# 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+ and +.slim+
# those with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+ and +.coffee+
# are taken into account.
def find_in(dir)
results = {}
Expand All @@ -63,7 +63,7 @@ def find_in(dir)

if File.directory?(item)
results.update(find_in(item))
elsif item =~ /\.(builder|rb)$/
elsif item =~ /\.(builder|rb|coffee)$/
results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
elsif item =~ /\.erb$/
results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
Expand Down
14 changes: 9 additions & 5 deletions railties/test/application/rake/notes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def setup
build_app
require "rails/all"
end

def teardown
teardown_app
end
Expand All @@ -17,24 +17,28 @@ def teardown
app_file "app/views/home/index.html.erb", "<% # TODO: note in erb %>"
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/controllers/application_controller.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in ruby"

boot_rails
require 'rake'
require 'rdoc/task'
require 'rake/testtask'

Rails.application.load_tasks

Dir.chdir(app_path) do
output = `bundle exec rake notes`

assert_match /note in erb/, output
assert_match /note in haml/, output
assert_match /note in slim/, output
assert_match /note in ruby/, output
assert_match /note in coffee/, output
end

end

private
def boot_rails
super
Expand Down

0 comments on commit f09ae85

Please sign in to comment.