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
47
|
# 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)
@spdx_id = settings.fetch(:spdx_id, '')
@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.
49
50
51
|
# File 'lib/license_finder/license.rb', line 49
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
71
72
73
|
# File 'lib/license_finder/license.rb', line 71
def eql?(other)
name == other.name
end
|
#hash ⇒ Object
75
76
77
|
# File 'lib/license_finder/license.rb', line 75
def hash
name.hash
end
|
#matches_name?(name) ⇒ Boolean
63
64
65
|
# File 'lib/license_finder/license.rb', line 63
def matches_name?(name)
names.map(&:downcase).include? name.to_s.downcase
end
|
#matches_text?(text) ⇒ Boolean
67
68
69
|
# File 'lib/license_finder/license.rb', line 67
def matches_text?(text)
matcher.matches_text?(text)
end
|
#name ⇒ Object
51
52
53
|
# File 'lib/license_finder/license.rb', line 51
def name
pretty_name
end
|
#standard_id ⇒ Object
55
56
57
|
# File 'lib/license_finder/license.rb', line 55
def standard_id
spdx_id
end
|
#stripped_name(name) ⇒ Object
59
60
61
|
# File 'lib/license_finder/license.rb', line 59
def stripped_name(name)
name.sub(/^The /i, '')
end
|
#unrecognized_matcher? ⇒ Boolean
79
80
81
|
# File 'lib/license_finder/license.rb', line 79
def unrecognized_matcher?
matcher.is_a?(NoneMatcher)
end
|