licensee 9.13.0 → 9.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +1 -1
  3. data/bin/licensee +2 -2
  4. data/lib/licensee.rb +4 -4
  5. data/lib/licensee/commands/detect.rb +3 -5
  6. data/lib/licensee/commands/diff.rb +3 -5
  7. data/lib/licensee/content_helper.rb +41 -44
  8. data/lib/licensee/hash_helper.rb +1 -1
  9. data/lib/licensee/license.rb +29 -15
  10. data/lib/licensee/matchers.rb +1 -0
  11. data/lib/licensee/matchers/cabal.rb +1 -1
  12. data/lib/licensee/matchers/cargo.rb +1 -1
  13. data/lib/licensee/matchers/copyright.rb +3 -8
  14. data/lib/licensee/matchers/cran.rb +1 -1
  15. data/lib/licensee/matchers/dice.rb +2 -2
  16. data/lib/licensee/matchers/dist_zilla.rb +1 -1
  17. data/lib/licensee/matchers/gemspec.rb +4 -4
  18. data/lib/licensee/matchers/npm_bower.rb +5 -2
  19. data/lib/licensee/matchers/nuget.rb +43 -0
  20. data/lib/licensee/matchers/spdx.rb +1 -1
  21. data/lib/licensee/project_files/license_file.rb +29 -22
  22. data/lib/licensee/project_files/package_manager_file.rb +3 -2
  23. data/lib/licensee/project_files/project_file.rb +3 -4
  24. data/lib/licensee/project_files/readme_file.rb +1 -1
  25. data/lib/licensee/projects/fs_project.rb +8 -5
  26. data/lib/licensee/projects/git_project.rb +6 -4
  27. data/lib/licensee/projects/github_project.rb +1 -1
  28. data/lib/licensee/projects/project.rb +11 -10
  29. data/lib/licensee/version.rb +1 -1
  30. data/licensee.gemspec +7 -8
  31. data/spec/fixture_spec.rb +3 -3
  32. data/spec/fixtures/bom/LICENSE.txt +21 -0
  33. data/spec/fixtures/bsd-3-authorowner/LICENSE +27 -0
  34. data/spec/fixtures/bsd-3-noendorseslash/LICENSE +30 -0
  35. data/spec/fixtures/cc-by-sa-mdlinks/License.md +173 -0
  36. data/spec/fixtures/cc-by-sa-nocclicensor/License.md +425 -0
  37. data/spec/fixtures/crlf-bsd/LICENSE.md +27 -0
  38. data/spec/fixtures/detect.json +16 -22
  39. data/spec/fixtures/eupl-cal2017/LICENSE.txt +274 -0
  40. data/spec/fixtures/fixtures.yml +68 -20
  41. data/spec/fixtures/license-hashes.json +39 -37
  42. data/spec/fixtures/markdown-artistic/LICENSE.md +192 -0
  43. data/spec/fixtures/multiple-arrs/LICENSE +30 -0
  44. data/spec/fixtures/pixar-modified-apache/LICENSE.txt +174 -0
  45. data/spec/fixtures/readme-invalid-encoding/README.md +24 -0
  46. data/spec/fixtures/vim/LICENSE +78 -0
  47. data/spec/integration_spec.rb +104 -9
  48. data/spec/licensee/commands/detect_spec.rb +2 -2
  49. data/spec/licensee/content_helper_spec.rb +17 -21
  50. data/spec/licensee/hash_helper_spec.rb +22 -22
  51. data/spec/licensee/license_meta_spec.rb +5 -11
  52. data/spec/licensee/license_spec.rb +14 -10
  53. data/spec/licensee/matchers/dice_matcher_spec.rb +4 -11
  54. data/spec/licensee/matchers/matcher_spec.rb +6 -6
  55. data/spec/licensee/matchers/npm_bower_matcher_spec.rb +9 -0
  56. data/spec/licensee/matchers/nu_get_matcher_spec.rb +91 -0
  57. data/spec/licensee/project_files/license_file_spec.rb +35 -28
  58. data/spec/licensee/project_files/package_info_spec.rb +8 -0
  59. data/spec/licensee/project_spec.rb +1 -3
  60. data/spec/licensee/rule_spec.rb +1 -1
  61. data/spec/licensee_spec.rb +1 -1
  62. data/spec/spec_helper.rb +3 -3
  63. data/spec/vendored_license_spec.rb +2 -2
  64. data/vendor/choosealicense.com/_data/meta.yml +1 -1
  65. data/vendor/choosealicense.com/_data/rules.yml +13 -13
  66. data/vendor/choosealicense.com/_licenses/0bsd.txt +3 -3
  67. data/vendor/choosealicense.com/_licenses/apache-2.0.txt +4 -4
  68. data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +1 -1
  69. data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +3 -3
  70. data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +3 -3
  71. data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +3 -3
  72. data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +4 -3
  73. data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +16 -16
  74. data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +16 -16
  75. data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +4 -4
  76. data/vendor/choosealicense.com/_licenses/cecill-2.1.txt +6 -6
  77. data/vendor/choosealicense.com/_licenses/ecl-2.0.txt +4 -4
  78. data/vendor/choosealicense.com/_licenses/epl-1.0.txt +3 -3
  79. data/vendor/choosealicense.com/_licenses/epl-2.0.txt +5 -5
  80. data/vendor/choosealicense.com/_licenses/eupl-1.2.txt +77 -60
  81. data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +3 -3
  82. data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +4 -4
  83. data/vendor/choosealicense.com/_licenses/isc.txt +3 -3
  84. data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +0 -1
  85. data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +1 -1
  86. data/vendor/choosealicense.com/_licenses/mit-0.txt +45 -0
  87. data/vendor/choosealicense.com/_licenses/mit.txt +3 -3
  88. data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +3 -3
  89. data/vendor/choosealicense.com/_licenses/ncsa.txt +24 -24
  90. data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +3 -3
  91. data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +4 -4
  92. data/vendor/choosealicense.com/_licenses/osl-3.0.txt +3 -3
  93. data/vendor/choosealicense.com/_licenses/postgresql.txt +5 -5
  94. data/vendor/choosealicense.com/_licenses/unlicense.txt +3 -3
  95. data/vendor/choosealicense.com/_licenses/upl-1.0.txt +4 -4
  96. data/vendor/choosealicense.com/_licenses/vim.txt +111 -0
  97. data/vendor/choosealicense.com/_licenses/zlib.txt +3 -3
  98. data/vendor/license-list-XML/src/0BSD.xml +21 -0
  99. data/vendor/license-list-XML/src/AFL-3.0.xml +212 -0
  100. data/vendor/license-list-XML/src/AGPL-3.0.xml +852 -0
  101. data/vendor/license-list-XML/src/Apache-2.0.xml +223 -0
  102. data/vendor/license-list-XML/src/Artistic-2.0.xml +238 -0
  103. data/vendor/license-list-XML/src/BSD-2-Clause.xml +42 -0
  104. data/vendor/license-list-XML/src/BSD-3-Clause-Clear.xml +59 -0
  105. data/vendor/license-list-XML/src/BSD-3-Clause.xml +46 -0
  106. data/vendor/license-list-XML/src/BSD-4-Clause.xml +59 -0
  107. data/vendor/license-list-XML/src/BSL-1.0.xml +30 -0
  108. data/vendor/license-list-XML/src/CC-BY-4.0.xml +444 -0
  109. data/vendor/license-list-XML/src/CC-BY-SA-4.0.xml +475 -0
  110. data/vendor/license-list-XML/src/CC0-1.0.xml +153 -0
  111. data/vendor/license-list-XML/src/CECILL-2.1.xml +669 -0
  112. data/vendor/license-list-XML/src/ECL-2.0.xml +242 -0
  113. data/vendor/license-list-XML/src/EPL-1.0.xml +255 -0
  114. data/vendor/license-list-XML/src/EPL-2.0.xml +639 -0
  115. data/vendor/license-list-XML/src/EUPL-1.1.xml +337 -0
  116. data/vendor/license-list-XML/src/EUPL-1.2.xml +502 -0
  117. data/vendor/license-list-XML/src/GPL-2.0.xml +474 -0
  118. data/vendor/license-list-XML/src/GPL-3.0.xml +858 -0
  119. data/vendor/license-list-XML/src/ISC.xml +29 -0
  120. data/vendor/license-list-XML/src/LGPL-2.1.xml +662 -0
  121. data/vendor/license-list-XML/src/LGPL-3.0.xml +260 -0
  122. data/vendor/license-list-XML/src/LPPL-1.3c.xml +380 -0
  123. data/vendor/license-list-XML/src/MIT-0.xml +40 -0
  124. data/vendor/license-list-XML/src/MIT.xml +32 -0
  125. data/vendor/license-list-XML/src/MPL-2.0.xml +438 -0
  126. data/vendor/license-list-XML/src/MS-PL.xml +89 -0
  127. data/vendor/license-list-XML/src/MS-RL.xml +97 -0
  128. data/vendor/license-list-XML/src/NCSA.xml +60 -0
  129. data/vendor/license-list-XML/src/ODbL-1.0.xml +660 -0
  130. data/vendor/license-list-XML/src/OFL-1.1.xml +94 -0
  131. data/vendor/license-list-XML/src/OSL-3.0.xml +209 -0
  132. data/vendor/license-list-XML/src/PostgreSQL.xml +32 -0
  133. data/vendor/license-list-XML/src/UPL-1.0.xml +46 -0
  134. data/vendor/license-list-XML/src/Unlicense.xml +27 -0
  135. data/vendor/license-list-XML/src/Vim.xml +124 -0
  136. data/vendor/license-list-XML/src/WTFPL.xml +30 -0
  137. data/vendor/license-list-XML/src/Zlib.xml +38 -0
  138. metadata +97 -29
