gitlab-license_finder 6.14.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/.force-build +0 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +70 -0
  6. data/CHANGELOG.md +981 -0
  7. data/CONTRIBUTING.md +121 -0
  8. data/Dockerfile +249 -0
  9. data/Gemfile +2 -0
  10. data/LICENSE +22 -0
  11. data/README.md +555 -0
  12. data/Rakefile +77 -0
  13. data/TODO.md +12 -0
  14. data/VERSION +1 -0
  15. data/appveyor.yml +21 -0
  16. data/bin/license_finder +6 -0
  17. data/bin/license_finder_pip.py +43 -0
  18. data/ci/pipelines/pull-request.yml.erb +141 -0
  19. data/ci/pipelines/release.yml.erb +200 -0
  20. data/ci/scripts/containerize-tests.sh +14 -0
  21. data/ci/scripts/pushscript.sh +32 -0
  22. data/ci/scripts/run-rubocop.sh +15 -0
  23. data/ci/scripts/run-tests.sh +24 -0
  24. data/ci/scripts/test.ps1 +81 -0
  25. data/ci/scripts/updateChangelog.sh +84 -0
  26. data/ci/tasks/build-and-push-gem.yml +10 -0
  27. data/ci/tasks/build-windows.yml +6 -0
  28. data/ci/tasks/build.yml +16 -0
  29. data/ci/tasks/rubocop.yml +15 -0
  30. data/ci/tasks/run-tests.yml +10 -0
  31. data/ci/tasks/update-changelog.yml +18 -0
  32. data/dlf +12 -0
  33. data/examples/Gemfile +4 -0
  34. data/examples/custom_erb_template.rb +24 -0
  35. data/examples/extract_license_data.rb +63 -0
  36. data/examples/sample_template.erb +7 -0
  37. data/lib/license_finder/cli/approvals.rb +28 -0
  38. data/lib/license_finder/cli/base.rb +107 -0
  39. data/lib/license_finder/cli/dependencies.rb +44 -0
  40. data/lib/license_finder/cli/ignored_dependencies.rb +32 -0
  41. data/lib/license_finder/cli/ignored_groups.rb +32 -0
  42. data/lib/license_finder/cli/inherited_decisions.rb +50 -0
  43. data/lib/license_finder/cli/licenses.rb +26 -0
  44. data/lib/license_finder/cli/main.rb +221 -0
  45. data/lib/license_finder/cli/makes_decisions.rb +38 -0
  46. data/lib/license_finder/cli/patched_thor.rb +33 -0
  47. data/lib/license_finder/cli/permitted_licenses.rb +32 -0
  48. data/lib/license_finder/cli/project_name.rb +32 -0
  49. data/lib/license_finder/cli/restricted_licenses.rb +32 -0
  50. data/lib/license_finder/cli.rb +20 -0
  51. data/lib/license_finder/configuration.rb +186 -0
  52. data/lib/license_finder/core.rb +118 -0
  53. data/lib/license_finder/decision_applier.rb +70 -0
  54. data/lib/license_finder/decisions.rb +312 -0
  55. data/lib/license_finder/decisions_factory.rb +13 -0
  56. data/lib/license_finder/diff.rb +51 -0
  57. data/lib/license_finder/license/any_matcher.rb +15 -0
  58. data/lib/license_finder/license/definitions.rb +366 -0
  59. data/lib/license_finder/license/header_matcher.rb +17 -0
  60. data/lib/license_finder/license/matcher.rb +24 -0
  61. data/lib/license_finder/license/none_matcher.rb +11 -0
  62. data/lib/license_finder/license/template.rb +19 -0
  63. data/lib/license_finder/license/templates/0BSD.txt +10 -0
  64. data/lib/license_finder/license/templates/Apache1_1.txt +16 -0
  65. data/lib/license_finder/license/templates/Apache2.txt +172 -0
  66. data/lib/license_finder/license/templates/BSD.txt +24 -0
  67. data/lib/license_finder/license/templates/CC01.txt +30 -0
  68. data/lib/license_finder/license/templates/CDDL1.txt +131 -0
  69. data/lib/license_finder/license/templates/EPL1.txt +86 -0
  70. data/lib/license_finder/license/templates/GPLv2.txt +339 -0
  71. data/lib/license_finder/license/templates/GPLv3.txt +674 -0
  72. data/lib/license_finder/license/templates/ISC.txt +2 -0
  73. data/lib/license_finder/license/templates/LGPL.txt +165 -0
  74. data/lib/license_finder/license/templates/LGPL2_1.txt +169 -0
  75. data/lib/license_finder/license/templates/MIT.txt +9 -0
  76. data/lib/license_finder/license/templates/MPL1_1.txt +469 -0
  77. data/lib/license_finder/license/templates/MPL2.txt +373 -0
  78. data/lib/license_finder/license/templates/NewBSD.txt +21 -0
  79. data/lib/license_finder/license/templates/OFL.txt +91 -0
  80. data/lib/license_finder/license/templates/Python.txt +47 -0
  81. data/lib/license_finder/license/templates/Ruby.txt +52 -0
  82. data/lib/license_finder/license/templates/SimplifiedBSD.txt +19 -0
  83. data/lib/license_finder/license/templates/WTFPL.txt +14 -0
  84. data/lib/license_finder/license/templates/Zlib.txt +17 -0
  85. data/lib/license_finder/license/text.rb +45 -0
  86. data/lib/license_finder/license.rb +117 -0
  87. data/lib/license_finder/license_aggregator.rb +59 -0
  88. data/lib/license_finder/logger.rb +69 -0
  89. data/lib/license_finder/package.rb +202 -0
  90. data/lib/license_finder/package_delta.rb +61 -0
  91. data/lib/license_finder/package_manager.rb +181 -0
  92. data/lib/license_finder/package_managers/bower.rb +37 -0
  93. data/lib/license_finder/package_managers/bundler.rb +110 -0
  94. data/lib/license_finder/package_managers/cargo.rb +38 -0
  95. data/lib/license_finder/package_managers/carthage.rb +68 -0
  96. data/lib/license_finder/package_managers/cocoa_pods.rb +61 -0
  97. data/lib/license_finder/package_managers/composer.rb +63 -0
  98. data/lib/license_finder/package_managers/conan.rb +28 -0
  99. data/lib/license_finder/package_managers/conda.rb +131 -0
  100. data/lib/license_finder/package_managers/dep.rb +43 -0
  101. data/lib/license_finder/package_managers/dotnet.rb +83 -0
  102. data/lib/license_finder/package_managers/erlangmk.rb +50 -0
  103. data/lib/license_finder/package_managers/glide.rb +36 -0
  104. data/lib/license_finder/package_managers/go_15vendorexperiment.rb +87 -0
  105. data/lib/license_finder/package_managers/go_dep.rb +80 -0
  106. data/lib/license_finder/package_managers/go_modules.rb +93 -0
  107. data/lib/license_finder/package_managers/go_workspace.rb +116 -0
  108. data/lib/license_finder/package_managers/govendor.rb +73 -0
  109. data/lib/license_finder/package_managers/gradle.rb +99 -0
  110. data/lib/license_finder/package_managers/gvt.rb +69 -0
  111. data/lib/license_finder/package_managers/maven.rb +65 -0
  112. data/lib/license_finder/package_managers/mix.rb +131 -0
  113. data/lib/license_finder/package_managers/npm.rb +57 -0
  114. data/lib/license_finder/package_managers/nuget.rb +154 -0
  115. data/lib/license_finder/package_managers/pip.rb +70 -0
  116. data/lib/license_finder/package_managers/pipenv.rb +63 -0
  117. data/lib/license_finder/package_managers/rebar.rb +65 -0
  118. data/lib/license_finder/package_managers/sbt.rb +50 -0
  119. data/lib/license_finder/package_managers/spm.rb +93 -0
  120. data/lib/license_finder/package_managers/trash.rb +43 -0
  121. data/lib/license_finder/package_managers/yarn.rb +107 -0
  122. data/lib/license_finder/package_utils/activation.rb +40 -0
  123. data/lib/license_finder/package_utils/conan_info_parser.rb +77 -0
  124. data/lib/license_finder/package_utils/gradle_dependency_finder.rb +15 -0
  125. data/lib/license_finder/package_utils/license_files.rb +41 -0
  126. data/lib/license_finder/package_utils/licensing.rb +39 -0
  127. data/lib/license_finder/package_utils/maven_dependency_finder.rb +15 -0
  128. data/lib/license_finder/package_utils/notice_files.rb +40 -0
  129. data/lib/license_finder/package_utils/possible_license_file.rb +27 -0
  130. data/lib/license_finder/package_utils/pypi.rb +41 -0
  131. data/lib/license_finder/package_utils/sbt_dependency_finder.rb +15 -0
  132. data/lib/license_finder/packages/bower_package.rb +42 -0
  133. data/lib/license_finder/packages/bundler_package.rb +33 -0
  134. data/lib/license_finder/packages/cargo_package.rb +28 -0
  135. data/lib/license_finder/packages/carthage_package.rb +18 -0
  136. data/lib/license_finder/packages/cocoa_pods_package.rb +22 -0
  137. data/lib/license_finder/packages/composer_package.rb +13 -0
  138. data/lib/license_finder/packages/conan_package.rb +23 -0
  139. data/lib/license_finder/packages/conda_package.rb +74 -0
  140. data/lib/license_finder/packages/erlangmk_package.rb +114 -0
  141. data/lib/license_finder/packages/go_package.rb +32 -0
  142. data/lib/license_finder/packages/gradle_package.rb +30 -0
  143. data/lib/license_finder/packages/manual_package.rb +27 -0
  144. data/lib/license_finder/packages/maven_package.rb +27 -0
  145. data/lib/license_finder/packages/merged_package.rb +44 -0
  146. data/lib/license_finder/packages/mix_package.rb +13 -0
  147. data/lib/license_finder/packages/npm_package.rb +171 -0
  148. data/lib/license_finder/packages/nuget_package.rb +13 -0
  149. data/lib/license_finder/packages/pip_package.rb +50 -0
  150. data/lib/license_finder/packages/rebar_package.rb +13 -0
  151. data/lib/license_finder/packages/sbt_package.rb +22 -0
  152. data/lib/license_finder/packages/spm_package.rb +18 -0
  153. data/lib/license_finder/packages/yarn_package.rb +13 -0
  154. data/lib/license_finder/platform.rb +15 -0
  155. data/lib/license_finder/project_finder.rb +62 -0
  156. data/lib/license_finder/report.rb +33 -0
  157. data/lib/license_finder/reports/csv_report.rb +99 -0
  158. data/lib/license_finder/reports/diff_report.rb +29 -0
  159. data/lib/license_finder/reports/erb_report.rb +58 -0
  160. data/lib/license_finder/reports/html_report.rb +13 -0
  161. data/lib/license_finder/reports/json_report.rb +30 -0
  162. data/lib/license_finder/reports/junit_report.rb +19 -0
  163. data/lib/license_finder/reports/markdown_report.rb +9 -0
  164. data/lib/license_finder/reports/merged_report.rb +16 -0
  165. data/lib/license_finder/reports/templates/bootstrap.css +9 -0
  166. data/lib/license_finder/reports/templates/html_report.erb +113 -0
  167. data/lib/license_finder/reports/templates/junit_report.erb +41 -0
  168. data/lib/license_finder/reports/templates/markdown_report.erb +49 -0
  169. data/lib/license_finder/reports/templates/xml_report.erb +19 -0
  170. data/lib/license_finder/reports/text_report.rb +12 -0
  171. data/lib/license_finder/reports/xml_report.rb +19 -0
  172. data/lib/license_finder/scanner.rb +83 -0
  173. data/lib/license_finder/shared_helpers/cmd.rb +13 -0
  174. data/lib/license_finder/shared_helpers/common_path.rb +29 -0
  175. data/lib/license_finder/version.rb +6 -0
  176. data/lib/license_finder.rb +14 -0
  177. data/license_finder.gemspec +72 -0
  178. data/release/instructions.md +8 -0
  179. data/swift-all-keys.asc +240 -0
  180. metadata +544 -0
