license_finder 3.0.4 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -0
  3. data/CHANGELOG.md +29 -2
  4. data/CONTRIBUTING.md +5 -1
  5. data/Dockerfile +33 -10
  6. data/Gemfile +2 -2
  7. data/README.md +27 -5
  8. data/Rakefile +15 -21
  9. data/ci/pipelines/pipeline.yml.erb +40 -6
  10. data/ci/pipelines/release.yml +11 -5
  11. data/ci/scripts/containerize-tests.sh +16 -0
  12. data/ci/scripts/run-rubocop.sh +8 -0
  13. data/ci/scripts/run-tests.sh +22 -0
  14. data/ci/scripts/test.ps1 +81 -0
  15. data/ci/tasks/build-windows.yml +6 -0
  16. data/ci/tasks/build.yml +2 -2
  17. data/ci/tasks/rubocop.yml +13 -0
  18. data/features/features/cli/cli_spec.rb +8 -8
  19. data/features/features/configure/add_dependencies_spec.rb +7 -7
  20. data/features/features/configure/approve_dependencies_spec.rb +15 -15
  21. data/features/features/configure/assign_licenses_spec.rb +4 -4
  22. data/features/features/configure/blacklist_licenses_spec.rb +3 -3
  23. data/features/features/configure/ignore_dependencies_spec.rb +3 -3
  24. data/features/features/configure/ignore_groups_spec.rb +4 -4
  25. data/features/features/configure/name_project_spec.rb +4 -4
  26. data/features/features/configure/set_project_path_spec.rb +2 -2
  27. data/features/features/configure/whitelist_licenses_spec.rb +4 -4
  28. data/features/features/package_managers/bower_spec.rb +3 -3
  29. data/features/features/package_managers/carthage_spec.rb +14 -0
  30. data/features/features/package_managers/cocoapods_spec.rb +3 -3
  31. data/features/features/package_managers/conan_spec.rb +11 -0
  32. data/features/features/package_managers/dep_spec.rb +15 -0
  33. data/features/features/package_managers/glide_spec.rb +14 -0
  34. data/features/features/package_managers/govendor_spec.rb +15 -0
  35. data/features/features/package_managers/gradle_spec.rb +1 -1
  36. data/features/features/package_managers/gvt_spec.rb +14 -0
  37. data/features/features/package_managers/maven_spec.rb +2 -3
  38. data/features/features/package_managers/mix_spec.rb +16 -0
  39. data/features/features/package_managers/npm_spec.rb +3 -3
  40. data/features/features/package_managers/nuget_spec.rb +4 -4
  41. data/features/features/package_managers/pip_spec.rb +2 -2
  42. data/features/features/package_managers/rebar_spec.rb +3 -3
  43. data/features/features/package_managers/yarn_spec.rb +14 -0
  44. data/features/features/report/composite_spec.rb +1 -1
  45. data/features/features/report/csv_spec.rb +3 -3
  46. data/features/features/report/diff_spec.rb +20 -10
  47. data/features/features/report/html_spec.rb +10 -10
  48. data/features/features/report/subproject_spec.rb +15 -4
  49. data/features/fixtures/Cartfile +1 -0
  50. data/features/fixtures/Podfile +1 -1
  51. data/features/fixtures/alternate-build-file-gradle/build-alt.gradle +5 -15
  52. data/features/fixtures/build.gradle +5 -15
  53. data/features/fixtures/conanfile.txt +11 -0
  54. data/features/fixtures/file-based-libs-gradle/build.gradle +5 -7
  55. data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.lock +9 -0
  56. data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.toml +7 -0
  57. data/features/fixtures/gopath_dep/src/foo-dep/bar/bar.go +10 -0
  58. data/features/fixtures/gopath_dep/src/foo-dep/foo.go +7 -0
  59. data/features/fixtures/gopath_glide/src/glide.lock +9 -0
  60. data/features/fixtures/gopath_glide/src/glide.yaml +6 -0
  61. data/features/fixtures/gopath_govendor/src/vendor/vendor.json +19 -0
  62. data/features/fixtures/gopath_gvt/src/vendor/manifest +22 -0
  63. data/features/fixtures/gradle-wrapper/build.gradle +5 -15
  64. data/features/fixtures/gradle-wrapper/gradlew +6 -1
  65. data/features/fixtures/gradle-wrapper/gradlew.bat +9 -1
  66. data/features/fixtures/mix.exs +22 -0
  67. data/features/fixtures/multi-module-gradle/build.gradle +7 -15
  68. data/features/fixtures/single-module-gradle/build.gradle +5 -15
  69. data/features/support/testing_dsl.rb +155 -43
  70. data/lib/license_finder.rb +4 -3
  71. data/lib/license_finder/cli.rb +0 -3
  72. data/lib/license_finder/cli/approvals.rb +3 -3
  73. data/lib/license_finder/cli/base.rb +11 -8
  74. data/lib/license_finder/cli/blacklist.rb +7 -7
  75. data/lib/license_finder/cli/dependencies.rb +8 -8
  76. data/lib/license_finder/cli/ignored_dependencies.rb +4 -4
  77. data/lib/license_finder/cli/ignored_groups.rb +4 -4
  78. data/lib/license_finder/cli/licenses.rb +2 -2
  79. data/lib/license_finder/cli/main.rb +59 -39
  80. data/lib/license_finder/cli/makes_decisions.rb +2 -2
  81. data/lib/license_finder/cli/patched_thor.rb +6 -7
  82. data/lib/license_finder/cli/project_name.rb +5 -6
  83. data/lib/license_finder/cli/whitelist.rb +7 -7
  84. data/lib/license_finder/configuration.rb +15 -4
  85. data/lib/license_finder/core.rb +20 -4
  86. data/lib/license_finder/decision_applier.rb +0 -1
  87. data/lib/license_finder/decisions.rb +12 -14
  88. data/lib/license_finder/diff.rb +33 -31
  89. data/lib/license_finder/license.rb +13 -9
  90. data/lib/license_finder/license/definitions.rb +55 -55
  91. data/lib/license_finder/license/none_matcher.rb +1 -1
  92. data/lib/license_finder/license/template.rb +1 -1
  93. data/lib/license_finder/license/text.rb +0 -1
  94. data/lib/license_finder/license_aggregator.rb +1 -0
  95. data/lib/license_finder/logger.rb +18 -61
  96. data/lib/license_finder/package.rb +25 -11
  97. data/lib/license_finder/package_delta.rb +3 -6
  98. data/lib/license_finder/package_manager.rb +77 -34
  99. data/lib/license_finder/package_managers/bower.rb +8 -8
  100. data/lib/license_finder/package_managers/bower_package.rb +12 -12
  101. data/lib/license_finder/package_managers/bundler.rb +21 -9
  102. data/lib/license_finder/package_managers/bundler_package.rb +1 -1
  103. data/lib/license_finder/package_managers/carthage.rb +66 -0
  104. data/lib/license_finder/package_managers/carthage_package.rb +16 -0
  105. data/lib/license_finder/package_managers/cocoa_pods.rb +13 -13
  106. data/lib/license_finder/package_managers/cocoa_pods_package.rb +1 -1
  107. data/lib/license_finder/package_managers/conan.rb +26 -0
  108. data/lib/license_finder/package_managers/conan_info_parser.rb +74 -0
  109. data/lib/license_finder/package_managers/conan_package.rb +17 -0
  110. data/lib/license_finder/package_managers/dep.rb +33 -0
  111. data/lib/license_finder/package_managers/glide.rb +30 -0
  112. data/lib/license_finder/package_managers/{go_vendor.rb → go_15vendorexperiment.rb} +19 -24
  113. data/lib/license_finder/package_managers/go_dep.rb +15 -12
  114. data/lib/license_finder/package_managers/go_package.rb +15 -13
  115. data/lib/license_finder/package_managers/go_workspace.rb +39 -34
  116. data/lib/license_finder/package_managers/govendor.rb +32 -0
  117. data/lib/license_finder/package_managers/gradle.rb +16 -16
  118. data/lib/license_finder/package_managers/gradle_package.rb +8 -8
  119. data/lib/license_finder/package_managers/gvt.rb +61 -0
  120. data/lib/license_finder/package_managers/maven.rb +17 -18
  121. data/lib/license_finder/package_managers/maven_package.rb +4 -6
  122. data/lib/license_finder/package_managers/merged_package.rb +25 -2
  123. data/lib/license_finder/package_managers/mix.rb +51 -0
  124. data/lib/license_finder/package_managers/mix_package.rb +7 -0
  125. data/lib/license_finder/package_managers/npm.rb +8 -32
  126. data/lib/license_finder/package_managers/npm_package.rb +51 -48
  127. data/lib/license_finder/package_managers/nuget.rb +30 -40
  128. data/lib/license_finder/package_managers/pip.rb +11 -11
  129. data/lib/license_finder/package_managers/pip_package.rb +8 -8
  130. data/lib/license_finder/package_managers/rebar.rb +11 -11
  131. data/lib/license_finder/package_managers/yarn.rb +62 -0
  132. data/lib/license_finder/packages/activation.rb +2 -2
  133. data/lib/license_finder/packages/license_files.rb +6 -6
  134. data/lib/license_finder/packages/licensing.rb +8 -10
  135. data/lib/license_finder/packages/manual_package.rb +2 -2
  136. data/lib/license_finder/project_finder.rb +6 -5
  137. data/lib/license_finder/report.rb +1 -0
  138. data/lib/license_finder/reports/csv_report.rb +4 -4
  139. data/lib/license_finder/reports/diff_report.rb +2 -2
  140. data/lib/license_finder/reports/erb_report.rb +2 -4
  141. data/lib/license_finder/reports/html_report.rb +2 -2
  142. data/lib/license_finder/reports/markdown_report.rb +1 -1
  143. data/lib/license_finder/reports/merged_report.rb +1 -1
  144. data/lib/license_finder/reports/text_report.rb +3 -5
  145. data/lib/license_finder/shared_helpers/cmd.rb +11 -0
  146. data/lib/license_finder/version.rb +1 -1
  147. data/license_finder-2.1.2.gem +0 -0
  148. data/license_finder.gemspec +38 -38
  149. metadata +84 -118
  150. data/ci/scripts/test.sh +0 -26
  151. data/ci/tasks/create-source-archives.yml +0 -23
  152. data/spec/dummy_app/Gemfile +0 -6
  153. data/spec/fixtures/all_pms/.envrc +0 -1
  154. data/spec/fixtures/all_pms/.nuget/.keep +0 -0
  155. data/spec/fixtures/all_pms/Gemfile +0 -0
  156. data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
  157. data/spec/fixtures/all_pms/Podfile +0 -0
  158. data/spec/fixtures/all_pms/bower.json +0 -0
  159. data/spec/fixtures/all_pms/build.gradle +0 -0
  160. data/spec/fixtures/all_pms/package.json +0 -0
  161. data/spec/fixtures/all_pms/pom.xml +0 -0
  162. data/spec/fixtures/all_pms/rebar.config +0 -0
  163. data/spec/fixtures/all_pms/requirements.txt +0 -0
  164. data/spec/fixtures/all_pms/vendor/.gitkeep +0 -0
  165. data/spec/fixtures/composite/Gemfile +0 -0
  166. data/spec/fixtures/composite/nested_project/.envrc +0 -8
  167. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +0 -16
  168. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +0 -5
  169. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +0 -6
  170. data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
  171. data/spec/fixtures/composite/project1/Gemfile +0 -0
  172. data/spec/fixtures/composite/project2/package.json +0 -0
  173. data/spec/fixtures/config/license_finder.yml +0 -5
  174. data/spec/fixtures/license_directory/COPYING +0 -1
  175. data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -1
  176. data/spec/fixtures/license_directory/LICENSE/lib/unrelated.txt +0 -2
  177. data/spec/fixtures/license_names/COPYING.txt +0 -1
  178. data/spec/fixtures/license_names/LICENSE +0 -1
  179. data/spec/fixtures/license_names/Licence.rdoc +0 -1
  180. data/spec/fixtures/license_names/Mit-License +0 -1
  181. data/spec/fixtures/license_names/README.rdoc +0 -1
  182. data/spec/fixtures/nested_gem/vendor/LICENSE +0 -1
  183. data/spec/fixtures/npm-circular-dependencies/npm-list.json +0 -5339
  184. data/spec/fixtures/npm-circular-dependencies/package.json +0 -5
  185. data/spec/fixtures/npm-circular-licenses/npm-list.json +0 -7597
  186. data/spec/fixtures/npm-circular-licenses/package.json +0 -23
  187. data/spec/fixtures/npm-licenses-string/npm-list.json +0 -7597
  188. data/spec/fixtures/npm-licenses-string/package.json +0 -23
  189. data/spec/fixtures/npm-recursive-dependencies/npm-list.json +0 -5158
  190. data/spec/fixtures/npm-recursive-dependencies/package.json +0 -15
  191. data/spec/fixtures/npm-stack-too-deep/npm-list.json +0 -13464
  192. data/spec/fixtures/npm-stack-too-deep/package.json +0 -5
  193. data/spec/fixtures/utf8_gem/README +0 -210
  194. data/spec/lib/license_finder/cli/approvals_spec.rb +0 -71
  195. data/spec/lib/license_finder/cli/blacklist_spec.rb +0 -58
  196. data/spec/lib/license_finder/cli/dependencies_spec.rb +0 -73
  197. data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +0 -47
  198. data/spec/lib/license_finder/cli/ignored_groups_spec.rb +0 -40
  199. data/spec/lib/license_finder/cli/licenses_spec.rb +0 -60
  200. data/spec/lib/license_finder/cli/main_spec.rb +0 -243
  201. data/spec/lib/license_finder/cli/project_name_spec.rb +0 -40
  202. data/spec/lib/license_finder/cli/whitelist_spec.rb +0 -58
  203. data/spec/lib/license_finder/configuration_spec.rb +0 -115
  204. data/spec/lib/license_finder/core_spec.rb +0 -54
  205. data/spec/lib/license_finder/decision_applier_spec.rb +0 -219
  206. data/spec/lib/license_finder/decisions_spec.rb +0 -408
  207. data/spec/lib/license_finder/diff_spec.rb +0 -129
  208. data/spec/lib/license_finder/license/definitions_spec.rb +0 -177
  209. data/spec/lib/license_finder/license_aggregator_spec.rb +0 -61
  210. data/spec/lib/license_finder/license_spec.rb +0 -106
  211. data/spec/lib/license_finder/package_delta_spec.rb +0 -18
  212. data/spec/lib/license_finder/package_manager_spec.rb +0 -62
  213. data/spec/lib/license_finder/package_managers/bower_package_spec.rb +0 -71
  214. data/spec/lib/license_finder/package_managers/bower_spec.rb +0 -39
  215. data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +0 -35
  216. data/spec/lib/license_finder/package_managers/bundler_spec.rb +0 -56
  217. data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +0 -48
  218. data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +0 -59
  219. data/spec/lib/license_finder/package_managers/go_dep_spec.rb +0 -126
  220. data/spec/lib/license_finder/package_managers/go_package_spec.rb +0 -33
  221. data/spec/lib/license_finder/package_managers/go_vendor_spec.rb +0 -144
  222. data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +0 -286
  223. data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +0 -80
  224. data/spec/lib/license_finder/package_managers/gradle_spec.rb +0 -180
  225. data/spec/lib/license_finder/package_managers/maven_package_spec.rb +0 -63
  226. data/spec/lib/license_finder/package_managers/maven_spec.rb +0 -128
  227. data/spec/lib/license_finder/package_managers/merged_package_spec.rb +0 -60
  228. data/spec/lib/license_finder/package_managers/npm_package_spec.rb +0 -57
  229. data/spec/lib/license_finder/package_managers/npm_spec.rb +0 -253
  230. data/spec/lib/license_finder/package_managers/nuget_package_spec.rb +0 -9
  231. data/spec/lib/license_finder/package_managers/nuget_spec.rb +0 -157
  232. data/spec/lib/license_finder/package_managers/pip_package_spec.rb +0 -87
  233. data/spec/lib/license_finder/package_managers/pip_spec.rb +0 -47
  234. data/spec/lib/license_finder/package_managers/rebar_package_spec.rb +0 -24
  235. data/spec/lib/license_finder/package_managers/rebar_spec.rb +0 -50
  236. data/spec/lib/license_finder/package_spec.rb +0 -179
  237. data/spec/lib/license_finder/packages/activation_spec.rb +0 -41
  238. data/spec/lib/license_finder/packages/license_files_spec.rb +0 -46
  239. data/spec/lib/license_finder/packages/licensing_spec.rb +0 -1
  240. data/spec/lib/license_finder/packages/possible_license_file_spec.rb +0 -38
  241. data/spec/lib/license_finder/project_finder_spec.rb +0 -33
  242. data/spec/lib/license_finder/reports/csv_report_spec.rb +0 -70
  243. data/spec/lib/license_finder/reports/diff_report_spec.rb +0 -56
  244. data/spec/lib/license_finder/reports/html_report_spec.rb +0 -101
  245. data/spec/lib/license_finder/reports/markdown_report_spec.rb +0 -45
  246. data/spec/lib/license_finder/reports/merged_report_spec.rb +0 -21
  247. data/spec/lib/license_finder/reports/text_report_spec.rb +0 -43
  248. data/spec/spec_helper.rb +0 -27
  249. data/spec/support/shared_examples_for_package_manager.rb +0 -52
  250. data/spec/support/stdout_helpers.rb +0 -31
  251. data/spec/support/test_fixtures.rb +0 -7
