class SourceAnnotationExtractor
def find_in(dir)
+.scss+, +.js+, +.coffee+, and +.rake+
with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+,
with their annotations. Only files with annotations are included. Files
Returns a hash that maps filenames under +dir+ (recursively) to arrays
def find_in(dir) results = {} Dir.glob("#{dir}/*") do |item| next if File.basename(item)[0] == ?. if File.directory?(item) results.update(find_in(item)) 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 results end