licensee 9.12.0 → 9.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/bin/licensee +3 -3
  3. data/lib/licensee/commands/detect.rb +5 -5
  4. data/lib/licensee/content_helper.rb +53 -8
  5. data/lib/licensee/hash_helper.rb +5 -5
  6. data/lib/licensee/license.rb +16 -20
  7. data/lib/licensee/matchers/dice.rb +3 -3
  8. data/lib/licensee/projects/git_project.rb +3 -3
  9. data/lib/licensee/projects/project.rb +3 -3
  10. data/lib/licensee/version.rb +1 -1
  11. data/licensee.gemspec +47 -0
  12. data/spec/bin_spec.rb +1 -1
  13. data/spec/fixture_spec.rb +5 -5
  14. data/spec/fixtures/cc0-cal2013/LICENSE +116 -0
  15. data/spec/fixtures/cc0-cc/LICENSE +121 -0
  16. data/spec/fixtures/detect.json +1 -1
  17. data/spec/fixtures/fixtures.yml +12 -0
  18. data/spec/fixtures/license-hashes.json +5 -4
  19. data/spec/fixtures/unlicense-noinfo/LICENSE +22 -0
  20. data/spec/integration_spec.rb +30 -2
  21. data/spec/licensee/commands/detect_spec.rb +4 -4
  22. data/spec/licensee/commands/license_path_spec.rb +1 -1
  23. data/spec/licensee/commands/version_spec.rb +1 -1
  24. data/spec/licensee/content_helper_spec.rb +43 -42
  25. data/spec/licensee/hash_helper_spec.rb +1 -1
  26. data/spec/licensee/license_field_spec.rb +3 -3
  27. data/spec/licensee/license_meta_spec.rb +13 -11
  28. data/spec/licensee/license_rules_spec.rb +4 -2
  29. data/spec/licensee/license_spec.rb +33 -33
  30. data/spec/licensee/matchers/cabal_matcher_spec.rb +4 -2
  31. data/spec/licensee/matchers/cargo_matcher_spec.rb +3 -2
  32. data/spec/licensee/matchers/copyright_matcher_spec.rb +3 -3
  33. data/spec/licensee/matchers/cran_matcher_spec.rb +3 -2
  34. data/spec/licensee/matchers/dice_matcher_spec.rb +11 -10
  35. data/spec/licensee/matchers/dist_zilla_matcher_spec.rb +3 -2
  36. data/spec/licensee/matchers/exact_matcher_spec.rb +3 -2
  37. data/spec/licensee/matchers/gemspec_matcher_spec.rb +3 -2
  38. data/spec/licensee/matchers/matcher_spec.rb +4 -2
  39. data/spec/licensee/matchers/npm_bower_matcher_spec.rb +3 -3
  40. data/spec/licensee/matchers/package_matcher_spec.rb +4 -2
  41. data/spec/licensee/matchers/reference_matcher_spec.rb +2 -2
  42. data/spec/licensee/matchers/spdx_matcher_spec.rb +3 -2
  43. data/spec/licensee/project_files/license_file_spec.rb +15 -15
  44. data/spec/licensee/project_files/package_info_spec.rb +3 -1
  45. data/spec/licensee/project_files/project_file_spec.rb +5 -2
  46. data/spec/licensee/project_files/readme_file_spec.rb +2 -1
  47. data/spec/licensee/project_spec.rb +22 -17
  48. data/spec/licensee/projects/github_project_spec.rb +6 -5
  49. data/spec/licensee/rule_spec.rb +4 -3
  50. data/spec/licensee_spec.rb +10 -9
  51. data/spec/spec_helper.rb +2 -2
  52. data/spec/vendored_license_spec.rb +3 -3
  53. data/vendor/choosealicense.com/_data/rules.yml +3 -0
  54. data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +1 -0
  55. data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +61 -0
  56. data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +4 -1
  57. data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +3 -0
  58. data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +3 -0
  59. data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +112 -103
  60. data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +3 -0
  61. data/vendor/choosealicense.com/_licenses/zlib.txt +4 -1
  62. metadata +37 -4
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -99,7 +99,7 @@
99
99
  },
