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,27 +1,27 @@
1
1
  module LicenseFinder
2
2
  class BowerPackage < Package
3
- def initialize(bower_module, options={})
4
- spec = bower_module.fetch("pkgMeta", Hash.new)
3
+ def initialize(bower_module, options = {})
4
+ spec = bower_module.fetch('pkgMeta', {})
5
5
 
6
6
  if spec.empty?
7
- endpoint = bower_module.fetch("endpoint", Hash.new)
8
- name = endpoint["name"]
9
- version = endpoint["target"]
7
+ endpoint = bower_module.fetch('endpoint', {})
8
+ name = endpoint['name']
9
+ version = endpoint['target']
10
10
  else
11
- name = spec["name"]
12
- version = spec["version"]
11
+ name = spec['name']
12
+ version = spec['version']
13
13
  end
14
14
 
15
15
  super(
16
16
  name,
17
17
  version,
18
18
  options.merge(
19
- summary: spec["description"],
20
- description: spec["readme"],
21
- homepage: spec["homepage"],
19
+ summary: spec['description'],
20
+ description: spec['readme'],
21
+ homepage: spec['homepage'],
22
22
  spec_licenses: Package.license_names_from_standard_spec(spec),
23
- install_path: bower_module["canonicalDir"],
24
- missing: bower_module["missing"]
23
+ install_path: bower_module['canonicalDir'],
24
+ missing: bower_module['missing']
25
25
  )
26
26
  )
27
27
  end
@@ -1,24 +1,24 @@
1
- require "bundler"
1
+ require 'bundler'
2
2
 
3
3
  module LicenseFinder
4
4
  class Bundler < PackageManager
5
- def initialize options={}
5
+ def initialize(options = {})
6
6
  super
7
7
  @ignored_groups = options[:ignored_groups]
8
- @definition = options[:definition] # dependency injection for tests
8
+ @definition = options[:definition] # dependency injection for tests
9
9
  end
10
10
 
11
11
  def current_packages
12
12
  logger.log self.class, "including groups #{included_groups.inspect}"
13
13
  details.map do |gem_detail, bundle_detail|
14
14
  BundlerPackage.new(gem_detail, bundle_detail, logger: logger).tap do |package|
15
- logger.package self.class, package
15
+ log_package_dependencies package
16
16
  end
17
17
  end
18
18
  end
19
19
 
20
20
  def self.package_management_command
21
- "bundle"
21
+ 'bundle'
22
22
  end
23
23
 
24
24
  private
@@ -27,12 +27,12 @@ module LicenseFinder
27
27
 
28
28
  def definition
29
29
  # DI
30
- @definition ||= ::Bundler::Definition.build(package_path, lockfile_path, nil)
30
+ @definition ||= ::Bundler::Definition.build(detected_package_path, lockfile_path, nil)
31
31
  end
32
32
 
33
33
  def details
34
34
  gem_details.map do |gem_detail|
35
- bundle_detail = bundler_details.detect { |bundle_detail| bundle_detail.name == gem_detail.name }
35
+ bundle_detail = bundler_details.detect { |bundler_detail| bundler_detail.name == gem_detail.name }
36
36
  [gem_detail, bundle_detail]
37
37
  end
38
38
  end
@@ -49,12 +49,24 @@ module LicenseFinder
49
49
  definition.groups - ignored_groups.map(&:to_sym)
50
50
  end
51
51
 
52
- def package_path
53
- project_path.join("Gemfile")
52
+ def possible_package_paths
53
+ [project_path.join('Gemfile')]
54
54
  end
55
55
 
56
56
  def lockfile_path
57
57
  project_path.join('Gemfile.lock')
58
58
  end
59
+
60
+ def log_package_dependencies(package)
61
+ dependencies = package.children
62
+ if dependencies.empty?
63
+ logger.log self.class, format("package '%s' has no dependencies", package.name)
64
+ else
65
+ logger.log self.class, format("package '%s' has dependencies:", package.name)
66
+ dependencies.each do |dep|
67
+ logger.log self.class, format('- %s', dep)
68
+ end
69
+ end
70
+ end
59
71
  end
