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 +4 -4
- data/README.md +1 -1
- data/lib/spdx.rb +12 -4
- data/lib/spdx/version.rb +1 -1
- data/spec/spdx_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e05e85c6f351876bc534860ed1885c57f13dc585
|
4
|
+
data.tar.gz: 28aafa0b4575e314cb4db89adf44f83fafe61714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 308ceedae725f58f9bf809fa853571d0d3c8cff96264d2098ff85cb56be149ca58717b0e47b8beb8d51fa25be8bec34eeed8921fa545a9051e455828dc2e474a
|
7
|
+
data.tar.gz: 21c992dfcfb6f894672224dc6f2d7b557829ec24e9d976e4d222302423439056dfd38691a0f05e9c3d85991b60ad1ffe3c980cba5a9f9e899dfd840fc9262441
|
data/README.md
CHANGED
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
|
-
|
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
|
-
|
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
|
-
|
42
|
+
lookup(match[0]) if match
|
35
43
|
end
|
36
44
|
|
37
45
|
def self.find_by_special_case(name)
|
38
|
-
|
46
|
+
lookup(special_cases[name.downcase])
|
39
47
|
end
|
40
48
|
|
41
49
|
def self.special_cases
|
data/lib/spdx/version.rb
CHANGED
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.
|
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
|
11
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spdx-licenses
|