100
100
  {
101
101
  "filename": "licensee.gemspec",
102
- "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', '~> 4.8')\n gem.add_dependency('reverse_markdown', '~> 1.0')\n gem.add_dependency('rugged', '~> 0.24')\n gem.add_dependency('thor', '~> 0.19')\n\n gem.add_development_dependency('mustache', '>= 0.9', '< 2.0')\n gem.add_development_dependency('pry', '~> 0.9')\n gem.add_development_dependency('rake', '~> 10.3')\n gem.add_development_dependency('rspec', '~> 3.5')\n gem.add_development_dependency('rubocop', '~> 0.69')\n gem.add_development_dependency('simplecov', '~> 0.16')\n gem.add_development_dependency('webmock', '~> 3.1')\n\n gem.required_ruby_version = '> 2.3'\n\n # ensure the gem is built out of versioned files\n gem.files = Dir[\n 'Rakefile',\n '{bin,lib,man,test,vendor,spec}/**/*',\n 'README*', 'LICENSE*'\n ] & `git ls-files -z`.split(\"\\0\")\nend\n",
102
+ "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', '~> 4.8')\n gem.add_dependency('reverse_markdown', '~> 1.0')\n gem.add_dependency('rugged', '~> 0.24')\n gem.add_dependency('thor', '~> 0.19')\n\n gem.add_development_dependency('mustache', '>= 0.9', '< 2.0')\n gem.add_development_dependency('pry', '~> 0.9')\n gem.add_development_dependency('rake', '~> 10.3')\n gem.add_development_dependency('rspec', '~> 3.5')\n gem.add_development_dependency('rubocop', '~> 0.76')\n gem.add_development_dependency('rubocop-performance', '~> 1.5')\n gem.add_development_dependency('rubocop-rspec', '~> 1.36')\n gem.add_development_dependency('simplecov', '~> 0.16')\n gem.add_development_dependency('webmock', '~> 3.1')\n\n gem.required_ruby_version = '> 2.3'\n\n # ensure the gem is built out of versioned files\n gem.files = Dir[\n 'Rakefile',\n '{bin,lib,man,test,vendor,spec}/**/*',\n 'README*', 'LICENSE*'\n ] & `git ls-files -z`.split(\"\\0\")\nend\n",
103
103
  "content_hash": null,
104
104
  "content_normalized": null,
105
105
  "matcher": {
@@ -28,6 +28,14 @@ cc-by-nd:
28
28
  key: other
29
29
  matcher:
30
30
  hash: a75ef554ca6941d195bbc1197f934d43a75b312d
31
+ cc0-cal2013:
32
+ key: cc0-1.0
33
+ matcher: dice
34
+ hash: 2aa555363d0d2ce0a924940fab198c38dd3ff30b
35
+ cc0-cc:
36
+ key: cc0-1.0
37
+ matcher: exact
38
+ hash: c07f7fdd02072b9b9ddafb29c7fe556ed4d31f6a
31
39
  copyright-encoding:
32
40
  key: no-license
33
41
  matcher: copyright
@@ -100,6 +108,10 @@ readme:
100
108
  key: mit
101
109
  matcher:
102
110
  hash:
111
+ unlicense-noinfo:
112
+ key: unlicense
113
+ matcher: exact
114
+ hash: 853b375edc61b9e823da0fa5fead97c9460c3e45
103
115
  webmock:
104
116
  key:
105
117
  matcher:
@@ -7,12 +7,13 @@
7
7
  "bsd-2-clause": "59f0099ff04225daf184db3fe55e478256133b1a",
8
8
  "bsd-3-clause": "fa22c672927af9c7334874561198799cbf4bdf31",
9
9
  "bsd-3-clause-clear": "251d4599b622d2a87b2c4bb21dfacd438c048466",
10
+ "bsd-4-clause": "c31a46c2b8764b63d73332c5e9e11f109dadee45",
10
11
  "bsl-1.0": "ca8f916d00c234719956e932061f192abb2d5bf9",
11
12
  "cc-by-4.0": "899872bc08626e6cf154dcf9e08ff0de82c9b3db",
12
13
  "cc-by-sa-4.0": "d11590d97684231d5358252e0cc97373d62ec4f1",
13
- "cc0-1.0": "ec5027313ed11fea202060f6958ac25b086d6dcb",
14
+ "cc0-1.0": "c07f7fdd02072b9b9ddafb29c7fe556ed4d31f6a",
14
15
  "cecill-2.1": "c996e4f8246fddc4fb083f72a70a85f36dffd288",
15
- "ecl-2.0": "58e7f645bfa1c5ccca7e2c37e626b3487e4d9d1b",
16
+ "ecl-2.0": "b24f240cd556a7764b9ace1bd763ad70c510d92a",
16
17
  "epl-1.0": "e306464a81ab0e6688653c6509245b451637172c",
17
18
  "epl-2.0": "b57663bc9c3f41446a8cd3f0050149221a58fe66",
18
19
  "eupl-1.1": "873e30dbc5f75d076d7aecb6ceb84fb6bb765452",
@@ -32,8 +33,8 @@
32
33
  "ofl-1.1": "1fb0563aa1250e18a6948afde286edc95761f461",
33
34
  "osl-3.0": "ab241ef932d3ac038e8ed62c860e9eba051ae7a0",
34
35
  "postgresql": "87550a6bb3409db00d8552b2ac07d373ea56a024",
35
- "unlicense": "86c75861af1b9b9e0573b190dcb2c2cdbbee7037",
36
- "upl-1.0": "554e63fea5b1220601b2d5030a8e1a3f80b59a75",
36
+ "unlicense": "853b375edc61b9e823da0fa5fead97c9460c3e45",
37
+ "upl-1.0": "af9efb6f7b29f8c2d486ccb28223db0aa8372c29",
37
38
  "wtfpl": "f8544c074f203d86cdcb24082fedfb2cf2fe411a",
38
39
  "zlib": "576139d1f785b8f3539099b9702fc68005ee2213"
39
40
  }
@@ -0,0 +1,22 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -6,6 +6,8 @@ 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) }
10
+
9
11
  let(:filename) { 'LICENSE' }
