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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d766a47dd9215350c16975d59ac9053d2e1b2e7
4
- data.tar.gz: df2aed7e4d51620490bc20737beddf11c3f4ffca
3
+ metadata.gz: 9fa5b959342b847dd4c55eff65bf5d466042edba
4
+ data.tar.gz: 6b125065762166d0b0fc53d5a1db53e01af2cf2e
5
5
  SHA512:
6
- metadata.gz: ea10fa6deca9df416c8977d1577be155ed13a12d8750c593ed9da4d034ac052f4043800a8c06d7fc86bed1c3bb153850fad1abd4cebefede831754f1534feb03
7
- data.tar.gz: 5dd629e1f02dba2d815eb052d3ae99be780196fbecd53c512002afdf28703ad4a8ad9cbfeac52fa39fd3b7dd1032b72f8f6fb314c26589b72c5c23349323ca19
6
+ metadata.gz: 363008842caa6f04d24cbe2f73400d11ee9279d6c052b8588bf0030d723fb2c5684316a8a7b17aef23e6931e8afa52e2a87ccc87d9f7693acef6ddf4c66ca355
7
+ data.tar.gz: 2dcc097077a44525ccc2a266291305c9ef6333e012ce60366571306bdb440d70bb9ce9c323340ddba086e5cb5a6bf28f8dea30e6ca7c2e12c9008e71aa96cbea
@@ -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= \"#{key}\" name=\"#{name}\">"
59
+ "#<Licensee::License key=\"#{key}\" name=\"#{name}\">"
55
60
  end
56
61
 
57
62
  private
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Licensee
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: licensee
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter