Class: LicenseFinder::License::Matcher

Inherits:
Struct
  • Object
show all
Defined in:
lib/license_finder/license/matcher.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#regexpObject

Returns the value of attribute regexp

Returns:

  • (Object)

    the current value of regexp



3
4
5
# File 'lib/license_finder/license/matcher.rb', line 3

def regexp
  @regexp
end

Class Method Details

.from_regex(regexp) ⇒ Object

an alias for Matcher.new, for uniformity of constructors



13
14
15
# File 'lib/license_finder/license/matcher.rb', line 13

def self.from_regex(regexp)
  new(regexp)
end

.from_template(template) ⇒ Object



4
5
6
# File 'lib/license_finder/license/matcher.rb', line 4

def self.from_template(template)
  from_text(template.content)
end

.from_text(text) ⇒ Object



8
9
10
# File 'lib/license_finder/license/matcher.rb', line 8

def self.from_text(text)
  from_regex(Text.compile_to_regex(text))
end

Instance Method Details

#matches_text?(text) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/license_finder/license/matcher.rb', line 17

def matches_text?(text)
  !!(Text.normalize_punctuation(text) =~ regexp)
end