Module: LicenseFinder::License::Text

Defined in:
lib/license_finder/license/text.rb

Constant Summary collapse

SPACES =
/\s+/
QUOTES =
/['`"]{1,2}/
PLACEHOLDERS =
/<[^<>]+>/

Class Method Summary collapse

Class Method Details

.compile_to_regex(text) ⇒ Object



14
15
16
# File 'lib/license_finder/license/text.rb', line 14

def self.compile_to_regex(text)
  Regexp.new(Regexp.escape(text).gsub(PLACEHOLDERS, '(.*)'))
end

.normalize_punctuation(text) ⇒ Object



8
9
10
11
12
# File 'lib/license_finder/license/text.rb', line 8

def self.normalize_punctuation(text)
  text.gsub(SPACES, ' ')
      .gsub(QUOTES, '"')
      .strip
end