@@ -0,0 +1,24 @@
1
+ # Readme fixture
2
+
3
+ ## License
4
+
5
+ Copyright (c) 2016 Ben Balter
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+ ��
@@ -0,0 +1,78 @@
1
+ VIM LICENSE
2
+
3
+ I) There are no restrictions on distributing unmodified copies of Vim except
4
+ that they must include this license text. You can also distribute
5
+ unmodified parts of Vim, likewise unrestricted except that they must
6
+ include this license text. You are also allowed to include executables
7
+ that you made from the unmodified Vim sources, plus your own usage
8
+ examples and Vim scripts.
9
+
10
+ II) It is allowed to distribute a modified (or extended) version of Vim,
11
+ including executables and/or source code, when the following four
12
+ conditions are met:
13
+ 1) This license text must be included unmodified.
14
+ 2) The modified Vim must be distributed in one of the following five ways:
15
+ a) If you make changes to Vim yourself, you must clearly describe in
16
+ the distribution how to contact you. When the maintainer asks you
17
+ (in any way) for a copy of the modified Vim you distributed, you
18
+ must make your changes, including source code, available to the
19
+ maintainer without fee. The maintainer reserves the right to
20
+ include your changes in the official version of Vim. What the
21
+ maintainer will do with your changes and under what license they
22
+ will be distributed is negotiable. If there has been no negotiation
23
+ then this license, or a later version, also applies to your changes.
24
+ The current maintainer is Bram Moolenaar <Bram@vim.org>. If this
25
+ changes it will be announced in appropriate places (most likely
26
+ vim.sf.net, www.vim.org and/or comp.editors). When it is completely
27
+ impossible to contact the maintainer, the obligation to send him
28
+ your changes ceases. Once the maintainer has confirmed that he has
29
+ received your changes they will not have to be sent again.
30
+ b) If you have received a modified Vim that was distributed as
31
+ mentioned under a) you are allowed to further distribute it
32
+ unmodified, as mentioned at I). If you make additional changes the
33
+ text under a) applies to those changes.
34
+ c) Provide all the changes, including source code, with every copy of
35
+ the modified Vim you distribute. This may be done in the form of a
36
+ context diff. You can choose what license to use for new code you
37
+ add. The changes and their license must not restrict others from
38
+ making their own changes to the official version of Vim.
39
+ d) When you have a modified Vim which includes changes as mentioned
40
+ under c), you can distribute it without the source code for the
41
+ changes if the following three conditions are met:
42
+ - The license that applies to the changes permits you to distribute
43
+ the changes to the Vim maintainer without fee or restriction, and
44
+ permits the Vim maintainer to include the changes in the official
45
+ version of Vim without fee or restriction.
46
+ - You keep the changes for at least three years after last
47
+ distributing the corresponding modified Vim. When the maintainer
48
+ or someone who you distributed the modified Vim to asks you (in
49
+ any way) for the changes within this period, you must make them
50
+ available to him.
51
+ - You clearly describe in the distribution how to contact you. This
52
+ contact information must remain valid for at least three years
53
+ after last distributing the corresponding modified Vim, or as long
54
+ as possible.
55
+ e) When the GNU General Public License (GPL) applies to the changes,
56
+ you can distribute the modified Vim under the GNU GPL version 2 or
57
+ any later version.
58
+ 3) A message must be added, at least in the output of the ":version"
59
+ command and in the intro screen, such that the user of the modified Vim
60
+ is able to see that it was modified. When distributing as mentioned
61
+ under 2)e) adding the message is only required for as far as this does
62
+ not conflict with the license used for the changes.
63
+ 4) The contact information as required under 2)a) and 2)d) must not be
64
+ removed or changed, except that the person himself can make
65
+ corrections.
66
+
67
+ III) If you distribute a modified version of Vim, you are encouraged to use
68
+ the Vim license for your changes and make them available to the
69
+ maintainer, including the source code. The preferred way to do this is
70
+ by e-mail or by uploading the files to a server and e-mailing the URL.
71
+ If the number of changes is small (e.g., a modified Makefile) e-mailing a
72
+ context diff will do. The e-mail address to be used is
73
+ <maintainer@vim.org>
74
+
75
+ IV) It is not allowed to remove this license from the distribution of the Vim
76
+ sources, parts of it or from a modified version. You may use this
77
+ license for previous Vim releases instead of the license that they came
78
+ with, at your option.
@@ -6,7 +6,7 @@ RSpec.describe 'integration test' do
6
6
  Licensee::Projects::GitProject
