licensee 6.1.1 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/bin/licensee +7 -4
  4. data/lib/licensee.rb +25 -22
  5. data/lib/licensee/content_helper.rb +5 -4
  6. data/lib/licensee/license.rb +56 -45
  7. data/lib/licensee/matchers/copyright_matcher.rb +2 -2
  8. data/lib/licensee/matchers/dice_matcher.rb +7 -4
  9. data/lib/licensee/matchers/exact_matcher.rb +2 -2
  10. data/lib/licensee/matchers/gemspec_matcher.rb +5 -2
  11. data/lib/licensee/matchers/npm_bower_matcher.rb +5 -2
  12. data/lib/licensee/matchers/package_matcher.rb +2 -2
  13. data/lib/licensee/project.rb +21 -96
  14. data/lib/licensee/project_file.rb +6 -7
  15. data/lib/licensee/project_files/license_file.rb +3 -3
  16. data/lib/licensee/project_files/package_info.rb +7 -7
  17. data/lib/licensee/project_files/readme.rb +24 -0
  18. data/lib/licensee/projects/fs_project.rb +32 -0
  19. data/lib/licensee/projects/git_project.rb +55 -0
  20. data/lib/licensee/version.rb +2 -2
  21. data/test/fixtures/bower-with-readme/README.md +1 -0
  22. data/test/fixtures/bower-with-readme/bower.json +3 -0
  23. data/test/functions.rb +23 -12
  24. data/test/helper.rb +5 -0
  25. data/test/test_licensee.rb +9 -8
  26. data/test/test_licensee_bin.rb +11 -5
  27. data/test/test_licensee_copyright_matcher.rb +23 -23
  28. data/test/test_licensee_dice_matcher.rb +5 -5
  29. data/test/test_licensee_exact_matcher.rb +4 -4
  30. data/test/test_licensee_gemspec_matcher.rb +4 -4
  31. data/test/test_licensee_license.rb +82 -70
  32. data/test/test_licensee_license_file.rb +30 -28
  33. data/test/test_licensee_npm_bower_matcher.rb +11 -11
  34. data/test/test_licensee_package_info.rb +8 -7
  35. data/test/test_licensee_project.rb +45 -37
  36. data/test/test_licensee_project_file.rb +9 -9
  37. data/test/test_licensee_readme.rb +47 -0
  38. data/test/test_licensee_vendor.rb +10 -7
  39. data/vendor/choosealicense.com/_licenses/afl-3.0.txt +0 -3
  40. data/vendor/choosealicense.com/_licenses/agpl-3.0.txt +5 -5
  41. data/vendor/choosealicense.com/_licenses/apache-2.0.txt +1 -2
  42. data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +14 -13
  43. data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +2 -3
  44. data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +0 -6
  45. data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +2 -4
  46. data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +2 -1
  47. data/vendor/choosealicense.com/_licenses/epl-1.0.txt +2 -1
  48. data/vendor/choosealicense.com/_licenses/eupl-1.1.txt +345 -0
  49. data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +5 -5
  50. data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +5 -4
  51. data/vendor/choosealicense.com/_licenses/isc.txt +1 -2
  52. data/vendor/choosealicense.com/_licenses/lgpl-2.1.txt +5 -6
  53. data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +8 -8
  54. data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +445 -0
  55. data/vendor/choosealicense.com/_licenses/mit.txt +1 -1
  56. data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +2 -1
  57. data/vendor/choosealicense.com/_licenses/ms-pl.txt +0 -1
  58. data/vendor/choosealicense.com/_licenses/ms-rl.txt +1 -1
  59. data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +1 -2
  60. data/vendor/choosealicense.com/_licenses/osl-3.0.txt +1 -3
  61. data/vendor/choosealicense.com/_licenses/unlicense.txt +1 -2
  62. data/vendor/choosealicense.com/_licenses/wtfpl.txt +0 -2
  63. metadata +33 -11
  64. 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 "detect NPM files" do
5
- pkg = File.read fixture_path("npm/package.json")
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 "mit", matcher.send(:license_property)
9
- assert_equal "mit", matcher.match.key
8
+ assert_equal 'mit', matcher.send(:license_property)
9
+ assert_equal 'mit', matcher.match.key
10
10
  end
11
11
 
12
- should "detect Bower files" do
13
- pkg = File.read fixture_path("bower/bower.json")
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 "mit", matcher.send(:license_property)
17
- assert_equal "mit", matcher.match.key
16
+ assert_equal 'mit', matcher.send(:license_property)
17
+ assert_equal 'mit', matcher.match.key
18
18
  end