60
72
  end
@@ -1,6 +1,6 @@
1
1
  module LicenseFinder
2
2
  class BundlerPackage < Package
3
- def initialize(spec, bundler_def, options={})
3
+ def initialize(spec, bundler_def, options = {})
4
4
  children = spec.dependencies.map(&:name)
5
5
  groups = Array(bundler_def && bundler_def.groups).map(&:to_s)
6
6
 
@@ -0,0 +1,66 @@
1
+ require 'json'
2
+
3
+ module LicenseFinder
4
+ class Carthage < PackageManager
5
+ class CarthageError < RuntimeError; end
6
+
7
+ def current_packages
8
+ cartfile.each_line.map do |line|
9
+ name, version = name_version_from_line line
10
+
11
+ CarthagePackage.new(
12
+ name,
13
+ version,
14
+ license_text(name),
15
+ logger: logger,
16
+ install_path: project_checkout(name)
17
+ )
18
+ end
19
+ end
20
+
21
+ def self.package_management_command
22
+ LicenseFinder::Platform.darwin? ? 'carthage' : nil
23
+ end
24
+
25
+ private
26
+
27
+ def cartfile
28
+ if File.exist?(resolved_path)
29
+ @cartfile ||= IO.read(resolved_path)
30
+ else
31
+ raise CarthageError, 'No Cartfile.resolved found.
32
+ Please install your dependencies first.'
33
+ end
34
+ end
35
+
36
+ def possible_package_paths
37
+ [public_dependency_path]
38
+ end
39
+
40
+ def public_dependency_path
41
+ project_path.join('Cartfile')
42
+ end
43
+
44
+ def resolved_path
45
+ project_path.join('Cartfile.resolved')
46
+ end
47
+
48
+ def project_checkout(name)
49
+ project_path.join('Carthage', 'Checkouts', name)
50
+ end
51
+
52
+ def license_text(name)
53
+ license_path = license_pattern(name).find { |f| File.exist?(f) }
54
+ license_path.nil? ? nil : IO.read(license_path)
55
+ end
56
+
57
+ def license_pattern(name)
58
+ checkout_path = project_checkout(name)
59
+ Dir.glob(checkout_path.join('LICENSE*'), File::FNM_CASEFOLD)
60
+ end
61
+
62
+ def name_version_from_line(cartfile_line)
63
+ cartfile_line.split(' ')[1, 2].map { |f| f.split('/').last.delete('"').gsub('.git', '') }
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,16 @@
1
+ module LicenseFinder
2
+ class CarthagePackage < Package
3
+ def initialize(name, version, license_text, options = {})
4
+ super(name, version, options)
5
+ @license = License.find_by_text(license_text.to_s)
6
+ end
7
+
8
+ def licenses_from_spec
9
+ [@license].compact
10
+ end
11
+
12
+ def package_manager
13
+ 'Carthage'
14
+ end
15
+ end
16
+ end
@@ -1,11 +1,11 @@
1
- require "json"
1
+ require 'json'
2
2
 
3
3
  module LicenseFinder
4
4
  class CocoaPods < PackageManager
5
5
  def current_packages
6
6
  podfile = YAML.load_file(lockfile_path)
7
7
 
8
- podfile["PODS"].map do |pod|
8
+ podfile['PODS'].map do |pod|
9
9
  pod = pod.keys.first if pod.is_a?(Hash)
10
10
 
11
11
  name, version = pod.scan(/(.*)\s\((.*)\)/).flatten
@@ -20,34 +20,34 @@ module LicenseFinder
20
20
  end
21
21
 
22
22
  def self.package_management_command
