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



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

def regexp
  @regexp
end

Class Method Details

.from_regex(regexp) ⇒ Object

an alias for Matcher.new, for uniformity of constructors



15
16
17
# File 'lib/license_finder/license/matcher.rb', line 15

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

.from_template(template) ⇒ Object



6
7
8
# File 'lib/license_finder/license/matcher.rb', line 6

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

.from_text(text) ⇒ Object



10
11
12
# File 'lib/license_finder/license/matcher.rb', line 10

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

Instance Method Details

#matches_text?(text) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/license_finder/license/matcher.rb', line 19

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