@@ -0,0 +1,366 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseFinder
4
+ class License
5
+ module Definitions
6
+ extend self
7
+
8
+ def all
9
+ [
10
+ apache1_1,
11
+ apache2,
12
+ bsd,
13
+ cc01,
14
+ cddl1,
15
+ eclipse1,
16
+ gplv2,
17
+ gplv3,
18
+ isc,
19
+ lgpl,
20
+ lgpl2_1,
21
+ mit,
22
+ mpl1_1,
23
+ mpl2,
24
+ newbsd,
25
+ ofl,
26
+ python,
27
+ ruby,
28
+ simplifiedbsd,
29
+ wtfpl,
30
+ zerobsd,
31
+ zlib
32
+ ]
33
+ end
34
+
35
+ def build_unrecognized(name)
36
+ License.new(
37
+ short_name: name,
38
+ url: nil,
39
+ matcher: NoneMatcher.new
40
+ )
41
+ end
42
+
43
+ private
44
+
45
+ def apache1_1
46
+ License.new(
47
+ short_name: 'Apache1_1',
48
+ pretty_name: 'Apache 1.1',
49
+ other_names: [
50
+ 'Apache-1.1',
51
+ 'The Apache Software License, Version 1.1'
52
+ ],
53
+ url: 'http://www.apache.org/licenses/LICENSE-1.1.txt'
54
+ )
55
+ end
56
+
57
+ def apache2
58
+ License.new(
59
+ short_name: 'Apache2',
60
+ pretty_name: 'Apache 2.0',
61
+ other_names: [
62
+ 'Apache-2.0',
63
+ 'Apache Software License',
64
+ 'Apache License 2.0',
65
+ 'Apache License Version 2.0',
66
+ 'Apache Public License 2.0',
67
+ 'Apache Software License, Version 2.0',
68
+ 'Apache Software License - Version 2.0',
69
+ 'Apache 2',
70
+ 'Apache License',
71
+ 'Apache License, Version 2.0',
72
+ 'ASL 2.0',
73
+ 'ASF 2.0'
74
+ ],
75
+ url: 'http://www.apache.org/licenses/LICENSE-2.0.txt'
76
+ )
77
+ end
78
+
79
+ def bsd
80
+ License.new(
81
+ short_name: 'BSD',
82
+ other_names: ['BSD4', 'bsd-old', '4-clause BSD', 'BSD-4-Clause', 'BSD 4-Clause', 'BSD License'],
83
+ url: 'http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_License.22.29'
84
+ )
85
+ end
86
+
87
+ def cc01
88
+ License.new(
89
+ short_name: 'CC01',
90
+ pretty_name: 'CC0 1.0 Universal',
91
+ other_names: ['CC0 1.0'],
92
+ url: 'http://creativecommons.org/publicdomain/zero/1.0'
93
+ )
94
+ end
95
+
96
+ def cddl1
97
+ License.new(
98
+ short_name: 'CDDL1',
99
+ pretty_name: 'Common Development and Distribution License 1.0',
100
+ other_names: [
101
+ 'CDDL-1.0',
102
+ 'Common Development and Distribution License (CDDL) v1.0',
103
+ 'COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0'
104
+ ],
105
+ url: 'https://spdx.org/licenses/CDDL-1.0.html'
106
+ )
107
+ end
108
+
109
+ def eclipse1
110
+ License.new(
111
+ short_name: 'EPL1',
112
+ pretty_name: 'Eclipse Public License 1.0',
113
+ other_names: [
114
+ 'EPL-1.0',
115
+ 'EPL 1.0',
116
+ 'Eclipse Public License - v 1.0'
117
+ ],
118
+ url: 'https://www.eclipse.org/legal/epl-v10.html'
119
+ )
120
+ end
121
+
122
+ def gplv2
123
+ License.new(
124
+ short_name: 'GPLv2',
125
+ other_names: ['GPL V2', 'gpl-v2', 'GNU GENERAL PUBLIC LICENSE Version 2'],
126
+ url: 'http://www.gnu.org/licenses/gpl-2.0.txt'
127
+ )
128
+ end
129
+
130
+ def gplv3
131
+ License.new(
132
+ short_name: 'GPLv3',
133
+ other_names: ['GPL V3', 'gpl-v3', 'GNU GENERAL PUBLIC LICENSE Version 3'],
134
+ url: 'http://www.gnu.org/licenses/gpl-3.0.txt'
135
+ )
136
+ end
137
+
138
+ def isc
139
+ License.new(
140
+ short_name: 'ISC',
141
+ url: 'http://en.wikipedia.org/wiki/ISC_license'
142
+ )
143
+ end
144
+
145
+ def lgpl
146
+ License.new(
147
+ short_name: 'LGPL',
148
+ other_names: ['LGPL-3', 'LGPLv3', 'LGPL-3.0'],
149
+ url: 'http://www.gnu.org/licenses/lgpl.txt'
150
+ )
151
+ end
152
+
153
+ def lgpl2_1
154
+ License.new(
155
+ short_name: 'LGPL2_1',
156
+ pretty_name: 'GNU Lesser General Public License version 2.1',
157
+ other_names: [
158
+ 'LGPL-2.1-only',
159
+ 'LGPL 2.1',
160
+ 'LGPL v2.1',
161
+ 'GNU Lesser General Public License 2.1'
162
+ ],
163
+ url: 'https://opensource.org/licenses/LGPL-2.1'
164
+ )
165
+ end
166
+
167
+ def mit
168
+ url_regexp = %r{MIT Licen[sc]e.*http://(?:www\.)?opensource\.org/licenses/mit-license}
169
+ header_regexp = /The MIT Licen[sc]e/
170
+ one_liner_regexp = /is released under the MIT licen[sc]e/
171
+
172
+ matcher = AnyMatcher.new(
173
+ Matcher.from_template(Template.named('MIT')),
174
+ Matcher.from_regex(url_regexp),
175
+ HeaderMatcher.new(Matcher.from_regex(header_regexp)),
176
+ Matcher.from_regex(one_liner_regexp)
177
+ )
178
+
179
+ License.new(
180
+ short_name: 'MIT',
181
+ other_names: ['Expat', 'MIT license', 'MIT License', 'The MIT License (MIT)'],
182
+ url: 'http://opensource.org/licenses/mit-license',
183
+ matcher: matcher
184
+ )
185
+ end
186
+
187
+ def mpl1_1
188
+ header_regexp = /Mozilla Public Licen[sc]e.*Version 1\.1/im
189
+
190
+ header_regexp_matcher = Matcher.from_regex(header_regexp)
191
+ mpl1_1_tmpl = Template.named('MPL1_1')
192
+
193
+ matcher = AnyMatcher.new(
194
+ HeaderMatcher.new(header_regexp_matcher, 2),
195
+ Matcher.from_template(mpl1_1_tmpl)
196
+ )
197
+
198
+ License.new(
199
+ short_name: 'MPL1_1',
200
+ pretty_name: 'Mozilla Public License 1.1',
201
+ other_names: [
202
+ 'MPL-1.1',
203
+ 'Mozilla Public License, Version 1.1',
204
+ 'Mozilla Public License version 1.1'
205
+ ],
206
+ url: 'https://www.mozilla.org/media/MPL/1.1/index.0c5913925d40.txt',
207
+ matcher: matcher
208
+ )
209
+ end
210
+
211
+ def mpl2
212
+ header_regexp = /Mozilla Public Licen[sc]e, version 2\.0/
213
+
214
+ matcher = AnyMatcher.new(
215
+ Matcher.from_template(Template.named('MPL2')),
216
+ HeaderMatcher.new(Matcher.from_regex(header_regexp))
217
+ )
218
+
219
+ License.new(
220
+ short_name: 'MPL2',
221
+ pretty_name: 'Mozilla Public License 2.0',
222
+ other_names: [
223
+ 'MPL-2.0',
224
+ 'Mozilla Public License, Version 2.0',
225
+ 'Mozilla Public License version 2.0'
226
+ ],
227
+ url: 'https://www.mozilla.org/media/MPL/2.0/index.815ca599c9df.txt',
228
+ matcher: matcher
229
+ )
230
+ end
231
+
232
+ def newbsd
233
+ template = Template.named('NewBSD')
234
+ alternate_content = template.content.gsub(
235
+ 'Neither the name of <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.',
236
+ 'The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.'
237
+ )
238
+
239
+ matcher = AnyMatcher.new(
240
+ Matcher.from_template(template),
241
+ Matcher.from_text(alternate_content)
242
+ )
243
+
244
+ License.new(
245
+ short_name: 'NewBSD',
246
+ pretty_name: 'New BSD',
247
+ other_names: [
248
+ 'Modified BSD',
249
+ 'BSD3',
250
+ 'BSD 3',
251
+ 'BSD-3',
252
+ '3-clause BSD',
253
+ 'BSD-3-Clause',
254
+ 'BSD 3-Clause License',
255
+ 'The 3-Clause BSD License',
256
+ 'BSD 3-clause New License',
257
+ 'New BSD License',
258
+ 'BSD New license',
259
+ 'BSD Licence 3'
260
+ ],
261
+ url: 'http://opensource.org/licenses/BSD-3-Clause',
262
+ matcher: matcher
263
+ )
264
+ end
265
+
266
+ def ofl
267
+ License.new(
268
+ short_name: 'OFL',
269
+ pretty_name: 'SIL OPEN FONT LICENSE Version 1.1',
270
+ other_names: [
271
+ 'OPEN FONT LICENSE Version 1.1'
272
+ ],
273
+ url: 'https://opensource.org/licenses/OFL-1.1'
274
+ )
275
+ end
276
+
277
+ def python
278
+ License.new(
279
+ short_name: 'Python',
280
+ pretty_name: 'Python Software Foundation License',
281
+ other_names: [
282
+ 'PSF',
283
+ 'PSFL',
284
+ 'PSF License'
285
+ ],
286
+ url: 'http://hg.python.org/cpython/raw-file/89ce323357db/LICENSE'
287
+ )
288
+ end
289
+
290
+ def ruby
291
+ url = 'http://www.ruby-lang.org/en/LICENSE.txt'
292
+
293
+ matcher = AnyMatcher.new(
294
+ Matcher.from_template(Template.named('Ruby')),
295
+ Matcher.from_text(url)
296
+ )
297
+
298
+ License.new(
299
+ short_name: 'Ruby',
300
+ pretty_name: 'ruby',
301
+ url: url,
302
+ matcher: matcher
303
+ )
304
+ end
305
+
306
+ def simplifiedbsd
307
+ License.new(
308
+ short_name: 'SimplifiedBSD',
309
+ pretty_name: 'Simplified BSD',
310
+ other_names: [
311
+ 'FreeBSD',
312
+ '2-clause BSD',
313
+ 'BSD-2-Clause',
314
+ 'BSD 2-Clause',
315
+ 'The BSD 2-Clause License'
316
+ ],
317
+ url: 'http://opensource.org/licenses/bsd-license'
318
+ )
319
+ end
320
+
321
+ def wtfpl
322
+ License.new(
323
+ short_name: 'WTFPL',
324
+ pretty_name: 'WTFPL',
325
+ other_names: [
326
+ 'WTFPL V2',
327
+ 'Do What The Fuck You Want To Public License'
328
+ ],
329
+ url: 'http://www.wtfpl.net/'
330
+ )
331
+ end
332
+
333
+ def zerobsd
334
+ matcher = AnyMatcher.new(
335
+ Matcher.from_template(Template.named('0BSD'))
336
+ )
337
+
338
+ License.new(
339
+ short_name: '0BSD',
340
+ pretty_name: 'BSD Zero Clause License',
341
+ other_names: [
342
+ '0-Clause BSD',
343
+ 'Zero-Clause BSD',
344
+ 'BSD-0-Clause',
345
+ 'BSD-Zero-Clause',
346
+ 'BSD 0-Clause',
347
+ 'BSD Zero-Clause'
348
+ ],
349
+ url: 'https://opensource.org/licenses/0BSD',
350
+ matcher: matcher
351
+ )
352
+ end
353
+
354
+ def zlib
355
+ License.new(
356
+ short_name: 'Zlib',
357
+ pretty_name: 'zlib/libpng license',
358
+ other_names: [
359
+ 'zlib License'
360
+ ],
361
+ url: 'https://opensource.org/licenses/Zlib'
362
+ )
363
+ end
364
+ end
365
+ end
366
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseFinder
4
+ class License
5
+ HeaderMatcher = Struct.new(:base_matcher, :first_n_lines) do
6
+ def matches_text?(text)
7
+ n = if first_n_lines.nil?
8
+ 1
9
+ else
10
+ first_n_lines
11
+ end
12
+ header = text.lines.first(n).join || ''
13
+ base_matcher.matches_text?(header)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseFinder
4
+ class License
5
+ Matcher = Struct.new(:regexp) do
6
+ def self.from_template(template)
7
+ from_text(template.content)
8
+ end
9
+
10
+ def self.from_text(text)
11
+ from_regex(Text.compile_to_regex(text))
12
+ end
13
+
14
+ # an alias for Matcher.new, for uniformity of constructors
15
+ def self.from_regex(regexp)
16
+ new(regexp)
17
+ end
18
+
19
+ def matches_text?(text)
20
+ !!(Text.normalize_punctuation(text) =~ regexp)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseFinder
4
+ class License
5
+ class NoneMatcher
6
+ def matches_text?(_text)
7
+ false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseFinder
4
+ class License
5
+ class Template
6
+ TEMPLATE_PATH = ROOT_PATH.join('license', 'templates')
7
+
8
+ def self.named(name)
9
+ new TEMPLATE_PATH.join("#{name}.txt").read
10
+ end
11
+
12
+ attr_reader :content
13
+
14
+ def initialize(raw_content)
15
+ @content = Text.normalize_punctuation(raw_content)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ Permission to use, copy, modify, and/or distribute this software for any
2
+ purpose with or without fee is hereby granted.
3
+
4
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
7
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
8
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
9
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
10
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,16 @@
1
+ The Apache Software License, Version 1.1
2
+
3
+ Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment:
10
+ "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)."
11
+ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear.
12
+ 4. The name "Apache" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org.
13
+ 5. Products derived from this software may not be called "Apache" [ex. "Jakarta," "Apache," or "Apache Commons,"] nor may "Apache" [ex. the names] appear in their name, without prior written permission of the Apache Software Foundation.
14
+ THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
+
16
+ This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see http://www.apache.org/. Portions of this software are based upon public domain software originally written at the National Center for Supercomputing Applications, University of Illinois, Urbana-Champaign.
@@ -0,0 +1,172 @@
1
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
2
+
3
+ 1. Definitions.
4
+
5
+ "License" shall mean the terms and conditions for use, reproduction,
6
+ and distribution as defined by Sections 1 through 9 of this document.
7
+
8
+ "Licensor" shall mean the copyright owner or entity authorized by
9
+ the copyright owner that is granting the License.
10
+
11
+ "Legal Entity" shall mean the union of the acting entity and all
12
+ other entities that control, are controlled by, or are under common
13
+ control with that entity. For the purposes of this definition,
14
+ "control" means (i) the power, direct or indirect, to cause the
15
+ direction or management of such entity, whether by contract or
16
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
17
+ outstanding shares, or (iii) beneficial ownership of such entity.
18
+
19
+ "You" (or "Your") shall mean an individual or Legal Entity
20
+ exercising permissions granted by this License.
21
+
22
+ "Source" form shall mean the preferred form for making modifications,
23
+ including but not limited to software source code, documentation
24
+ source, and configuration files.
25
+
26
+ "Object" form shall mean any form resulting from mechanical
27
+ transformation or translation of a Source form, including but
28
+ not limited to compiled object code, generated documentation,
29
+ and conversions to other media types.
30
+
31
+ "Work" shall mean the work of authorship, whether in Source or
32
+ Object form, made available under the License, as indicated by a
33
+ copyright notice that is included in or attached to the work
34
+ (an example is provided in the Appendix below).
35
+
36
+ "Derivative Works" shall mean any work, whether in Source or Object
37
+ form, that is based on (or derived from) the Work and for which the
38
+ editorial revisions, annotations, elaborations, or other modifications
39
+ represent, as a whole, an original work of authorship. For the purposes
40
+ of this License, Derivative Works shall not include works that remain
41
+ separable from, or merely link (or bind by name) to the interfaces of,
42
+ the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including
45
+ the original version of the Work and any modifications or additions
46
+ to that Work or Derivative Works thereof, that is intentionally
47
+ submitted to Licensor for inclusion in the Work by the copyright owner
48
+ or by an individual or Legal Entity authorized to submit on behalf of
49
+ the copyright owner. For the purposes of this definition, "submitted"
50
+ means any form of electronic, verbal, or written communication sent
51
+ to the Licensor or its representatives, including but not limited to
52
+ communication on electronic mailing lists, source code control systems,
53
+ and issue tracking systems that are managed by, or on behalf of, the
54
+ Licensor for the purpose of discussing and improving the Work, but
55
+ excluding communication that is conspicuously marked or otherwise
56
+ designated in writing by the copyright owner as "Not a Contribution."
57
+
58
+ "Contributor" shall mean Licensor and any individual or Legal Entity
59
+ on behalf of whom a Contribution has been received by Licensor and
60
+ subsequently incorporated within the Work.
61
+
62
+ 2. Grant of Copyright License. Subject to the terms and conditions of
63
+ this License, each Contributor hereby grants to You a perpetual,
64
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
65
+ copyright license to reproduce, prepare Derivative Works of,
66
+ publicly display, publicly perform, sublicense, and distribute the
67
+ Work and such Derivative Works in Source or Object form.
68
+
69
+ 3. Grant of Patent License. Subject to the terms and conditions of
70
+ this License, each Contributor hereby grants to You a perpetual,
71
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72
+ (except as stated in this section) patent license to make, have made,
73
+ use, offer to sell, sell, import, and otherwise transfer the Work,
74
+ where such license applies only to those patent claims licensable
75
+ by such Contributor that are necessarily infringed by their
76
+ Contribution(s) alone or by combination of their Contribution(s)
77
+ with the Work to which such Contribution(s) was submitted. If You
78
+ institute patent litigation against any entity (including a
79
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
80
+ or a Contribution incorporated within the Work constitutes direct
81
+ or contributory patent infringement, then any patent licenses
82
+ granted to You under this License for that Work shall terminate
83
+ as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or
91
+ Derivative Works a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works
97
+ that You distribute, all copyright, patent, trademark, and
98
+ attribution notices from the Source form of the Work,
99
+ excluding those notices that do not pertain to any part of
100
+ the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its
103
+ distribution, then any Derivative Works that You distribute must
104
+ include a readable copy of the attribution notices contained
105
+ within such NOTICE file, excluding those notices that do not
106
+ pertain to any part of the Derivative Works, in at least one
107
+ of the following places: within a NOTICE text file distributed
108
+ as part of the Derivative Works; within the Source form or
109
+ documentation, if provided along with the Derivative Works; or,
110
+ within a display generated by the Derivative Works, if and
111
+ wherever such third-party notices normally appear. The contents
112
+ of the NOTICE file are for informational purposes only and
113
+ do not modify the License. You may add Your own attribution
114
+ notices within Derivative Works that You distribute, alongside
115
+ or as an addendum to the NOTICE text from the Work, provided
116
+ that such additional attribution notices cannot be construed
117
+ as modifying the License.
118
+
119
+ You may add Your own copyright statement to Your modifications and
120
+ may provide additional or different license terms and conditions
121
+ for use, reproduction, or distribution of Your modifications, or
122
+ for any such Derivative Works as a whole, provided Your use,
123
+ reproduction, and distribution of the Work otherwise complies with
124
+ the conditions stated in this License.
125
+
126
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
127
+ any Contribution intentionally submitted for inclusion in the Work
128
+ by You to the Licensor shall be under the terms and conditions of
129
+ this License, without any additional terms or conditions.
130
+ Notwithstanding the above, nothing herein shall supersede or modify
131
+ the terms of any separate license agreement you may have executed
132
+ with Licensor regarding such Contributions.
133
+
134
+ 6. Trademarks. This License does not grant permission to use the trade
135
+ names, trademarks, service marks, or product names of the Licensor,
136
+ except as required for reasonable and customary use in describing the
137
+ origin of the Work and reproducing the content of the NOTICE file.
138
+
139
+ 7. Disclaimer of Warranty. Unless required by applicable law or
140
+ agreed to in writing, Licensor provides the Work (and each
141
+ Contributor provides its Contributions) on an "AS IS" BASIS,
142
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
143
+ implied, including, without limitation, any warranties or conditions
144
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
145
+ PARTICULAR PURPOSE. You are solely responsible for determining the
146
+ appropriateness of using or redistributing the Work and assume any
147
+ risks associated with Your exercise of permissions under this License.
148
+
149
+ 8. Limitation of Liability. In no event and under no legal theory,
150
+ whether in tort (including negligence), contract, or otherwise,
151
+ unless required by applicable law (such as deliberate and grossly
152
+ negligent acts) or agreed to in writing, shall any Contributor be
153
+ liable to You for damages, including any direct, indirect, special,
154
+ incidental, or consequential damages of any character arising as a
155
+ result of this License or out of the use or inability to use the
156
+ Work (including but not limited to damages for loss of goodwill,
157
+ work stoppage, computer failure or malfunction, or any and all
158
+ other commercial damages or losses), even if such Contributor
159
+ has been advised of the possibility of such damages.
160
+
161
+ 9. Accepting Warranty or Additional Liability. While redistributing
162
+ the Work or Derivative Works thereof, You may choose to offer,
163
+ and charge a fee for, acceptance of support, warranty, indemnity,
164
+ or other liability obligations and/or rights consistent with this
165
+ License. However, in accepting such obligations, You may act only
166
+ on Your own behalf and on Your sole responsibility, not on behalf
167
+ of any other Contributor, and only if You agree to indemnify,
168
+ defend, and hold each Contributor harmless for any liability
169
+ incurred by, or claims asserted against, such Contributor by reason
170
+ of your accepting any such warranty or additional liability.
171
+
172
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,24 @@
1
+ Redistribution and use in source and binary forms, with or without
2
+ modification, are permitted provided that the following conditions are met:
3
+ 1. Redistributions of source code must retain the above copyright
4
+ notice, this list of conditions and the following disclaimer.
5
+ 2. Redistributions in binary form must reproduce the above copyright
6
+ notice, this list of conditions and the following disclaimer in the
7
+ documentation and/or other materials provided with the distribution.
8
+ 3. All advertising materials mentioning features or use of this software
9
+ must display the following acknowledgement:
10
+ This product includes software developed by <organization>.
11
+ 4. Neither the name of <organization> nor the
12
+ names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
16
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.