@@ -1,129 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe Diff do
5
- subject { Diff }
6
-
7
- let(:diff) { subject.compare(file1_content, file2_content) }
8
-
9
- def find_package_with_name(name)
10
- diff.find_all { |d| d.name == name }
11
- end
12
-
13
- describe '#compare' do
14
- context 'when a dependency is added' do
15
- let(:file1_content) { "nokogiri,1.6.6.2,MIT" }
16
- let(:file2_content) { "nokogiri,1.6.6.2,MIT\nrspec,3.2.0,MIT" }
17
-
18
- it 'should create and set packages with added diff state' do
19
- rspec = find_package_with_name('rspec')[0]
20
- expect(rspec.status).to eq :added
21
- end
22
- end
23
-
24
- context 'when a dependency is removed' do
25
- let(:file1_content) { "nokogiri,1.6.6.2,MIT\nrspec,3.2.0,MIT" }
26
- let(:file2_content) { "nokogiri,1.6.6.2,MIT" }
27
-
28
- it 'should create and set packages with removed diff state' do
29
- rspec = find_package_with_name('rspec')[0]
30
- expect(rspec.status).to eq :removed
31
- end
32
- end
33
-
34
- context 'when a dependency is unchanged' do
35
- let(:file1_content) { "nokogiri,1.6.6.2,MIT" }
36
- let(:file2_content) { "nokogiri,1.6.6.2,MIT" }
37
-
38
- it 'should create and set packages with unchanged diff state' do
39
- nokogiri = find_package_with_name('nokogiri')[0]
40
- expect(nokogiri.status).to eq :unchanged
41
- end
42
- end
43
-
44
- context 'when there are all types of changes' do
45
- let(:file1_content) { "rspec,3.2.0,MIT\nnokogiri,1.6.6.2,MIT\nfakefs,0.6.7,MIT" }
46
- let(:file2_content) { "nokogiri,1.6.6.2,MIT\nminitest,5.7.0,MIT\nfakefs,0.6.7,BSD" }
47
-
48
- it 'should create and set packages diff states' do
49
- expect(find_package_with_name('minitest')[0].status).to eq :added
50
- expect(find_package_with_name('rspec')[0].status).to eq :removed
51
- expect(find_package_with_name('nokogiri')[0].status).to eq :unchanged
52
- end
53
- end
54
-
55
- context 'when the version changes' do
56
- let(:file1_content) { "rspec,3.2.0,MIT" }
57
- let(:file2_content) { "rspec,3.3.0,MIT" }
58
-
59
- it 'should add the new version and remove the previous version' do
60
- rspecs = find_package_with_name('rspec')
61
- expect(rspecs.size).to eq(2)
62
- rspecs.each do |rspec|
63
- case rspec.status
64
- when :removed
65
- expect(rspec.version).to eq('3.2.0')
66
- when :added
67
- expect(rspec.version).to eq('3.3.0')
68
- end
69
- end
70
- end
71
-
72
- context 'when there are two versions of the same dependency' do
73
- let(:file1_content) { "rspec,3.2.0,MIT\nrspec,1.1.0,MIT\nnokogiri,1.6.6.2,MIT" }
74
- let(:file2_content) { "rspec,3.3.0,MIT\nrspec,1.1.0,MIT\nnokogiri,1.6.6.2,MIT" }
75
- it 'should identify which version was updated' do
76
- rspecs = find_package_with_name('rspec')
77
- expect(rspecs.size).to eq(3)
78
- rspecs.each do |rspec|
79
- case rspec.status
80
- when :removed
81
- expect(rspec.version).to eq('3.2.0')
82
- when :added
83
- expect(rspec.version).to eq('3.3.0')
84
- else
85
- expect(rspec.status).to eq(:unchanged)
86
- expect(rspec.version).to eq('1.1.0')
87
- end
88
- end
89
- end
90
- end
91
- end
92
-
93
- context 'when the license changes' do
94
- let(:file1_content) { "rspec,3.2.0,MIT" }
95
- let(:file2_content) { "rspec,3.3.0,GPLv2" }
96
-
97
- it 'should set the state to unchanged and record the version change' do
98
- rspec_old = diff.find {|p| p.version == '3.2.0'}
99
- rspec_new = diff.find {|p| p.version == '3.3.0'}
100
-
101
- expect(rspec_old.status).to eq(:removed)
102
- expect(rspec_old.version).to eq('3.2.0')
103
-
104
- expect(rspec_new.status).to eq(:added)
105
- expect(rspec_new.version).to eq('3.3.0')
106
- end
107
- end
108
-
109
- context 'when the files are merged reports' do
110
- let(:file1_content) { "rspec,3.2.0,MIT,\"/path/to/project1,/path/to/project2\"" }
111
- let(:file2_content) { "rspec,3.2.0,MIT,\"/path/to/project1,/path/to/project2\"\nrails,4.2.0,MIT,/path/to/project1" }
112
-
113
- it 'should show the diff of the reports' do
114
- rspec = find_package_with_name('rspec')[0]
115
- expect(rspec.status).to eq(:unchanged)
116
- expect(rspec.version).to eq('3.2.0')
117
- paths = ['/path/to/project1', '/path/to/project2'].map { |p| File.absolute_path(p) }
118
- expect(rspec.subproject_paths).to match_array(paths)
119
-
120
- rails = find_package_with_name('rails')[0]
121
- expect(rails.status).to eq(:added)
122
- expect(rails.version).to eq('4.2.0')
123
- paths = ['/path/to/project1'].map { |p| File.absolute_path(p) }
124
- expect(rails.subproject_paths).to match_array(paths)
125
- end
126
- end
127
- end
128
- end
129
- end
@@ -1,177 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe LicenseFinder::License::Definitions do
4
- it "should create unrecognized licenses" do
5
- license = described_class.build_unrecognized("foo")
6
- expect(license.name).to eq("foo")
7
- expect(license.url).to be_nil
8
- expect(license).to be_matches_name("foo")
9
- expect(license).not_to be_matches_text("foo")
10
- end
11
- end
12
-
13
- describe LicenseFinder::License, "Apache2" do
14
- it "should be recognized" do |e|
15
- expect(described_class.find_by_name("Apache2").url).to be
16
- end
17
- end
18
-
19
- describe LicenseFinder::License, "BSD" do
20
- it "should be recognized" do |e|
21
- expect(described_class.find_by_name("BSD").url).to be
22
- end
23
- end
24
-
25
- describe LicenseFinder::License, "GPLv2" do
26
- it "should be recognized" do
27
- expect(described_class.find_by_name("GPLv2").url).to be
28
- end
29
- end
30
-
31
- describe LicenseFinder::License, "GPLv3" do
32
- it "should be recognized" do
33
- expect(described_class.find_by_name("GPLv3").url).to be
34
- end
35
- end
36
-
37
- describe LicenseFinder::License, "ISC" do
38
- it "should be recognized" do
39
- expect(described_class.find_by_name("ISC").url).to be
40
- end
41
- end
42
-
43
- describe LicenseFinder::License, "LGPL" do
44
- it "should be recognized" do
45
- expect(described_class.find_by_name("LGPL").url).to be
46
- end
47
- end
48
-
49
- describe LicenseFinder::License, "MIT" do
50
- subject { described_class.find_by_name "MIT" }
51
-
52
- describe "#matches_text?" do
53
- it "should return true if the text contains the MIT url" do
54
- expect(subject).to be_matches_text "MIT License is awesome http://opensource.org/licenses/mit-license"
55
-
56
- expect(subject).to be_matches_text "MIT Licence is awesome http://www.opensource.org/licenses/mit-license"
57
-
58
- expect(subject).not_to be_matches_text "MIT Licence is awesome http://www!opensource!org/licenses/mit-license"
59
- end
60
-
61
- it "should return true if the text begins with 'The MIT License'" do
62
- expect(subject).to be_matches_text "The MIT License"
63
-
64
- expect(subject).to be_matches_text "The MIT Licence"
65
-
66
- expect(subject).not_to be_matches_text "Something else\nThe MIT License"
67
- end
68
-
69
- it "should return true if the text contains 'is released under the MIT license'" do
70
- expect(subject).to be_matches_text "is released under the MIT license"
71
-
72
- expect(subject).to be_matches_text "is released under the MIT licence"
73
- end
74
- end
75
- end
76
-
77
- describe LicenseFinder::License, "MPL2" do
78
- subject { described_class.find_by_name "MPL2" }
79
-
80
- describe "#matches_text?" do
81
- it "should return true if the text begins with 'The Mozilla Public License, version 2.0'" do
82
- expect(subject).to be_matches_text "Mozilla Public License, version 2.0"
83
-
84
- expect(subject).not_to be_matches_text "Something else\nMozilla Public License, version 2.0"
85
- end
86
- end
87
- end
88
-
89
- describe LicenseFinder::License, "NewBSD" do
90
- subject { described_class.find_by_name "NewBSD" }
91
-
92
- it "should match regardless of organization or copyright holder names" do
93
- license = <<-LICENSE
94
- Redistribution and use in source and binary forms, with or without
95
- modification, are permitted provided that the following conditions are met:
96
- * Redistributions of source code must retain the above copyright
97
- notice, this list of conditions and the following disclaimer.
98
- * Redistributions in binary form must reproduce the above copyright
99
- notice, this list of conditions and the following disclaimer in the
100
- documentation and/or other materials provided with the distribution.
101
- * Neither the name of Johnny %$#!.43298432, Guitar INC! nor the
102
- names of its contributors may be used to endorse or promote products
103
- derived from this software without specific prior written permission.
104
-
105
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
106
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
107
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
108
- DISCLAIMED. IN NO EVENT SHALL Johnny %$#!.43298432, Guitar BE LIABLE FOR ANY
109
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
110
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
111
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
112
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
113
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
114
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115
- LICENSE
116
-
117
- expect(subject).to be_matches_text license
118
- end
119
-
120
- it "should match with the alternate wording of third clause" do
121
- license = <<-LICENSE
122
- Redistribution and use in source and binary forms, with or without
123
- modification, are permitted provided that the following conditions are met:
124
- * Redistributions of source code must retain the above copyright
125
- notice, this list of conditions and the following disclaimer.
126
- * Redistributions in binary form must reproduce the above copyright
127
- notice, this list of conditions and the following disclaimer in the
128
- documentation and/or other materials provided with the distribution.
129
- * The names of its contributors may not be used to endorse or promote
130
- products derived from this software without specific prior written
131
- permission.
132
-
133
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
134
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
135
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
136
- DISCLAIMED. IN NO EVENT SHALL Johnny %$#!.43298432, Guitar BE LIABLE FOR ANY
137
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
138
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
139
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
140
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
141
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
142
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
143
- LICENSE
144
-
145
- expect(subject).to be_matches_text license
146
- end
147
- end
148
-
149
- describe LicenseFinder::License, "Python" do
150
- it "should be recognized" do
151
- expect(described_class.find_by_name("Python").url).to be
152
- end
153
- end
154
-
155
- describe LicenseFinder::License, "Ruby" do
156
- subject { described_class.find_by_name "Ruby" }
157
-
158
- describe "#matches?" do
159
- it "should return true when the Ruby license URL is present" do
160
- expect(subject).to be_matches_text "This gem is available under the following license:\nhttp://www.ruby-lang.org/en/LICENSE.txt\nOkay?"
161
- end
162
-
163
- it "should return false when the Ruby License URL is not present" do
164
- expect(subject).not_to be_matches_text "This gem is available under the following license:\nhttp://www.example.com\nOkay?"
165
- end
166
-
167
- it "should return false for pathological licenses" do
168
- expect(subject).not_to be_matches_text "This gem is available under the following license:\nhttp://wwwzruby-langzorg/en/LICENSEztxt\nOkay?"
169
- end
170
- end
171
- end
172
-
173
- describe LicenseFinder::License, "SimplifiedBSD" do
174
- it "should be recognized" do
175
- expect(described_class.find_by_name("SimplifiedBSD").url).to be
176
- end
177
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe LicenseAggregator do
5
- describe '#dependencies' do
6
- let(:hammer) { Package.new('hammer', '1.0.0') }
7
- let(:helmet) { Package.new('helmet', '3.0.0') }
8
- let(:license_finder_1) { double(:license_finder, acknowledged: [hammer]) }
9
- let(:license_finder_2) { double(:license_finder, acknowledged: [helmet]) }
10
-
11
- before do
12
- allow(Core).to receive(:new).and_return(license_finder_1, license_finder_2)
13
- end
14
-
15
- it 'returns an array of MergedPackage objects' do
16
- aggregator = LicenseAggregator.new({}, ['path/to/subproject-1', 'path/to/subproject-2'])
17
- results = aggregator.dependencies
18
- expect(results.first).to be_a(MergedPackage)
19
- expect(results.map(&:name)).to match_array ['hammer', 'helmet']
20
- end
21
-
22
- context 'when there are duplicates' do
23
- let(:license_finder_2) { double(:license_finder, acknowledged: [helmet, hammer])}
24
-
25
- it 'aggregates duplicate packages by package name' do
26
- aggregator = LicenseAggregator.new({}, ['path/to/subproject-1', 'path/to/subproject-2'])
27
- results = aggregator.dependencies
28
-
29
- expect(results.count).to eq(2)
30
-
31
- expect(results[1].name).to eq('helmet')
32
- expect(results[1].subproject_paths[0]).to end_with('path/to/subproject-2')
33
-
34
- expect(results[0].name).to eq('hammer')
35
- expect(results[0].subproject_paths[0]).to end_with('path/to/subproject-1')
36
- expect(results[0].subproject_paths[1]).to end_with('path/to/subproject-2')
37
- end
38
- end
39
-
40
- context 'when there are duplicate packages with different versions' do
41
- let(:hammer_new) { Package.new('hammer', '2.0.0') }
42
- let(:license_finder_2) { double(:license_finder, acknowledged: [helmet, hammer_new])}
43
-
44
- it 'does not aggregate packages with different versions' do
45
- aggregator = LicenseAggregator.new({}, ['path/to/subproject-1', 'path/to/subproject-2'])
46
- results = aggregator.dependencies
47
-
48
- expect(results.count).to eq(3)
49
- expect(results.map(&:name)).to match_array ['hammer', 'helmet', 'hammer']
50
- expect(find_package(results, 'hammer', '1.0.0').subproject_paths[0]).to end_with('path/to/subproject-1')
51
- expect(find_package(results, 'hammer', '2.0.0').subproject_paths[0]).to end_with('path/to/subproject-2')
52
- expect(find_package(results, 'helmet', '3.0.0').subproject_paths[0]).to end_with('path/to/subproject-2')
53
- end
54
- end
55
-
56
- def find_package(packages, name, version)
57
- packages.find { |dep| dep.name == name && dep.version == version }
58
- end
59
- end
60
- end
61
- end
@@ -1,106 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe License do
5
- describe ".find_by_name" do
6
- it "should find a registered license" do
7
- license = License.find_by_name("Expat")
8
- expect(license.name).to eq "MIT"
9
- end
10
-
11
- it "should make an unrecognized license" do
12
- license = License.find_by_name("not a known license")
13
- expect(license.name).to eq "not a known license"
14
- end
15
-
16
- context "making the default license" do
17
- it "sets the name to 'unknown'" do
18
- expect(License.find_by_name(nil).name).to eq("unknown")
19
- end
20
-
21
- it "does not equal other uses of the default license" do
22
- expect(License.find_by_name(nil)).not_to eq(License.find_by_name(nil))
23
- end
24
- end
25
- end
26
-
27
- describe ".find_by_text" do
28
- it "should find a registered license" do
29
- license = License.find_by_text('This gem is released under the MIT license')
30
- expect(license.name).to eq "MIT"
31
- end
32
-
33
- it "returns nil if not found" do
34
- license = License.find_by_text("foo")
35
-
36
- expect(license).to be_nil
37
- end
38
- end
39
-
40
- def make_license(settings = {})
41
- defaults = {
42
- short_name: "Default Short Name",
43
- url: "http://example.com/license",
44
- matcher: License::Matcher.from_text('Default Matcher')
45
- }
46
-
47
- License.new(defaults.merge(settings))
48
- end
49
-
50
- describe "#matches_name?" do
51
- it "should match on short_name" do
52
- expect(make_license(short_name: "Foo")).to be_matches_name "Foo"
53
- end
54
-
55
- it "should match on pretty name" do
56
- expect(make_license(pretty_name: "Foo")).to be_matches_name "Foo"
57
- end
58
-
59
- it "should match on alternative names" do
60
- license = make_license(other_names: ["Foo", "Bar"])
61
- expect(license).to be_matches_name "Foo"
62
- expect(license).to be_matches_name "Bar"
63
- end
64
-
65
- it "should ignore case" do
66
- expect(make_license(pretty_name: "Foo")).to be_matches_name "foo"
67
- expect(make_license(pretty_name: "foo")).to be_matches_name "Foo"
68
- end
69
-
70
- it "should not fail if pretty_name or other_names are omitted" do
71
- expect(make_license).to be_matches_name "Default Short Name"
72
- end
73
- end
74
-
75
- describe ".matches_text?" do
76
- it "should match on text" do
77
- license = make_license(matcher: License::Matcher.from_regex(/The license text/))
78
- expect(license).to be_matches_text "The license text"
79
- expect(license).not_to be_matches_text "Some other text"
80
- end
81
-
82
- it "should match regardless of placeholder names, whitespace, or quotes" do
83
- license_text = <<-LICENSE
84
- The "company" of <company name> shall not be
85
- held `responsible` for 'anything'.
86
- LICENSE
87
- license = make_license(matcher: License::Matcher.from_text(License::Text.normalize_punctuation(license_text)))
88
-
89
- expect(license).to be_matches_text <<-FILE
90
- The ''company'' of foo bar *%*%*%*%
91
- shall not be held "responsible" for `anything`.
92
- FILE
93
- end
94
-
95
- it "should match even if whitespace at beginning and end don't match" do
96
- template = License::Template.new("\nThe license text")
97
- license = make_license(matcher: License::Matcher.from_template(template))
98
- expect(license).to be_matches_text "The license text\n"
99
- end
100
- end
101
-
102
- it "should default pretty_name to short_name" do
103
- expect(make_license.name).to eq("Default Short Name")
104
- end
105
- end
106
- end