7
7
  ].each do |project_type|
8
8
  context "with a #{project_type} project" do
9
- subject { project_type.new(project_path, arguments) }
9
+ subject { project_type.new(project_path, **arguments) }
10
10
 
11
11
  let(:filename) { 'LICENSE' }
12
12
  let(:license) { Licensee::License.find('mit') }
@@ -40,9 +40,7 @@ RSpec.describe 'integration test' do
40
40
 
41
41
  before do
42
42
  File.write(file_path, 'bar')
43
- if project_type == Licensee::Projects::GitProject
44
- git_init(project_path)
45
- end
43
+ git_init(project_path) if project_type == Licensee::Projects::GitProject
46
44
  end
47
45
 
48
46
  after { FileUtils.rm_rf(project_path) }
@@ -74,6 +72,15 @@ RSpec.describe 'integration test' do
74
72
  end
75
73
  end
76
74
 
75
+ context 'with multiple all rights reserved lines' do
76
+ let(:license) { Licensee::License.find('bsd-3-clause') }
77
+ let(:fixture) { 'multiple-arrs' }
78
+
79
+ it 'matches other' do
80
+ expect(subject.license).to eql(license)
81
+ end
82
+ end
83
+
77
84
  context 'with CC-BY-NC-SA' do
78
85
  let(:fixture) { 'cc-by-nc-sa' }
