Class: LicenseFinder::License::Base
- Inherits:
-
Object
- Object
- LicenseFinder::License::Base
show all
- Defined in:
- lib/license_finder/license.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(text) ⇒ Base
Returns a new instance of Base.
71
72
73
|
# File 'lib/license_finder/license.rb', line 71
def initialize(text)
self.text = text
end
|
Class Attribute Details
.alternative_names ⇒ Object
Returns the value of attribute alternative_names.
31
32
33
|
# File 'lib/license_finder/license.rb', line 31
def alternative_names
@alternative_names
end
|
.license_url ⇒ Object
Returns the value of attribute license_url.
31
32
33
|
# File 'lib/license_finder/license.rb', line 31
def license_url
@license_url
end
|
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
75
76
77
|
# File 'lib/license_finder/license.rb', line 75
def text
@text
end
|
Class Method Details
.demodulized_name ⇒ Object
45
46
47
|
# File 'lib/license_finder/license.rb', line 45
def demodulized_name
name.gsub(/^.*::/, '')
end
|
.inherited(descendant) ⇒ Object
33
34
35
|
# File 'lib/license_finder/license.rb', line 33
def inherited(descendant)
License.all << descendant
end
|
.license_regex ⇒ Object
66
67
68
|
# File 'lib/license_finder/license.rb', line 66
def license_regex
/#{Regexp.escape(license_text).gsub(/<[^<>]+>/, '(.*)')}/ if license_text
end
|
.license_text ⇒ Object
57
58
59
60
61
62
63
64
|
# File 'lib/license_finder/license.rb', line 57
def license_text
unless defined?(@license_text)
template = ROOT_PATH.join("data", "licenses", "#{demodulized_name}.txt")
@license_text = Text.new(template.read).to_s if template.exist?
end
@license_text
end
|
.names ⇒ Object
37
38
39
|
# File 'lib/license_finder/license.rb', line 37
def names
([demodulized_name, pretty_name] + self.alternative_names).uniq
end
|
.pretty_name ⇒ Object
53
54
55
|
# File 'lib/license_finder/license.rb', line 53
def pretty_name
demodulized_name
end
|
.slug ⇒ Object
49
50
51
|
# File 'lib/license_finder/license.rb', line 49
def slug
demodulized_name.downcase
end
|
Instance Method Details
#matches? ⇒ Boolean
81
82
83
|
# File 'lib/license_finder/license.rb', line 81
def matches?
!!(text =~ self.class.license_regex if self.class.license_regex)
end
|