spdx 1.4.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spdx.gemspec CHANGED
@@ -1,25 +1,28 @@
1
- lib = File.expand_path('lib', __dir__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'spdx/version'
5
+ require "spdx/version"
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = 'spdx'
8
+ spec.name = "spdx"
7
9
  spec.version = Spdx::VERSION
8
- spec.authors = ['Andrew Nesbitt']
9
- spec.email = ['andrewnez@gmail.com']
10
- spec.summary = 'A SPDX license normalizer'
11
- spec.homepage = 'https://github.com/librariesio/spdx'
12
- spec.license = 'MIT'
10
+ spec.authors = ["Tidelift, Inc."]
11
+ spec.email = ["support@tidelift.com"]
12
+ spec.summary = "A SPDX license normalizer"
13
+ spec.homepage = "https://github.com/librariesio/spdx"
14
+ spec.license = "MIT"
13
15
 
14
16
  spec.files = `git ls-files -z`.split("\x0")
15
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
- spec.require_paths = ['lib']
19
+ spec.require_paths = ["lib"]
18
20
 
19
- spec.add_dependency 'fuzzy_match', '~> 2.1'
20
- spec.add_dependency 'spdx-licenses', '~> 1.2'
21
- spec.add_development_dependency 'bundler', '~> 1.16'
22
- spec.add_development_dependency 'rake', '~> 12'
23
- spec.add_development_dependency 'rspec', '~> 3.7'
24
- spec.add_development_dependency 'rubocop'
21
+ spec.add_dependency "fuzzy_match", "~> 2.1"
22
+ spec.add_dependency "treetop", "~> 1.6"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "pry"
25
+ spec.add_development_dependency "rake", "~> 12"
26
+ spec.add_development_dependency "rspec", "~> 3.7"
27
+ spec.add_development_dependency "rubocop"
25
28
  end
data/spec/spdx_spec.rb CHANGED
@@ -1,183 +1,220 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
2
4
 
3
5
  describe Spdx do
4
- describe 'find' do
5
- it 'should return know license from short code' do
6
- expect(Spdx.find('Apache-2.0').name).to eq('Apache License 2.0')
6
+ describe "find" do
7
+ it "should return know license from short code" do
8
+ expect(Spdx.find("Apache-2.0").name).to eq("Apache License 2.0")
7
9
  end
8
10
 
9
- it 'should work with case-insentive short codes' do
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
+ it "should work with case-insentive short codes" do
12
+ expect(Spdx.find("apache-2.0").name).to eq("Apache License 2.0")
13
+ expect(Spdx.find("agpl-3.0").name).to eq("GNU Affero General Public License v3.0")
12
14
  end
13
15
 
14
- it 'should return know license from full name' do
15
- expect(Spdx.find('Apache License 2.0').name).to eq('Apache License 2.0')
16
+ it "should return know license from full name" do
17
+ expect(Spdx.find("Apache License 2.0").name).to eq("Apache License 2.0")
16
18
  end
17
19
 
18
- it 'should return nil for commercial' do
19
- expect(Spdx.find('Commercial')).to be_nil
20
+ it "should return nil for commercial" do
21
+ expect(Spdx.find("Commercial")).to be_nil
20
22
  end
21
23
 
22
- it 'should return nil for garbage' do
23
- expect(Spdx.find('foo bar baz')).to be_nil
24
- expect(Spdx.find('Copyright Zendesk. All Rights Reserved.')).to be_nil
25
- expect(Spdx.find('https://github.com/AuthorizeNet/sdk-ruby/blob/master/license.txt')).to be_nil
24
+ it "should return nil for garbage" do
25
+ expect(Spdx.find("foo bar baz")).to be_nil
26
+ expect(Spdx.find("https://github.com/AuthorizeNet/sdk-ruby/blob/master/license.txt")).to be_nil
26
27
  end
27
28
 
28
- it 'should return know license from an alias' do
29
- expect(Spdx.find('The Apache Software License, Version 2.0').name).to eq('Apache License 2.0')
30
- expect(Spdx.find('Apache 2.0').name).to eq('Apache License 2.0')
31
- expect(Spdx.find('Apache2').name).to eq('Apache License 2.0')
32
- expect(Spdx.find('Apache License, Version 2.0').name).to eq('Apache License 2.0')
33
- expect(Spdx.find('Educational Community License, Version 2.0').name).to eq('Educational Community License v2.0')
34
- expect(Spdx.find('CDDL + GPLv2 with classpath exception').name).to \
35
- eq('GNU General Public License v2.0 w/Classpath exception')
36
- expect(Spdx.find('The MIT License').name).to eq('MIT License')
37
- expect(Spdx.find('UNLICENSE').name).to eq('The Unlicense')
29
+ it "should return know license from an alias" do
30
+ expect(Spdx.find("The Apache Software License, Version 2.0").name).to eq("Apache License 2.0")
31
+ expect(Spdx.find("Apache 2.0").name).to eq("Apache License 2.0")
32
+ expect(Spdx.find("Apache2").name).to eq("Apache License 2.0")
33
+ expect(Spdx.find("Apache License, Version 2.0").name).to eq("Apache License 2.0")
34
+ expect(Spdx.find("Educational Community License, Version 2.0").name).to eq("Educational Community License v2.0")
35
+ expect(Spdx.find("CDDL + GPLv2 with classpath exception").name).to \
36
+ eq("GNU General Public License v2.0 w/Classpath exception")
37
+ expect(Spdx.find("The MIT License").name).to eq("MIT License")
38
+ expect(Spdx.find("UNLICENSE").name).to eq("The Unlicense")
38
39
  end
39
40
 
40
- it 'should strip whitespace from strings before lookups' do
41
- expect(Spdx.find(' BSD-3-Clause').id).to eq('BSD-3-Clause')
41
+ it "should strip whitespace from strings before lookups" do
42
+ expect(Spdx.find(" BSD-3-Clause").id).to eq("BSD-3-Clause")
42
43
  end
43
44
 
44
- it 'should handle pypi classifiers properly' do
45
+ it "should handle pypi classifiers properly" do
45
46
  pypi_mappings = [
46
- ['Aladdin Free Public License (AFPL)', 'Aladdin'],
47
- ['CC0 1.0 Universal (CC0 1.0) Public Domain Dedication', 'CC0-1.0'],
48
- ['CeCILL-B Free Software License Agreement (CECILL-B)', 'CECILL-B'],
49
- ['CeCILL-C Free Software License Agreement (CECILL-C)', 'CECILL-C'],
50
- ['Eiffel Forum License (EFL)', 'EFL-2.0'],
51
- ['Netscape Public License (NPL)', 'NPL-1.1'],
52
- ['Nokia Open Source License (NOKOS)', 'Nokia'],
53
- ['Academic Free License (AFL)', 'AFL-3.0'],
54
- ['Apache Software License', 'Apache-2.0'],
55
- ['Apple Public Source License', 'APSL-2.0'],
56
- ['Artistic License', 'Artistic-2.0'],
57
- ['Attribution Assurance License', 'AAL'],
58
- ['Boost Software License 1.0 (BSL-1.0)', 'BSL-1.0'],
59
- ['BSD License', 'BSD-3-Clause'],
60
- ['Common Development and Distribution License 1.0 (CDDL-1.0)', 'CDDL-1.0'],
61
- ['Common Public License', 'CPL-1.0'],
62
- ['Eclipse Public License 1.0 (EPL-1.0)', 'EPL-1.0'],
63
- ['Eclipse Public License 2.0 (EPL-2.0)', 'EPL-2.0'],
64
- ['Eiffel Forum License', 'EFL-2.0'],
65
- ['European Union Public Licence 1.0 (EUPL 1.0)', 'EUPL-1.0'],
66
- ['European Union Public Licence 1.1 (EUPL 1.1)', 'EUPL-1.1'],
67
- ['European Union Public Licence 1.2 (EUPL 1.2)', 'EUPL-1.2'],
68
- ['GNU Affero General Public License v3', 'AGPL-3.0'],
69
- ['GNU Affero General Public License v3 or later (AGPLv3+)', 'AGPL-3.0-or-later'],
70
- ['GNU Free Documentation License (FDL)', 'GFDL-1.3'],
71
- ['GNU General Public License (GPL)', 'GPL-2.0+'],
72
- ['GNU General Public License v2 (GPLv2)', 'GPL-2.0'],
73
- ['GNU General Public License v2 or later (GPLv2+)', 'GPL-2.0+'],
74
- ['GNU General Public License v3 (GPLv3)', 'GPL-3.0'],
75
- ['GNU General Public License v3 or later (GPLv3+)', 'GPL-3.0+'],
76
- ['GNU Lesser General Public License v2 (LGPLv2)', 'LGPL-2.0'],
77
- ['GNU Lesser General Public License v2 or later (LGPLv2+)', 'LGPL-2.0+'],
78
- ['GNU Lesser General Public License v3 (LGPLv3)', 'LGPL-3.0'],
79
- ['GNU Lesser General Public License v3 or later (LGPLv3+)', 'LGPL-3.0+'],
80
- ['GNU Library or Lesser General Public License (LGPL)', 'LGPL-2.0+'],
81
- ['IBM Public License', 'IPL-1.0'],
82
- ['Intel Open Source License', 'Intel'],
83
- ['ISC License (ISCL)', 'ISC'],
84
- ['MirOS License (MirOS)', 'MirOS'],
85
- ['MIT License', 'MIT'],
86
- ['Motosoto License', 'Motosoto'],
87
- ['Mozilla Public License 1.0 (MPL)', 'MPL-1.0'],
88
- ['Mozilla Public License 1.1 (MPL 1.1)', 'MPL-1.1'],
89
- ['Mozilla Public License 2.0 (MPL 2.0)', 'MPL-2.0'],
90
- ['Nethack General Public License', 'NGPL'],
91
- ['Nokia Open Source License', 'Nokia'],
92
- ['Open Group Test Suite License', 'OGTSL'],
93
- ['PostgreSQL License', 'PostgreSQL'],
94
- ['Python License (CNRI Python License)', 'CNRI-Python'],
95
- ['Python Software Foundation License', 'Python-2.0'],
96
- ['Qt Public License (QPL)', 'QPL-1.0'],
97
- ['Ricoh Source Code Public License', 'RSCPL'],
98
- ['SIL Open Font License 1.1 (OFL-1.1)', 'OFL-1.1'],
99
- ['Sleepycat License', 'Sleepycat'],
100
- ['Sun Industry Standards Source License (SISSL)', 'SISSL-1.2'],
101
- ['Sun Public License', 'SPL-1.0'],
102
- ['Universal Permissive License (UPL)', 'UPL-1.0'],
103
- ['University of Illinois/NCSA Open Source License', 'NCSA'],
104
- ['Vovida Software License 1.0', 'VSL-1.0'],
105
- ['W3C License', 'W3C'],
106
- ['X.Net License', 'Xnet'],
107
- ['zlib/libpng License', 'zlib-acknowledgement'],
108
- ['Zope Public License', 'ZPL-2.1']
47
+ ["Aladdin Free Public License (AFPL)", "Aladdin"],
48
+ ["CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", "CC0-1.0"],
49
+ ["CeCILL-B Free Software License Agreement (CECILL-B)", "CECILL-B"],
50
+ ["CeCILL-C Free Software License Agreement (CECILL-C)", "CECILL-C"],
51
+ ["Eiffel Forum License (EFL)", "EFL-2.0"],
52
+ ["Netscape Public License (NPL)", "NPL-1.1"],
53
+ ["Nokia Open Source License (NOKOS)", "Nokia"],
54
+ ["Academic Free License (AFL)", "AFL-3.0"],
55
+ ["Apache Software License", "Apache-2.0"],
56
+ ["Apple Public Source License", "APSL-2.0"],
57
+ ["Artistic License", "Artistic-2.0"],
58
+ ["Attribution Assurance License", "AAL"],
59
+ ["Boost Software License 1.0 (BSL-1.0)", "BSL-1.0"],
60
+ ["BSD License", "BSD-3-Clause"],
61
+ ["Common Development and Distribution License 1.0 (CDDL-1.0)", "CDDL-1.0"],
62
+ ["Common Public License", "CPL-1.0"],
63
+ ["Eclipse Public License 1.0 (EPL-1.0)", "EPL-1.0"],
64
+ ["Eclipse Public License 2.0 (EPL-2.0)", "EPL-2.0"],
65
+ ["Eiffel Forum License", "EFL-2.0"],
66
+ ["European Union Public Licence 1.0 (EUPL 1.0)", "EUPL-1.0"],
67
+ ["European Union Public Licence 1.1 (EUPL 1.1)", "EUPL-1.1"],
68
+ ["European Union Public Licence 1.2 (EUPL 1.2)", "EUPL-1.2"],
69
+ ["GNU Affero General Public License v3", "AGPL-3.0"],
70
+ ["GNU Affero General Public License v3 or later (AGPLv3+)", "AGPL-3.0-or-later"],
71
+ ["GNU Free Documentation License (FDL)", "GFDL-1.3"],
72
+ ["GNU General Public License (GPL)", "GPL-2.0+"],
73
+ ["GNU General Public License v2 (GPLv2)", "GPL-2.0"],
74
+ ["GNU General Public License v2 or later (GPLv2+)", "GPL-2.0+"],
75
+ ["GNU General Public License v3 (GPLv3)", "GPL-3.0"],
76
+ ["GNU General Public License v3 or later (GPLv3+)", "GPL-3.0+"],
77
+ ["GNU Lesser General Public License v2 (LGPLv2)", "LGPL-2.0"],
78
+ ["GNU Lesser General Public License v2 or later (LGPLv2+)", "LGPL-2.0+"],
79
+ ["GNU Lesser General Public License v3 (LGPLv3)", "LGPL-3.0"],
80
+ ["GNU Lesser General Public License v3 or later (LGPLv3+)", "LGPL-3.0+"],
81
+ ["GNU Library or Lesser General Public License (LGPL)", "LGPL-2.0+"],
82
+ ["IBM Public License", "IPL-1.0"],
83
+ ["Intel Open Source License", "Intel"],
84
+ ["ISC License (ISCL)", "ISC"],
85
+ # ['MirOS License (MirOS)', 'MirOS'],
86
+ ["MIT License", "MIT"],
87
+ ["Motosoto License", "Motosoto"],
88
+ ["Mozilla Public License 1.0 (MPL)", "MPL-1.0"],
89
+ ["Mozilla Public License 1.1 (MPL 1.1)", "MPL-1.1"],
90
+ ["Mozilla Public License 2.0 (MPL 2.0)", "MPL-2.0"],
91
+ ["Nethack General Public License", "NGPL"],
92
+ ["Nokia Open Source License", "Nokia"],
93
+ ["Open Group Test Suite License", "OGTSL"],
94
+ ["PostgreSQL License", "PostgreSQL"],
95
+ ["Python License (CNRI Python License)", "CNRI-Python"],
96
+ # ['Python Software Foundation License', 'Python-2.0'],
97
+ ["Qt Public License (QPL)", "QPL-1.0"],
98
+ ["Ricoh Source Code Public License", "RSCPL"],
99
+ ["SIL Open Font License 1.1 (OFL-1.1)", "OFL-1.1"],
100
+ ["Sleepycat License", "Sleepycat"],
101
+ ["Sun Industry Standards Source License (SISSL)", "SISSL-1.2"],
102
+ ["Sun Public License", "SPL-1.0"],
103
+ ["Universal Permissive License (UPL)", "UPL-1.0"],
104
+ ["University of Illinois/NCSA Open Source License", "NCSA"],
105
+ ["Vovida Software License 1.0", "VSL-1.0"],
106
+ ["W3C License", "W3C"],
107
+ ["X.Net License", "Xnet"],
108
+ ["zlib/libpng License", "zlib-acknowledgement"],
109
+ ["Zope Public License", "ZPL-2.1"],
109
110
  ]
110
111
  pypi_mappings.each do |license, mapped|
111
112
  expect(Spdx.find(license).id).to eq(mapped)
112
113
  end
113
114
  end
114
115
 
115
- it 'should return know licenses for special cases' do
116
- expect(Spdx.find('MPL1').name).to eq('Mozilla Public License 1.0')
117
- expect(Spdx.find('MPL1.0').name).to eq('Mozilla Public License 1.0')
118
- expect(Spdx.find('MPL1.1').name).to eq('Mozilla Public License 1.1')
119
- expect(Spdx.find('MPL2').name).to eq('Mozilla Public License 2.0')
120
- expect(Spdx.find('MPL2.0').name).to eq('Mozilla Public License 2.0')
121
- expect(Spdx.find('GPL3').name).to eq('GNU General Public License v3.0 only')
122
- expect(Spdx.find('GPL v3').name).to eq('GNU General Public License v3.0 only')
123
- expect(Spdx.find('GPL3').name).to eq('GNU General Public License v3.0 only')
124
- expect(Spdx.find('GPL 3.0').name).to eq('GNU General Public License v3.0 only')
125
- expect(Spdx.find('GPL-3').name).to eq('GNU General Public License v3.0 only')
126
- expect(Spdx.find('GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]').name).to \
127
- eq('GNU General Public License v2.0 or later')
128
- expect(Spdx.find('GPL-2 | GPL-3 [expanded from: GPL]').name).to \
129
- eq('GNU General Public License v2.0 or later')
130
- expect(Spdx.find('GPL (≥ 3)').name).to eq('GNU General Public License v3.0 or later')
131
- expect(Spdx.find('gpl30').name).to eq('GNU General Public License v3.0 only')
132
- expect(Spdx.find('GPL v2+').name).to eq('GNU General Public License v2.0 or later')
133
- expect(Spdx.find('GPL 2').name).to eq('GNU General Public License v2.0 only')
134
- expect(Spdx.find('GPL v2').name).to eq('GNU General Public License v2.0 only')
135
- expect(Spdx.find('GPL2').name).to eq('GNU General Public License v2.0 only')
136
- expect(Spdx.find('GPL-2 | GPL-3').name).to eq('GNU General Public License v2.0 or later')
137
- expect(Spdx.find('GPL-2 | GPL-3 [expanded from: GPL (≥ 2.0)]').name).to \
138
- eq('GNU General Public License v2.0 or later')
139
- expect(Spdx.find('GPL2 w/ CPE').name).to eq('GNU General Public License v2.0 w/Classpath exception')
140
- expect(Spdx.find('GPL 2.0').name).to eq('GNU General Public License v2.0 only')
141
- expect(Spdx.find('New BSD License (GPL-compatible)').name).to eq('BSD 3-Clause "New" or "Revised" License')
142
- expect(Spdx.find('The GPL V3').name).to eq('GNU General Public License v3.0 only')
143
- expect(Spdx.find('perl_5').name).to eq('Artistic License 1.0 (Perl)')
144
- expect(Spdx.find('BSD3').name).to eq('BSD 3-Clause "New" or "Revised" License')
145
- expect(Spdx.find('BSD').name).to eq('BSD 3-Clause "New" or "Revised" License')
146
- expect(Spdx.find('GPLv3').name).to eq('GNU General Public License v3.0 only')
147
- expect(Spdx.find('LGPLv2 or later').name).to eq('GNU Library General Public License v2.1 or later')
148
- expect(Spdx.find('GPLv2 or later').name).to eq('GNU General Public License v2.0 or later')
149
- expect(Spdx.find('Public Domain').name).to eq('The Unlicense')
150
- expect(Spdx.find('GPL-2').name).to eq('GNU General Public License v2.0 only')
151
- expect(Spdx.find('GPL').name).to eq('GNU General Public License v2.0 or later')
152
- expect(Spdx.find('GNU LESSER GENERAL PUBLIC LICENSE').name).to \
153
- eq('GNU Library General Public License v2.1 or later')
154
- expect(Spdx.find('New BSD License').name).to eq('BSD 3-Clause "New" or "Revised" License')
155
- expect(Spdx.find('(MIT OR X11) ').name).to eq('MIT License')
156
- expect(Spdx.find('mit-license').name).to eq('MIT License')
157
- expect(Spdx.find('lgpl-3').name).to eq('GNU Lesser General Public License v3.0 only')
158
- expect(Spdx.find('agpl-3').name).to eq('GNU Affero General Public License v3.0')
159
- expect(Spdx.find('cc by-sa 4.0').name).to eq('Creative Commons Attribution Share Alike 4.0 International')
160
- expect(Spdx.find('cc by-nc-sa 3.0').name).to \
161
- eq('Creative Commons Attribution Non Commercial Share Alike 3.0 Unported')
162
- expect(Spdx.find('cc by-sa 3.0').name).to eq('Creative Commons Attribution Share Alike 3.0 Unported')
163
- expect(Spdx.find('gpl_1').name).to eq('GNU General Public License v1.0 only')
164
- expect(Spdx.find('gpl_2').name).to eq('GNU General Public License v2.0 only')
165
- expect(Spdx.find('gpl_3').name).to eq('GNU General Public License v3.0 only')
166
- expect(Spdx.find('artistic_2').name).to eq('Artistic License 2.0')
167
- expect(Spdx.find('artistic_1').name).to eq('Artistic License 1.0')
168
- expect(Spdx.find('apache_2_0').name).to eq('Apache License 2.0')
169
- expect(Spdx.find('apache_v2').name).to eq('Apache License 2.0')
170
- expect(Spdx.find('lgpl_2_1').name).to eq('GNU Lesser General Public License v2.1 only')
171
- expect(Spdx.find('lgpl_v2_1').name).to eq('GNU Lesser General Public License v2.1 only')
116
+ it "should return know licenses for special cases" do
117
+ expect(Spdx.find("MPL1").name).to eq("Mozilla Public License 1.0")
118
+ expect(Spdx.find("MPL1.0").name).to eq("Mozilla Public License 1.0")
119
+ expect(Spdx.find("MPL1.1").name).to eq("Mozilla Public License 1.1")
120
+ expect(Spdx.find("MPL2").name).to eq("Mozilla Public License 2.0")
121
+ expect(Spdx.find("MPL2.0").name).to eq("Mozilla Public License 2.0")
122
+ expect(Spdx.find("GPL3").name).to eq("GNU General Public License v3.0 only")
123
+ expect(Spdx.find("GPL v3").name).to eq("GNU General Public License v3.0 only")
124
+ expect(Spdx.find("GPL3").name).to eq("GNU General Public License v3.0 only")
125
+ expect(Spdx.find("GPL 3.0").name).to eq("GNU General Public License v3.0 only")
126
+ expect(Spdx.find("GPL-3").name).to eq("GNU General Public License v3.0 only")
127
+ expect(Spdx.find("GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]").name).to \
128
+ eq("GNU General Public License v2.0 or later")
129
+ expect(Spdx.find("GPL-2 | GPL-3 [expanded from: GPL]").name).to \
130
+ eq("GNU General Public License v2.0 or later")
131
+ expect(Spdx.find("GPL (≥ 3)").name).to eq("GNU General Public License v3.0 or later")
132
+ expect(Spdx.find("gpl30").name).to eq("GNU General Public License v3.0 only")
133
+ expect(Spdx.find("GPL v2+").name).to eq("GNU General Public License v2.0 or later")
134
+ expect(Spdx.find("GPL 2").name).to eq("GNU General Public License v2.0 only")
135
+ expect(Spdx.find("GPL v2").name).to eq("GNU General Public License v2.0 only")
136
+ expect(Spdx.find("GPL2").name).to eq("GNU General Public License v2.0 only")
137
+ expect(Spdx.find("GPL-2 | GPL-3").name).to eq("GNU General Public License v2.0 or later")
138
+ expect(Spdx.find("GPL-2 | GPL-3 [expanded from: GPL (≥ 2.0)]").name).to \
139
+ eq("GNU General Public License v2.0 or later")
140
+ expect(Spdx.find("GPL2 w/ CPE").name).to eq("GNU General Public License v2.0 w/Classpath exception")
141
+ expect(Spdx.find("GPL 2.0").name).to eq("GNU General Public License v2.0 only")
142
+ expect(Spdx.find("New BSD License (GPL-compatible)").name).to eq('BSD 3-Clause "New" or "Revised" License')
143
+ expect(Spdx.find("The GPL V3").name).to eq("GNU General Public License v3.0 only")
144
+ expect(Spdx.find("perl_5").name).to eq("Artistic License 1.0 (Perl)")
145
+ expect(Spdx.find("BSD3").name).to eq('BSD 3-Clause "New" or "Revised" License')
146
+ expect(Spdx.find("BSD").name).to eq('BSD 3-Clause "New" or "Revised" License')
147
+ expect(Spdx.find("GPLv3").name).to eq("GNU General Public License v3.0 only")
148
+ expect(Spdx.find("LGPLv2 or later").name).to eq("GNU Library General Public License v2.1 or later")
149
+ expect(Spdx.find("GPLv2 or later").name).to eq("GNU General Public License v2.0 or later")
150
+ expect(Spdx.find("Public Domain").name).to eq("The Unlicense")
151
+ expect(Spdx.find("GPL-2").name).to eq("GNU General Public License v2.0 only")
152
+ expect(Spdx.find("GPL").name).to eq("GNU General Public License v2.0 or later")
153
+ expect(Spdx.find("GNU LESSER GENERAL PUBLIC LICENSE").name).to \
154
+ eq("GNU Library General Public License v2.1 or later")
155
+ expect(Spdx.find("New BSD License").name).to eq('BSD 3-Clause "New" or "Revised" License')
156
+ expect(Spdx.find("(MIT OR X11) ").name).to eq("MIT License")
157
+ expect(Spdx.find("mit-license").name).to eq("MIT License")
158
+ expect(Spdx.find("lgpl-3").name).to eq("GNU Lesser General Public License v3.0 only")
159
+ expect(Spdx.find("agpl-3").name).to eq("GNU Affero General Public License v3.0")
160
+ expect(Spdx.find("cc by-sa 4.0").name).to eq("Creative Commons Attribution Share Alike 4.0 International")
161
+ expect(Spdx.find("cc by-nc-sa 3.0").name).to \
162
+ eq("Creative Commons Attribution Non Commercial Share Alike 3.0 Unported")
163
+ expect(Spdx.find("cc by-sa 3.0").name).to eq("Creative Commons Attribution Share Alike 3.0 Unported")
164
+ expect(Spdx.find("gpl_1").name).to eq("GNU General Public License v1.0 only")
165
+ expect(Spdx.find("gpl_2").name).to eq("GNU General Public License v2.0 only")
166
+ expect(Spdx.find("gpl_3").name).to eq("GNU General Public License v3.0 only")
167
+ expect(Spdx.find("artistic_2").name).to eq("Artistic License 2.0")
168
+ expect(Spdx.find("artistic_1").name).to eq("Artistic License 1.0")
169
+ expect(Spdx.find("apache_2_0").name).to eq("Apache License 2.0")
170
+ expect(Spdx.find("apache_v2").name).to eq("Apache License 2.0")
171
+ expect(Spdx.find("lgpl_2_1").name).to eq("GNU Lesser General Public License v2.1 only")
172
+ expect(Spdx.find("lgpl_v2_1").name).to eq("GNU Lesser General Public License v2.1 only")
172
173
 
173
- expect(Spdx.find('BSD 3-Clause').name).to eq('BSD 3-Clause "New" or "Revised" License')
174
- expect(Spdx.find('BSD 3-Clause').name).to eq('BSD 3-Clause "New" or "Revised" License')
175
- expect(Spdx.find('BSD 2-Clause').name).to eq('BSD 2-Clause "Simplified" License')
176
- expect(Spdx.find('BSD 2-clause').name).to eq('BSD 2-Clause "Simplified" License')
177
- expect(Spdx.find('BSD Style').name).to eq('BSD 3-Clause "New" or "Revised" License')
174
+ expect(Spdx.find("BSD 3-Clause").name).to eq('BSD 3-Clause "New" or "Revised" License')
175
+ expect(Spdx.find("BSD 3-Clause").name).to eq('BSD 3-Clause "New" or "Revised" License')
176
+ expect(Spdx.find("BSD 2-Clause").name).to eq('BSD 2-Clause "Simplified" License')
177
+ expect(Spdx.find("BSD 2-clause").name).to eq('BSD 2-Clause "Simplified" License')
178
+ expect(Spdx.find("BSD Style").name).to eq('BSD 3-Clause "New" or "Revised" License')
178
179
 
179
- expect(Spdx.find('GNU LGPL v3+').name).to eq('GNU Lesser General Public License v3.0 only')
180
- expect(Spdx.find('ZPL 2.1').name).to eq('Zope Public License 2.1')
180
+ expect(Spdx.find("GNU LGPL v3+").name).to eq("GNU Lesser General Public License v3.0 only")
181
+ expect(Spdx.find("ZPL 2.1").name).to eq("Zope Public License 2.1")
182
+ end
183
+ end
184
+ context "spdx parsing" do
185
+ context "valid_spdx?" do
186
+ it "returns false for invalid spdx" do
187
+ expect(Spdx.valid_spdx?("AND AND")).to be false
188
+ expect(Spdx.valid_spdx?("MIT OR MIT AND OR")).to be false
189
+ expect(Spdx.valid_spdx?("MIT OR FAKEYLICENSE")).to be false
190
+ expect(Spdx.valid_spdx?(nil)).to be false
191
+ expect(Spdx.valid_spdx?("")).to be false
192
+ end
193
+ it "returns true for valid spdx" do
194
+ expect(Spdx.valid_spdx?("(MIT OR MPL-2.0)")).to be true
195
+ expect(Spdx.valid_spdx?("MIT")).to be true
196
+ expect(Spdx.valid_spdx?("((MIT OR AGPL-1.0) AND (MIT OR MPL-2.0))")).to be true
197
+ end
198
+ it "returns true for NONE and NOASSERTION" do
199
+ expect(Spdx.valid_spdx?("NONE")).to be true
200
+ expect(Spdx.valid_spdx?("(NONE)")).to be false
201
+ expect(Spdx.valid_spdx?("NOASSERTION")).to be true
202
+ expect(Spdx.valid_spdx?("MIT OR NONE")).to be false
203
+ end
204
+ end
205
+ end
206
+ context "alias lookup" do
207
+ it "returns false for an alias that doesn't exist" do
208
+ expect(Spdx.alias_exists?("FAKEALIAS")).to be false
209
+ end
210
+ end
211
+ context "licenses" do
212
+ it "returns a list of possible licenses" do
213
+ expect(Spdx.parse_spdx("MIT OR MPL-2.0").licenses).to eq ["MIT", "MPL-2.0"]
214
+ end
215
+ it "returns empty array for NONE or NOASSERTION" do
216
+ expect(Spdx.parse_spdx("NONE").licenses).to eq []
217
+ expect(Spdx.parse_spdx("NOASSERTION").licenses).to eq []
181
218
  end
182
219
  end
183
220
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,4 @@
1
- require 'bundler/setup'
2
- require 'spdx'
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "spdx"
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.4.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
- - Andrew Nesbitt
7
+ - Tidelift, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-10 00:00:00.000000000 Z
11
+ date: 2020-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fuzzy_match
@@ -25,33 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: spdx-licenses
28
+ name: treetop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.2'
33
+ version: '1.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.2'
40
+ version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.16'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.16'
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -96,8 +110,9 @@ dependencies:
96
110
  version: '0'
97
111
  description:
98
112
  email:
99
- - andrewnez@gmail.com
100
- executables: []
113
+ - support@tidelift.com
114
+ executables:
115
+ - update-license-files
101
116
  extensions: []
102
117
  extra_rdoc_files: []
103
118
  files:
@@ -114,8 +129,17 @@ files:
114
129
  - LICENSE.txt
115
130
  - README.md
116
131
  - Rakefile
132
+ - aliases.json
133
+ - bin/update-license-files
134
+ - exceptions.json
135
+ - lib/exception.rb
136
+ - lib/license.rb
117
137
  - lib/spdx.rb
118
138
  - lib/spdx/version.rb
139
+ - lib/spdx_grammar.rb
140
+ - lib/spdx_parser.rb
141
+ - lib/spdx_parser.treetop
142
+ - licenses.json
119
143
  - spdx.gemspec
120
144
  - spec/spdx_spec.rb
121
145
  - spec/spec_helper.rb
@@ -138,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
162
  - !ruby/object:Gem::Version
139
163
  version: '0'
140
164
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.6.13
165
+ rubygems_version: 3.0.3
143
166
  signing_key:
144
167
  specification_version: 4
145
168
  summary: A SPDX license normalizer