licensee 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/licensee/license.rb +6 -1
- data/lib/licensee/licenses.rb +7 -0
- data/lib/licensee/version.rb +1 -1
- data/test/test_licensee_licenses.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fa5b959342b847dd4c55eff65bf5d466042edba
|
4
|
+
data.tar.gz: 6b125065762166d0b0fc53d5a1db53e01af2cf2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 363008842caa6f04d24cbe2f73400d11ee9279d6c052b8588bf0030d723fb2c5684316a8a7b17aef23e6931e8afa52e2a87ccc87d9f7693acef6ddf4c66ca355
|
7
|
+
data.tar.gz: 2dcc097077a44525ccc2a266291305c9ef6333e012ce60366571306bdb440d70bb9ce9c323340ddba086e5cb5a6bf28f8dea30e6ca7c2e12c9008e71aa96cbea
|
data/lib/licensee/license.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
class Licensee
|
2
2
|
class License
|
3
|
+
|
4
|
+
def self.all
|
5
|
+
Licensee::licenses.list
|
6
|
+
end
|
7
|
+
|
3
8
|
attr_reader :key
|
4
9
|
|
5
10
|
def initialize(key)
|
@@ -51,7 +56,7 @@ class Licensee
|
|
51
56
|
end
|
52
57
|
|
53
58
|
def inspect
|
54
|
-
"#<Licensee::License key
|
59
|
+
"#<Licensee::License key=\"#{key}\" name=\"#{name}\">"
|
55
60
|
end
|
56
61
|
|
57
62
|
private
|
data/lib/licensee/licenses.rb
CHANGED
@@ -11,10 +11,17 @@ class Licensee
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def sorted_list
|
15
|
+
list.sort { |a,b| a.name <=> b.name }.
|
16
|
+
partition { |license| license.featured? }.
|
17
|
+
flatten
|
18
|
+
end
|
19
|
+
|
14
20
|
# Given a license key, attempt to return a matching Licensee::License instance
|
15
21
|
def find(key)
|
16
22
|
list.find { |l| l.key.downcase == key.downcase }
|
17
23
|
end
|
24
|
+
alias_method :[], :find
|
18
25
|
|
19
26
|
# Path to vendored licenses
|
20
27
|
def base
|
data/lib/licensee/version.rb
CHANGED
@@ -16,6 +16,11 @@ class TestLicenseeLicenses < Minitest::Test
|
|
16
16
|
should "find a license" do
|
17
17
|
assert_equal "mit", Licensee::Licenses.find("mit").key
|
18
18
|
assert_equal "mit", Licensee::Licenses.find("MIT").key
|
19
|
+
assert_equal "mit", Licensee::Licenses["mit"].key
|
19
20
|
end
|
20
21
|
|
22
|
+
should "sort the licenses" do
|
23
|
+
assert_equal "apache-2.0", Licensee::Licenses.sorted_list.first.key
|
24
|
+
assert_equal "bsd-2-clause", Licensee::Licenses.sorted_list.last.key
|
25
|
+
end
|
21
26
|
end
|