10
12
  let(:license) { Licensee::License.find('mit') }
11
13
  let(:other_license) { Licensee::License.find('other') }
@@ -13,8 +15,6 @@ RSpec.describe 'integration test' do
13
15
  let(:license_path) { File.expand_path(filename, project_path) }
14
16
  let(:arguments) { {} }
15
17
 
16
- subject { project_type.new(project_path, arguments) }
17
-
18
18
  context 'fixtures' do
19
19
  let(:fixture) { 'mit' }
20
20
  let(:project_path) { fixture_path(fixture) }
@@ -22,6 +22,7 @@ RSpec.describe 'integration test' do
22
22
 
23
23
  if project_type == Licensee::Projects::GitProject
24
24
  before { git_init(project_path) }
25
+
25
26
  after { FileUtils.rm_rf(git_path) }
26
27
  end
27
28
 
@@ -160,6 +161,33 @@ RSpec.describe 'integration test' do
160
161
  end
161
162
  end
162
163
 
164
+ context 'CC0 as published by CC' do
165
+ let(:license) { Licensee::License.find('cc0-1.0') }
166
+ let(:fixture) { 'cc0-cc' }
167
+
168
+ it 'returns cc0-1.0' do
169
+ expect(subject.license).to eql(license)
170
+ end
171
+ end
172
+
173
+ context 'CC0 as published on choosealicense.com 2013-2019' do
174
+ let(:license) { Licensee::License.find('cc0-1.0') }
175
+ let(:fixture) { 'cc0-cal2013' }
176
+
177
+ it 'returns cc0-1.0' do
178
+ expect(subject.license).to eql(license)
179
+ end
180
+ end
181
+
182
+ context 'Unlicense without optional line' do
183
+ let(:license) { Licensee::License.find('unlicense') }
184
+ let(:fixture) { 'unlicense-noinfo' }
185
+
186
+ it 'returns unlicense' do
187
+ expect(subject.license).to eql(license)
188
+ end
189
+ end
190
+
163
191
  context 'MIT w/optional phrase' do
164
192
  let(:license) { Licensee::License.find('mit') }
165
193
  let(:fixture) { 'mit-optional' }
@@ -41,7 +41,7 @@ RSpec.describe 'detect command' do
41
41
  let(:arguments) { args }
42
42
 
43
43
  it 'Returns a zero exit code' do