23
- LicenseFinder::Platform.darwin? ? "pod" : nil
23
+ LicenseFinder::Platform.darwin? ? 'pod' : nil
24
24
  end
25
25
 
26
26
  private
27
27
 
28
- def package_path
29
- project_path.join("Podfile")
28
+ def possible_package_paths
29
+ [project_path.join('Podfile')]
30
30
  end
31
31
 
32
32
  def lockfile_path
33
- project_path.join("Podfile.lock")
33
+ project_path.join('Podfile.lock')
34
34
  end
35
35
 
36
36
  def license_texts
37
37
  # package name => license text
38
- @license_texts ||= read_plist(acknowledgements_path)["PreferenceSpecifiers"]
39
- .each_with_object({}) { |hash, memo| memo[hash["Title"]] = hash["FooterText"] }
38
+ @license_texts ||= read_plist(acknowledgements_path)['PreferenceSpecifiers']
39
+ .each_with_object({}) { |hash, memo| memo[hash['Title']] = hash['FooterText'] }
40
40
  end
41
41
 
42
42
  def acknowledgements_path
43
- search_paths = [ "Pods/Pods-acknowledgements.plist",
44
- "Pods/Target Support Files/Pods/Pods-acknowledgements.plist",
45
- "Pods/Target Support Files/Pods-*/Pods-*-acknowledgements.plist" ]
43
+ search_paths = ['Pods/Pods-acknowledgements.plist',
44
+ 'Pods/Target Support Files/Pods/Pods-acknowledgements.plist',
45
+ 'Pods/Target Support Files/Pods-*/Pods-*-acknowledgements.plist']
46
46
 
47
- Dir[*search_paths.map {|path| File.join(project_path, path) }].first
47
+ Dir[*search_paths.map { |path| File.join(project_path, path) }].first
48
48
  end
49
49
 
50
- def read_plist pathname
50
+ def read_plist(pathname)
51
51
  JSON.parse(`plutil -convert json -o - '#{pathname}'`)
52
52
  end
53
53
  end
@@ -1,6 +1,6 @@
1
1
  module LicenseFinder
2
2
  class CocoaPodsPackage < Package
3
- def initialize(name, version, license_text, options={})
3
+ def initialize(name, version, license_text, options = {})
4
4
  super(name, version, options)
5
5
  @license = License.find_by_text(license_text.to_s)
6
6
  end
