Class: LicenseFinder::License
- Inherits:
-
Object
- Object
- LicenseFinder::License
show all
- Defined in:
- lib/license_finder/license.rb,
lib/license_finder/license/text.rb,
lib/license_finder/license/matcher.rb,
lib/license_finder/license/template.rb,
lib/license_finder/license/any_matcher.rb,
lib/license_finder/license/definitions.rb,
lib/license_finder/license/none_matcher.rb,
lib/license_finder/license/header_matcher.rb
Defined Under Namespace
Modules: Definitions, Text
Classes: AnyMatcher, HeaderMatcher, Matcher, NoneMatcher, Template
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(settings) ⇒ License
Returns a new instance of License.
40
41
42
43
44
45
46
|
# File 'lib/license_finder/license.rb', line 40
def initialize(settings)
@short_name = settings.fetch(:short_name)
@pretty_name = settings.fetch(:pretty_name, short_name)
@other_names = settings.fetch(:other_names, [])
@url = settings.fetch(:url)
@matcher = settings.fetch(:matcher) { Matcher.from_template(Template.named(short_name)) }
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
48
49
50
|
# File 'lib/license_finder/license.rb', line 48
def url
@url
end
|
Class Method Details
.all ⇒ Object
16
17
18
|
# File 'lib/license_finder/license.rb', line 16
def all
@all ||= Definitions.all
end
|
.find_by_name(name) ⇒ Object
.find_by_text(text) ⇒ Object
35
36
37
|
# File 'lib/license_finder/license.rb', line 35
def find_by_text(text)
all.detect { |l| l.matches_text? text }
end
|
Instance Method Details
#eql?(other) ⇒ Boolean
66
67
68
|
# File 'lib/license_finder/license.rb', line 66
def eql?(other)
name == other.name
end
|
#hash ⇒ Object
70
71
72
|
# File 'lib/license_finder/license.rb', line 70
def hash
name.hash
end
|
#matches_name?(name) ⇒ Boolean
58
59
60
|
# File 'lib/license_finder/license.rb', line 58
def matches_name?(name)
names.map(&:downcase).include? name.to_s.downcase
end
|
#matches_text?(text) ⇒ Boolean
62
63
64
|
# File 'lib/license_finder/license.rb', line 62
def matches_text?(text)
matcher.matches_text?(text)
end
|
#name ⇒ Object
50
51
52
|
# File 'lib/license_finder/license.rb', line 50
def name
pretty_name
end
|
#stripped_name(name) ⇒ Object
54
55
56
|
# File 'lib/license_finder/license.rb', line 54
def stripped_name(name)
name.sub(/^The /i, '')
end
|
#unrecognized_matcher? ⇒ Boolean
74
75
76
|
# File 'lib/license_finder/license.rb', line 74
def unrecognized_matcher?
matcher.is_a?(NoneMatcher)
end
|