44
- expect(status.exitstatus).to eql(0)
44
+ expect(status.exitstatus).to be(0)
45
45
  end
46
46
 
47
47
  it 'returns the exected values' do
@@ -62,11 +62,11 @@ RSpec.describe 'detect command' do
62
62
  let(:expected) { JSON.parse fixture_contents('detect.json') }
63
63
 
64
64
  it 'Returns a zero exit code' do
65
- expect(status.exitstatus).to eql(0)
65
+ expect(status.exitstatus).to be(0)
66
66
  end
67
67
 
68
68
  it 'returns valid JSON' do
69
- expect { JSON.parse(stdout) }.to_not raise_error
69
+ expect { JSON.parse(stdout) }.not_to raise_error
70
70
  end
71
71
 
72
72
  it 'returns the expected output' do
@@ -80,7 +80,7 @@ RSpec.describe 'detect command' do
80
80
  let(:command) { ['bundle', 'exec', 'bin/licensee'] }
81
81
 
82
82
  it 'Returns a zero exit code' do
83
- expect(status.exitstatus).to eql(0)
83
+ expect(status.exitstatus).to be(0)
84
84
  end
85
85
 
86
86
  it 'returns the exected values' do
@@ -18,6 +18,6 @@ RSpec.describe 'license-path command' do
18
18
  end
19
19
 
20
20
  it 'Returns a zero exit code' do
21
- expect(status.exitstatus).to eql(0)
21
+ expect(status.exitstatus).to be(0)
22
22
  end
23
23
  end
@@ -18,6 +18,6 @@ RSpec.describe 'version command' do
18
18
  end
19
19
 
20
20
  it 'Returns a zero exit code' do
21
- expect(status.exitstatus).to eql(0)
21
+ expect(status.exitstatus).to be(0)
22
22
  end
23
23
  end
@@ -15,6 +15,8 @@ class ContentHelperTestHelper
15
15
  end
16
16
 
17
17
  RSpec.describe Licensee::ContentHelper do
18
+ subject { ContentHelperTestHelper.new(content, filename: filename) }
19
+
18
20
  let(:content) do
19
21
  <<-LICENSE.gsub(/^\s*/, '')
20
22
  # The MIT License
@@ -35,7 +37,7 @@ RSpec.describe Licensee::ContentHelper do
35
37
  LICENSE
36
38
  end
37
39
  let(:filename) { 'license.md' }
38
- subject { ContentHelperTestHelper.new(content, filename: filename) }
40
+
39
41
  let(:mit) { Licensee::License.find('mit') }
40
42
  let(:normalized_content) { subject.content_normalized }
41
43
 
@@ -50,25 +52,25 @@ RSpec.describe Licensee::ContentHelper do
50
52
  end
51
53
 
52
54
  it 'knows the length' do
53
- expect(subject.length).to eql(135)
55
+ expect(subject.length).to be(135)
54
56
  end
55
57
 
56
58
  context 'a very long license' do
57
59
  let(:content) { 'license' * 1000 }
58
60
 
59
61
  it 'returns the max delta' do
60
- expect(subject.max_delta).to eql(140)
62
+ expect(subject.max_delta).to be(140)
61
63
  end
62
64
  end
63
65
 
64
66
  it 'knows the length delta' do
65
- expect(subject.length_delta(mit)).to eql(885)
66
- expect(subject.length_delta(subject)).to eql(0)
67
+ expect(subject.length_delta(mit)).to be(885)
68
+ expect(subject.length_delta(subject)).to be(0)
67
69
  end
68
70
 
69
71
  it 'knows the similarity' do
70
72
  expect(subject.similarity(mit)).to be_within(1).of(11)
71
- expect(subject.similarity(subject)).to eql(100.0)
73
+ expect(subject.similarity(subject)).to be(100.0)
72
74
  end
73
75
 
74
76
  it 'calculates the hash' do
@@ -77,17 +79,17 @@ RSpec.describe Licensee::ContentHelper do
77
79
  end
78
80
 
79
81
  it 'wraps' do
80
- content = Licensee::ContentHelper.wrap(mit.content, 40)
82
+ content = described_class.wrap(mit.content, 40)
81
83
  lines = content.split("\n")
82
84
  expect(lines.first.length).to be <= 40
