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,20 +1,12 @@
1
- buildscript {
2
- repositories {
3
- maven {
4
- url 'https://plugins.gradle.org/m2/'
5
- }
6
- }
7
-
8
- dependencies {
9
- classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1'
10
- }
1
+ plugins {
2
+ id 'com.github.hierynomus.license' version '0.14.0' apply false
11
3
  }
12
4
 
13
5
  allprojects {
14
- apply plugin: 'java'
15
- apply plugin: 'license'
6
+ apply plugin: 'java'
7
+ apply plugin: 'license'
16
8
 
17
- repositories {
18
- mavenCentral()
19
- }
9
+ repositories {
10
+ mavenCentral()
11
+ }
20
12
  }
@@ -1,3 +1,7 @@
1
+ plugins {
2
+ id 'com.github.hierynomus.license' version '0.14.0'
3
+ }
4
+
1
5
  apply plugin: 'java'
2
6
 
3
7
  sourceCompatibility = 1.5
@@ -8,19 +12,5 @@ repositories {
8
12
  }
9
13
 
10
14
  dependencies {
11
- compile group: 'junit', name: 'junit', version: '4.11'
12
- }
13
-
14
- buildscript {
15
- repositories {
16
- maven {
17
- url 'https://plugins.gradle.org/m2/'
18
- }
19
- }
20
-
21
- dependencies {
22
- classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1'
23
- }
15
+ compile 'junit:junit:4.11'
24
16
  }
25
-
26
- apply plugin: 'license'
@@ -1,9 +1,10 @@
1
1
  require 'delegate'
2
+ require 'English'
2
3
 
3
4
  module LicenseFinder
4
5
  module TestingDSL
5
6
  class User
6
- def run_license_finder(path = nil, options='')
7
+ def run_license_finder(path = nil, options = '')
7
8
  if path
8
9
  execute_command_in_path("license_finder --quiet #{options}", Paths.project("my_app/#{path}"))
9
10
  else
@@ -11,11 +12,11 @@ module LicenseFinder
11
12
  end
12
13
  end
13
14
 
14
- def create_empty_project(name = "my_app")
15
+ def create_empty_project(name = 'my_app')
15
16
  EmptyProject.create(name)
16
17
  end
17
18
 
18
- def create_ruby_app(name = "my_app")
19
+ def create_ruby_app(name = 'my_app')
19
20
  BundlerProject.create(name)
20
21
  end
21
22
 
@@ -48,7 +49,7 @@ module LicenseFinder
48
49
  end
49
50
 
50
51
  def seeing_something_like?(regex)
51
- @output =~ regex
52
+ !!(@output =~ regex)
52
53
  end
53
54
 
54
55
  def receiving_exit_code?(code)
@@ -74,23 +75,21 @@ module LicenseFinder
74
75
 
75
76
  attr_reader :name
76
77
 
77
- def self.create(name = "my_app")
78
+ def self.create(name = 'my_app')
78
79
  project = new(name)
79
80
  project.add_dep
80
81
  project.install
81
82
  project
82
83
  end
83
84
 
84
- def initialize(name = "my_app")
85
+ def initialize(name = 'my_app')
85
86
  @name = name
86
87
  project_dir.make
87
88
  end
88
89
 
89
- def add_dep
90
- end
90
+ def add_dep; end
91
91
 
92
- def install
93
- end
92
+ def install; end
94
93
 
95
94
  def project_dir
96
95
  Paths.project(name)
@@ -107,21 +106,21 @@ module LicenseFinder
107
106
 
108
107
  class PipProject < Project
109
108
  def add_dep
110
- add_to_file("requirements.txt", 'rsa==3.1.4')
109
+ add_to_file('requirements.txt', 'rsa==3.1.4')
111
110
  end
112
111
 
113
112
  def install
114
- shell_out("pip install -r requirements.txt --user")
113
+ shell_out('pip install -r requirements.txt --user')
115
114
  end
116
115
  end
117
116
 
118
117
  class NpmProject < Project
119
118
  def add_dep
120
- add_to_file("package.json", '{"dependencies" : {"http-server": "0.6.1"}}')
119
+ add_to_file('package.json', '{"dependencies" : {"http-server": "0.6.1"}}')
121
120
  end
122
121
 
123
122
  def install
124
- shell_out("npm install 2>/dev/null")
123
+ shell_out('npm install 2>/dev/null')
125
124
  end
126
125
  end
127
126
 
@@ -131,17 +130,24 @@ module LicenseFinder
131
130
  end
132
131
 
133
132
  def install
134
- shell_out("bower install --allow-root 2>/dev/null")
133
+ shell_out('bower install --allow-root 2>/dev/null')
134
+ end
135
+ end
136
+
137
+ class YarnProject < Project
138
+ def add_dep
139
+ add_to_file('yarn.lock', '')
140
+ add_to_file('package.json', '{"dependencies" : {"http-server": "0.6.1"}}')
135
141
  end
136
142
  end
137
143
 
138
144
  class MavenProject < Project
139
145
  def add_dep
140
- install_fixture("pom.xml")
146
+ install_fixture('pom.xml')
141
147
  end
142
148
 
143
149
  def install
144
- shell_out("mvn install")
150
+ shell_out('mvn install')
145
151
  end
146
152
  end
147
153
 
@@ -183,7 +189,7 @@ module LicenseFinder
183
189
  def install
184
190
  orig_gopath = ENV['GOPATH']
185
191
  ENV['GOPATH'] = "#{project_dir}/gopath"
186
- shell_out("godep restore")
192
+ shell_out('godep restore')
187
193
  ENV['GOPATH'] = orig_gopath
188
194
  end
189
195
 
@@ -192,6 +198,74 @@ module LicenseFinder
192
198
  end
193
199
  end
194
200
 
201
+ class GlideProject < Project
202
+ def add_dep
203
+ clone('gopath_glide')
204
+ end
205
+
206
+ def install
207
+ orig_gopath = ENV['GOPATH']
208
+ ENV['GOPATH'] = "#{project_dir}/gopath_glide"
209
+ shell_out('glide install')
210
+ ENV['GOPATH'] = orig_gopath
211
+ end
212
+
213
+ def shell_out(command)
214
+ ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_glide', 'src')).shell_out(command)
215
+ end
216
+ end
217
+
218
+ class GvtProject < Project
219
+ def add_dep
220
+ clone('gopath_gvt')
221
+ end
222
+
223
+ def install
224
+ orig_gopath = ENV['GOPATH']
225
+ ENV['GOPATH'] = "#{project_dir}/gopath_gvt"
226
+ shell_out('gvt restore')
227
+ ENV['GOPATH'] = orig_gopath
228
+ end
229
+
230
+ def shell_out(command)
231
+ ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_gvt', 'src')).shell_out(command)
232
+ end
233
+ end
234
+
235
+ class DepProject < Project
236
+ def add_dep
237
+ clone('gopath_dep')
238
+ end
239
+
240
+ def install
241
+ orig_gopath = ENV['GOPATH']
242
+ ENV['GOPATH'] = "#{project_dir}/gopath_dep"
243
+ shell_out('dep ensure')
244
+ ENV['GOPATH'] = orig_gopath
245
+ end
246
+
247
+ def shell_out(command)
248
+ ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_dep', 'src', 'foo-dep')).shell_out(command)
249
+ end
250
+ end
251
+
252
+ class GovendorProject < Project
253
+ def add_dep
254
+ clone('gopath_govendor')
255
+ end
256
+
257
+ def install
258
+ orig_gopath = ENV['GOPATH']
259
+ ENV['GOPATH'] = "#{project_dir}/gopath_govendor"
260
+ shell_out('govendor sync')
261
+ ENV['GOPATH'] = orig_gopath
262
+ end
263
+
264
+ def shell_out(command)
265
+ ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_govendor', 'src')).shell_out(command)
266
+ end
267
+ end
268
+
195
269
  class CompositeProject < Project
196
270
  def add_dep
197
271
  clone('single-module-gradle')
@@ -201,21 +275,54 @@ module LicenseFinder
201
275
 
202
276
  class CocoaPodsProject < Project
203
277
  def add_dep
204
- install_fixture("Podfile")
278
+ install_fixture('Podfile')
205
279
  end
206
280
 
207
281
  def install
208
- shell_out("pod install --no-integrate")
282
+ shell_out('pod install --no-integrate')
283
+ end
284
+ end
285
+
286
+ class CarthageProject < Project
287
+ def add_dep
288
+ install_fixture('Cartfile')
289
+ end
290
+
291
+ def install
292
+ shell_out('carthage bootstrap')
293
+ end
294
+ end
295
+
296
+ class ConanProject < Project
297
+ def add_dep
298
+ install_fixture('conanfile.txt')
299
+ end
300
+
301
+ def install
302
+ shell_out('conan install')
209
303
  end
210
304
  end
211
305
 
212
306
  class RebarProject < Project
213
307
  def add_dep
214
- install_fixture("rebar.config")
308
+ install_fixture('rebar.config')
215
309
  end
216
310
 
217
311
  def install
218
- shell_out("rebar get-deps")
312
+ shell_out('rebar get-deps')
313
+ end
314
+ end
315
+
316
+ class MixProject < Project
317
+ def add_dep
318
+ install_fixture('mix.exs')
319
+ end
320
+
321
+ def install
322
+ shell_out('mix local.hex --force')
323
+ shell_out('mix local.rebar --force')
324
+ shell_out('mix deps.get')
325
+ shell_out('mix deps.compile')
219
326
  end
220
327
  end
221
328
 
@@ -232,7 +339,7 @@ module LicenseFinder
232
339
  end
233
340
 
234
341
  def install
235
- shell_out("bundle install")
342
+ shell_out('bundle install')
236
343
  end
237
344
 
238
345
  def depend_on(gem, bundler_options = {})
@@ -247,11 +354,12 @@ module LicenseFinder
247
354
  end
248
355
 
249
356
  def add_to_gemfile(content)
250
- add_to_file("Gemfile", content)
357
+ add_to_file('Gemfile', content)
251
358
  end
252
359
  end
253
360
 
254
- class GemProject # lives adjacent to a BundlerProject, so has a different lifecycle from other Projects and doesn't inherit
361
+ # lives adjacent to a BundlerProject, so has a different lifecycle from other Projects and doesn't inherit
362
+ class GemProject
255
363
  def self.create(name, options)
256
364
  result = new(name)
257
365
  result.define(options)
@@ -288,13 +396,13 @@ module LicenseFinder
288
396
 
289
397
  def gemspec_string(options)
290
398
  dependencies = Array(options[:dependencies]).map do |dep|
291
- %[s.add_dependency "#{dep}"]
399
+ %(s.add_dependency "#{dep}")
292
400
  end.join("\n")
293
401
 
294
402
  <<-GEMSPEC
295
403
  Gem::Specification.new do |s|
296
404
  s.name = "#{name}"
297
- s.version = "#{options[:version] || "0.0.0"}"
405
+ s.version = "#{options[:version] || '0.0.0'}"
298
406
  s.license = "#{options.fetch(:license)}"
299
407
  s.author = "license_finder tests"
300
408
  s.summary = "#{options[:summary]}"
@@ -307,7 +415,9 @@ module LicenseFinder
307
415
  end
308
416
 
309
417
  require 'capybara'
310
- class HtmlReport < SimpleDelegator # delegates to the parsed html
418
+ class HtmlReport < SimpleDelegator
419
+ # delegates to the parsed html
420
+
311
421
  def self.from_string(str)
312
422
  new(Capybara.string(str))
313
423
  end
@@ -319,15 +429,15 @@ module LicenseFinder
319
429
  end
320
430
 
321
431
  def approved?(dep_name)
322
- classes_of(dep_name).include? "approved"
432
+ classes_of(dep_name).include? 'approved'
323
433
  end
324
434
 
325
435
  def unapproved?(dep_name)
326
- classes_of(dep_name).include? "unapproved"
436
+ classes_of(dep_name).include? 'unapproved'
327
437
  end
328
438
 
329
439
  def titled?(title)
330
- find("h1").has_content? title
440
+ find('h1').has_content? title
331
441
  end
332
442
 
333
443
  private
@@ -337,7 +447,9 @@ module LicenseFinder
337
447
  end
338
448
  end
339
449
 
340
- class ProjectDir < SimpleDelegator # delegates to a Pathname
450
+ class ProjectDir < SimpleDelegator
451
+ # delegates to a Pathname
452
+
341
453
  def shell_out(command, allow_failures = false)
342
454
  Dir.chdir(self) { Shell.run(command, allow_failures) }
343
455
  end
@@ -369,22 +481,22 @@ module LicenseFinder
369
481
 
370
482
  def root
371
483
  # where license_finder is installed
372
- ProjectDir.new(Pathname.new(__FILE__).dirname.join("..", "..").realpath)
484
+ ProjectDir.new(Pathname.new(__FILE__).dirname.join('..', '..').realpath)
373
485
  end
374
486
 
375
487
  def fixtures
376
- root.join("features", "fixtures")
488
+ root.join('features', 'fixtures')
377
489
  end
378
490
 
379
491
  def projects
380
- root.join("tmp", "projects")
492
+ root.join('tmp', 'projects')
381
493
  end
382
494
 
383
495
  def my_app
384
- root.join("tmp", "projects", "my_app")
496
+ root.join('tmp', 'projects', 'my_app')
385
497
  end
386
498
 
387
- def project(name = "my_app")
499
+ def project(name = 'my_app')
388
500
  ProjectDir.new(projects.join(name))
389
501
  end
390
502
 
@@ -397,21 +509,21 @@ module LicenseFinder
397
509
  end
398
510
 
399
511
  module Shell
400
- ERROR_MESSAGE_FORMAT = <<EOM
512
+ ERROR_MESSAGE_FORMAT = <<ERRORFORMAT.freeze
401
513
  Command failed: `%s`
402
514
  output: %s
403
515
  exit: %d
404
- EOM
516
+ ERRORFORMAT
405
517
 
406
518
  def self.run(command, allow_failures = false)
407
519
  output = `#{command} 2>&1`
408
- status = $?
520
+ status = $CHILD_STATUS
409
521
  unless status.success? || allow_failures
410
- message = sprintf ERROR_MESSAGE_FORMAT, command, output.chomp, status.exitstatus
411
- raise RuntimeError.new(message)
522
+ message = format ERROR_MESSAGE_FORMAT, command, output.chomp, status.exitstatus
523
+ raise message
412
524
  end
413
525
 
414
- return [output, status.exitstatus]
526
+ [output, status.exitstatus]
415
527
  end
416
528
  end
417
529
  end
@@ -2,10 +2,11 @@ require 'pathname'
2
2
  require 'yaml'
3
3
 
4
4
  module LicenseFinder
5
- ROOT_PATH = Pathname.new(__FILE__).dirname.join("license_finder")
6
- BIN_PATH = ROOT_PATH.join("../../bin")
5
+ ROOT_PATH = Pathname.new(__FILE__).dirname.join('license_finder')
6
+ BIN_PATH = ROOT_PATH.join('../../bin')
7
7
  end
8
8
 
9
- require 'license_finder/core'
9
+ require 'license_finder/shared_helpers/cmd'
10
10
 
11
+ require 'license_finder/core'
11
12
  require 'license_finder/cli'