Returns a hash that maps filenames under dir (recursively) to
arrays with their annotations. Only files with annotations are included.
Files with extension .builder,.rb,.erb,.haml,.slim,.css,.scss,.js,.coffee, and .rake are taken into account.
# File railties/lib/rails/source_annotation_extractor.rb, line 72
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