licensee 9.15.3 → 9.16.1
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.
- checksums.yaml +4 -4
- data/bin/licensee +5 -1
- data/lib/licensee/commands/license_path.rb +8 -8
- data/lib/licensee/content_helper.rb +10 -9
- data/lib/licensee/license.rb +12 -4
- data/lib/licensee/license_field.rb +2 -2
- data/lib/licensee/license_meta.rb +2 -2
- data/lib/licensee/matchers/cabal.rb +1 -1
- data/lib/licensee/matchers/cargo.rb +1 -1
- data/lib/licensee/matchers/copyright.rb +3 -3
- data/lib/licensee/matchers/cran.rb +3 -3
- data/lib/licensee/matchers/dist_zilla.rb +1 -1
- data/lib/licensee/matchers/gemspec.rb +5 -5
- data/lib/licensee/matchers/npm_bower.rb +1 -1
- data/lib/licensee/matchers/nuget.rb +6 -6
- data/lib/licensee/matchers/spdx.rb +1 -1
- data/lib/licensee/project_files/license_file.rb +9 -9
- data/lib/licensee/project_files/readme_file.rb +3 -3
- data/lib/licensee/projects/fs_project.rb +2 -2
- data/lib/licensee/projects/git_project.rb +2 -2
- data/lib/licensee/projects/github_project.rb +1 -1
- data/lib/licensee/rule.rb +1 -1
- data/lib/licensee/version.rb +1 -1
- data/spec/fixture_spec.rb +1 -1
- data/spec/fixtures/agpl-3.0_markdown/LICENSE.md +651 -0
- data/spec/fixtures/apache-2.0_markdown/LICENSE.md +195 -0
- data/spec/fixtures/bsd-2-author/LICENSE +22 -0
- data/spec/fixtures/bsd-3-clause_markdown/LICENSE.md +28 -0
- data/spec/fixtures/cc-by-4.0_markdown/LICENSE.md +157 -0
- data/spec/fixtures/cc-by-sa-4.0_markdown/LICENSE.md +171 -0
- data/spec/fixtures/cc0-1.0_markdown/LICENSE.md +41 -0
- data/spec/fixtures/detect.json +1 -1
- data/spec/fixtures/epl-1.0_markdown/LICENSE.md +76 -0
- data/spec/fixtures/fixtures.yml +105 -41
- data/spec/fixtures/gfdl-1.3_markdown/LICENSE.md +450 -0
- data/spec/fixtures/gpl-2.0_markdown/LICENSE.md +336 -0
- data/spec/fixtures/gpl-3.0_markdown/LICENSE.md +595 -0
- data/spec/fixtures/lgpl-2.1_markdown/LICENSE.md +494 -0
- data/spec/fixtures/lgpl-3.0_markdown/LICENSE.md +163 -0
- data/spec/fixtures/license-hashes.json +6 -6
- data/spec/fixtures/mit_markdown/LICENSE.md +26 -0
- data/spec/fixtures/mpl-2.0_markdown/LICENSE.md +357 -0
- data/spec/fixtures/unlicense_markdown/LICENSE.md +27 -0
- data/spec/integration_spec.rb +11 -2
- data/spec/licensee/commands/detect_spec.rb +16 -0
- data/spec/licensee/commands/license_path_spec.rb +3 -2
- data/spec/licensee/content_helper_spec.rb +17 -1
- data/spec/licensee/license_meta_spec.rb +2 -2
- data/spec/licensee/matchers/cran_matcher_spec.rb +0 -2
- data/spec/licensee/matchers/reference_matcher_spec.rb +17 -0
- data/spec/spec_helper.rb +1 -1
- data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +1 -0
- data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/epl-1.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/epl-2.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/upl-1.0.txt +3 -3
- data/vendor/license-list-XML/src/AGPL-3.0.xml +2 -2
- data/vendor/license-list-XML/src/Apache-2.0.xml +2 -2
- data/vendor/license-list-XML/src/Artistic-2.0.xml +5 -3
- data/vendor/license-list-XML/src/BSD-2-Clause.xml +2 -2
- data/vendor/license-list-XML/src/BSD-3-Clause-Clear.xml +3 -1
- data/vendor/license-list-XML/src/BSD-3-Clause.xml +9 -9
- data/vendor/license-list-XML/src/GFDL-1.3.xml +1 -1
- data/vendor/license-list-XML/src/GPL-2.0.xml +1 -1
- data/vendor/license-list-XML/src/GPL-3.0.xml +1 -1
- data/vendor/license-list-XML/src/LGPL-2.1.xml +1 -1
- data/vendor/license-list-XML/src/LGPL-3.0.xml +1 -1
- metadata +29 -14
- data/licensee.gemspec +0 -47
- /data/spec/fixtures/{markdown-artistic → artistic-2.0_markdown}/LICENSE.md +0 -0
- /data/spec/fixtures/{markdown-gpl → gpl-2.0_markdown_headings}/LICENSE.md +0 -0
- /data/spec/licensee/project_files/{package_info_spec.rb → package_manager_file_spec.rb} +0 -0
- /data/spec/licensee/projects/{github_project_spec.rb → git_hub_project_spec.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f5ee0aef5bea7c09d85b5fe00cde34590331108dea73bede502928d3e863809
|
|
4
|
+
data.tar.gz: 4ce51466168c4b9aaf354ffe897f6727e598cc534aadff4846f028a2a66dff7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 314636d52fd93d47a39b9b9835fe3b305735fc84be5767f1ab31a6bb0f933abb0e837d7bb9c4cb20ce64be0bcb0e2043adbce964b09dfc05776d955e6a089012
|
|
7
|
+
data.tar.gz: 308beab7147f0e4f5f8f16c70533e899c5106b30245544d0d27cea2727d28a929e5b328031dd1658be998da04b477e2adc6c5e3f0686cfbe8d2cd05fb93eca25
|
data/bin/licensee
CHANGED
|
@@ -12,6 +12,10 @@ class LicenseeCLI < Thor
|
|
|
12
12
|
class_option :remote, type: :boolean, desc: 'Assume PATH is a GitHub owner/repo path'
|
|
13
13
|
default_task :detect
|
|
14
14
|
|
|
15
|
+
def self.exit_on_failure?
|
|
16
|
+
true
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
private
|
|
16
20
|
|
|
17
21
|
def path
|
|
@@ -33,6 +37,6 @@ class LicenseeCLI < Thor
|
|
|
33
37
|
end
|
|
34
38
|
|
|
35
39
|
commands_dir = File.expand_path '../lib/licensee/commands/', __dir__
|
|
36
|
-
Dir["#{commands_dir}/*.rb"].
|
|
40
|
+
Dir["#{commands_dir}/*.rb"].each { |c| require(c) }
|
|
37
41
|
|
|
38
42
|
LicenseeCLI.start(ARGV)
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
class LicenseeCLI < Thor
|
|
4
4
|
desc 'license-path [PATH]', "Returns the path to the given project's license file"
|
|
5
|
-
def license_path(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
def license_path(path)
|
|
6
|
+
project = Licensee.project(path)
|
|
7
|
+
|
|
8
|
+
exit 1 unless project.license_file
|
|
9
|
+
|
|
10
|
+
if remote?
|
|
11
|
+
say project.license_file.path
|
|
12
12
|
else
|
|
13
|
-
|
|
13
|
+
say File.expand_path(project.license_file.path, path)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -6,8 +6,8 @@ require 'digest'
|
|
|
6
6
|
module Licensee
|
|
7
7
|
module ContentHelper
|
|
8
8
|
DIGEST = Digest::SHA1
|
|
9
|
-
START_REGEX = /\A\s
|
|
10
|
-
END_OF_TERMS_REGEX = /^[\s#*_]*end of (the )?terms and conditions[\s#*_]*$/i
|
|
9
|
+
START_REGEX = /\A\s*/
|
|
10
|
+
END_OF_TERMS_REGEX = /^[\s#*_]*end of (the )?terms and conditions[\s#*_]*$/i
|
|
11
11
|
REGEXES = {
|
|
12
12
|
bom: /#{START_REGEX}\xEF\xBB\xBF/,
|
|
13
13
|
hrs: /^\s*[=\-*]{3,}\s*$/,
|
|
@@ -32,11 +32,12 @@ module Licensee
|
|
|
32
32
|
mit_optional: /\(including the next paragraph\)/i
|
|
33
33
|
}.freeze
|
|
34
34
|
NORMALIZATIONS = {
|
|
35
|
-
lists: { from: /^\s*(?:\d
|
|
35
|
+
lists: { from: /^\s*(?:\d\.|[*-])(?: [*_]{0,2}\(?[\da-z]\)[*_]{0,2})?\s+([^\n])/, to: '- \1' },
|
|
36
36
|
https: { from: /http:/, to: 'https:' },
|
|
37
37
|
ampersands: { from: '&', to: 'and' },
|
|
38
38
|
dashes: { from: /(?<!^)([—–-]+)(?!$)/, to: '-' },
|
|
39
|
-
quote: { from: /[`'"‘“’”]/, to: "'" }
|
|
39
|
+
quote: { from: /[`'"‘“’”]/, to: "'" },
|
|
40
|
+
hyphenated: { from: /(\w+)-\s*\n\s*(\w+)/, to: '\1-\2' }
|
|
40
41
|
}.freeze
|
|
41
42
|
|
|
42
43
|
# Legally equivalent words that schould be ignored for comparison
|
|
@@ -82,8 +83,8 @@ module Licensee
|
|
|
82
83
|
'whilst' => 'while',
|
|
83
84
|
'wilful' => 'wilfull',
|
|
84
85
|
'non-commercial' => 'noncommercial',
|
|
85
|
-
'cent'
|
|
86
|
-
'owner'
|
|
86
|
+
'per cent' => 'percent',
|
|
87
|
+
'copyright owner' => 'copyright holder'
|
|
87
88
|
}.freeze
|
|
88
89
|
STRIP_METHODS = %i[
|
|
89
90
|
bom
|
|
@@ -303,8 +304,8 @@ module Licensee
|
|
|
303
304
|
|
|
304
305
|
if operation
|
|
305
306
|
@_content = _content.gsub operation[:from], operation[:to]
|
|
306
|
-
elsif respond_to?("normalize_#{from_or_key}", true)
|
|
307
|
-
send("normalize_#{from_or_key}")
|
|
307
|
+
elsif respond_to?(:"normalize_#{from_or_key}", true)
|
|
308
|
+
send(:"normalize_#{from_or_key}")
|
|
308
309
|
else
|
|
309
310
|
raise ArgumentError, "#{from_or_key} is an invalid normalization"
|
|
310
311
|
end
|
|
@@ -341,7 +342,7 @@ module Licensee
|
|
|
341
342
|
# Use that if it's present, otherwise, just return the simple delta.
|
|
342
343
|
return delta unless respond_to?(:spdx_alt_segments, true)
|
|
343
344
|
|
|
344
|
-
adjusted_delta = delta - ([fields_normalized.size, spdx_alt_segments].max *
|
|
345
|
+
adjusted_delta = delta - ([fields_normalized.size, spdx_alt_segments].max * 5)
|
|
345
346
|
adjusted_delta.positive? ? adjusted_delta : 0
|
|
346
347
|
end
|
|
347
348
|
end
|
data/lib/licensee/license.rb
CHANGED
|
@@ -74,7 +74,7 @@ module Licensee
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def keys_licenses(options = {})
|
|
77
|
-
@keys_licenses[options] ||= all(options).
|
|
77
|
+
@keys_licenses[options] ||= all(options).to_h { |l| [l.key, l] }
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -98,8 +98,8 @@ module Licensee
|
|
|
98
98
|
pseudo: true
|
|
99
99
|
}.freeze
|
|
100
100
|
|
|
101
|
-
SOURCE_PREFIX = %r{https?://(?:www\.)?}i
|
|
102
|
-
SOURCE_SUFFIX = %r{(?:\.html?|\.txt|/)(?:\?[^\s]*)?}i
|
|
101
|
+
SOURCE_PREFIX = %r{https?://(?:www\.)?}i
|
|
102
|
+
SOURCE_SUFFIX = %r{(?:\.html?|\.txt|/)(?:\?[^\s]*)?}i
|
|
103
103
|
|
|
104
104
|
HASH_METHODS = %i[
|
|
105
105
|
key spdx_id meta url rules fields other? gpl? lgpl? cc?
|
|
@@ -151,7 +151,15 @@ module Licensee
|
|
|
151
151
|
string.sub!(/v(\d+\.\d+)/, '\1')
|
|
152
152
|
string = Regexp.escape(string)
|
|
153
153
|
string = string.sub(/\\ licen[sc]e/i, '(?:\ licen[sc]e)?')
|
|
154
|
-
|
|
154
|
+
version_match = string.match(/\d+\\.(\d+)/)
|
|
155
|
+
if version_match
|
|
156
|
+
vsub = if version_match[1] == '0'
|
|
157
|
+
',?\s+(?:version\ |v(?:\. )?)?\1(\2)?'
|
|
158
|
+
else
|
|
159
|
+
',?\s+(?:version\ |v(?:\. )?)?\1\2'
|
|
160
|
+
end
|
|
161
|
+
string = string.sub(/\\ (\d+)(\\.\d+)/, vsub)
|
|
162
|
+
end
|
|
155
163
|
string = string.sub(/\bgnu\\ /, '(?:GNU )?')
|
|
156
164
|
title_regex = Regexp.new string, 'i'
|
|
157
165
|
|
|
@@ -22,7 +22,7 @@ module Licensee
|
|
|
22
22
|
@all ||= begin
|
|
23
23
|
path = '../../vendor/choosealicense.com/_data/fields.yml'
|
|
24
24
|
path = File.expand_path path, __dir__
|
|
25
|
-
fields = YAML.
|
|
25
|
+
fields = YAML.safe_load_file(path)
|
|
26
26
|
fields.map { |field| LicenseField.from_hash(field) }
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -47,7 +47,7 @@ module Licensee
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
alias key name
|
|
50
|
-
FIELD_REGEX = /\[(#{Regexp.union(LicenseField.keys)})\]
|
|
50
|
+
FIELD_REGEX = /\[(#{Regexp.union(LicenseField.keys)})\]/
|
|
51
51
|
|
|
52
52
|
# The human-readable field name
|
|
53
53
|
def label
|
|
@@ -43,12 +43,12 @@ module Licensee
|
|
|
43
43
|
|
|
44
44
|
# Array of symbolized helper methods to expose on the License class
|
|
45
45
|
def helper_methods
|
|
46
|
-
members - PREDICATE_FIELDS + PREDICATE_FIELDS.map { |f| "#{f}?"
|
|
46
|
+
members - PREDICATE_FIELDS + PREDICATE_FIELDS.map { |f| :"#{f}?" }
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
PREDICATE_FIELDS.each do |field|
|
|
51
|
-
alias_method "#{field}?"
|
|
51
|
+
alias_method :"#{field}?", field
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
# Backward compatibalize `#["spdx-id"]` calls to avoid a breaking change
|
|
@@ -5,7 +5,7 @@ module Licensee
|
|
|
5
5
|
class Cabal < Licensee::Matchers::Package
|
|
6
6
|
# While we could parse the cabal file, prefer
|
|
7
7
|
# a lenient regex for speed and security. Moar parsing moar problems.
|
|
8
|
-
LICENSE_REGEX = /^\s*license\s*:\s*([a-z\-0-9.]+)\s*$/ix
|
|
8
|
+
LICENSE_REGEX = /^\s*license\s*:\s*([a-z\-0-9.]+)\s*$/ix
|
|
9
9
|
LICENSE_CONVERSIONS = {
|
|
10
10
|
'GPL-2' => 'GPL-2.0',
|
|
11
11
|
'GPL-3' => 'GPL-3.0',
|
|
@@ -6,9 +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
|
-
MAIN_LINE_REGEX = /[_*\-\s]*#{COPYRIGHT_SYMBOLS}.*$/i
|
|
10
|
-
OPTIONAL_LINE_REGEX = /[_*\-\s]*with Reserved Font Name.*$/i
|
|
11
|
-
REGEX = /#{ContentHelper::START_REGEX}(#{MAIN_LINE_REGEX}#{OPTIONAL_LINE_REGEX}*)+$/i
|
|
9
|
+
MAIN_LINE_REGEX = /[_*\-\s]*#{COPYRIGHT_SYMBOLS}.*$/i
|
|
10
|
+
OPTIONAL_LINE_REGEX = /[_*\-\s]*with Reserved Font Name.*$/i
|
|
11
|
+
REGEX = /#{ContentHelper::START_REGEX}(#{MAIN_LINE_REGEX}#{OPTIONAL_LINE_REGEX}*)+$/i
|
|
12
12
|
def match
|
|
13
13
|
# NOTE: must use content, and not content_normalized here
|
|
14
14
|
Licensee::License.find('no-license') if /#{REGEX}+\z/io.match?(file.content.strip)
|
|
@@ -7,9 +7,9 @@ module Licensee
|
|
|
7
7
|
|
|
8
8
|
# While we could parse the DESCRIPTION file, prefer
|
|
9
9
|
# a lenient regex for speed and security. Moar parsing moar problems.
|
|
10
|
-
LICENSE_FIELD_REGEX = /^license:\s*(.+)/i
|
|
11
|
-
PLUS_FILE_LICENSE_REGEX = /\s*\+\s*file\s+LICENSE$/i
|
|
12
|
-
GPL_VERSION_REGEX = /^GPL(?:-([23])|\s*\(\s*>=\s*([23])\s*\))$/i
|
|
10
|
+
LICENSE_FIELD_REGEX = /^license:\s*(.+)/i
|
|
11
|
+
PLUS_FILE_LICENSE_REGEX = /\s*\+\s*file\s+LICENSE$/i
|
|
12
|
+
GPL_VERSION_REGEX = /^GPL(?:-([23])|\s*\(\s*>=\s*([23])\s*\))$/i
|
|
13
13
|
|
|
14
14
|
private
|
|
15
15
|
|
|
@@ -5,24 +5,24 @@ module Licensee
|
|
|
5
5
|
class Gemspec < Licensee::Matchers::Package
|
|
6
6
|
# a value is a string surrounded by any amount of whitespace
|
|
7
7
|
# optionally ended with (non-captured) ".freeze"
|
|
8
|
-
VALUE_REGEX = /\s*['"]([a-z\-0-9.]+)['"](?:\.freeze)?\s*/i
|
|
8
|
+
VALUE_REGEX = /\s*['"]([a-z\-0-9.]+)['"](?:\.freeze)?\s*/i
|
|
9
9
|
|
|
10
10
|
# an array contains one or more values. all values, or array itself,
|
|
11
11
|
# can be surrounded by any amount of whitespace. do not capture
|
|
12
12
|
# non-value groups
|
|
13
|
-
ARRAY_REGEX = /\s*\[#{VALUE_REGEX}(?:,#{VALUE_REGEX})*\]\s*/i
|
|
13
|
+
ARRAY_REGEX = /\s*\[#{VALUE_REGEX}(?:,#{VALUE_REGEX})*\]\s*/i
|
|
14
14
|
|
|
15
15
|
DECLARATION_REGEX = /
|
|
16
16
|
^\s*[a-z0-9_]+\.([a-z0-9_]+)\s*=#{VALUE_REGEX}$
|
|
17
|
-
/ix
|
|
17
|
+
/ix
|
|
18
18
|
|
|
19
19
|
LICENSE_REGEX = /
|
|
20
20
|
^\s*[a-z0-9_]+\.license\s*=#{VALUE_REGEX}$
|
|
21
|
-
/ix
|
|
21
|
+
/ix
|
|
22
22
|
|
|
23
23
|
LICENSE_ARRAY_REGEX = /
|
|
24
24
|
^\s*[a-z0-9_]+\.licenses\s*=#{ARRAY_REGEX}$
|
|
25
|
-
/ix
|
|
25
|
+
/ix
|
|
26
26
|
|
|
27
27
|
private
|
|
28
28
|
|
|
@@ -7,14 +7,14 @@ module Licensee
|
|
|
7
7
|
# Moar parsing moar problems.
|
|
8
8
|
LICENSE_REGEX = %r{
|
|
9
9
|
<license\s*type\s*=\s*["']expression["']\s*>([a-z\-0-9. +()]+)</license\s*>
|
|
10
|
-
}ix
|
|
10
|
+
}ix
|
|
11
11
|
|
|
12
|
-
LICENSE_URL_REGEX = %r{<licenseUrl>\s*(.*)\s*</licenseUrl>}i
|
|
12
|
+
LICENSE_URL_REGEX = %r{<licenseUrl>\s*(.*)\s*</licenseUrl>}i
|
|
13
13
|
|
|
14
|
-
NUGET_REGEX = %r{https?://licenses.nuget.org/(.*)}i
|
|
15
|
-
OPENSOURCE_REGEX = %r{https?://(?:www\.)?opensource.org/licenses/(.*)}i
|
|
16
|
-
SPDX_REGEX = %r{https?://(?:www\.)?spdx.org/licenses/(.*?)(?:\.html|\.txt)?$}i
|
|
17
|
-
APACHE_REGEX = %r{https?://(?:www\.)?apache.org/licenses/(.*?)(?:\.html|\.txt)?$}i
|
|
14
|
+
NUGET_REGEX = %r{https?://licenses.nuget.org/(.*)}i
|
|
15
|
+
OPENSOURCE_REGEX = %r{https?://(?:www\.)?opensource.org/licenses/(.*)}i
|
|
16
|
+
SPDX_REGEX = %r{https?://(?:www\.)?spdx.org/licenses/(.*?)(?:\.html|\.txt)?$}i
|
|
17
|
+
APACHE_REGEX = %r{https?://(?:www\.)?apache.org/licenses/(.*?)(?:\.html|\.txt)?$}i
|
|
18
18
|
|
|
19
19
|
private
|
|
20
20
|
|
|
@@ -5,7 +5,7 @@ module Licensee
|
|
|
5
5
|
class Spdx < Licensee::Matchers::Package
|
|
6
6
|
# While we could parse the LICENSE.spdx file, prefer
|
|
7
7
|
# a lenient regex for speed and security. Moar parsing moar problems.
|
|
8
|
-
LICENSE_REGEX = /PackageLicenseDeclared:\s*([a-z\-0-9. +()]+)\s*/i
|
|
8
|
+
LICENSE_REGEX = /PackageLicenseDeclared:\s*([a-z\-0-9. +()]+)\s*/i
|
|
9
9
|
|
|
10
10
|
private
|
|
11
11
|
|
|
@@ -7,29 +7,29 @@ module Licensee
|
|
|
7
7
|
|
|
8
8
|
# List of extensions to give preference to
|
|
9
9
|
PREFERRED_EXT = %w[md markdown txt html].freeze
|
|
10
|
-
PREFERRED_EXT_REGEX = /\.#{Regexp.union(PREFERRED_EXT)}\z
|
|
10
|
+
PREFERRED_EXT_REGEX = /\.#{Regexp.union(PREFERRED_EXT)}\z/
|
|
11
11
|
|
|
12
12
|
# Regex to match any extension except .spdx or .header
|
|
13
|
-
LICENSE_EXT_REGEX = %r{\.(?!spdx|header)[^./]+\z}i
|
|
13
|
+
LICENSE_EXT_REGEX = %r{\.(?!spdx|header)[^./]+\z}i
|
|
14
14
|
|
|
15
15
|
# Regex to match any extension except a few unlikely as license
|
|
16
16
|
# texts with complex filenames
|
|
17
|
-
OTHER_EXT_REGEX = %r{\.(?!xml|go|gemspec)[^./]+\z}i
|
|
17
|
+
OTHER_EXT_REGEX = %r{\.(?!xml|go|gemspec)[^./]+\z}i
|
|
18
18
|
|
|
19
19
|
# Regex to match any extension
|
|
20
|
-
ANY_EXT_REGEX = %r{\.[^./]+\z}i
|
|
20
|
+
ANY_EXT_REGEX = %r{\.[^./]+\z}i
|
|
21
21
|
|
|
22
22
|
# Regex to match, LICENSE, LICENCE, unlicense, etc.
|
|
23
|
-
LICENSE_REGEX = /(un)?licen[sc]e/i
|
|
23
|
+
LICENSE_REGEX = /(un)?licen[sc]e/i
|
|
24
24
|
|
|
25
25
|
# Regex to match COPYING, COPYRIGHT, etc.
|
|
26
|
-
COPYING_REGEX = /copy(ing|right)/i
|
|
26
|
+
COPYING_REGEX = /copy(ing|right)/i
|
|
27
27
|
|
|
28
28
|
# Regex to match OFL.
|
|
29
|
-
OFL_REGEX = /ofl/i
|
|
29
|
+
OFL_REGEX = /ofl/i
|
|
30
30
|
|
|
31
31
|
# BSD + PATENTS patent file
|
|
32
|
-
PATENTS_REGEX = /patents/i
|
|
32
|
+
PATENTS_REGEX = /patents/i
|
|
33
33
|
|
|
34
34
|
# Hash of Regex => score with which to score potential license files
|
|
35
35
|
FILENAME_REGEXES = {
|
|
@@ -55,7 +55,7 @@ module Licensee
|
|
|
55
55
|
# detected as CC-BY or CC-BY-SA which are 98%+ similar
|
|
56
56
|
CC_FALSE_POSITIVE_REGEX = /
|
|
57
57
|
^(creative\ commons\ )?Attribution-(NonCommercial|NoDerivatives)
|
|
58
|
-
/xi
|
|
58
|
+
/xi
|
|
59
59
|
|
|
60
60
|
def possible_matchers
|
|
61
61
|
[Matchers::Copyright, Matchers::Exact, Matchers::Dice]
|
|
@@ -9,8 +9,8 @@ module Licensee
|
|
|
9
9
|
/\AREADME\.(#{Regexp.union(EXTENSIONS).source})\z/i => 0.9
|
|
10
10
|
}.freeze
|
|
11
11
|
|
|
12
|
-
TITLE_REGEX = /licen[sc]e:?/i
|
|
13
|
-
UNDERLINE_REGEX = /\n[-=]+/m
|
|
12
|
+
TITLE_REGEX = /licen[sc]e:?/i
|
|
13
|
+
UNDERLINE_REGEX = /\n[-=]+/m
|
|
14
14
|
CONTENT_REGEX = /^
|
|
15
15
|
(?: # Header lookbehind
|
|
16
16
|
[\#=]+\s#{TITLE_REGEX}\s*[\#=]* # Start of hashes or rdoc header
|
|
@@ -27,7 +27,7 @@ module Licensee
|
|
|
27
27
|
|
|
|
28
28
|
\z # End of file
|
|
29
29
|
)
|
|
30
|
-
/mix
|
|
30
|
+
/mix
|
|
31
31
|
|
|
32
32
|
def possible_matchers
|
|
33
33
|
super.push(Matchers::Reference)
|
|
@@ -34,11 +34,11 @@ module Licensee
|
|
|
34
34
|
def files
|
|
35
35
|
@files ||= search_directories.flat_map do |dir|
|
|
36
36
|
relative_dir = Pathname.new(dir).relative_path_from(dir_path).to_s
|
|
37
|
-
Dir.glob(::File.join(dir, @pattern).tr('\\', '/')).
|
|
37
|
+
Dir.glob(::File.join(dir, @pattern).tr('\\', '/')).filter_map do |file|
|
|
38
38
|
next unless ::File.file?(file)
|
|
39
39
|
|
|
40
40
|
{ name: ::File.basename(file), dir: relative_dir }
|
|
41
|
-
end
|
|
41
|
+
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -15,7 +15,7 @@ module Licensee
|
|
|
15
15
|
# If there's any trailing data (e.g. `.git`) this pattern will ignore it:
|
|
16
16
|
# we're going to use the API rather than clone the repo.
|
|
17
17
|
GITHUB_REPO_PATTERN =
|
|
18
|
-
%r{https://github.com/([^/]+/([^/]+(?=\.git)|[^/]+)).*}
|
|
18
|
+
%r{https://github.com/([^/]+/([^/]+(?=\.git)|[^/]+)).*}
|
|
19
19
|
|
|
20
20
|
class RepoNotFound < StandardError; end
|
|
21
21
|
|
data/lib/licensee/rule.rb
CHANGED
data/lib/licensee/version.rb
CHANGED
data/spec/fixture_spec.rb
CHANGED