diff options
author | Brian D. Burns <burns@iosctr.com> | 2013-01-15 13:47:12 -0500 |
---|---|---|
committer | Brian D. Burns <burns@iosctr.com> | 2013-01-15 13:47:12 -0500 |
commit | 7fff04f4e8a5fcb8081adeeb81bbd7f866ac07ee (patch) | |
tree | a11a6bb0091fbbb96fc33684cf3a5910ee1b9da4 | |
parent | f1d8f2af72e21d41efd02488f1c2dcf829e17783 (diff) | |
download | rails-7fff04f4e8a5fcb8081adeeb81bbd7f866ac07ee.tar.gz rails-7fff04f4e8a5fcb8081adeeb81bbd7f866ac07ee.tar.bz2 rails-7fff04f4e8a5fcb8081adeeb81bbd7f866ac07ee.zip |
use case statement
-rw-r--r-- | railties/lib/rails/source_annotation_extractor.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 971fbf627b..0a352f1a18 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -68,16 +68,22 @@ class SourceAnnotationExtractor if File.directory?(item) results.update(find_in(item)) - 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*(.*)$/)) - elsif item =~ /\.erb$/ - results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/)) - elsif item =~ /\.haml$/ - results.update(extract_annotations_from(item, /-\s*#\s*(#{tag}):?\s*(.*)$/)) - elsif item =~ /\.slim$/ - results.update(extract_annotations_from(item, /\/\s*\s*(#{tag}):?\s*(.*)$/)) + else + pattern = + case item + when /\.(builder|rb|coffee|rake)$/ + /#\s*(#{tag}):?\s*(.*)$/ + when /\.(css|scss|js)$/ + /\/\/\s*(#{tag}):?\s*(.*)$/ + when /\.erb$/ + /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/ + when /\.haml$/ + /-\s*#\s*(#{tag}):?\s*(.*)$/ + when /\.slim$/ + /\/\s*\s*(#{tag}):?\s*(.*)$/ + else nil + end + results.update(extract_annotations_from(item, pattern)) if pattern end end |