class Rouge::Guessers::Filename
Attributes
fname[R]
Public Class Methods
new(filename)
click to toggle source
# File lib/rouge/guessers/filename.rb, line 7 def initialize(filename) @filename = filename end
Public Instance Methods
filter(lexers)
click to toggle source
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.
# File lib/rouge/guessers/filename.rb, line 17 def filter(lexers) mapping = {} lexers.each do |lexer| mapping[lexer.name] = lexer.filenames || [] end GlobMapping.new(mapping, @filename).filter(lexers) end