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.
26
27
28
29
30
31
32
33
|
# File 'lib/license_finder/license.rb', line 26
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)
@whitelisted = settings.fetch(:whitelisted, false)
@matcher = settings.fetch(:matcher) { Matcher.from_template(Template.named(short_name)) }
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
35
36
37
|
# File 'lib/license_finder/license.rb', line 35
def url
@url
end
|
Class Method Details
.find_by_name(name) ⇒ Object
.find_by_text(text) ⇒ Object
13
14
15
|
# File 'lib/license_finder/license.rb', line 13
def find_by_text(text)
all.detect { |l| l.matches_text? text }
end
|
Instance Method Details
#matches_name?(name) ⇒ Boolean
41
42
43
|
# File 'lib/license_finder/license.rb', line 41
def matches_name?(name)
names.map(&:downcase).include? name.to_s.downcase
end
|
#matches_text?(text) ⇒ Boolean
45
46
47
|
# File 'lib/license_finder/license.rb', line 45
def matches_text?(text)
matcher.matches_text?(text)
end
|
#name ⇒ Object
37
38
39
|
# File 'lib/license_finder/license.rb', line 37
def name
pretty_name
end
|
#whitelist ⇒ Object
53
54
55
|
# File 'lib/license_finder/license.rb', line 53
def whitelist
copy(whitelisted: true)
end
|
#whitelisted? ⇒ Boolean
49
50
51
|
# File 'lib/license_finder/license.rb', line 49
def whitelisted?
@whitelisted
end
|