83
85
  end
84
86
 
85
87
  it 'formats percents' do
86
- percent = Licensee::ContentHelper.format_percent(12.3456789)
88
+ percent = described_class.format_percent(12.3456789)
87
89
  expect(percent).to eql('12.35%')
88
90
  end
89
91
 
90
- context '#strip' do
92
+ describe '#strip' do
91
93
  {
92
94
  version: "The MIT License\nVersion 1.0\nfoo",
93
95
  hrs: "The MIT License\n=====\n-----\n*******\nfoo",
@@ -102,7 +104,8 @@ RSpec.describe Licensee::ContentHelper do
102
104
  end_of_terms: "Foo\nend of terms and conditions\nbar",
103
105
  block_markup: '> Foo',
104
106
  link_markup: '[Foo](http://exmaple.com)',
105
- comment_markup: "/*\n* The MIT License\n* Foo\n*/"
107
+ comment_markup: "/*\n* The MIT License\n* Foo\n*/",
108
+ copyright_title: "Copyright 2019 Ben Balter\nMIT License\nFoo"
106
109
  }.each do |field, fixture|
107
110
  context "#strip_#{field}" do
108
111
  let(:content) { fixture }
@@ -133,45 +136,45 @@ RSpec.describe Licensee::ContentHelper do
133
136
 
134
137
  context 'integration fixture' do
135
138
  it 'strips copyright' do
136
- expect(normalized_content).to_not match 'Copyright'
137
- expect(normalized_content).to_not match 'Ben Balter'
139
+ expect(normalized_content).not_to match 'Copyright'
140
+ expect(normalized_content).not_to match 'Ben Balter'
138
141
  end
139
142
 
140
143
  it 'downcases' do
141
- expect(normalized_content).to_not match 'The'
144
+ expect(normalized_content).not_to match 'The'
142
145
  expect(normalized_content).to match 'the'
143
146
  end
144
147
 
145
148
  it 'strips HRs' do
146
- expect(normalized_content).to_not match '---'
147
- expect(normalized_content).to_not match '==='
148
- expect(normalized_content).to_not include '***'
149
- expect(normalized_content).to_not include '* *'
149
+ expect(normalized_content).not_to match '---'
150
+ expect(normalized_content).not_to match '==='
151
+ expect(normalized_content).not_to include '***'
152
+ expect(normalized_content).not_to include '* *'
150
153
  end
151
154
 
152
155
  it 'squeezes whitespace' do
153
- expect(normalized_content).to_not match ' '
156
+ expect(normalized_content).not_to match ' '
154
157
  end
155
158
 
156
159
  it 'strips whitespace' do
157
- expect(normalized_content).to_not match(/\n/)
158
- expect(normalized_content).to_not match(/\t/)
160
+ expect(normalized_content).not_to match(/\n/)
161
+ expect(normalized_content).not_to match(/\t/)
159
162
  end
160
163
 
161
164
  it 'strips markdown headings' do
162
- expect(normalized_content).to_not match('#')
165
+ expect(normalized_content).not_to match('#')
163
166
  end
164
167
 
165
168
  it 'strips all rights reserved' do
166
- expect(normalized_content).to_not match(/all rights reserved/i)
169
+ expect(normalized_content).not_to match(/all rights reserved/i)
167
170
  end
168
171
 
169
172
  it 'strips markup' do
170
- expect(normalized_content).to_not match(/[*=_-]+/)
173
+ expect(normalized_content).not_to match(/[*=_-]+/)
171
174
  end
172
175
 
173
176
  it 'normalizes quotes' do
174
- expect(normalized_content).to_not match("'as is'")
177
+ expect(normalized_content).not_to match("'as is'")
175
178
  end
176
179
 
177
180
  it 'preserves possessives' do
@@ -184,7 +187,7 @@ RSpec.describe Licensee::ContentHelper do
184
187
  end
185
188
 
186
189
  it 'strips the title' do
187
- expect(normalized_content).to_not match('MIT')
190
+ expect(normalized_content).not_to match('MIT')
188
191
  end
189
192
 
190
193
  it 'normalize the content' do
@@ -238,13 +241,13 @@ RSpec.describe Licensee::ContentHelper do
238
241
 
239
242
  it 'strips formatting from the MPL' do
