Module: Rouge::Guessers::Util

Included in:
Disambiguation, Disambiguation::Disambiguator, GlobMapping, Modeline, Source
Defined in:
lib/rouge/guessers/util.rb

Defined Under Namespace

Modules: SourceNormalizer

Instance Method Summary collapse

Instance Method Details

#get_source(source) ⇒ String

Parameters:

  • source (String, IO)

Returns:

  • (String)


23
24
25
26
27
28
29
30
31
# File 'lib/rouge/guessers/util.rb', line 23

def get_source(source)
  if source.respond_to?(:to_str)
    SourceNormalizer.normalize(source.to_str)
  elsif source.respond_to?(:read)
    SourceNormalizer.normalize(source.read)
  else
    raise ArgumentError, "Invalid source: #{source.inspect}"
  end
end

#test_glob(pattern, path) ⇒ Object



17
18
19
# File 'lib/rouge/guessers/util.rb', line 17

def test_glob(pattern, path)
  File.fnmatch?(pattern, path, File::FNM_DOTMATCH | File::FNM_CASEFOLD)
end