Class: Licensee::Licenses
- Inherits:
-
Object
- Object
- Licensee::Licenses
- Defined in:
- lib/licensee/licenses.rb
Class Method Summary collapse
-
.base ⇒ Object
Path to vendored licenses.
-
.find(key) ⇒ Object
(also: [])
Given a license key, attempt to return a matching Licensee::License instance.
-
.keys ⇒ Object
Returns a list of potential license keys, as vendored.
-
.list ⇒ Object
Returns an array of Licensee::License instances.
Class Method Details
.base ⇒ Object
Path to vendored licenses
21 22 23 |
# File 'lib/licensee/licenses.rb', line 21 def base @base ||= File. "../../vendor/choosealicense.com/_licenses", File.dirname(__FILE__) end |
.find(key) ⇒ Object Also known as: []
Given a license key, attempt to return a matching Licensee::License instance
15 16 17 |
# File 'lib/licensee/licenses.rb', line 15 def find(key) list.find { |l| l.key.downcase == key.downcase } end |
.keys ⇒ Object
Returns a list of potential license keys, as vendored
26 27 28 29 30 31 32 33 |
# File 'lib/licensee/licenses.rb', line 26 def keys @keys ||= begin keyes = Dir.entries(base) keyes.map! { |l| File.basename(l, ".txt").downcase } keyes.reject! { |l| l =~ /^\./ || l.nil? } keyes end end |