Skip to content
This repository
Browse code

use case statement

  • Loading branch information...
commit 7fff04f4e8a5fcb8081adeeb81bbd7f866ac07ee 1 parent f1d8f2a
authored January 15, 2013
26  railties/lib/rails/source_annotation_extractor.rb
@@ -68,16 +68,22 @@ def find_in(dir)
68 68
 
69 69
       if File.directory?(item)
70 70
         results.update(find_in(item))
71  
-      elsif item =~ /\.(builder|rb|coffee|rake)$/
72  
-        results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
73  
-      elsif item =~ /\.(css|scss|js)$/
74  
-        results.update(extract_annotations_from(item, /\/\/\s*(#{tag}):?\s*(.*)$/))
75  
-      elsif item =~ /\.erb$/
76  
-        results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
77  
-      elsif item =~ /\.haml$/
78  
-        results.update(extract_annotations_from(item, /-\s*#\s*(#{tag}):?\s*(.*)$/))
79  
-      elsif item =~ /\.slim$/
80  
-        results.update(extract_annotations_from(item, /\/\s*\s*(#{tag}):?\s*(.*)$/))
  71
+      else
  72
+        pattern =
  73
+            case item
  74
+            when /\.(builder|rb|coffee|rake)$/
  75
+              /#\s*(#{tag}):?\s*(.*)$/
  76
+            when /\.(css|scss|js)$/
  77
+              /\/\/\s*(#{tag}):?\s*(.*)$/
  78
+            when /\.erb$/
  79
+              /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/
  80
+            when /\.haml$/
  81
+              /-\s*#\s*(#{tag}):?\s*(.*)$/
  82
+            when /\.slim$/
  83
+              /\/\s*\s*(#{tag}):?\s*(.*)$/
  84
+            else nil
  85
+            end
  86
+        results.update(extract_annotations_from(item, pattern)) if pattern
81 87
       end
82 88
     end
83 89
 

0 notes on commit 7fff04f

Please sign in to comment.
Something went wrong with that request. Please try again.