79
86
 
@@ -98,6 +105,14 @@ RSpec.describe 'integration test' do
98
105
  end
99
106
  end
100
107
 
108
+ context 'with Pixar Modified Apache 2.0' do
109
+ let(:fixture) { 'pixar-modified-apache' }
110
+
111
+ it 'matches other' do
112
+ expect(subject.license).to eql(other_license)
113
+ end
114
+ end
115
+
101
116
  context 'with FCPL Modified MPL' do
102
117
  let(:fixture) { 'fcpl-modified-mpl' }
103
118
 
@@ -143,6 +158,15 @@ RSpec.describe 'integration test' do
143
158
  end
144
159
  end
145
160
 
161
+ context 'A BSD license with CRLF line-endings' do
162
+ let(:license) { Licensee::License.find('bsd-3-clause') }
163
+ let(:fixture) { 'crlf-bsd' }
164
+
165
+ it 'matches' do
166
+ expect(subject.license).to eql(license)
167
+ end
168
+ end
169
+
146
170
  context 'BSD + PATENTS' do
147
171
  let(:license) { Licensee::License.find('other') }
148
172
  let(:fixture) { 'bsd-plus-patents' }
@@ -179,6 +203,15 @@ RSpec.describe 'integration test' do
179
203
  end
180
204
  end
