licensee 6.1.1 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/bin/licensee +7 -4
- data/lib/licensee.rb +25 -22
- data/lib/licensee/content_helper.rb +5 -4
- data/lib/licensee/license.rb +56 -45
- data/lib/licensee/matchers/copyright_matcher.rb +2 -2
- data/lib/licensee/matchers/dice_matcher.rb +7 -4
- data/lib/licensee/matchers/exact_matcher.rb +2 -2
- data/lib/licensee/matchers/gemspec_matcher.rb +5 -2
- data/lib/licensee/matchers/npm_bower_matcher.rb +5 -2
- data/lib/licensee/matchers/package_matcher.rb +2 -2
- data/lib/licensee/project.rb +21 -96
- data/lib/licensee/project_file.rb +6 -7
- data/lib/licensee/project_files/license_file.rb +3 -3
- data/lib/licensee/project_files/package_info.rb +7 -7
- data/lib/licensee/project_files/readme.rb +24 -0
- data/lib/licensee/projects/fs_project.rb +32 -0
- data/lib/licensee/projects/git_project.rb +55 -0
- data/lib/licensee/version.rb +2 -2
- data/test/fixtures/bower-with-readme/README.md +1 -0
- data/test/fixtures/bower-with-readme/bower.json +3 -0
- data/test/functions.rb +23 -12
- data/test/helper.rb +5 -0
- data/test/test_licensee.rb +9 -8
- data/test/test_licensee_bin.rb +11 -5
- data/test/test_licensee_copyright_matcher.rb +23 -23
- data/test/test_licensee_dice_matcher.rb +5 -5
- data/test/test_licensee_exact_matcher.rb +4 -4
- data/test/test_licensee_gemspec_matcher.rb +4 -4
- data/test/test_licensee_license.rb +82 -70
- data/test/test_licensee_license_file.rb +30 -28
- data/test/test_licensee_npm_bower_matcher.rb +11 -11
- data/test/test_licensee_package_info.rb +8 -7
- data/test/test_licensee_project.rb +45 -37
- data/test/test_licensee_project_file.rb +9 -9
- data/test/test_licensee_readme.rb +47 -0
- data/test/test_licensee_vendor.rb +10 -7
- data/vendor/choosealicense.com/_licenses/afl-3.0.txt +0 -3
- data/vendor/choosealicense.com/_licenses/agpl-3.0.txt +5 -5
- data/vendor/choosealicense.com/_licenses/apache-2.0.txt +1 -2
- data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +14 -13
- data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +2 -3
- data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +0 -6
- data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +2 -4
- data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +2 -1
- data/vendor/choosealicense.com/_licenses/epl-1.0.txt +2 -1
- data/vendor/choosealicense.com/_licenses/eupl-1.1.txt +345 -0
- data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +5 -5
- data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +5 -4
- data/vendor/choosealicense.com/_licenses/isc.txt +1 -2
- data/vendor/choosealicense.com/_licenses/lgpl-2.1.txt +5 -6
- data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +8 -8
- data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +445 -0
- data/vendor/choosealicense.com/_licenses/mit.txt +1 -1
- data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +2 -1
- data/vendor/choosealicense.com/_licenses/ms-pl.txt +0 -1
- data/vendor/choosealicense.com/_licenses/ms-rl.txt +1 -1
- data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +1 -2
- data/vendor/choosealicense.com/_licenses/osl-3.0.txt +1 -3
- data/vendor/choosealicense.com/_licenses/unlicense.txt +1 -2
- data/vendor/choosealicense.com/_licenses/wtfpl.txt +0 -2
- metadata +33 -11
- data/vendor/choosealicense.com/_licenses/no-license.txt +0 -25
@@ -1,27 +1,27 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestLicenseeNpmBowerMatchers < Minitest::Test
|
4
|
-
should
|
5
|
-
pkg = File.read fixture_path(
|
4
|
+
should 'detect NPM files' do
|
5
|
+
pkg = File.read fixture_path('npm/package.json')
|
6
6
|
pkgfile = Licensee::Project::PackageInfo.new(pkg)
|
7
7
|
matcher = Licensee::Matchers::NpmBower.new(pkgfile)
|
8
|
-
assert_equal
|
9
|
-
assert_equal
|
8
|
+
assert_equal 'mit', matcher.send(:license_property)
|
9
|
+
assert_equal 'mit', matcher.match.key
|
10
10
|
end
|
11
11
|
|
12
|
-
should
|
13
|
-
pkg = File.read fixture_path(
|
12
|
+
should 'detect Bower files' do
|
13
|
+
pkg = File.read fixture_path('bower/bower.json')
|
14
14
|
pkgfile = Licensee::Project::PackageInfo.new(pkg)
|
15
15
|
matcher = Licensee::Matchers::NpmBower.new(pkgfile)
|
16
|
-
assert_equal
|
17
|
-
assert_equal
|
16
|
+
assert_equal 'mit', matcher.send(:license_property)
|
17
|
+
assert_equal 'mit', matcher.match.key
|
18
18
|
end
|
19
19
|
|
20
|
-
should
|
21
|
-
pkg = File.read fixture_path(
|
20
|
+
should 'not err on non-spdx licenses' do
|
21
|
+
pkg = File.read fixture_path('npm-non-spdx/package.json')
|
22
22
|
pkgfile = Licensee::Project::PackageInfo.new(pkg)
|
23
23
|
matcher = Licensee::Matchers::NpmBower.new(pkgfile)
|
24
|
-
assert_equal
|
24
|
+
assert_equal 'mit-1.0', matcher.send(:license_property)
|
25
25
|
assert_equal nil, matcher.match
|
26
26
|
end
|
27
27
|
end
|
@@ -1,17 +1,18 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestLicenseePackageInfo < Minitest::Test
|
4
|
-
context
|
4
|
+
context 'license filename scoring' do
|
5
5
|
EXPECTATIONS = {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
}
|
6
|
+
'licensee.gemspec' => 1.0,
|
7
|
+
'package.json' => 1.0,
|
8
|
+
'bower.json' => 0.75,
|
9
|
+
'README.md' => 0.0
|
10
|
+
}.freeze
|
11
11
|
|
12
12
|
EXPECTATIONS.each do |filename, expected|
|
13
13
|
should "score a license named `#{filename}` as `#{expected}`" do
|
14
|
-
|
14
|
+
score = Licensee::Project::PackageInfo.name_score(filename)
|
15
|
+
assert_equal expected, score
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -2,86 +2,94 @@ require 'helper'
|
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
4
|
class TestLicenseeProject < Minitest::Test
|
5
|
-
|
6
|
-
["git", "filesystem"].each do |project_type|
|
5
|
+
%w(git filesystem).each do |project_type|
|
7
6
|
describe("#{project_type} repository project") do
|
8
|
-
if project_type ==
|
7
|
+
if project_type == 'git'
|
9
8
|
def make_project(fixture_name)
|
10
9
|
fixture = fixture_path fixture_name
|
11
10
|
Licensee::GitProject.new(fixture)
|
12
11
|
end
|
13
12
|
else
|
14
13
|
def make_project(fixture_name)
|
15
|
-
dest = File.join(
|
14
|
+
dest = File.join('tmp', 'fixtures', fixture_name)
|
16
15
|
FileUtils.mkdir_p File.dirname(dest)
|
17
|
-
system
|
18
|
-
FileUtils.rm_r File.join(dest,
|
16
|
+
system 'git', 'clone', '-q', fixture_path(fixture_name), dest
|
17
|
+
FileUtils.rm_r File.join(dest, '.git')
|
19
18
|
|
20
19
|
Licensee::FSProject.new(dest)
|
21
20
|
end
|
22
21
|
|
23
22
|
def teardown
|
24
|
-
FileUtils.rm_rf
|
23
|
+
FileUtils.rm_rf 'tmp/fixtures'
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
|
-
should
|
29
|
-
project = make_project
|
27
|
+
should 'detect the license file' do
|
28
|
+
project = make_project 'licenses.git'
|
30
29
|
assert_instance_of Licensee::Project::LicenseFile, project.license_file
|
31
30
|
end
|
32
31
|
|
33
|
-
should
|
34
|
-
project = make_project
|
35
|
-
assert_equal
|
32
|
+
should 'detect the license' do
|
33
|
+
project = make_project 'licenses.git'
|
34
|
+
assert_equal 'mit', project.license.key
|
36
35
|
end
|
37
36
|
|
38
|
-
should
|
39
|
-
project = make_project
|
37
|
+
should 'detect an atypically cased license file' do
|
38
|
+
project = make_project 'case-sensitive.git'
|
40
39
|
assert_instance_of Licensee::Project::LicenseFile, project.license_file
|
41
40
|
end
|
42
41
|
|
43
|
-
should
|
44
|
-
project = make_project
|
45
|
-
assert_equal
|
42
|
+
should 'detect MIT-LICENSE licensed projects' do
|
43
|
+
project = make_project 'named-license-file-prefix.git'
|
44
|
+
assert_equal 'mit', project.license.key
|
46
45
|
end
|
47
46
|
|
48
|
-
should
|
49
|
-
project = make_project
|
50
|
-
assert_equal
|
47
|
+
should 'detect LICENSE-MIT licensed projects' do
|
48
|
+
project = make_project 'named-license-file-suffix.git'
|
49
|
+
assert_equal 'mit', project.license.key
|
51
50
|
end
|
52
51
|
|
53
|
-
should
|
54
|
-
project = make_project
|
52
|
+
should 'not error out on repos with folders names license' do
|
53
|
+
project = make_project 'license-folder.git'
|
55
54
|
assert_equal nil, project.license
|
56
55
|
end
|
57
56
|
|
58
|
-
should
|
59
|
-
project = make_project
|
60
|
-
assert_equal
|
57
|
+
should 'detect licence files' do
|
58
|
+
project = make_project 'licence.git'
|
59
|
+
assert_equal 'mit', project.license.key
|
61
60
|
end
|
62
61
|
|
63
|
-
should
|
64
|
-
project = make_project
|
62
|
+
should 'detect an unlicensed project' do
|
63
|
+
project = make_project 'no-license.git'
|
65
64
|
assert_equal nil, project.license
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
|
-
describe
|
71
|
-
should
|
72
|
-
verify_license_file fixture_path(
|
69
|
+
describe 'mit license with title removed' do
|
70
|
+
should 'detect the MIT license' do
|
71
|
+
verify_license_file fixture_path('mit-without-title/mit.txt')
|
73
72
|
end
|
74
73
|
|
75
|
-
should
|
76
|
-
verify_license_file fixture_path(
|
74
|
+
should 'should detect the MIT license when rewrapped' do
|
75
|
+
verify_license_file fixture_path('mit-without-title-rewrapped/mit.txt')
|
77
76
|
end
|
78
77
|
end
|
79
78
|
|
80
|
-
describe
|
81
|
-
should
|
82
|
-
|
83
|
-
|
84
|
-
|
79
|
+
describe 'packages' do
|
80
|
+
should 'detect a package file' do
|
81
|
+
path = fixture_path('npm.git')
|
82
|
+
options = { detect_packages: true }
|
83
|
+
project = Licensee::GitProject.new(path, options)
|
84
|
+
assert_equal 'package.json', project.package_file.filename
|
85
|
+
assert_equal 'mit', project.license.key
|
86
|
+
end
|
87
|
+
|
88
|
+
should 'skip readme if no license content' do
|
89
|
+
path = fixture_path('bower-with-readme')
|
90
|
+
options = { detect_packages: true, detect_readme: true }
|
91
|
+
project = Licensee::FSProject.new(path, options)
|
92
|
+
assert_equal 'mit', project.license.key
|
85
93
|
end
|
86
94
|
end
|
87
95
|
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestLicenseeProjectFile < Minitest::Test
|
4
|
-
|
5
4
|
def setup
|
6
|
-
@repo = Rugged::Repository.new(fixture_path(
|
7
|
-
|
5
|
+
@repo = Rugged::Repository.new(fixture_path('licenses.git'))
|
6
|
+
ref = 'bcb552d06d9cf1cd4c048a6d3bf716849c2216cc'
|
7
|
+
blob, = Rugged::Blob.to_buffer(@repo, ref)
|
8
8
|
@file = Licensee::Project::LicenseFile.new(blob)
|
9
|
-
@gpl = Licensee::License.find
|
10
|
-
@mit = Licensee::License.find
|
9
|
+
@gpl = Licensee::License.find 'GPL-3.0'
|
10
|
+
@mit = Licensee::License.find 'MIT'
|
11
11
|
end
|
12
12
|
|
13
|
-
should
|
13
|
+
should 'read the file' do
|
14
14
|
assert @file.content =~ /MIT/
|
15
15
|
end
|
16
16
|
|
17
|
-
should
|
18
|
-
assert_equal
|
17
|
+
should 'match the license' do
|
18
|
+
assert_equal 'mit', @file.license.key
|
19
19
|
end
|
20
20
|
|
21
|
-
should
|
21
|
+
should 'calculate confidence' do
|
22
22
|
assert_equal 100, @file.confidence
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestLicenseeReadme < Minitest::Test
|
4
|
+
context 'readme filename scoring' do
|
5
|
+
EXPECTATIONS = {
|
6
|
+
'readme' => 1.0,
|
7
|
+
'README' => 1.0,
|
8
|
+
'readme.md' => 0.9,
|
9
|
+
'README.md' => 0.9,
|
10
|
+
'readme.txt' => 0.9,
|
11
|
+
'LICENSE' => 0.0
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
EXPECTATIONS.each do |filename, expected|
|
15
|
+
should "score a readme named `#{filename}` as `#{expected}`" do
|
16
|
+
assert_equal expected, Licensee::Project::Readme.name_score(filename)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'readme content' do
|
22
|
+
should 'be blank if not license text' do
|
23
|
+
assert_license_content nil, 'There is no License in this README'
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'get content after h1' do
|
27
|
+
assert_license_content 'hello world', "# License\n\nhello world"
|
28
|
+
end
|
29
|
+
|
30
|
+
should 'get content after h2' do
|
31
|
+
assert_license_content 'hello world', "## License\n\nhello world"
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'be case-insensitive' do
|
35
|
+
assert_license_content 'hello world', "## LICENSE\n\nhello world"
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'be british' do
|
39
|
+
assert_license_content 'hello world', "## Licence\n\nhello world"
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'not include trailing content' do
|
43
|
+
readme = "## License\n\nhello world\n\n# Contributing"
|
44
|
+
assert_license_content 'hello world', readme
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,28 +1,31 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestLicenseeVendor < Minitest::Test
|
4
|
-
|
5
|
-
SKIP = %[wtfpl no-license]
|
4
|
+
SKIP = %(wtfpl no-license).freeze
|
6
5
|
|
7
6
|
Licensee::License.send(:license_files).shuffle.each do |license|
|
8
7
|
should "detect the #{license} license" do
|
9
8
|
verify_license_file(license)
|
10
9
|
end
|
11
10
|
|
12
|
-
context
|
11
|
+
context 'when modified' do
|
13
12
|
should "detect the #{license} license" do
|
14
|
-
|
13
|
+
unless SKIP.include?(File.basename(license, '.txt'))
|
14
|
+
verify_license_file(license, true)
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
context
|
19
|
+
context 'different line lengths' do
|
19
20
|
should "detect the #{license} license" do
|
20
21
|
verify_license_file(license, false, 50)
|
21
22
|
end
|
22
23
|
|
23
|
-
context
|
24
|
+
context 'when modified' do
|
24
25
|
should "detect the #{license} license" do
|
25
|
-
|
26
|
+
unless SKIP.include?(File.basename(license, '.txt'))
|
27
|
+
verify_license_file(license, true, 50)
|
28
|
+
end
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
@@ -4,8 +4,6 @@ source: http://opensource.org/licenses/afl-3.0
|
|
4
4
|
|
5
5
|
description: The Academic Free License is a variant of the Open Source License that does not require that the source code of derivative works be disclosed. It contains explicit copyright and patent grants and reserves trademark rights in the author.
|
6
6
|
|
7
|
-
hidden: true
|
8
|
-
|
9
7
|
how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Files licensed under OSL 3.0 must also include the notice "Licensed under the Academic Free License version 3.0" adjacent to the copyright notice.
|
10
8
|
|
11
9
|
required:
|
@@ -15,7 +13,6 @@ permitted:
|
|
15
13
|
- commercial-use
|
16
14
|
- modifications
|
17
15
|
- distribution
|
18
|
-
- sublicense
|
19
16
|
- private-use
|
20
17
|
- patent-use
|
21
18
|
|
@@ -1,13 +1,12 @@
|
|
1
1
|
---
|
2
2
|
title: GNU Affero General Public License v3.0
|
3
|
-
nickname: GNU
|
4
|
-
tab-slug: agpl-v3
|
3
|
+
nickname: GNU AGPLv3
|
5
4
|
redirect_from: /licenses/agpl/
|
6
|
-
family: GPL
|
5
|
+
family: GNU GPL
|
7
6
|
variant: true
|
8
7
|
source: http://www.gnu.org/licenses/agpl-3.0.txt
|
9
8
|
|
10
|
-
description: "The GPL family of licenses is the most widely used free software license and has a strong copyleft requirement. When distributing derived works, the source code of the work must be made available under the same license.
|
9
|
+
description: "The GNU GPL family of licenses is the most widely used free software license and has a strong copyleft requirement. When distributing derived works, the source code of the work must be made available under the same license. GNU AGPLv3 is distinguished from GNU GPLv3 in that hosted services using the code are considered distribution and trigger the copyleft requirements."
|
11
10
|
|
12
11
|
how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file.
|
13
12
|
|
@@ -18,6 +17,7 @@ required:
|
|
18
17
|
- document-changes
|
19
18
|
- disclose-source
|
20
19
|
- network-use-disclose
|
20
|
+
- same-license
|
21
21
|
|
22
22
|
permitted:
|
23
23
|
- commercial-use
|
@@ -28,8 +28,8 @@ permitted:
|
|
28
28
|
|
29
29
|
forbidden:
|
30
30
|
- no-liability
|
31
|
-
- no-sublicense
|
32
31
|
|
32
|
+
hidden: false
|
33
33
|
---
|
34
34
|
|
35
35
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
@@ -1,6 +1,5 @@
|
|
1
1
|
---
|
2
2
|
title: Apache License 2.0
|
3
|
-
nickname: Apache
|
4
3
|
redirect_from: /licenses/apache/
|
5
4
|
featured: true
|
6
5
|
source: http://www.apache.org/licenses/LICENSE-2.0.html
|
@@ -19,7 +18,6 @@ permitted:
|
|
19
18
|
- commercial-use
|
20
19
|
- modifications
|
21
20
|
- distribution
|
22
|
-
- sublicense
|
23
21
|
- patent-use
|
24
22
|
- private-use
|
25
23
|
|
@@ -27,6 +25,7 @@ forbidden:
|
|
27
25
|
- trademark-use
|
28
26
|
- no-liability
|
29
27
|
|
28
|
+
hidden: false
|
30
29
|
---
|
31
30
|
|
32
31
|
Apache License
|
@@ -15,18 +15,19 @@ permitted:
|
|
15
15
|
- commercial-use
|
16
16
|
- modifications
|
17
17
|
- distribution
|
18
|
-
-
|
18
|
+
- patent-use
|
19
19
|
- private-use
|
20
20
|
|
21
21
|
forbidden:
|
22
22
|
- no-liability
|
23
23
|
- trademark-use
|
24
24
|
|
25
|
+
hidden: false
|
25
26
|
---
|
26
27
|
|
27
|
-
|
28
|
+
The Artistic License 2.0
|
28
29
|
|
29
|
-
|
30
|
+
Copyright (c) 2000-2006, The Perl Foundation.
|
30
31
|
|
31
32
|
Everyone is permitted to copy and distribute verbatim copies
|
32
33
|
of this license document, but changing it is not allowed.
|
@@ -134,16 +135,16 @@ you do at least ONE of the following:
|
|
134
135
|
(c) allow anyone who receives a copy of the Modified Version to
|
135
136
|
make the Source form of the Modified Version available to others
|
136
137
|
under
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
138
|
+
|
139
|
+
(i) the Original License or
|
140
|
+
|
141
|
+
(ii) a license that permits the licensee to freely copy,
|
142
|
+
modify and redistribute the Modified Version using the same
|
143
|
+
licensing terms that apply to the copy that the licensee
|
144
|
+
received, and requires that the Source form of the Modified
|
145
|
+
Version, and of any works derived from it, be made freely
|
146
|
+
available in that license fees are prohibited but Distributor
|
147
|
+
Fees are allowed.
|
147
148
|
|
148
149
|
|
149
150
|
Distribution of Compiled Forms of the Standard Version
|