240
243
  license = Licensee::License.find('mpl-2.0')
241
- expect(license.content_normalized).to_not include('* *')
244
+ expect(license.content_normalized).not_to include('* *')
242
245
  end
243
246
 
244
247
  it 'normalizes http: to https:' do
245
248
  license = Licensee::License.find('mpl-2.0')
246
249
  expect(license.content).to include('http:')
247
- expect(license.content_normalized).to_not include('http:')
250
+ expect(license.content_normalized).not_to include('http:')
248
251
  end
249
252
 
250
253
  it 'wraps' do
@@ -265,31 +268,29 @@ RSpec.describe Licensee::ContentHelper do
265
268
  let(:stripped_content) { subject.content_without_title_and_version }
266
269
 
267
270
  it 'strips the title' do
268
- skip "Doesn't strip ECL title" if license.key == 'ecl-2.0'
269
- regex = Licensee::License::ALT_TITLE_REGEX[license.key]
270
- regex ||= /\A#{license.name_without_version}/i
271
- expect(stripped_content).to_not match(regex)
272
- expect(license.content_normalized).to_not match(regex)
271
+ regex = /\A#{license.name_without_version}/i
272
+ expect(stripped_content).not_to match(regex)
273
+ expect(license.content_normalized).not_to match(regex)
273
274
  end
274
275
 
275
276
  it 'strips the version' do
276
- expect(license.content_normalized).to_not match(/\Aversion/i)
277
- expect(stripped_content).to_not match(/\Aversion/i)
277
+ expect(license.content_normalized).not_to match(/\Aversion/i)
278
+ expect(stripped_content).not_to match(/\Aversion/i)
278
279
  end
279
280
 
280
281
  it 'strips all rights reserved' do
281
282
  regex = /all rights reserved/i
282
- expect(license.content_normalized).to_not match(regex)
283
+ expect(license.content_normalized).not_to match(regex)
283
284
  end
284
285
 
285
286
  it 'strips the copyright' do
286
- expect(license.content_normalized).to_not match(/\Acopyright/i)
287
+ expect(license.content_normalized).not_to match(/\Acopyright/i)
287
288
  end
288
289
 
289
290
  it 'strips the implementation instructions' do
290
291
  end_terms_regex = /END OF TERMS AND CONDITIONS/i
291
- expect(license.content_normalized).to_not match(end_terms_regex)
292
- expect(license.content_normalized).to_not match(/How to apply/i)
292
+ expect(license.content_normalized).not_to match(end_terms_regex)
293
+ expect(license.content_normalized).not_to match(/How to apply/i)
293
294
  end
294
295
  end
295
296
  end
@@ -298,7 +299,7 @@ RSpec.describe Licensee::ContentHelper do
298
299
  let(:content) { "(The MIT License)\n\nfoo" }
299
300
 
300
301
  it 'strips the title' do
301
- expect(normalized_content).to_not match('MIT')
302
+ expect(normalized_content).not_to match('MIT')
302
303
  expect(normalized_content).to eql('foo')
303
304
  end
304
305
  end
@@ -307,7 +308,7 @@ RSpec.describe Licensee::ContentHelper do
307
308
  let(:content) { "Copyright 2016 Ben Balter\nCopyright 2017 Bob\nFoo" }
308
309
 
309
310
  it 'strips multiple copyrights' do
310
- expect(normalized_content).to_not match('Ben')
311
+ expect(normalized_content).not_to match('Ben')
311
312
  expect(normalized_content).to eql('foo')
312
313
  end
313
314
  end
@@ -361,7 +362,7 @@ RSpec.describe Licensee::ContentHelper do
361
362
  let(:text) { 'gpl-3 0' }
362
363
 
363
364
  it 'escapes' do
364
- expect(text).to_not match(described_class.title_regex)
365
+ expect(text).not_to match(described_class.title_regex)
365
366
  end
366
367
  end
367
368
 
@@ -371,7 +372,7 @@ RSpec.describe Licensee::ContentHelper do
371
372
  end
372
373
 
373
374
  it 'matches' do
374
- expect(text).to_not match(described_class.title_regex)
375
+ expect(text).not_to match(described_class.title_regex)
375
376
  end
376
377
  end
377
378
  end