@@ -0,0 +1,26 @@
1
+ require_relative 'conan_info_parser'
2
+
3
+ module LicenseFinder
4
+ class Conan < PackageManager
5
+ def possible_package_paths
6
+ [project_path.join('conanfile.txt')]
7
+ end
8
+
9
+ def current_packages
10
+ install_command = 'conan install'
11
+ info_command = 'conan info'
12
+ Dir.chdir(project_path) { Cmd.run(install_command) }
13
+ info_output, _stderr, _status = Dir.chdir(project_path) { Cmd.run(info_command) }
14
+
15
+ info_parser = ConanInfoParser.new
16
+
17
+ deps = info_parser.parse(info_output)
18
+ deps.map do |dep|
19
+ name, version = dep['name'].split('@').first.split('/')
20
+ url = dep['URL']
21
+ license_file_path = Dir.glob("#{project_path}/licenses/#{name}/**/LICENSE*").first
22
+ ConanPackage.new(name, version, File.open(license_file_path).read, url) unless name == 'PROJECT'
23
+ end.compact
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,74 @@
1
+ module LicenseFinder
2
+ class ConanInfoParser
3
+ def parse(info)
4
+ @lines = info.lines.map(&:chomp)
5
+ @state = :project_level # state of the state machine
6
+ @projects = [] # list of projects
7
+ @current_project = nil # current project being populated in the SM
8
+ @current_vals = [] # current val list being populate in the SM
9
+ @current_key = nil # current key to be associated with the current val
10
+ while (line = @lines.shift)
11
+ next if line == ''
12
+ case @state
13
+ when :project_level
14
+ @current_project = {}
15
+ @current_project['name'] = line.strip
16
+ @state = :key_val
17
+ when :key_val
18
+ parse_key_val(line)
19
+ when :val_list
20
+ parse_val_list(line)
21
+ end
22
+ end
23
+ wrap_up
24
+ end
25
+
26
+ private
27
+
28
+ def parse_key_val(line)
29
+ key, val = key_val(line)
30
+ if val
31
+ @current_project[key] = val
32
+ elsif line.start_with?(' ')
33
+ @current_key = key
34
+ @current_vals = []
35
+ @state = :val_list
36
+ else
37
+ change_to_new_project_state line
38
+ end
39
+ end
40
+
41
+ def parse_val_list(line)
42
+ if val_list_level(line)
43
+ @current_vals << line.strip
44
+ else
45
+ @current_project[@current_key] = @current_vals
46
+ if line.start_with?(' ')
47
+ @state = :key_val
48
+ @lines.unshift(line)
49
+ else
50
+ change_to_new_project_state line
51
+ end
52
+ end
53
+ end
54
+
55
+ def wrap_up
56
+ if @current_vals.count && @current_key then @current_project[@current_key] = @current_vals end
57
+ @projects << @current_project
58
+ end
59
+
60
+ def val_list_level(line)
61
+ line.start_with?(' ')
62
+ end
63
+
64
+ def change_to_new_project_state(line)
65
+ @state = :project_level
66
+ @projects << @current_project
67
+ @lines.unshift(line)
68
+ end
69
+
70
+ def key_val(info)
71
+ info.split(':', 2).map(&:strip!)
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,17 @@
1
+ module LicenseFinder
2
+ class ConanPackage < Package
3
+ def initialize(name, version, license_text, url, options = {})
4
+ super(name, version, options)
5
+ @license = License.find_by_text(license_text.to_s)
6
+ @homepage = url
7
+ end
8
+
9
+ def licenses_from_spec
10
+ [@license].compact
11
+ end
12
+
13
+ def package_manager
14
+ 'Conan'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ require 'toml'
2
+
3
+ module LicenseFinder
4
+ class Dep < PackageManager
5
+ def possible_package_paths
6
+ [project_path.join('Gopkg.lock')]
7
+ end
8
+
9
+ def current_packages
10
+ toml = TOML.load_file(detected_package_path)
11
+ projects = toml['projects']
12
+ projects.map do |project|
13
+ GoPackage.from_dependency({
14
+ 'ImportPath' => project['name'],
15
+ 'InstallPath' => project_path.join('vendor', project['name']),
16
+ 'Rev' => project['revision']
17
+ }, nil, true)
18
+ end
19
+ end
20
+
21
+ def self.takes_priority_over
22
+ Go15VendorExperiment
23
+ end
24
+
25
+ def self.prepare_command
26
+ 'dep ensure'
27
+ end
28
+
29
+ def self.package_management_command
30
+ 'dep'
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ module LicenseFinder
2
+ class Glide < PackageManager
3
+ def possible_package_paths
4
+ [project_path.join('src', 'glide.lock'), project_path.join('glide.lock')]
5
+ end
6
+
7
+ def current_packages
8
+ YAML.load_file(detected_package_path).fetch('imports').map do |package_hash|
9
+ import_path = package_hash.fetch('name')
10
+ GoPackage.from_dependency({
11
+ 'ImportPath' => import_path,
12
+ 'InstallPath' => project_path.join('src', 'vendor', import_path),
13
+ 'Rev' => package_hash.fetch('version')
14
+ }, nil, true)
15
+ end
16
+ end
17
+
18
+ def self.takes_priority_over
19
+ Go15VendorExperiment
20
+ end
21
+
22
+ def self.package_management_command
23
+ 'glide'
24
+ end
25
+
26
+ def self.prepare_command
27
+ 'glide install'
28
+ end
29
+ end
30
+ end