licensee 9.4.0 → 9.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/licensee/content_helper.rb +15 -15
- data/lib/licensee/license.rb +43 -1
- data/lib/licensee/matchers.rb +9 -8
- data/lib/licensee/matchers/reference.rb +16 -0
- data/lib/licensee/project_files/project_file.rb +8 -0
- data/lib/licensee/project_files/readme_file.rb +4 -0
- data/lib/licensee/projects/project.rb +11 -3
- data/lib/licensee/version.rb +1 -1
- data/spec/fixtures/license-with-readme-reference/LICENSE +19 -0
- data/spec/fixtures/license-with-readme-reference/README +5 -0
- data/spec/fixtures/mit-with-copyright/COPYRIGHT.md +1 -0
- data/spec/fixtures/mit-with-copyright/LICENSE.txt +21 -0
- data/spec/integration_spec.rb +10 -0
- data/spec/licensee/content_helper_spec.rb +65 -0
- data/spec/licensee/license_spec.rb +90 -0
- data/spec/licensee/matchers/reference_matcher_spec.rb +42 -0
- data/spec/licensee/project_files/license_file_spec.rb +27 -0
- data/spec/licensee/project_files/readme_spec.rb +9 -0
- data/spec/licensee/project_spec.rb +8 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba8051e36fee570aacfe7594c0ba6b293f6ec091
|
4
|
+
data.tar.gz: 6c24e69c2f219d3fb32e4a86e240a04a28e547ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdfe0a0195cbdaeaae793156af0aebde1faf319ce812ebe999386c8d35f30b4f20332be41ab97679af82a0f30046fd5de4654b13a3e125c377900d346266ec5d
|
7
|
+
data.tar.gz: 2a9562f47b7ac5667b38e3871bda75b88856695682b77cd8c7830352f64336d5e4d056da65b93037baa3807c8ac556bb226be54794a3bc8d51bffc7f6c9a8d11
|
@@ -6,11 +6,7 @@ module Licensee
|
|
6
6
|
DIGEST = Digest::SHA1
|
7
7
|
END_OF_TERMS_REGEX = /^\s*end of terms and conditions\s*$/i
|
8
8
|
HR_REGEX = /[=\-\*][=\-\*\s]{3,}/
|
9
|
-
ALT_TITLE_REGEX =
|
10
|
-
'bsd-2-clause' => /bsd 2-clause( \"simplified\")? license/i,
|
11
|
-
'bsd-3-clause' => /bsd 3-clause( \"new\" or \"revised\")? license/i,
|
12
|
-
'bsd-3-clause-clear' => /(clear bsd|bsd 3-clause( clear)?) license/i
|
13
|
-
}.freeze
|
9
|
+
ALT_TITLE_REGEX = License::ALT_TITLE_REGEX
|
14
10
|
ALL_RIGHTS_RESERVED_REGEX = /\Aall rights reserved\.?$/i
|
15
11
|
WHITESPACE_REGEX = /\s+/
|
16
12
|
MARKDOWN_HEADING_REGEX = /\A\s*#+/
|
@@ -62,7 +58,7 @@ module Licensee
|
|
62
58
|
string = content.strip
|
63
59
|
string = strip_markdown_headings(string)
|
64
60
|
string = strip_hrs(string)
|
65
|
-
string = strip_title(string) while string =~ title_regex
|
61
|
+
string = strip_title(string) while string =~ ContentHelper.title_regex
|
66
62
|
strip_version(string).strip
|
67
63
|
end
|
68
64
|
end
|
@@ -112,21 +108,25 @@ module Licensee
|
|
112
108
|
"#{format('%.2f', float)}%"
|
113
109
|
end
|
114
110
|
|
115
|
-
|
111
|
+
def self.title_regex
|
112
|
+
licenses = Licensee::License.all(hidden: true, psuedo: false)
|
113
|
+
titles = licenses.map(&:title_regex)
|
116
114
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
115
|
+
# Title regex must include the version to support matching within
|
116
|
+
# families, but for sake of normalization, we can be less strict
|
117
|
+
without_versions = licenses.map do |license|
|
118
|
+
next if license.title == license.name_without_version
|
119
|
+
Regexp.new Regexp.escape(license.name_without_version), 'i'
|
121
120
|
end
|
122
|
-
|
121
|
+
titles.concat(without_versions.compact)
|
123
122
|
|
124
|
-
|
125
|
-
/\A\(?(the )?(#{Regexp.union(license_names).source}).*$/i
|
123
|
+
/\A\s*\(?(the )?#{Regexp.union titles}.*$/i
|
126
124
|
end
|
127
125
|
|
126
|
+
private
|
127
|
+
|
128
128
|
def strip_title(string)
|
129
|
-
strip(string, title_regex)
|
129
|
+
strip(string, ContentHelper.title_regex)
|
130
130
|
end
|
131
131
|
|
132
132
|
def strip_version(string)
|
data/lib/licensee/license.rb
CHANGED
@@ -16,9 +16,10 @@ module Licensee
|
|
16
16
|
# Returns an Array of License objects.
|
17
17
|
def all(options = {})
|
18
18
|
@all[options] ||= begin
|
19
|
-
options =
|
19
|
+
options = DEFAULT_OPTIONS.merge(options)
|
20
20
|
output = licenses.dup
|
21
21
|
output.reject!(&:hidden?) unless options[:hidden]
|
22
|
+
output.reject!(&:pseudo_license?) unless options[:psuedo]
|
22
23
|
return output if options[:featured].nil?
|
23
24
|
output.select { |l| l.featured? == options[:featured] }
|
24
25
|
end
|
@@ -37,6 +38,13 @@ module Licensee
|
|
37
38
|
alias [] find
|
38
39
|
alias find_by_key find
|
39
40
|
|
41
|
+
# Given a license title or nickname, fuzzy match the license
|
42
|
+
def find_by_title(title)
|
43
|
+
License.all(hidden: true, psuedo: false).find do |license|
|
44
|
+
title =~ /\A(the )?#{license.title_regex}( license)?\z/i
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
40
48
|
def license_dir
|
41
49
|
dir = ::File.dirname(__FILE__)
|
42
50
|
::File.expand_path '../../vendor/choosealicense.com/_licenses', dir
|
@@ -70,6 +78,19 @@ module Licensee
|
|
70
78
|
# Note: A lack of detected license will be a nil license
|
71
79
|
PSEUDO_LICENSES = %w[other no-license].freeze
|
72
80
|
|
81
|
+
# Default options to use when retrieving licenses via #all
|
82
|
+
DEFAULT_OPTIONS = {
|
83
|
+
hidden: false,
|
84
|
+
featured: nil,
|
85
|
+
psuedo: true
|
86
|
+
}.freeze
|
87
|
+
|
88
|
+
ALT_TITLE_REGEX = {
|
89
|
+
'bsd-2-clause' => /bsd 2-clause(?: \"simplified\")?/i,
|
90
|
+
'bsd-3-clause' => /bsd 3-clause(?: \"new\" or \"revised\")?/i,
|
91
|
+
'bsd-3-clause-clear' => /(?:clear bsd|bsd 3-clause(?: clear)?)/i
|
92
|
+
}.freeze
|
93
|
+
|
73
94
|
include Licensee::ContentHelper
|
74
95
|
extend Forwardable
|
75
96
|
def_delegators :meta, *LicenseMeta.helper_methods
|
@@ -97,6 +118,27 @@ module Licensee
|
|
97
118
|
/(.+?)(( v?\d\.\d)|$)/.match(name)[1]
|
98
119
|
end
|
99
120
|
|
121
|
+
def title_regex
|
122
|
+
return @regex if defined? @regex
|
123
|
+
|
124
|
+
title_regex = ALT_TITLE_REGEX[key]
|
125
|
+
title_regex ||= begin
|
126
|
+
string = name.downcase.sub('*', 'u')
|
127
|
+
string.sub!(/\Athe /i, '')
|
128
|
+
string.sub!(/ license\z/i, '')
|
129
|
+
string = Regexp.escape(string)
|
130
|
+
string = string.sub(/\bgnu\\ /, '(?:GNU )?')
|
131
|
+
Regexp.new string, 'i'
|
132
|
+
end
|
133
|
+
|
134
|
+
parts = [title_regex, key]
|
135
|
+
if meta.nickname
|
136
|
+
parts.push Regexp.new meta.nickname.sub(/\bGNU /i, '(?:GNU )?')
|
137
|
+
end
|
138
|
+
|
139
|
+
@regex = Regexp.union parts
|
140
|
+
end
|
141
|
+
|
100
142
|
def other?
|
101
143
|
key == 'other'
|
102
144
|
end
|
data/lib/licensee/matchers.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
module Licensee
|
2
2
|
module Matchers
|
3
|
-
autoload :Matcher,
|
4
|
-
autoload :Cabal,
|
3
|
+
autoload :Matcher, 'licensee/matchers/matcher'
|
4
|
+
autoload :Cabal, 'licensee/matchers/cabal'
|
5
5
|
autoload :Copyright, 'licensee/matchers/copyright'
|
6
|
-
autoload :Cran,
|
7
|
-
autoload :Dice,
|
6
|
+
autoload :Cran, 'licensee/matchers/cran'
|
7
|
+
autoload :Dice, 'licensee/matchers/dice'
|
8
8
|
autoload :DistZilla, 'licensee/matchers/dist_zilla'
|
9
|
-
autoload :Exact,
|
10
|
-
autoload :Gemspec,
|
11
|
-
autoload :NpmBower,
|
12
|
-
autoload :Package,
|
9
|
+
autoload :Exact, 'licensee/matchers/exact'
|
10
|
+
autoload :Gemspec, 'licensee/matchers/gemspec'
|
11
|
+
autoload :NpmBower, 'licensee/matchers/npm_bower'
|
12
|
+
autoload :Package, 'licensee/matchers/package'
|
13
|
+
autoload :Reference, 'licensee/matchers/reference'
|
13
14
|
end
|
14
15
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Licensee
|
2
|
+
module Matchers
|
3
|
+
# Matches README files that include a license by reference
|
4
|
+
class Reference < Licensee::Matchers::Matcher
|
5
|
+
def match
|
6
|
+
License.all(hidden: true, psuedo: false).find do |license|
|
7
|
+
/\b#{license.title_regex}\b/ =~ file.content
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def confidence
|
12
|
+
90
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -60,6 +60,14 @@ module Licensee
|
|
60
60
|
|
61
61
|
alias match license
|
62
62
|
alias path filename
|
63
|
+
|
64
|
+
# Is this file a COPYRIGHT file with only a copyright statement?
|
65
|
+
# If so, it can be excluded from determining if a project has >1 license
|
66
|
+
def copyright?
|
67
|
+
return false unless is_a?(LicenseFile)
|
68
|
+
return false unless matcher.is_a?(Matchers::Copyright)
|
69
|
+
filename =~ /\Acopyright(?:#{LicenseFile::ANY_EXT_REGEX})?\z/i
|
70
|
+
end
|
63
71
|
end
|
64
72
|
end
|
65
73
|
end
|
@@ -18,9 +18,9 @@ module Licensee
|
|
18
18
|
# Returns the matching License instance if a license can be detected
|
19
19
|
def license
|
20
20
|
return @license if defined? @license
|
21
|
-
@license = if
|
22
|
-
|
23
|
-
elsif
|
21
|
+
@license = if licenses_without_copyright.count == 1 || lgpl?
|
22
|
+
licenses_without_copyright.first
|
23
|
+
elsif licenses_without_copyright.count > 1
|
24
24
|
Licensee::License.find('other')
|
25
25
|
end
|
26
26
|
end
|
@@ -136,6 +136,14 @@ module Licensee
|
|
136
136
|
def project_files
|
137
137
|
@project_files ||= [license_files, readme, package_file].flatten.compact
|
138
138
|
end
|
139
|
+
|
140
|
+
# Returns an array of matches licenses, excluding the COPYRIGHT file
|
141
|
+
# which can often be ignored for purposes of determing dual licensing
|
142
|
+
def licenses_without_copyright
|
143
|
+
@licenses_without_copyright ||= begin
|
144
|
+
matched_files.reject(&:copyright?).map(&:license).uniq
|
145
|
+
end
|
146
|
+
end
|
139
147
|
end
|
140
148
|
|
141
149
|
def files
|
data/lib/licensee/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2017 Ben Balter
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
Copyright (c) 2017 Ben Balter
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Ben Balter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/spec/integration_spec.rb
CHANGED
@@ -148,6 +148,16 @@ RSpec.describe 'integration test' do
|
|
148
148
|
expect(subject.license).to eql(license)
|
149
149
|
end
|
150
150
|
end
|
151
|
+
|
152
|
+
context 'license + README reference' do
|
153
|
+
let(:license) { Licensee::License.find('mit') }
|
154
|
+
let(:fixture) { 'license-with-readme-reference' }
|
155
|
+
let(:arguments) { { detect_readme: true } }
|
156
|
+
|
157
|
+
it 'determines the project is MIT' do
|
158
|
+
expect(subject.license).to eql(license)
|
159
|
+
end
|
160
|
+
end
|
151
161
|
end
|
152
162
|
|
153
163
|
context 'with the license file stubbed' do
|
@@ -175,4 +175,69 @@ LICENSE
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
178
|
+
|
179
|
+
context 'title regex' do
|
180
|
+
let(:license) { Licensee::License.find('gpl-3.0') }
|
181
|
+
|
182
|
+
%i[key title nickname name_without_version].each do |variation|
|
183
|
+
context "a license #{variation}" do
|
184
|
+
let(:license_variation) { license.send(variation) }
|
185
|
+
let(:text) { license_variation }
|
186
|
+
|
187
|
+
it 'matches' do
|
188
|
+
expect(text).to match(described_class.title_regex)
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'preceded by the' do
|
192
|
+
let(:text) { "The #{license_variation} license" }
|
193
|
+
|
194
|
+
it 'matches' do
|
195
|
+
expect(text).to match(described_class.title_regex)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'with parens' do
|
200
|
+
let(:text) { "(#{license_variation})" }
|
201
|
+
|
202
|
+
it 'matches' do
|
203
|
+
expect(text).to match(described_class.title_regex)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'with parens and a preceding the' do
|
208
|
+
let(:text) { "(the #{license_variation} license)" }
|
209
|
+
|
210
|
+
it 'matches' do
|
211
|
+
expect(text).to match(described_class.title_regex)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
context 'with whitespace' do
|
216
|
+
let(:text) { " the #{license_variation} license" }
|
217
|
+
|
218
|
+
it 'matches' do
|
219
|
+
expect(text).to match(described_class.title_regex)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'escaping' do
|
224
|
+
let(:text) { 'gpl-3 0' }
|
225
|
+
|
226
|
+
it 'escapes' do
|
227
|
+
expect(text).to_not match(described_class.title_regex)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context 'in the middle of a string' do
|
232
|
+
let(:text) do
|
233
|
+
"The project is not licensed under the #{license_variation} license"
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'matches' do
|
237
|
+
expect(text).to_not match(described_class.title_regex)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
178
243
|
end
|
@@ -85,6 +85,42 @@ RSpec.describe Licensee::License do
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
+
|
89
|
+
context 'psudo licenses' do
|
90
|
+
let(:other) { Licensee::License.find('other') }
|
91
|
+
|
92
|
+
context 'by default' do
|
93
|
+
let(:arguments) { {} }
|
94
|
+
|
95
|
+
it "doesn't include psudo licenses" do
|
96
|
+
expect(licenses).to_not include(other)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'with hidden licenses' do
|
101
|
+
let(:arguments) { { hidden: true } }
|
102
|
+
|
103
|
+
it 'includes psudo licenses' do
|
104
|
+
expect(licenses).to include(other)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when explicitly asked' do
|
109
|
+
let(:arguments) { { hidden: true, psuedo: true } }
|
110
|
+
|
111
|
+
it 'includes psudo licenses' do
|
112
|
+
expect(licenses).to include(other)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'when explicitly excluded' do
|
117
|
+
let(:arguments) { { hidden: true, psuedo: false } }
|
118
|
+
|
119
|
+
it "doesn'tincludes psudo licenses" do
|
120
|
+
expect(licenses).to_not include(other)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
88
124
|
end
|
89
125
|
|
90
126
|
context 'finding' do
|
@@ -297,4 +333,58 @@ RSpec.describe Licensee::License do
|
|
297
333
|
end
|
298
334
|
end
|
299
335
|
end
|
336
|
+
|
337
|
+
context 'License.title_regex' do
|
338
|
+
Licensee::License.all(hidden: true, psuedo: false).each do |license|
|
339
|
+
context "the #{license.title} license" do
|
340
|
+
%i[title nickname key].each do |variation|
|
341
|
+
next if license.send(variation).nil?
|
342
|
+
|
343
|
+
context "the license #{variation}" do
|
344
|
+
let(:license_variation) { license.send(variation).sub('*', 'u') }
|
345
|
+
let(:text) { license_variation }
|
346
|
+
|
347
|
+
it 'matches' do
|
348
|
+
expect(text).to match(license.title_regex)
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'finds by title' do
|
352
|
+
expect(described_class.find_by_title(text)).to eql(license)
|
353
|
+
end
|
354
|
+
|
355
|
+
if license.title =~ /\bGNU\b/
|
356
|
+
context "without 'GNU'" do
|
357
|
+
let(:text) { license_variation.sub(/GNU /i, '') }
|
358
|
+
|
359
|
+
it 'still matches' do
|
360
|
+
expect(text).to match(license.title_regex)
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
context "with 'the' and 'license'" do
|
366
|
+
let(:text) { "The #{license_variation} license" }
|
367
|
+
|
368
|
+
it 'matches' do
|
369
|
+
expect(text).to match(license.title_regex)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
context 'a license with an alt title' do
|
378
|
+
let(:text) { 'The Clear BSD license' }
|
379
|
+
let(:license) { Licensee::License.find('bsd-3-clause-clear') }
|
380
|
+
|
381
|
+
it 'matches' do
|
382
|
+
expect(text).to match(license.title_regex)
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'finds by title' do
|
386
|
+
expect(described_class.find_by_title(text)).to eql(license)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
300
390
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
RSpec.describe Licensee::Matchers::Reference do
|
2
|
+
let(:content) { 'Copyright 2015 Ben Balter' }
|
3
|
+
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
4
|
+
let(:license) { Licensee::License.find('gpl-3.0') }
|
5
|
+
|
6
|
+
subject { described_class.new(file) }
|
7
|
+
|
8
|
+
%i[title key nickname].each do |variation|
|
9
|
+
context "with a license #{variation}" do
|
10
|
+
let(:content) { "Licensed under the #{license.send(variation)} license" }
|
11
|
+
|
12
|
+
it 'matches' do
|
13
|
+
expect(subject.match).to eql(license)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'as a markdown link' do
|
17
|
+
let(:content) { "[#{license.send(variation)}](https://example.com)" }
|
18
|
+
|
19
|
+
it 'matches' do
|
20
|
+
expect(subject.match).to eql(license)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'a license key in a word' do
|
27
|
+
let(:content) { 'My name is MITch!' }
|
28
|
+
|
29
|
+
it "doesn't match" do
|
30
|
+
expect(subject.match).to be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'a license with alt regex' do
|
35
|
+
let(:content) { 'Clear BSD' }
|
36
|
+
let(:license) { Licensee::License.find('bsd-3-clause-clear') }
|
37
|
+
|
38
|
+
it 'matches' do
|
39
|
+
expect(subject.match).to eql(license)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -238,4 +238,31 @@ Creative Commons Attribution-NonCommercial 4.0
|
|
238
238
|
expect(subject.license).to eql(other)
|
239
239
|
end
|
240
240
|
end
|
241
|
+
|
242
|
+
context 'copyright?' do
|
243
|
+
context 'a copyright file' do
|
244
|
+
let(:content) { 'Copyright 2017 Ben Balter' }
|
245
|
+
let(:filename) { 'COPYRIGHT.txt' }
|
246
|
+
|
247
|
+
it "knows it's a copyright file" do
|
248
|
+
expect(subject.send(:copyright?)).to be_truthy
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
context 'A copyright file with license text' do
|
253
|
+
let(:filename) { 'COPYRIGHT.txt' }
|
254
|
+
|
255
|
+
it "knows it's not a copyright file" do
|
256
|
+
expect(subject.send(:copyright?)).to be_falsy
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
context 'a license file with copyright text' do
|
261
|
+
let(:content) { 'Copyright 2017 Ben Balter' }
|
262
|
+
|
263
|
+
it "knows it's not a copyright file" do
|
264
|
+
expect(subject.send(:copyright?)).to be_falsy
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
241
268
|
end
|
@@ -98,4 +98,13 @@ RSpec.describe Licensee::ProjectFiles::ReadmeFile do
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
context 'a license reference' do
|
103
|
+
let(:content) { 'The MIT License' }
|
104
|
+
let(:mit) { Licensee::License.find('mit') }
|
105
|
+
|
106
|
+
it 'matches' do
|
107
|
+
expect(subject.match).to eql(mit)
|
108
|
+
end
|
109
|
+
end
|
101
110
|
end
|
@@ -240,5 +240,13 @@
|
|
240
240
|
expect(subject.license_files.last.filename).to eql('LICENSE')
|
241
241
|
end
|
242
242
|
end
|
243
|
+
|
244
|
+
context 'with a copyright file' do
|
245
|
+
let(:fixture) { 'mit-with-copyright' }
|
246
|
+
|
247
|
+
it 'returns MIT' do
|
248
|
+
expect(subject.license).to eql(mit)
|
249
|
+
end
|
250
|
+
end
|
243
251
|
end
|
244
252
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: licensee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/licensee/matchers/matcher.rb
|
143
143
|
- lib/licensee/matchers/npm_bower.rb
|
144
144
|
- lib/licensee/matchers/package.rb
|
145
|
+
- lib/licensee/matchers/reference.rb
|
145
146
|
- lib/licensee/project_files.rb
|
146
147
|
- lib/licensee/project_files/license_file.rb
|
147
148
|
- lib/licensee/project_files/package_manager_file.rb
|
@@ -172,6 +173,10 @@ files:
|
|
172
173
|
- spec/fixtures/license-folder/README.md
|
173
174
|
- spec/fixtures/license-in-parent-folder/LICENSE.txt
|
174
175
|
- spec/fixtures/license-in-parent-folder/license-folder/LICENSE.txt
|
176
|
+
- spec/fixtures/license-with-readme-reference/LICENSE
|
177
|
+
- spec/fixtures/license-with-readme-reference/README
|
178
|
+
- spec/fixtures/mit-with-copyright/COPYRIGHT.md
|
179
|
+
- spec/fixtures/mit-with-copyright/LICENSE.txt
|
175
180
|
- spec/fixtures/mit/LICENSE.txt
|
176
181
|
- spec/fixtures/mit/README.md
|
177
182
|
- spec/fixtures/mpl-without-hrs/LICENSE
|
@@ -194,6 +199,7 @@ files:
|
|
194
199
|
- spec/licensee/matchers/gemspec_matcher_spec.rb
|
195
200
|
- spec/licensee/matchers/npm_bower_matcher_spec.rb
|
196
201
|
- spec/licensee/matchers/package_matcher_spec.rb
|
202
|
+
- spec/licensee/matchers/reference_matcher_spec.rb
|
197
203
|
- spec/licensee/project_files/license_file_spec.rb
|
198
204
|
- spec/licensee/project_files/package_info_spec.rb
|
199
205
|
- spec/licensee/project_files/project_file_spec.rb
|