181
205
 
206
+ context 'EUPL as published on choosealicense.com 2017-2019' do
207
+ let(:license) { Licensee::License.find('eupl-1.2') }
208
+ let(:fixture) { 'eupl-cal2017' }
209
+
210
+ it 'returns eupl-1.2' do
211
+ expect(subject.license).to eql(license)
212
+ end
213
+ end
214
+
182
215
  context 'Unlicense without optional line' do
183
216
  let(:license) { Licensee::License.find('unlicense') }
184
217
  let(:fixture) { 'unlicense-noinfo' }
@@ -226,6 +259,15 @@ RSpec.describe 'integration test' do
226
259
  end
227
260
  end
228
261
 
262
+ context 'Artistic with Markdown formatting' do
263
+ let(:license) { Licensee::License.find('artistic-2.0') }
264
+ let(:fixture) { 'markdown-artistic' }
265
+
266
+ it 'matches to Artistic' do
267
+ expect(subject.license).to eql(license)
268
+ end
269
+ end
270
+
229
271
  context 'BSD-3-Clause numbered and bulleted' do
230
272
  let(:license) { Licensee::License.find('bsd-3-clause') }
231
273
  let(:fixture) { 'bsd-3-lists' }
@@ -235,6 +277,24 @@ RSpec.describe 'integration test' do
235
277
  end
236
278
  end
237
279
 
280
+ context 'BSD-3-Clause no-endorsement name with slashes' do
281
+ let(:license) { Licensee::License.find('bsd-3-clause') }
282
+ let(:fixture) { 'bsd-3-noendorseslash' }
283
+
284
+ it 'determines the project is BSD-3-Clause' do
285
+ expect(subject.license).to eql(license)
286
+ end
287
+ end
288
+
289
+ context 'BSD-3-Clause author/owner variant' do
290
+ let(:license) { Licensee::License.find('bsd-3-clause') }
291
+ let(:fixture) { 'bsd-3-authorowner' }
292
+
293
+ it 'determines the project is BSD-3-Clause' do
294
+ expect(subject.license).to eql(license)
295
+ end
296
+ end
297
+
238
298
  context 'HTML license file' do
239
299
  let(:license) { Licensee::License.find('epl-1.0') }
240
300
  let(:fixture) { 'html' }
@@ -243,6 +303,42 @@ RSpec.describe 'integration test' do
243
303
  expect(subject.license).to eql(license)
244
304
  end
245
305
  end
306
+
307
+ context 'Vim license file' do
308
+ let(:license) { Licensee::License.find('vim') }
309
+ let(:fixture) { 'vim' }
310
+
311
+ it 'matches to Vim' do
312
+ expect(subject.license).to eql(license)
313
+ end
314
+ end
315
+
316
+ context 'CC-BY-SA no CC licensor statement license file' do
317
+ let(:license) { Licensee::License.find('cc-by-sa-4.0') }
318
+ let(:fixture) { 'cc-by-sa-nocclicensor' }
319
+
320
+ it 'matches to CC-BY-SA' do
321
+ expect(subject.license).to eql(license)
322
+ end
323
+ end
324
+
325
+ context 'CC-BY-SA markdown links file' do
326
+ let(:license) { Licensee::License.find('cc-by-sa-4.0') }
327
+ let(:fixture) { 'cc-by-sa-mdlinks' }
328
+
329
+ it 'matches to CC-BY-SA' do
330
+ expect(subject.license).to eql(license)
331
+ end
332
+ end
333
+
334
+ context 'MIT with byte order mark' do
335
+ let(:license) { Licensee::License.find('mit') }
336
+ let(:fixture) { 'bom' }
337
+
338
+ it 'matches to MIT' do
339
+ expect(subject.license).to eql(license)
340
+ end
341
+ end
246
342
  end
247
343
 
248
344
  context 'with the license file stubbed' do
@@ -250,17 +346,16 @@ RSpec.describe 'integration test' do
250
346
 
251
347
  before do
252
348
  File.write(license_path, content)