19
19
 
20
- should "not err on non-spdx licenses" do
21
- pkg = File.read fixture_path("npm-non-spdx/package.json")
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 "mit-1.0", matcher.send(:license_property)
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 "license filename scoring" do
4
+ context 'license filename scoring' do
5
5
  EXPECTATIONS = {
6
- "licensee.gemspec" => 1.0,
7
- "package.json" => 1.0,
8
- "bower.json" => 0.75,
9
- "README.md" => 0.0
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
- assert_equal expected, Licensee::Project::PackageInfo.name_score(filename)
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 == "git"
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("tmp", "fixtures", fixture_name)
14
+ dest = File.join('tmp', 'fixtures', fixture_name)
16
15
  FileUtils.mkdir_p File.dirname(dest)
17
- system "git", "clone", "-q", fixture_path(fixture_name), dest
18
- FileUtils.rm_r File.join(dest, ".git")
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 "tmp/fixtures"
23
+ FileUtils.rm_rf 'tmp/fixtures'
25
24
  end
26
25
  end
27
26
 
28
- should "detect the license file" do
29
- project = make_project "licenses.git"
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 "detect the license" do
34
- project = make_project "licenses.git"
35
- assert_equal "mit", project.license.key
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 "detect an atypically cased license file" do
39
- project = make_project "case-sensitive.git"
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 "detect MIT-LICENSE licensed projects" do
44
- project = make_project "named-license-file-prefix.git"
45
- assert_equal "mit", project.license.key
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 "detect LICENSE-MIT licensed projects" do
49
- project = make_project "named-license-file-suffix.git"
50
- assert_equal "mit", project.license.key
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 "not error out on repos with folders names license" do
54
- project = make_project "license-folder.git"
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 "detect licence files" do
59
- project = make_project "licence.git"
60
- assert_equal "mit", project.license.key
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 "detect an unlicensed project" do
64
- project = make_project "no-license.git"
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 "mit license with title removed" do
71
- should "detect the MIT license" do
72
- verify_license_file fixture_path("mit-without-title/mit.txt")
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 "should detect the MIT license when rewrapped" do
76
- verify_license_file fixture_path("mit-without-title-rewrapped/mit.txt")
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 "packages" do
81
- should "detect a package file" do
82
- project = Licensee::GitProject.new(fixture_path("npm.git"), detect_packages: true)
83
- assert_equal "package.json", project.package_file.filename
84
- assert_equal "mit", project.license.key
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("licenses.git"))
7
- blob, _ = Rugged::Blob.to_buffer(@repo, 'bcb552d06d9cf1cd4c048a6d3bf716849c2216cc')
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 "GPL-3.0"
10
- @mit = Licensee::License.find "MIT"
9
+ @gpl = Licensee::License.find 'GPL-3.0'
10
+ @mit = Licensee::License.find 'MIT'
11
11
  end
12
12
 
13
- should "read the file" do
13
+ should 'read the file' do
14
14
  assert @file.content =~ /MIT/
15
15
  end
16
16
 
17
- should "match the license" do
18
- assert_equal "mit", @file.license.key
17
+ should 'match the license' do
18
+ assert_equal 'mit', @file.license.key
19
19
  end
20
20
 
21
- should "calculate confidence" do
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 "when modified" do
11
+ context 'when modified' do
13
12
  should "detect the #{license} license" do
14
- verify_license_file(license, true) unless SKIP.include?(File.basename(license, ".txt"))
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 "different line lengths" do
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 "when modified" do
24
+ context 'when modified' do
24
25
  should "detect the #{license} license" do
25
- verify_license_file(license, true, 50) unless SKIP.include?(File.basename(license, ".txt"))
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 Affero GPL v3.0
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. The AGPL family of licenses is distinguished from GPLv2 and GPLv3 in that hosted services using the code are considered distribution and trigger the copyleft requirements."
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
- - sublicense
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
- The Artistic License 2.0
28
+ The Artistic License 2.0
28
29
 
29
- Copyright (c) [year] [fullname]
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
- (i) the Original License or
139
-
140
- (ii) a license that permits the licensee to freely copy,
141
- modify and redistribute the Modified Version using the same
142
- licensing terms that apply to the copy that the licensee
143
- received, and requires that the Source form of the Modified
144
- Version, and of any works derived from it, be made freely
145
- available in that license fees are prohibited but Distributor
146
- Fees are allowed.
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