Sha256: 0cb756f223c465a7b943566a214ba6a08932bc3a37f4d2e345128f64584c446a

Contents?: true

Size: 805 Bytes

Versions: 48

Compression:

Stored size: 805 Bytes

Contents

# frozen_string_literal: true

module Rouge
  module Guessers
    class Filename < Guesser
      attr_reader :fname
      def initialize(filename)
        @filename = filename
      end

      # returns a list of lexers that match the given filename with
      # equal specificity (i.e. number of wildcards in the pattern).
      # This helps disambiguate between, e.g. the Nginx lexer, which
      # matches `nginx.conf`, and the Conf lexer, which matches `*.conf`.
      # In this case, nginx will win because the pattern has no wildcards,
      # while `*.conf` has one.
      def filter(lexers)
        mapping = {}
        lexers.each do |lexer|
          mapping[lexer.name] = lexer.filenames || []
        end

        GlobMapping.new(mapping, @filename).filter(lexers)
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
rouge-4.5.1 lib/rouge/guessers/filename.rb
rouge-4.5.0 lib/rouge/guessers/filename.rb
rouge-4.4.0 lib/rouge/guessers/filename.rb
rouge-4.3.0 lib/rouge/guessers/filename.rb
rouge-4.2.1 lib/rouge/guessers/filename.rb
rouge-4.2.0 lib/rouge/guessers/filename.rb
rouge-4.1.3 lib/rouge/guessers/filename.rb
rouge-4.1.2 lib/rouge/guessers/filename.rb
rouge-4.1.1 lib/rouge/guessers/filename.rb
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/rouge-3.30.0/lib/rouge/guessers/filename.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/rouge-3.30.0/lib/rouge/guessers/filename.rb
rouge-4.1.0 lib/rouge/guessers/filename.rb
rouge-4.0.1 lib/rouge/guessers/filename.rb
rouge-4.0.0 lib/rouge/guessers/filename.rb
rouge-3.30.0 lib/rouge/guessers/filename.rb
rouge-3.29.0 lib/rouge/guessers/filename.rb
rouge-3.28.0 lib/rouge/guessers/filename.rb
rouge-3.27.0 lib/rouge/guessers/filename.rb
rouge-3.26.1 lib/rouge/guessers/filename.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/rouge-3.26.0/lib/rouge/guessers/filename.rb