licensee 9.13.0 → 9.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/bin/licensee +2 -2
- data/lib/licensee.rb +4 -4
- data/lib/licensee/commands/detect.rb +3 -5
- data/lib/licensee/commands/diff.rb +3 -5
- data/lib/licensee/content_helper.rb +41 -44
- data/lib/licensee/hash_helper.rb +1 -1
- data/lib/licensee/license.rb +29 -15
- data/lib/licensee/matchers.rb +1 -0
- data/lib/licensee/matchers/cabal.rb +1 -1
- data/lib/licensee/matchers/cargo.rb +1 -1
- data/lib/licensee/matchers/copyright.rb +3 -8
- data/lib/licensee/matchers/cran.rb +1 -1
- data/lib/licensee/matchers/dice.rb +2 -2
- data/lib/licensee/matchers/dist_zilla.rb +1 -1
- data/lib/licensee/matchers/gemspec.rb +4 -4
- data/lib/licensee/matchers/npm_bower.rb +5 -2
- data/lib/licensee/matchers/nuget.rb +43 -0
- data/lib/licensee/matchers/spdx.rb +1 -1
- data/lib/licensee/project_files/license_file.rb +29 -22
- data/lib/licensee/project_files/package_manager_file.rb +3 -2
- data/lib/licensee/project_files/project_file.rb +3 -4
- data/lib/licensee/project_files/readme_file.rb +1 -1
- data/lib/licensee/projects/fs_project.rb +8 -5
- data/lib/licensee/projects/git_project.rb +6 -4
- data/lib/licensee/projects/github_project.rb +1 -1
- data/lib/licensee/projects/project.rb +11 -10
- data/lib/licensee/version.rb +1 -1
- data/licensee.gemspec +7 -8
- data/spec/fixture_spec.rb +3 -3
- data/spec/fixtures/bom/LICENSE.txt +21 -0
- data/spec/fixtures/bsd-3-authorowner/LICENSE +27 -0
- data/spec/fixtures/bsd-3-noendorseslash/LICENSE +30 -0
- data/spec/fixtures/cc-by-sa-mdlinks/License.md +173 -0
- data/spec/fixtures/cc-by-sa-nocclicensor/License.md +425 -0
- data/spec/fixtures/crlf-bsd/LICENSE.md +27 -0
- data/spec/fixtures/detect.json +16 -22
- data/spec/fixtures/eupl-cal2017/LICENSE.txt +274 -0
- data/spec/fixtures/fixtures.yml +68 -20
- data/spec/fixtures/license-hashes.json +39 -37
- data/spec/fixtures/markdown-artistic/LICENSE.md +192 -0
- data/spec/fixtures/multiple-arrs/LICENSE +30 -0
- data/spec/fixtures/pixar-modified-apache/LICENSE.txt +174 -0
- data/spec/fixtures/readme-invalid-encoding/README.md +24 -0
- data/spec/fixtures/vim/LICENSE +78 -0
- data/spec/integration_spec.rb +104 -9
- data/spec/licensee/commands/detect_spec.rb +2 -2
- data/spec/licensee/content_helper_spec.rb +17 -21
- data/spec/licensee/hash_helper_spec.rb +22 -22
- data/spec/licensee/license_meta_spec.rb +5 -11
- data/spec/licensee/license_spec.rb +14 -10
- data/spec/licensee/matchers/dice_matcher_spec.rb +4 -11
- data/spec/licensee/matchers/matcher_spec.rb +6 -6
- data/spec/licensee/matchers/npm_bower_matcher_spec.rb +9 -0
- data/spec/licensee/matchers/nu_get_matcher_spec.rb +91 -0
- data/spec/licensee/project_files/license_file_spec.rb +35 -28
- data/spec/licensee/project_files/package_info_spec.rb +8 -0
- data/spec/licensee/project_spec.rb +1 -3
- data/spec/licensee/rule_spec.rb +1 -1
- data/spec/licensee_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- data/spec/vendored_license_spec.rb +2 -2
- data/vendor/choosealicense.com/_data/meta.yml +1 -1
- data/vendor/choosealicense.com/_data/rules.yml +13 -13
- data/vendor/choosealicense.com/_licenses/0bsd.txt +3 -3
- data/vendor/choosealicense.com/_licenses/apache-2.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +3 -3
- data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +3 -3
- data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +3 -3
- data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +4 -3
- data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +16 -16
- data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +16 -16
- data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/cecill-2.1.txt +6 -6
- data/vendor/choosealicense.com/_licenses/ecl-2.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/epl-1.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/epl-2.0.txt +5 -5
- data/vendor/choosealicense.com/_licenses/eupl-1.2.txt +77 -60
- data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/isc.txt +3 -3
- data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +0 -1
- data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +1 -1
- data/vendor/choosealicense.com/_licenses/mit-0.txt +45 -0
- data/vendor/choosealicense.com/_licenses/mit.txt +3 -3
- data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/ncsa.txt +24 -24
- data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +4 -4
- data/vendor/choosealicense.com/_licenses/osl-3.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/postgresql.txt +5 -5
- data/vendor/choosealicense.com/_licenses/unlicense.txt +3 -3
- data/vendor/choosealicense.com/_licenses/upl-1.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/vim.txt +111 -0
- data/vendor/choosealicense.com/_licenses/zlib.txt +3 -3
- data/vendor/license-list-XML/src/0BSD.xml +21 -0
- data/vendor/license-list-XML/src/AFL-3.0.xml +212 -0
- data/vendor/license-list-XML/src/AGPL-3.0.xml +852 -0
- data/vendor/license-list-XML/src/Apache-2.0.xml +223 -0
- data/vendor/license-list-XML/src/Artistic-2.0.xml +238 -0
- data/vendor/license-list-XML/src/BSD-2-Clause.xml +42 -0
- data/vendor/license-list-XML/src/BSD-3-Clause-Clear.xml +59 -0
- data/vendor/license-list-XML/src/BSD-3-Clause.xml +46 -0
- data/vendor/license-list-XML/src/BSD-4-Clause.xml +59 -0
- data/vendor/license-list-XML/src/BSL-1.0.xml +30 -0
- data/vendor/license-list-XML/src/CC-BY-4.0.xml +444 -0
- data/vendor/license-list-XML/src/CC-BY-SA-4.0.xml +475 -0
- data/vendor/license-list-XML/src/CC0-1.0.xml +153 -0
- data/vendor/license-list-XML/src/CECILL-2.1.xml +669 -0
- data/vendor/license-list-XML/src/ECL-2.0.xml +242 -0
- data/vendor/license-list-XML/src/EPL-1.0.xml +255 -0
- data/vendor/license-list-XML/src/EPL-2.0.xml +639 -0
- data/vendor/license-list-XML/src/EUPL-1.1.xml +337 -0
- data/vendor/license-list-XML/src/EUPL-1.2.xml +502 -0
- data/vendor/license-list-XML/src/GPL-2.0.xml +474 -0
- data/vendor/license-list-XML/src/GPL-3.0.xml +858 -0
- data/vendor/license-list-XML/src/ISC.xml +29 -0
- data/vendor/license-list-XML/src/LGPL-2.1.xml +662 -0
- data/vendor/license-list-XML/src/LGPL-3.0.xml +260 -0
- data/vendor/license-list-XML/src/LPPL-1.3c.xml +380 -0
- data/vendor/license-list-XML/src/MIT-0.xml +40 -0
- data/vendor/license-list-XML/src/MIT.xml +32 -0
- data/vendor/license-list-XML/src/MPL-2.0.xml +438 -0
- data/vendor/license-list-XML/src/MS-PL.xml +89 -0
- data/vendor/license-list-XML/src/MS-RL.xml +97 -0
- data/vendor/license-list-XML/src/NCSA.xml +60 -0
- data/vendor/license-list-XML/src/ODbL-1.0.xml +660 -0
- data/vendor/license-list-XML/src/OFL-1.1.xml +94 -0
- data/vendor/license-list-XML/src/OSL-3.0.xml +209 -0
- data/vendor/license-list-XML/src/PostgreSQL.xml +32 -0
- data/vendor/license-list-XML/src/UPL-1.0.xml +46 -0
- data/vendor/license-list-XML/src/Unlicense.xml +27 -0
- data/vendor/license-list-XML/src/Vim.xml +124 -0
- data/vendor/license-list-XML/src/WTFPL.xml +30 -0
- data/vendor/license-list-XML/src/Zlib.xml +38 -0
- metadata +97 -29
@@ -115,17 +115,11 @@ RSpec.describe Licensee::LicenseMeta do
|
|
115
115
|
context 'to_h' do
|
116
116
|
let(:hash) { subject.to_h }
|
117
117
|
let(:using) do
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
'.NET Core' => 'https://github.com/dotnet/corefx/blob/master/LICENSE.TXT'
|
124
|
-
},
|
125
|
-
{
|
126
|
-
'Rails' => 'https://github.com/rails/rails/blob/master/MIT-LICENSE'
|
127
|
-
}
|
128
|
-
]
|
118
|
+
{
|
119
|
+
'Babel' => 'https://github.com/babel/babel/blob/master/LICENSE',
|
120
|
+
'.NET Core' => 'https://github.com/dotnet/runtime/blob/master/LICENSE.TXT',
|
121
|
+
'Rails' => 'https://github.com/rails/rails/blob/master/MIT-LICENSE'
|
122
|
+
}
|
129
123
|
end
|
130
124
|
let(:expected) do
|
131
125
|
{
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::License do
|
4
|
-
let(:license_count) {
|
5
|
-
let(:hidden_license_count) {
|
4
|
+
let(:license_count) { 42 }
|
5
|
+
let(:hidden_license_count) { 29 }
|
6
6
|
let(:featured_license_count) { 3 }
|
7
7
|
let(:pseudo_license_count) { 2 }
|
8
8
|
let(:non_featured_license_count) do
|
@@ -345,7 +345,7 @@ RSpec.describe Licensee::License do
|
|
345
345
|
context 'muscache' do
|
346
346
|
let(:license) do
|
347
347
|
license = described_class.new 'MIT'
|
348
|
-
content = license.content
|
348
|
+
content = "#{license.content}[foo] [bar]"
|
349
349
|
license.instance_variable_set(:@content, content)
|
350
350
|
license
|
351
351
|
end
|
@@ -365,9 +365,10 @@ RSpec.describe Licensee::License do
|
|
365
365
|
end
|
366
366
|
|
367
367
|
context 'License.title_regex' do
|
368
|
+
namey = %i[title nickname key]
|
368
369
|
described_class.all(hidden: true, pseudo: false).each do |license|
|
369
370
|
context "the #{license.title} license" do
|
370
|
-
|
371
|
+
namey.each do |variation|
|
371
372
|
next if license.send(variation).nil?
|
372
373
|
|
373
374
|
context "the license #{variation}" do
|
@@ -382,7 +383,7 @@ RSpec.describe Licensee::License do
|
|
382
383
|
expect(described_class.find_by_title(text)).to eql(license)
|
383
384
|
end
|
384
385
|
|
385
|
-
if
|
386
|
+
if /\bGNU\b/.match?(license.title)
|
386
387
|
context "without 'GNU'" do
|
387
388
|
let(:text) { license_variation.sub(/GNU /i, '') }
|
388
389
|
|
@@ -475,26 +476,29 @@ RSpec.describe Licensee::License do
|
|
475
476
|
end
|
476
477
|
|
477
478
|
context 'source regex' do
|
479
|
+
schemes = %w[http https]
|
480
|
+
prefixes = ['www.', '']
|
481
|
+
suffixes = ['.html', '.htm', '.txt', '']
|
478
482
|
described_class.all(hidden: true, pseudo: false).each do |license|
|
479
483
|
context "the #{license.title} license" do
|
480
484
|
let(:source) { URI.parse(license.source) }
|
481
485
|
|
482
|
-
|
486
|
+
schemes.each do |scheme|
|
483
487
|
context "with a #{scheme}:// scheme" do
|
484
488
|
before { source.scheme = scheme }
|
485
489
|
|
486
|
-
|
490
|
+
prefixes.each do |prefix|
|
487
491
|
context "with '#{prefix}' before the host" do
|
488
492
|
before do
|
489
|
-
source.host = "#{prefix}#{source.host.
|
493
|
+
source.host = "#{prefix}#{source.host.delete_prefix('www.')}"
|
490
494
|
end
|
491
495
|
|
492
|
-
|
496
|
+
suffixes.each do |suffix|
|
493
497
|
context "with '#{suffix}' after the path" do
|
494
498
|
before do
|
495
499
|
next if license.key == 'wtfpl'
|
496
500
|
|
497
|
-
regex = /#{Licensee::License::SOURCE_SUFFIX}\z/
|
501
|
+
regex = /#{Licensee::License::SOURCE_SUFFIX}\z/o
|
498
502
|
source.path = source.path.sub(regex, '')
|
499
503
|
source.path = "#{source.path}#{suffix}"
|
500
504
|
end
|
@@ -6,6 +6,7 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
6
6
|
let(:mit) { Licensee::License.find('mit') }
|
7
7
|
let(:gpl) { Licensee::License.find('gpl-3.0') }
|
8
8
|
let(:agpl) { Licensee::License.find('agpl-3.0') }
|
9
|
+
let(:lgpl) { Licensee::License.find('lgpl-2.1') }
|
9
10
|
let(:cc_by) { Licensee::License.find('cc-by-4.0') }
|
10
11
|
let(:cc_by_sa) { Licensee::License.find('cc-by-sa-4.0') }
|
11
12
|
let(:content) { sub_copyright_info(gpl) }
|
@@ -19,18 +20,10 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
19
20
|
expect(subject.match).to eql(gpl)
|
20
21
|
end
|
21
22
|
|
22
|
-
it 'builds a list of potential licenses' do
|
23
|
-
expect(subject.potential_matches).to eql([agpl, gpl])
|
24
|
-
end
|
25
|
-
|
26
23
|
it 'sorts licenses by similarity' do
|
27
24
|
expect(subject.matches_by_similarity[0]).to eql([gpl, 100.0])
|
28
|
-
expect(subject.matches_by_similarity[1]).to eql([agpl,
|
29
|
-
|
30
|
-
|
31
|
-
it 'returns a list of licenses above the confidence threshold' do
|
32
|
-
expect(subject.matches_by_similarity[0]).to eql([gpl, 100.0])
|
33
|
-
expect(subject.matches_by_similarity[1]).to eql([agpl, 95.67966280295047])
|
25
|
+
expect(subject.matches_by_similarity[1]).to eql([agpl, 94.56967213114754])
|
26
|
+
expect(subject.matches_by_similarity[2]).to eql([lgpl, 26.821370750134918])
|
34
27
|
end
|
35
28
|
|
36
29
|
it 'returns the match confidence' do
|
@@ -49,7 +42,7 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
49
42
|
|
50
43
|
context 'stacked licenses' do
|
51
44
|
let(:content) do
|
52
|
-
sub_copyright_info(mit)
|
45
|
+
"#{sub_copyright_info(mit)}\n\n#{sub_copyright_info(gpl)}"
|
53
46
|
end
|
54
47
|
|
55
48
|
it "doesn't match" do
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
class MatcherSpecFixture < Licensee::Matchers::Matcher
|
4
|
+
def confidence
|
5
|
+
0
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
RSpec.describe Licensee::Matchers::Matcher do
|
4
10
|
subject { described_class.new(file) }
|
5
11
|
|
@@ -16,12 +22,6 @@ RSpec.describe Licensee::Matchers::Matcher do
|
|
16
22
|
end
|
17
23
|
|
18
24
|
context 'to_h' do
|
19
|
-
class MatcherSpecFixture < Licensee::Matchers::Matcher
|
20
|
-
def confidence
|
21
|
-
0
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
25
|
subject { MatcherSpecFixture.new(file) }
|
26
26
|
|
27
27
|
let(:hash) { subject.to_h }
|
@@ -7,6 +7,7 @@ RSpec.describe Licensee::Matchers::NpmBower do
|
|
7
7
|
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
8
8
|
let(:mit) { Licensee::License.find('mit') }
|
9
9
|
let(:other) { Licensee::License.find('other') }
|
10
|
+
let(:no_license) { Licensee::License.find('no-license') }
|
10
11
|
|
11
12
|
it 'matches' do
|
12
13
|
expect(subject.match).to eql(mit)
|
@@ -56,4 +57,12 @@ RSpec.describe Licensee::Matchers::NpmBower do
|
|
56
57
|
expect(subject.match).to eql(other)
|
57
58
|
end
|
58
59
|
end
|
60
|
+
|
61
|
+
context 'UNLICENSED' do
|
62
|
+
let(:content) { "'license': 'UNLICENSED'" }
|
63
|
+
|
64
|
+
it 'returns none' do
|
65
|
+
expect(subject.match).to eql(no_license)
|
66
|
+
end
|
67
|
+
end
|
59
68
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Licensee::Matchers::NuGet do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
6
|
+
let(:content) { '<license type="expression">mit</license>' }
|
7
|
+
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'foo.nuspec') }
|
8
|
+
let(:mit) { Licensee::License.find('mit') }
|
9
|
+
let(:apache2) { Licensee::License.find('apache-2.0') }
|
10
|
+
let(:other) { Licensee::License.find('other') }
|
11
|
+
|
12
|
+
it 'matches' do
|
13
|
+
expect(subject.match).to eql(mit)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has a confidence' do
|
17
|
+
expect(subject.confidence).to be(90)
|
18
|
+
end
|
19
|
+
|
20
|
+
{
|
21
|
+
'double quotes' => '<license type="expression">mit</license>',
|
22
|
+
'single quotes' => "<license type='expression'>mit</license>",
|
23
|
+
'whitespace' => '<license type = "expression" >mit</license >',
|
24
|
+
'leading whitespace' => ' <license type="expression">mit</license>'
|
25
|
+
}.each do |description, license_declaration|
|
26
|
+
context "with a #{description} license element" do
|
27
|
+
let(:content) { license_declaration }
|
28
|
+
|
29
|
+
it 'matches' do
|
30
|
+
expect(subject.match).to eql(mit)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'no license field' do
|
36
|
+
let(:content) { '<file>wrongelement</file>' }
|
37
|
+
|
38
|
+
it 'returns nil' do
|
39
|
+
expect(subject.match).to be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'an unknown license' do
|
44
|
+
let(:content) { '<license type="expression">foo</license>' }
|
45
|
+
|
46
|
+
it 'returns other' do
|
47
|
+
expect(subject.match).to eql(other)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'a license expression' do
|
52
|
+
let(:content) { '<license type="expression">BSD-2-Clause OR MIT</license>' }
|
53
|
+
|
54
|
+
it 'returns other' do
|
55
|
+
expect(subject.match).to eql(other)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
{
|
60
|
+
'nuget' => '<licenseUrl>https://licenses.nuget.org/Apache-2.0</licenseUrl>',
|
61
|
+
'nuget (http)' => '<licenseUrl>http://licenses.nuget.org/Apache-2.0</licenseUrl>',
|
62
|
+
'opensource' => '<licenseUrl>https://opensource.org/licenses/Apache-2.0</licenseUrl>',
|
63
|
+
'opensource (www)' => '<licenseUrl>http://www.opensource.org/licenses/Apache-2.0</licenseUrl>',
|
64
|
+
'spdx' => '<licenseUrl>https://spdx.org/licenses/Apache-2.0</licenseUrl>',
|
65
|
+
'spdx (www)' => '<licenseUrl>http://www.spdx.org/licenses/Apache-2.0</licenseUrl>',
|
66
|
+
'spdx (html)' => '<licenseUrl>https://spdx.org/licenses/Apache-2.0.html</licenseUrl>',
|
67
|
+
'spdx (txt)' => '<licenseUrl>https://spdx.org/licenses/Apache-2.0.txt</licenseUrl>'
|
68
|
+
}.each do |description, license_declaration|
|
69
|
+
context "with a #{description} licenseUrl element containing SPDX" do
|
70
|
+
let(:content) { license_declaration }
|
71
|
+
|
72
|
+
it 'matches' do
|
73
|
+
expect(subject.match).to eql(apache2)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
{
|
79
|
+
'2.0 (https)' => '<licenseUrl>https://apache.org/licenses/LICENSE-2.0</licenseUrl>',
|
80
|
+
'2.0 (http/www)' => '<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>',
|
81
|
+
'2.0 (txt)' => '<licenseUrl>https://apache.org/licenses/LICENSE-2.0.txt</licenseUrl>'
|
82
|
+
}.each do |description, license_declaration|
|
83
|
+
context "with an apache.org #{description} licenseUrl element" do
|
84
|
+
let(:content) { license_declaration }
|
85
|
+
|
86
|
+
it 'matches' do
|
87
|
+
expect(subject.match).to eql(apache2)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -47,7 +47,7 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'creates the wordset' do
|
50
|
-
expect(subject.wordset.count).to be(
|
50
|
+
expect(subject.wordset.count).to be(93)
|
51
51
|
expect(subject.wordset.first).to eql('permission')
|
52
52
|
end
|
53
53
|
|
@@ -57,32 +57,39 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
57
57
|
|
58
58
|
context 'filename scoring' do
|
59
59
|
{
|
60
|
-
'license'
|
61
|
-
'LICENCE'
|
62
|
-
'unLICENSE'
|
63
|
-
'unlicence'
|
64
|
-
'license.md'
|
65
|
-
'LICENSE.md'
|
66
|
-
'license.txt'
|
67
|
-
'COPYING'
|
68
|
-
'copyRIGHT'
|
69
|
-
'COPYRIGHT.txt'
|
70
|
-
'copying.txt'
|
71
|
-
'LICENSE.php'
|
72
|
-
'LICENCE.docs'
|
73
|
-
'
|
74
|
-
'
|
75
|
-
'
|
76
|
-
'
|
77
|
-
'
|
78
|
-
'
|
79
|
-
'
|
80
|
-
'
|
81
|
-
'
|
82
|
-
'
|
83
|
-
'ofl'
|
84
|
-
'
|
85
|
-
'
|
60
|
+
'license' => 1.00,
|
61
|
+
'LICENCE' => 1.00,
|
62
|
+
'unLICENSE' => 1.00,
|
63
|
+
'unlicence' => 1.00,
|
64
|
+
'license.md' => 0.95,
|
65
|
+
'LICENSE.md' => 0.95,
|
66
|
+
'license.txt' => 0.95,
|
67
|
+
'COPYING' => 0.90,
|
68
|
+
'copyRIGHT' => 0.90,
|
69
|
+
'COPYRIGHT.txt' => 0.85,
|
70
|
+
'copying.txt' => 0.85,
|
71
|
+
'LICENSE.php' => 0.80,
|
72
|
+
'LICENCE.docs' => 0.80,
|
73
|
+
'license.xml' => 0.80,
|
74
|
+
'copying.image' => 0.75,
|
75
|
+
'COPYRIGHT.go' => 0.75,
|
76
|
+
'LICENSE-MIT' => 0.70,
|
77
|
+
'LICENSE_1_0.txt' => 0.70,
|
78
|
+
'COPYING-GPL' => 0.65,
|
79
|
+
'COPYRIGHT-BSD' => 0.65,
|
80
|
+
'MIT-LICENSE.txt' => 0.60,
|
81
|
+
'mit-license-foo.md' => 0.60,
|
82
|
+
'OFL.md' => 0.50,
|
83
|
+
'ofl.textile' => 0.45,
|
84
|
+
'ofl' => 0.40,
|
85
|
+
'not-the-ofl' => 0.00,
|
86
|
+
'README.txt' => 0.00,
|
87
|
+
'.pip-license-ignore' => 0.00,
|
88
|
+
'license-checks.xml' => 0.00,
|
89
|
+
'license_test.go' => 0.00,
|
90
|
+
'licensee.gemspec' => 0.00,
|
91
|
+
'LICENSE.spdx' => 0.00
|
92
|
+
|
86
93
|
}.each do |filename, expected|
|
87
94
|
context "a file named #{filename}" do
|
88
95
|
let(:score) { described_class.name_score(filename) }
|
@@ -162,7 +169,7 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
162
169
|
expect(subject).not_to be_a_potential_false_positive
|
163
170
|
end
|
164
171
|
|
165
|
-
context 'a CC false positive
|
172
|
+
context 'a CC false positive with creative commons in the title' do
|
166
173
|
let(:content) { 'Creative Commons Attribution-NonCommercial 4.0' }
|
167
174
|
|
168
175
|
it "knows it's a potential false positive" do
|
@@ -71,5 +71,13 @@ RSpec.describe Licensee::ProjectFiles::PackageManagerFile do
|
|
71
71
|
expect(possible_matchers).to eql([Licensee::Matchers::Cran])
|
72
72
|
end
|
73
73
|
end
|
74
|
+
|
75
|
+
context 'with nuspec file' do
|
76
|
+
let(:filename) { 'foo.nuspec' }
|
77
|
+
|
78
|
+
it 'returns the NuGet matcher' do
|
79
|
+
expect(possible_matchers).to eql([Licensee::Matchers::NuGet])
|
80
|
+
end
|
81
|
+
end
|
74
82
|
end
|
75
83
|
end
|
@@ -106,9 +106,7 @@
|
|
106
106
|
license = files.find { |f| f[:name] == 'LICENSE.txt' }
|
107
107
|
expect(license).not_to be_nil
|
108
108
|
|
109
|
-
if described_class == Licensee::Projects::GitProject
|
110
|
-
expect(files.first).to have_key(:oid)
|
111
|
-
end
|
109
|
+
expect(files.first).to have_key(:oid) if described_class == Licensee::Projects::GitProject
|
112
110
|
end
|
113
111
|
|
114
112
|
it "returns a file's content" do
|
data/spec/licensee/rule_spec.rb
CHANGED
@@ -62,7 +62,7 @@ RSpec.describe Licensee::Rule do
|
|
62
62
|
context 'to_h' do
|
63
63
|
let(:hash) { described_class.all.first.to_h }
|
64
64
|
let(:description) do
|
65
|
-
'
|
65
|
+
'The licensed material and derivatives may be used for commercial purposes.'
|
66
66
|
end
|
67
67
|
let(:expected) do
|
68
68
|
{
|
data/spec/licensee_spec.rb
CHANGED
@@ -4,7 +4,7 @@ RSpec.describe Licensee do
|
|
4
4
|
let(:project_path) { fixture_path('mit') }
|
5
5
|
let(:license_path) { fixture_path('mit/LICENSE.txt') }
|
6
6
|
let(:mit_license) { Licensee::License.find('mit') }
|
7
|
-
let(:hidden_license_count) {
|
7
|
+
let(:hidden_license_count) { 42 }
|
8
8
|
|
9
9
|
it 'exposes licenses' do
|
10
10
|
expect(described_class.licenses).to be_an(Array)
|
data/spec/spec_helper.rb
CHANGED
@@ -80,8 +80,8 @@ end
|
|
80
80
|
|
81
81
|
# Add random words to the end of a license to test similarity tollerances
|
82
82
|
def add_random_words(string, count = 5)
|
83
|
-
words = string.dup.split
|
84
|
-
ipsum = File.read(fixture_path('ipsum.txt')).split
|
83
|
+
words = string.dup.split
|
84
|
+
ipsum = File.read(fixture_path('ipsum.txt')).split
|
85
85
|
count.times do
|
86
86
|
word = ipsum[Random.rand(ipsum.length)]
|
87
87
|
index = Random.rand(words.length)
|
@@ -91,7 +91,7 @@ def add_random_words(string, count = 5)
|
|
91
91
|
end
|
92
92
|
|
93
93
|
# Init git dir
|
94
|
-
#
|
94
|
+
# NOTE: we disable gpgsign and restore it to its original setting to avoid
|
95
95
|
# Signing commits during tests and slowing down / breaking specs
|
96
96
|
def git_init(path)
|
97
97
|
Dir.chdir path do
|
@@ -16,8 +16,8 @@ RSpec.describe 'vendored licenses' do
|
|
16
16
|
let(:content) { content_with_copyright }
|
17
17
|
let(:expected_hash) { license_hashes[license.key] }
|
18
18
|
let(:hash_change_msg) do
|
19
|
-
msg = 'Did you update a vendored license? Run'
|
20
|
-
msg << '
|
19
|
+
msg = +'Did you update a vendored license? Run '
|
20
|
+
msg << '`bundle exec script/hash-licenses`. '
|
21
21
|
msg << 'Changes in license hashes must be a MINOR (or MAJOR) bump.'
|
22
22
|
msg
|
23
23
|
end
|
@@ -30,7 +30,7 @@
|
|
30
30
|
required: true
|
31
31
|
|
32
32
|
- name: using
|
33
|
-
description: 'A list of 3 notable projects using the license with straightforward LICENSE files which serve as examples newcomers can follow and that can be detected by [licensee](https://github.com/
|
33
|
+
description: 'A list of 3 notable projects using the license with straightforward LICENSE files which serve as examples newcomers can follow and that can be detected by [licensee](https://github.com/licensee/licensee) in the form of `project_name: license_file_url`'
|
34
34
|
required: true
|
35
35
|
|
36
36
|
# Optional fields
|