licensee 9.15.1 → 9.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/licensee/commands/detect.rb +1 -1
- data/lib/licensee/commands/diff.rb +2 -4
- data/lib/licensee/content_helper.rb +3 -3
- data/lib/licensee/license.rb +4 -5
- data/lib/licensee/matchers/copyright.rb +3 -1
- data/lib/licensee/matchers/dice.rb +5 -7
- data/lib/licensee/matchers/dist_zilla.rb +1 -0
- data/lib/licensee/project_files/license_file.rb +5 -7
- data/lib/licensee/projects/git_project.rb +5 -7
- data/lib/licensee/projects/github_project.rb +1 -1
- data/lib/licensee/projects/project.rb +13 -19
- data/lib/licensee/version.rb +1 -1
- data/lib/licensee.rb +6 -3
- data/licensee.gemspec +3 -2
- data/spec/fixtures/detect.json +2 -2
- data/spec/fixtures/license-hashes.json +7 -2
- data/spec/licensee/commands/detect_spec.rb +2 -2
- data/spec/licensee/content_helper_spec.rb +1 -1
- data/spec/licensee/license_meta_spec.rb +3 -3
- data/spec/licensee/license_spec.rb +8 -3
- data/spec/licensee/matchers/copyright_matcher_spec.rb +12 -3
- data/spec/licensee/matchers/dice_matcher_spec.rb +3 -3
- data/spec/licensee/project_files/license_file_spec.rb +1 -1
- data/spec/licensee/project_files/package_info_spec.rb +2 -2
- data/spec/licensee/project_spec.rb +3 -2
- data/spec/licensee_spec.rb +8 -2
- data/spec/vendored_license_spec.rb +0 -2
- data/vendor/choosealicense.com/_licenses/0bsd.txt +4 -2
- data/vendor/choosealicense.com/_licenses/afl-3.0.txt +12 -12
- data/vendor/choosealicense.com/_licenses/agpl-3.0.txt +3 -0
- data/vendor/choosealicense.com/_licenses/apache-2.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +0 -1
- data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +2 -3
- data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/cecill-2.1.txt +1 -0
- data/vendor/choosealicense.com/_licenses/cern-ohl-p-2.0.txt +216 -0
- data/vendor/choosealicense.com/_licenses/cern-ohl-s-2.0.txt +299 -0
- data/vendor/choosealicense.com/_licenses/cern-ohl-w-2.0.txt +321 -0
- data/vendor/choosealicense.com/_licenses/eupl-1.1.txt +1 -1
- data/vendor/choosealicense.com/_licenses/gfdl-1.3.txt +483 -0
- data/vendor/choosealicense.com/_licenses/isc.txt +8 -8
- data/vendor/choosealicense.com/_licenses/mit.txt +1 -1
- data/vendor/choosealicense.com/_licenses/mulanpsl-2.0.txt +225 -0
- data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/osl-3.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/unlicense.txt +1 -1
- data/vendor/choosealicense.com/_licenses/upl-1.0.txt +1 -1
- data/vendor/license-list-XML/src/0BSD.xml +5 -1
- data/vendor/license-list-XML/src/AGPL-3.0.xml +4 -4
- data/vendor/license-list-XML/src/Apache-2.0.xml +1 -1
- data/vendor/license-list-XML/src/BSD-2-Clause.xml +1 -1
- data/vendor/license-list-XML/src/BSD-3-Clause.xml +4 -2
- data/vendor/license-list-XML/src/BSD-4-Clause.xml +3 -3
- data/vendor/license-list-XML/src/CC-BY-4.0.xml +13 -11
- data/vendor/license-list-XML/src/CC-BY-SA-4.0.xml +13 -11
- data/vendor/license-list-XML/src/CERN-OHL-P-2.0.xml +90 -0
- data/vendor/license-list-XML/src/CERN-OHL-S-2.0.xml +109 -0
- data/vendor/license-list-XML/src/CERN-OHL-W-2.0.xml +116 -0
- data/vendor/license-list-XML/src/GFDL-1.3.xml +594 -0
- data/vendor/license-list-XML/src/GPL-3.0.xml +5 -5
- data/vendor/license-list-XML/src/ISC.xml +7 -5
- data/vendor/license-list-XML/src/LGPL-3.0.xml +829 -2
- data/vendor/license-list-XML/src/MPL-2.0.xml +67 -30
- data/vendor/license-list-XML/src/MulanPSL-2.0.xml +167 -0
- metadata +33 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6b54db113cb4f1c4933826886afe3ed5e4b66d757a97df74dc43dbb2f8d6bc7
|
4
|
+
data.tar.gz: 72fa1baf7073bfb9132823d1953977ab49618d03320694647d6947b66aee311f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 461a7ed0479855f6e2c08353ee902b2b8f53661d24161ef22f6c7dbb0f9db1ee375f6fc4e196d1c266cd5830221525af471c9158b64891fa4b0b0b7b373e6eac
|
7
|
+
data.tar.gz: '09bfdd2cb1d12bd2b4a32bad1de90c65058d9ab1f3ed98ccb94ed9657b8965e236d4be84ce32e7801edf071de3ca7154d34455bfa749d29b1d89d9030c9a0ca4'
|
@@ -95,7 +95,7 @@ class LicenseeCLI < Thor
|
|
95
95
|
def licenses_by_similarity(matched_file)
|
96
96
|
matcher = Licensee::Matchers::Dice.new(matched_file)
|
97
97
|
potential_licenses = Licensee.licenses(hidden: true).select(&:wordset)
|
98
|
-
matcher.instance_variable_set(
|
98
|
+
matcher.instance_variable_set(:@potential_licenses, potential_licenses)
|
99
99
|
matcher.licenses_by_similarity
|
100
100
|
end
|
101
101
|
|
@@ -41,11 +41,9 @@ class LicenseeCLI < Thor
|
|
41
41
|
|
42
42
|
def license_to_diff
|
43
43
|
return options[:license_to_diff] if options[:license_to_diff]
|
44
|
-
return project.license_file if remote? || $stdin.tty? && project.license_file
|
44
|
+
return project.license_file if remote? || ($stdin.tty? && project.license_file)
|
45
45
|
|
46
|
-
@license_to_diff ||=
|
47
|
-
Licensee::ProjectFiles::LicenseFile.new($stdin.read, 'LICENSE')
|
48
|
-
end
|
46
|
+
@license_to_diff ||= Licensee::ProjectFiles::LicenseFile.new($stdin.read, 'LICENSE')
|
49
47
|
end
|
50
48
|
|
51
49
|
def expected_license
|
@@ -7,7 +7,7 @@ module Licensee
|
|
7
7
|
module ContentHelper
|
8
8
|
DIGEST = Digest::SHA1
|
9
9
|
START_REGEX = /\A\s*/.freeze
|
10
|
-
END_OF_TERMS_REGEX = /^[\s#*_]*end of terms and conditions[\s#*_]*$/i.freeze
|
10
|
+
END_OF_TERMS_REGEX = /^[\s#*_]*end of (the )?terms and conditions[\s#*_]*$/i.freeze
|
11
11
|
REGEXES = {
|
12
12
|
bom: /#{START_REGEX}\xEF\xBB\xBF/,
|
13
13
|
hrs: /^\s*[=\-*]{3,}\s*$/,
|
@@ -128,7 +128,7 @@ module Licensee
|
|
128
128
|
overlap = (wordset_fieldless & other.wordset).size
|
129
129
|
total = wordset_fieldless.size + other.wordset.size -
|
130
130
|
fields_normalized_set.size
|
131
|
-
(overlap * 200.0) / (total + variation_adjusted_length_delta(other) / 4)
|
131
|
+
(overlap * 200.0) / (total + (variation_adjusted_length_delta(other) / 4))
|
132
132
|
end
|
133
133
|
|
134
134
|
# SHA1 of the normalized content
|
@@ -341,7 +341,7 @@ module Licensee
|
|
341
341
|
# Use that if it's present, otherwise, just return the simple delta.
|
342
342
|
return delta unless respond_to?(:spdx_alt_segments, true)
|
343
343
|
|
344
|
-
adjusted_delta = delta - [fields_normalized.size, spdx_alt_segments].max * 4
|
344
|
+
adjusted_delta = delta - ([fields_normalized.size, spdx_alt_segments].max * 4)
|
345
345
|
adjusted_delta.positive? ? adjusted_delta : 0
|
346
346
|
end
|
347
347
|
end
|
data/lib/licensee/license.rb
CHANGED
@@ -145,6 +145,7 @@ module Licensee
|
|
145
145
|
return @title_regex if defined? @title_regex
|
146
146
|
|
147
147
|
string = name.downcase.sub('*', 'u')
|
148
|
+
simple_title_regex = Regexp.new string, 'i'
|
148
149
|
string.sub!(/\Athe /i, '')
|
149
150
|
string.sub!(/,? version /, ' ')
|
150
151
|
string.sub!(/v(\d+\.\d+)/, '\1')
|
@@ -159,7 +160,7 @@ module Licensee
|
|
159
160
|
string << '(?:\ licen[sc]e)?'
|
160
161
|
key_regex = Regexp.new string, 'i'
|
161
162
|
|
162
|
-
parts = [title_regex, key_regex]
|
163
|
+
parts = [simple_title_regex, title_regex, key_regex]
|
163
164
|
parts.push Regexp.new meta.nickname.sub(/\bGNU /i, '(?:GNU )?') if meta.nickname
|
164
165
|
|
165
166
|
@title_regex = Regexp.union parts
|
@@ -215,7 +216,7 @@ module Licensee
|
|
215
216
|
end
|
216
217
|
|
217
218
|
def ==(other)
|
218
|
-
|
219
|
+
other.is_a?(self.class) && key == other.key
|
219
220
|
end
|
220
221
|
|
221
222
|
def pseudo_license?
|
@@ -238,9 +239,7 @@ module Licensee
|
|
238
239
|
# Returns a string with `[fields]` replaced by `{{{fields}}}`
|
239
240
|
# Does not mangle non-supported fields in the form of `[field]`
|
240
241
|
def content_for_mustache
|
241
|
-
@content_for_mustache ||=
|
242
|
-
content.gsub(LicenseField::FIELD_REGEX, '{{{\1}}}')
|
243
|
-
end
|
242
|
+
@content_for_mustache ||= content.gsub(LicenseField::FIELD_REGEX, '{{{\1}}}')
|
244
243
|
end
|
245
244
|
|
246
245
|
private
|
@@ -6,7 +6,9 @@ module Licensee
|
|
6
6
|
attr_reader :file
|
7
7
|
|
8
8
|
COPYRIGHT_SYMBOLS = Regexp.union([/copyright/i, /\(c\)/i, "\u00A9", "\xC2\xA9"])
|
9
|
-
|
9
|
+
MAIN_LINE_REGEX = /[_*\-\s]*#{COPYRIGHT_SYMBOLS}.*$/i.freeze
|
10
|
+
OPTIONAL_LINE_REGEX = /[_*\-\s]*with Reserved Font Name.*$/i.freeze
|
11
|
+
REGEX = /#{ContentHelper::START_REGEX}(#{MAIN_LINE_REGEX}#{OPTIONAL_LINE_REGEX}*)+$/i.freeze
|
10
12
|
def match
|
11
13
|
# NOTE: must use content, and not content_normalized here
|
12
14
|
Licensee::License.find('no-license') if /#{REGEX}+\z/io.match?(file.content.strip)
|
@@ -21,13 +21,11 @@ module Licensee
|
|
21
21
|
# 2. The percentage change in file length may not exceed the inverse
|
22
22
|
# of the confidence threshold
|
23
23
|
def potential_matches
|
24
|
-
@potential_matches ||=
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
license.wordset
|
30
|
-
end
|
24
|
+
@potential_matches ||= super.select do |license|
|
25
|
+
if license.creative_commons? && file.potential_false_positive?
|
26
|
+
false
|
27
|
+
else
|
28
|
+
license.wordset
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
@@ -62,13 +62,11 @@ module Licensee
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def attribution
|
65
|
-
@attribution ||=
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
65
|
+
@attribution ||= if copyright? || license.content&.include?('[fullname]')
|
66
|
+
matches = Matchers::Copyright::REGEX
|
67
|
+
.match(content_without_title_and_version)
|
68
|
+
matches[0] if matches
|
69
|
+
end
|
72
70
|
end
|
73
71
|
|
74
72
|
# Is this file likely to result in a creative commons false positive?
|
@@ -27,13 +27,11 @@ module Licensee
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def repository
|
30
|
-
@repository ||=
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
30
|
+
@repository ||= if @raw_repo.is_a? Rugged::Repository
|
31
|
+
@raw_repo
|
32
|
+
else
|
33
|
+
Rugged::Repository.new(@raw_repo)
|
34
|
+
end
|
37
35
|
rescue Rugged::OSError, Rugged::RepositoryError
|
38
36
|
raise InvalidRepository
|
39
37
|
end
|
@@ -43,9 +43,7 @@ module Licensee
|
|
43
43
|
|
44
44
|
# Returns an array of matches LicenseFiles
|
45
45
|
def matched_files
|
46
|
-
@matched_files ||=
|
47
|
-
project_files.select(&:license)
|
48
|
-
end
|
46
|
+
@matched_files ||= project_files.select(&:license)
|
49
47
|
end
|
50
48
|
|
51
49
|
# Returns the LicenseFile used to determine the License
|
@@ -54,19 +52,17 @@ module Licensee
|
|
54
52
|
end
|
55
53
|
|
56
54
|
def license_files
|
57
|
-
@license_files ||=
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
55
|
+
@license_files ||= if files.empty? || files.nil?
|
56
|
+
[]
|
57
|
+
else
|
58
|
+
files = find_files do |n|
|
59
|
+
Licensee::ProjectFiles::LicenseFile.name_score(n)
|
60
|
+
end
|
61
|
+
files = files.map do |file|
|
62
|
+
Licensee::ProjectFiles::LicenseFile.new(load_file(file), file)
|
63
|
+
end
|
64
|
+
prioritize_lgpl(files)
|
65
|
+
end
|
70
66
|
end
|
71
67
|
|
72
68
|
def readme_file
|
@@ -155,9 +151,7 @@ module Licensee
|
|
155
151
|
# Returns an array of matches licenses, excluding the COPYRIGHT file
|
156
152
|
# which can often be ignored for purposes of determing dual licensing
|
157
153
|
def licenses_without_copyright
|
158
|
-
@licenses_without_copyright ||=
|
159
|
-
matched_files.reject(&:copyright?).map(&:license).uniq
|
160
|
-
end
|
154
|
+
@licenses_without_copyright ||= matched_files.reject(&:copyright?).map(&:license).uniq
|
161
155
|
end
|
162
156
|
|
163
157
|
def files
|
data/lib/licensee/version.rb
CHANGED
data/lib/licensee.rb
CHANGED
@@ -24,8 +24,6 @@ module Licensee
|
|
24
24
|
DOMAIN = 'http://choosealicense.com'
|
25
25
|
|
26
26
|
class << self
|
27
|
-
attr_writer :confidence_threshold
|
28
|
-
|
29
27
|
# Returns an array of Licensee::License instances
|
30
28
|
def licenses(options = {})
|
31
29
|
Licensee::License.all(options)
|
@@ -50,11 +48,16 @@ module Licensee
|
|
50
48
|
@confidence_threshold ||= CONFIDENCE_THRESHOLD
|
51
49
|
end
|
52
50
|
|
51
|
+
def confidence_threshold=(value)
|
52
|
+
@confidence_threshold = value
|
53
|
+
@inverse_confidence_threshold = nil
|
54
|
+
end
|
55
|
+
|
53
56
|
# Inverse of the confidence threshold, represented as a float
|
54
57
|
# By default this will be 0.02
|
55
58
|
def inverse_confidence_threshold
|
56
59
|
@inverse_confidence_threshold ||=
|
57
|
-
(1 - Licensee.confidence_threshold / 100.0).round(2)
|
60
|
+
(1 - (Licensee.confidence_threshold / 100.0)).round(2)
|
58
61
|
end
|
59
62
|
end
|
60
63
|
end
|
data/licensee.gemspec
CHANGED
@@ -16,13 +16,14 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.email = 'ben.balter@github.com'
|
17
17
|
gem.homepage = 'https://github.com/benbalter/licensee'
|
18
18
|
gem.license = 'MIT'
|
19
|
+
gem.metadata['rubygems_mfa_required'] = 'true'
|
19
20
|
|
20
21
|
gem.bindir = 'bin'
|
21
22
|
gem.executables << 'licensee'
|
22
23
|
|
23
24
|
gem.add_dependency('dotenv', '~> 2.0')
|
24
|
-
gem.add_dependency('octokit', '
|
25
|
-
gem.add_dependency('reverse_markdown', '
|
25
|
+
gem.add_dependency('octokit', '>= 4.20', '< 7.0')
|
26
|
+
gem.add_dependency('reverse_markdown', '>= 1', '< 3')
|
26
27
|
gem.add_dependency('rugged', '>= 0.24', '<2.0')
|
27
28
|
gem.add_dependency('thor', '>= 0.19', '< 2.0')
|
28
29
|
|
data/spec/fixtures/detect.json
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
"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. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders.",
|
11
11
|
"using": {
|
12
12
|
"Babel": "https://github.com/babel/babel/blob/master/LICENSE",
|
13
|
-
".NET
|
13
|
+
".NET": "https://github.com/dotnet/runtime/blob/main/LICENSE.TXT",
|
14
14
|
"Rails": "https://github.com/rails/rails/blob/master/MIT-LICENSE"
|
15
15
|
},
|
16
16
|
"featured": true,
|
@@ -93,7 +93,7 @@
|
|
93
93
|
},
|
94
94
|
{
|
95
95
|
"filename": "licensee.gemspec",
|
96
|
-
"content": "# frozen_string_literal: true\n\nrequire File.expand_path('lib/licensee/version', __dir__)\n\nGem::Specification.new do |gem|\n gem.name = 'licensee'\n gem.version = Licensee::VERSION\n\n gem.summary = 'A Ruby Gem to detect open source project licenses'\n gem.description = <<-DESC\n Licensee automates the process of reading LICENSE files and\n compares their contents to known licenses using a fancy maths.\n DESC\n\n gem.authors = ['Ben Balter']\n gem.email = 'ben.balter@github.com'\n gem.homepage = 'https://github.com/benbalter/licensee'\n gem.license = 'MIT'\n\n gem.bindir = 'bin'\n gem.executables << 'licensee'\n\n gem.add_dependency('dotenv', '~> 2.0')\n gem.add_dependency('octokit', '
|
96
|
+
"content": "# frozen_string_literal: true\n\nrequire File.expand_path('lib/licensee/version', __dir__)\n\nGem::Specification.new do |gem|\n gem.name = 'licensee'\n gem.version = Licensee::VERSION\n\n gem.summary = 'A Ruby Gem to detect open source project licenses'\n gem.description = <<-DESC\n Licensee automates the process of reading LICENSE files and\n compares their contents to known licenses using a fancy maths.\n DESC\n\n gem.authors = ['Ben Balter']\n gem.email = 'ben.balter@github.com'\n gem.homepage = 'https://github.com/benbalter/licensee'\n gem.license = 'MIT'\n gem.metadata['rubygems_mfa_required'] = 'true'\n\n gem.bindir = 'bin'\n gem.executables << 'licensee'\n\n gem.add_dependency('dotenv', '~> 2.0')\n gem.add_dependency('octokit', '>= 4.20', '< 6.0')\n gem.add_dependency('reverse_markdown', '>= 1', '< 3')\n gem.add_dependency('rugged', '>= 0.24', '<2.0')\n gem.add_dependency('thor', '>= 0.19', '< 2.0')\n\n gem.add_development_dependency('gem-release', '~> 2.0')\n gem.add_development_dependency('mustache', '>= 0.9', '< 2.0')\n gem.add_development_dependency('pry', '~> 0.9')\n gem.add_development_dependency('rspec', '~> 3.5')\n gem.add_development_dependency('rubocop', '~> 1.0')\n gem.add_development_dependency('rubocop-performance', '~> 1.5')\n gem.add_development_dependency('rubocop-rspec', '~> 2.0')\n gem.add_development_dependency('simplecov', '~> 0.16')\n gem.add_development_dependency('webmock', '~> 3.1')\n\n gem.required_ruby_version = '>= 2.5'\n\n # ensure the gem is built out of versioned files\n gem.files = Dir[\n '{bin,lib,man,test,vendor,spec}/**/*',\n 'README*', 'LICENSE*'\n ] & `git ls-files -z`.split(\"\\0\")\nend\n",
|
97
97
|
"content_hash": null,
|
98
98
|
"content_normalized": null,
|
99
99
|
"matcher": {
|
@@ -10,14 +10,18 @@
|
|
10
10
|
"bsd-4-clause": "3b2917580b2b6f13efaaea37546b8b7a53716a30",
|
11
11
|
"bsl-1.0": "27e28f20b57048cf04be07e1532b6fb501a0753b",
|
12
12
|
"cc-by-4.0": "b2089be110aca4cf4a562a88f0ecfd082ce32167",
|
13
|
-
"cc-by-sa-4.0": "
|
13
|
+
"cc-by-sa-4.0": "0684e2df6671166351097b387abc0d1170d26f2f",
|
14
14
|
"cc0-1.0": "94c8187ec82b2b4a69fb990f80833fbe6e3c95e7",
|
15
15
|
"cecill-2.1": "edb804827a40bcdcf3e82b6bab3bd1f5b923ac74",
|
16
|
+
"cern-ohl-p-2.0": "f10b4b8d75502ab65a7bdbe1d616e5eb8d157aed",
|
17
|
+
"cern-ohl-s-2.0": "c9a4188fec2c6a98ea9392cf9a26633fe7fd0e42",
|
18
|
+
"cern-ohl-w-2.0": "099c18c653223d137a5ce8331d8a4ebbacaf1623",
|
16
19
|
"ecl-2.0": "296976ce9e84ba380866e4519b68a779c2059b3a",
|
17
20
|
"epl-1.0": "5e3cb10996b4ba2821d04d5c99a912c924b3bdcb",
|
18
21
|
"epl-2.0": "e2f3e266432478d9248422228a75a404cce1c43c",
|
19
22
|
"eupl-1.1": "b35810b4113910f5f85af75f24e2538ba64c8876",
|
20
23
|
"eupl-1.2": "2098182069695981c6dc71093888f6204c7bbdae",
|
24
|
+
"gfdl-1.3": "164a858691ea0a6fb0dd06c5ca00e5dd7620eef8",
|
21
25
|
"gpl-2.0": "32108116603c30687d8d0d2f77f140fb6ecea082",
|
22
26
|
"gpl-3.0": "7d4cdf499d39e2e1ce27b2878e22872f0f5a74dd",
|
23
27
|
"isc": "7fcb74e2084b361556b8285d6f800495d0d5e36a",
|
@@ -29,8 +33,9 @@
|
|
29
33
|
"mpl-2.0": "820048a1dbef5dfac65547bd9eb935beb76b2257",
|
30
34
|
"ms-pl": "1a7eb02101924998c296c8ede182005d2f77ae4a",
|
31
35
|
"ms-rl": "9f0c4c8be853cf1836a619cd0abaf0e0235d76ad",
|
36
|
+
"mulanpsl-2.0": "c9b54da98007cb8baa0a658b34dbe3a55a80baa8",
|
32
37
|
"ncsa": "0d481a7ff9345e19cfdd9b7fea46caea1ebd08ee",
|
33
|
-
"odbl-1.0": "
|
38
|
+
"odbl-1.0": "e3bb38ce8a932d226829dcb6fd2143e5977d13e7",
|
34
39
|
"ofl-1.1": "f92ca13e3976f94f20b49a007f7592631b4f8e96",
|
35
40
|
"osl-3.0": "bdde11f936b834bd06451d1ad8aad790d4a7c72c",
|
36
41
|
"postgresql": "6bddd8a2425baa88ee240b1c54b532d6208028bd",
|
@@ -59,7 +59,7 @@ RSpec.describe 'detect command' do
|
|
59
59
|
|
60
60
|
context 'json' do
|
61
61
|
let(:arguments) { ['--json'] }
|
62
|
-
let(:expected) { JSON.parse
|
62
|
+
let(:expected) { JSON.parse(fixture_contents('detect.json')).tap { |h| h['matched_files'][1].delete('content') } }
|
63
63
|
|
64
64
|
it 'Returns a zero exit code' do
|
65
65
|
expect(status.exitstatus).to be(0)
|
@@ -72,7 +72,7 @@ RSpec.describe 'detect command' do
|
|
72
72
|
it 'returns the expected output' do
|
73
73
|
msg = +'`licensee detect --json` output did not match expectations. '
|
74
74
|
msg << 'Run `script/dump-detect-json-fixture` and verify the output.'
|
75
|
-
expect(JSON.parse(stdout)).to eql(expected), msg
|
75
|
+
expect(JSON.parse(stdout).tap { |h| h['matched_files'][1].delete('content') }).to eql(expected), msg
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -67,7 +67,7 @@ RSpec.describe Licensee::ContentHelper do
|
|
67
67
|
|
68
68
|
it 'knows the similarity' do
|
69
69
|
expect(mit.similarity(subject)).to be_within(1).of(4)
|
70
|
-
expect(mit.similarity(mit)).to
|
70
|
+
expect(mit.similarity(mit)).to eq(100.0)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'calculates simple delta for similarity' do
|
@@ -116,9 +116,9 @@ RSpec.describe Licensee::LicenseMeta do
|
|
116
116
|
let(:hash) { subject.to_h }
|
117
117
|
let(:using) do
|
118
118
|
{
|
119
|
-
'Babel'
|
120
|
-
'.NET
|
121
|
-
'Rails'
|
119
|
+
'Babel' => 'https://github.com/babel/babel/blob/master/LICENSE',
|
120
|
+
'.NET' => 'https://github.com/dotnet/runtime/blob/main/LICENSE.TXT',
|
121
|
+
'Rails' => 'https://github.com/rails/rails/blob/master/MIT-LICENSE'
|
122
122
|
}
|
123
123
|
end
|
124
124
|
let(:expected) do
|
@@ -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) { 47 }
|
5
|
+
let(:hidden_license_count) { 34 }
|
6
6
|
let(:featured_license_count) { 3 }
|
7
7
|
let(:pseudo_license_count) { 2 }
|
8
8
|
let(:non_featured_license_count) do
|
@@ -300,10 +300,15 @@ RSpec.describe Licensee::License do
|
|
300
300
|
end
|
301
301
|
|
302
302
|
it 'knows equality' do
|
303
|
-
expect(mit).to eql(mit)
|
303
|
+
expect(described_class.find('mit')).to eql(mit)
|
304
|
+
expect(described_class.find('mit')).to eq(mit)
|
304
305
|
expect(gpl).not_to eql(mit)
|
305
306
|
end
|
306
307
|
|
308
|
+
it 'returns false when compared to a boolean' do
|
309
|
+
expect(described_class.find('mit')).not_to be(true)
|
310
|
+
end
|
311
|
+
|
307
312
|
it 'knows if a license is a pseudo license' do
|
308
313
|
expect(mit).not_to be_pseudo_license
|
309
314
|
expect(other).to be_pseudo_license
|
@@ -27,10 +27,11 @@ RSpec.describe Licensee::Matchers::Copyright do
|
|
27
27
|
'UTF-8 Encoded' => 'Copyright (c) 2010-2014 Simon Hürlimann',
|
28
28
|
'Comma-separated date' => 'Copyright (c) 2003, 2004 Ben Balter',
|
29
29
|
'Hyphen-separated date' => 'Copyright (c) 2003-2004 Ben Balter',
|
30
|
-
'ASCII-8BIT encoded' => "Copyright \xC2\xA92015 Ben Balter`"
|
30
|
+
'ASCII-8BIT encoded' => "Copyright \xC2\xA92015 Ben Balter`"
|
31
|
+
.dup.force_encoding('ASCII-8BIT'),
|
31
32
|
'No year' => 'Copyright Ben Balter',
|
32
|
-
'Multiline' => "Copyright Ben Balter\nCopyright Another Entity"
|
33
|
-
|
33
|
+
'Multiline' => "Copyright Ben Balter\nCopyright Another Entity",
|
34
|
+
'OFL font name' => "Copyright (c) 2016, Ben Balter,\nwith Reserved Font Name \"Ben's Font\"."
|
34
35
|
}.each do |description, notice|
|
35
36
|
context "with a #{description} notice" do
|
36
37
|
let(:content) { notice }
|
@@ -41,6 +42,14 @@ RSpec.describe Licensee::Matchers::Copyright do
|
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
45
|
+
context 'with arbitrary additional notice line' do
|
46
|
+
let(:content) { "(c) Ben Balter\nwith foo bar baz" }
|
47
|
+
|
48
|
+
it "doesn't match" do
|
49
|
+
expect(subject.match).to be_nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
context 'with a license with a copyright notice' do
|
45
54
|
let(:content) { sub_copyright_info(mit) }
|
46
55
|
|
@@ -27,14 +27,14 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns the match confidence' do
|
30
|
-
expect(subject.confidence).to
|
30
|
+
expect(subject.confidence).to eq(100.0)
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'without a match' do
|
34
34
|
let(:content) { 'Not really a license' }
|
35
35
|
|
36
36
|
it "doesn't match" do
|
37
|
-
expect(subject.match).to
|
37
|
+
expect(subject.match).to be_nil
|
38
38
|
expect(subject.matches).to be_empty
|
39
39
|
expect(subject.confidence).to be(0)
|
40
40
|
end
|
@@ -47,7 +47,7 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
47
47
|
|
48
48
|
it "doesn't match" do
|
49
49
|
expect(content).not_to be_detected_as(gpl)
|
50
|
-
expect(subject.match).to
|
50
|
+
expect(subject.match).to be_nil
|
51
51
|
expect(subject.matches).to be_empty
|
52
52
|
expect(subject.confidence).to be(0)
|
53
53
|
end
|
@@ -24,7 +24,7 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
24
24
|
context 'with an non-UTF-8-encoded license' do
|
25
25
|
let(:content) { "\x91License\x93".dup.force_encoding('windows-1251') }
|
26
26
|
|
27
|
-
it "doesn't blow up
|
27
|
+
it "doesn't blow up" do
|
28
28
|
expect(subject.attribution).to be_nil
|
29
29
|
end
|
30
30
|
end
|
@@ -31,7 +31,7 @@ RSpec.describe Licensee::ProjectFiles::PackageManagerFile do
|
|
31
31
|
context 'matchers' do
|
32
32
|
let(:possible_matchers) { subject.possible_matchers }
|
33
33
|
|
34
|
-
context 'with a gemspec
|
34
|
+
context 'with a gemspec' do
|
35
35
|
let(:filename) { 'project.gemspec' }
|
36
36
|
|
37
37
|
it 'returns the gemspec matcher' do
|
@@ -39,7 +39,7 @@ RSpec.describe Licensee::ProjectFiles::PackageManagerFile do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
context 'with cabal file
|
42
|
+
context 'with cabal file' do
|
43
43
|
let(:filename) { 'test.cabal' }
|
44
44
|
|
45
45
|
it 'returns the cabal matcher' do
|
@@ -66,7 +66,7 @@
|
|
66
66
|
let(:revision) { subject.repository.last_commit.oid }
|
67
67
|
|
68
68
|
before do
|
69
|
-
subject.instance_variable_set(
|
69
|
+
subject.instance_variable_set(:@revision, revision)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'returns the commit' do
|
@@ -116,11 +116,12 @@
|
|
116
116
|
|
117
117
|
if described_class == Licensee::Projects::FSProject
|
118
118
|
context 'with search root argument' do
|
119
|
+
subject { described_class.new(path, search_root: search_root) }
|
120
|
+
|
119
121
|
let(:fixture) { 'license-in-parent-folder/license-folder/package' }
|
120
122
|
let(:path) { fixture_path(fixture) }
|
121
123
|
let(:license_folder) { 'license-in-parent-folder/license-folder' }
|
122
124
|
let(:search_root) { fixture_path(license_folder) }
|
123
|
-
let(:subject) { described_class.new(path, search_root: search_root) }
|
124
125
|
let(:files) { subject.send(:files) }
|
125
126
|
|
126
127
|
it 'looks for licenses in parent directories up to the search root' do
|
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) { 47 }
|
8
8
|
|
9
9
|
it 'exposes licenses' do
|
10
10
|
expect(described_class.licenses).to be_an(Array)
|
@@ -43,7 +43,7 @@ RSpec.describe Licensee do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'exposes the inverse of the confidence threshold' do
|
46
|
-
expect(described_class.inverse_confidence_threshold).to
|
46
|
+
expect(described_class.inverse_confidence_threshold).to eq(0.02)
|
47
47
|
end
|
48
48
|
|
49
49
|
context 'user overridden' do
|
@@ -54,6 +54,12 @@ RSpec.describe Licensee do
|
|
54
54
|
it 'lets the user override the confidence threshold' do
|
55
55
|
expect(described_class.confidence_threshold).to be(50)
|
56
56
|
end
|
57
|
+
|
58
|
+
it 'resets inverse confidence threshold when confidence threshold changes' do
|
59
|
+
expect(described_class.inverse_confidence_threshold).to be(0.5)
|
60
|
+
described_class.confidence_threshold = Licensee::CONFIDENCE_THRESHOLD
|
61
|
+
expect(described_class.inverse_confidence_threshold).to be(0.02)
|
62
|
+
end
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
@@ -5,8 +5,6 @@ RSpec.describe 'vendored licenses' do
|
|
5
5
|
let(:license_file) do
|
6
6
|
Licensee::ProjectFiles::LicenseFile.new(content, filename)
|
7
7
|
end
|
8
|
-
let(:detected_license) { license_file&.license }
|
9
|
-
let(:wtfpl) { Licensee::License.find('wtfpl') }
|
10
8
|
|
11
9
|
Licensee.licenses(hidden: true).each do |license|
|
12
10
|
next if license.pseudo_license?
|
@@ -7,9 +7,9 @@ description: The BSD Zero Clause license goes further than the BSD 2-Clause lice
|
|
7
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. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders. You may take the additional step of removing the copyright notice.
|
8
8
|
|
9
9
|
using:
|
10
|
-
|
11
|
-
smoltcp: https://github.com/m-labs/smoltcp/blob/master/LICENSE-0BSD.txt
|
10
|
+
gatsby-starter-default: https://github.com/gatsbyjs/gatsby-starter-default/blob/master/LICENSE
|
12
11
|
Toybox: https://github.com/landley/toybox/blob/master/LICENSE
|
12
|
+
PickMeUp: https://github.com/nazar-pc/PickMeUp/blob/master/copying.md
|
13
13
|
|
14
14
|
permissions:
|
15
15
|
- commercial-use
|
@@ -25,6 +25,8 @@ limitations:
|
|
25
25
|
|
26
26
|
---
|
27
27
|
|
28
|
+
BSD Zero Clause License
|
29
|
+
|
28
30
|
Copyright (c) [year] [fullname]
|
29
31
|
|
30
32
|
Permission to use, copy, modify, and/or distribute this software for any
|