253
- if project_type == Licensee::Projects::GitProject
254
- git_init(project_path)
255
- end
349
+ git_init(project_path) if project_type == Licensee::Projects::GitProject
256
350
  end
257
351
 
258
352
  after { FileUtils.rm_rf(project_path) }
259
353
 
260
- [
354
+ filenames = [
261
355
  'LICENSE.md', 'LICENSE.txt', 'LICENSE.md', 'LiCeNSe.Txt',
262
356
  'LICENSE-MIT', 'MIT-LICENSE', 'licence', 'unlicense'
263
- ].each do |filename|
357
+ ]
358
+ filenames.each do |filename|
264
359
  context "with a #{filename} file" do
265
360
  let(:filename) { filename }
266
361
 
@@ -19,7 +19,7 @@ RSpec.describe 'detect command' do
19
19
  'Matched files' => 'LICENSE.md, licensee.gemspec',
20
20
  'LICENSE.md' => {
21
21
  'Content hash' => hash,
22
- 'Attribution' => 'Copyright (c) 2014-2017 Ben Balter',
22
+ 'Attribution' => 'Copyright (c) 2014-2021 Ben Balter and Licensee contributors',
23
23
  'Confidence' => '100.00%',
24
24
  'Matcher' => 'Licensee::Matchers::Exact',
25
25
  'License' => 'MIT'
@@ -70,7 +70,7 @@ RSpec.describe 'detect command' do
70
70
  end
71
71
 
72
72
  it 'returns the expected output' do
73
- msg = '`licensee detect --json` output did not match expectations. '.dup
73
+ msg = +'`licensee detect --json` output did not match expectations. '
74
74
  msg << 'Run `script/dump-detect-json-fixture` and verify the output.'
75
75
  expect(JSON.parse(stdout)).to eql(expected), msg
76
76
  end
@@ -12,10 +12,14 @@ class ContentHelperTestHelper
12
12
  def filename
13
13
  @data[:filename]
14
14
  end
15
+
16
+ def spdx_id
17
+ @data[:spdx_id]
18
+ end
15
19
  end
16
20
 
17
21
  RSpec.describe Licensee::ContentHelper do
18
- subject { ContentHelperTestHelper.new(content, filename: filename) }
22
+ subject { ContentHelperTestHelper.new(content, filename: filename, spdx_id: spdx_id) }
19
23
 
20
24
  let(:content) do
21
25
  <<-LICENSE.gsub(/^\s*/, '')
@@ -37,6 +41,7 @@ RSpec.describe Licensee::ContentHelper do
37
41
  LICENSE
38
42
  end
39
43
  let(:filename) { 'license.md' }
44
+ let(:spdx_id) { 'MIT' }
40
45
 
41
46
  let(:mit) { Licensee::License.find('mit') }
42
47
  let(:normalized_content) { subject.content_normalized }
@@ -44,7 +49,7 @@ RSpec.describe Licensee::ContentHelper do
44
49
  it 'creates the wordset' do
45
50
  wordset = Set.new(
46
51
  %w[
47
- the made up license this provided as is please respect
52
+ the made up license this provided as is' please respect
48
53
  contributors' wishes when implementing license's software
49
54
  ]
50
55
  )
@@ -55,26 +60,18 @@ RSpec.describe Licensee::ContentHelper do
55
60
  expect(subject.length).to be(135)
56
61
  end
57
62
 
58
- context 'a very long license' do
59
- let(:content) { 'license' * 1000 }
60
-
61
- it 'returns the max delta' do
62
- expect(subject.max_delta).to be(140)
63
- end
64
- end
65
-
66
63
  it 'knows the length delta' do
67
64
  expect(subject.length_delta(mit)).to be(885)
68
65
  expect(subject.length_delta(subject)).to be(0)
69
66
  end
70
67
 
71
68
  it 'knows the similarity' do
72
- expect(subject.similarity(mit)).to be_within(1).of(11)
73
- expect(subject.similarity(subject)).to be(100.0)
69
+ expect(mit.similarity(subject)).to be_within(1).of(4)
70
+ expect(mit.similarity(mit)).to be(100.0)
74
71
  end
75
72
 
76
73
  it 'calculates the hash' do
77
- content_hash = '916b978940ecf8070c96bd3aca9321768e7f4901'
74
+ content_hash = '9b4bed43726cf39e17b11c2942f37be232f5709a'
78
75
  expect(subject.content_hash).to eql(content_hash)
79
76
  end
80
77
 
@@ -101,7 +98,10 @@ RSpec.describe Licensee::ContentHelper do
101
98
  borders: '* Foo *',
102
99
  title: "The MIT License\nfoo",
103
100
  copyright: "The MIT License\nCopyright 2018 Ben Balter\nFoo",
101
+ copyright_bullet: "The MIT License\n* Copyright 2018 Ben Balter\nFoo",
102
+ copyright_italic: "The MIT License\n_Copyright 2018 Ben Balter_\nFoo",
104
103
  end_of_terms: "Foo\nend of terms and conditions\nbar",
104
+ end_of_terms_hashes: "Foo\n# end of terms and conditions ####\nbar",
105
105
  block_markup: '> Foo',
106
106
  link_markup: '[Foo](http://exmaple.com)',
107
107
  comment_markup: "/*\n* The MIT License\n* Foo\n*/",
@@ -174,7 +174,7 @@ RSpec.describe Licensee::ContentHelper do
174
174
  end
175
175
 
176
176
  it 'normalizes quotes' do
177
- expect(normalized_content).not_to match("'as is'")
177
+ expect(normalized_content).not_to match('"as is"')
178
178
  end
179
179
 
180
180
  it 'preserves possessives' do
@@ -182,18 +182,14 @@ RSpec.describe Licensee::ContentHelper do
182
182
  expect(normalized_content).to match("license's")
183
183
  end
184
184
 
185
- it 'preserves double quotes' do
186
- expect(normalized_content).to match('"software"')
187
- end
188
-
189
185
  it 'strips the title' do
190
186
  expect(normalized_content).not_to match('MIT')
191
187
  end
192
188
 
193
189
  it 'normalize the content' do
194
- expected = 'the made up license. this license provided "as is". '.dup
190
+ expected = +"the made up license. this license provided 'as is'. "
195
191
  expected << "please respect the contributors' wishes when implementing "
196
- expected << "the license's \"software\"."
192
+ expected << "the license's 'software'."
197
193
  expect(normalized_content).to eql(expected)
198
194
  end
199
195
  end
@@ -235,7 +231,7 @@ RSpec.describe Licensee::ContentHelper do
235
231
  let(:content) { "`a` 'b' \"c\" ‘d’ “e”" }
236
232
 
237
233
  it 'normalizes quotes' do
238
- expect(subject.content_normalized).to eql('"a" "b" "c" "d" "e"')
234
+ expect(subject.content_normalized).to eql("'a' 'b' 'c' 'd' 'e'")
239
235
  end
240
236
  end
241
237
 
@@ -1,35 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Licensee::HashHelper do
4
- class HashHelperSpecFixture
5
- include Licensee::HashHelper
6
- HASH_METHODS = %w[string array rule rules nil_value].freeze
3
+ class HashHelperSpecFixture
4
+ include Licensee::HashHelper
5
+ HASH_METHODS = %w[string array rule rules nil_value].freeze
7
6
 
8
- def string
9
- 'foo'
10
- end
7
+ def string
8
+ 'foo'
9
+ end
11
10
 
12
- def array
13
- [1, 2, 3]
14
- end
11
+ def array
12
+ [1, 2, 3]
13
+ end
15
14
 
16
- def rule
17
- rules.first
18
- end
15
+ def rule
16
+ rules.first
17
+ end
19
18
 
20
- def rules
21
- Licensee::Rule.all
22
- end
19
+ def rules
20
+ Licensee::Rule.all
21
+ end
23
22
 
24
- def baz
25
- 'baz'
26
- end
23
+ def baz
24
+ 'baz'
25
+ end
27
26
 
28
- def nil_value
29
- nil
30
- end
27
+ def nil_value
28
+ nil
31
29
  end
30
+ end
32
31
 
32
+ RSpec.describe Licensee::HashHelper do
33
33
  let(:fixture) { HashHelperSpecFixture.new }
34
34
  let(:hash) { fixture.to_h }
35
35
  let(:expected) do