instance method find_in

Ruby on Rails 3.2.22.5

Since v2.2.3 Last seen in v5.2.8.1

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1

Signature

find_in(dir)

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, .slim and .coffee are taken into account.

Parameters

dir req
Source
# File railties/lib/rails/source_annotation_extractor.rb, line 58
  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))
      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*%>/))
      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*(.*)$/))
      end
    end

    results
  end

Defined in railties/lib/rails/source_annotation_extractor.rb line 58 · View on GitHub · Improve this page · Find usages on GitHub

Defined in SourceAnnotationExtractor

Type at least 2 characters to search.

↑↓ navigate · open · esc close