spdx 1.2.2 → 1.2.3

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: 9ee8c6428b27ec96a45846d4bcd98a9fd1d769ba
4
- data.tar.gz: 6e8ba7832367a63e560b144c9043adb3981b93f2
3
+ metadata.gz: e05e85c6f351876bc534860ed1885c57f13dc585
4
+ data.tar.gz: 28aafa0b4575e314cb4db89adf44f83fafe61714
5
5
  SHA512:
6
- metadata.gz: 10ff3a6783d7bb21042f8ac931e6657a5c30b312d5dea4552bd5131468b769d657ccec580fe1bec642f8bccc673e6299238411089ecacd1702a6527389267ce3
7
- data.tar.gz: de633ce981bc1c1acb783f83247bd6f796f917b5dc149cf2738312fc9296a9e38cdb35bd40d2ec01e2f705fdb61392c9b793b5d4eae160f140b7b4881973f3c1
6
+ metadata.gz: 308ceedae725f58f9bf809fa853571d0d3c8cff96264d2098ff85cb56be149ca58717b0e47b8beb8d51fa25be8bec34eeed8921fa545a9051e455828dc2e474a
7
+ data.tar.gz: 21c992dfcfb6f894672224dc6f2d7b557829ec24e9d976e4d222302423439056dfd38691a0f05e9c3d85991b60ad1ffe3c980cba5a9f9e899dfd840fc9262441
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Spdx
1
+ # [Spdx](http://libraries.io/rubygems/spdx)
2
2
 
3
3
  A SPDX license checker
4
4
 
data/lib/spdx.rb CHANGED
@@ -4,7 +4,15 @@ require "fuzzy_match"
4
4
 
5
5
  module Spdx
6
6
  def self.find(name)
7
- SpdxLicenses[name] || find_by_special_case(name) || closest(name)
7
+ name = name.downcase
8
+ lookup(name) || find_by_special_case(name) || closest(name)
9
+ end
10
+
11
+ def self.lookup(name)
12
+ return false if name.nil?
13
+ return SpdxLicenses[name] if SpdxLicenses[name]
14
+ lowercase = SpdxLicenses.data.keys.find{|k| k.downcase == name.downcase }
15
+ SpdxLicenses[lowercase] if lowercase
8
16
  end
9
17
 
10
18
  def self.closest(name)
@@ -12,7 +20,7 @@ module Spdx
12
20
  name = name.gsub(/(\d)/, ' \1 ')
13
21
  best_match = fuzzy_match(name)
14
22
  return nil unless best_match
15
- SpdxLicenses[best_match] || find_by_name(best_match)
23
+ lookup(best_match) || find_by_name(best_match)
16
24
  end
17
25
 
18
26
  def self.matches(name, max_distance = 40)
@@ -31,11 +39,11 @@ module Spdx
31
39
 
32
40
  def self.find_by_name(name)
33
41
  match = SpdxLicenses.data.find{|k,v| v['name'] == name }
34
- SpdxLicenses[match[0]] if match
42
+ lookup(match[0]) if match
35
43
  end
36
44
 
37
45
  def self.find_by_special_case(name)
38
- SpdxLicenses[special_cases[name.downcase]]
46
+ lookup(special_cases[name.downcase])
39
47
  end
40
48
 
41
49
  def self.special_cases
data/lib/spdx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spdx
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
data/spec/spdx_spec.rb CHANGED
@@ -8,6 +8,7 @@ describe Spdx do
8
8
 
9
9
  it "should work with case-insentive short codes" do
10
10
  expect(Spdx.find('apache-2.0').name).to eq("Apache License 2.0")
11
+ expect(Spdx.find('agpl-3.0').name).to eq("GNU Affero General Public License v3.0")
11
12
  end
12
13
 
13
14
  it "should return know license from full name" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spdx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-09 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spdx-licenses