license_finder 4.0.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -2
  3. data/CHANGELOG.md +16 -1
  4. data/CONTRIBUTING.md +23 -5
  5. data/Gemfile +0 -1
  6. data/README.md +6 -1
  7. data/Rakefile +2 -2
  8. data/ci/pipelines/pipeline.yml.erb +1 -1
  9. data/ci/pipelines/release.yml +14 -23
  10. data/ci/scripts/pushscript.sh +1 -2
  11. data/ci/scripts/run-rubocop.sh +1 -1
  12. data/ci/scripts/updateChangelog.sh +77 -0
  13. data/ci/tasks/build.yml +1 -1
  14. data/ci/tasks/update-changelog.yml +15 -0
  15. data/lib/license_finder/cli/base.rb +19 -13
  16. data/lib/license_finder/cli/main.rb +54 -37
  17. data/lib/license_finder/cli/makes_decisions.rb +3 -2
  18. data/lib/license_finder/configuration.rb +68 -15
  19. data/lib/license_finder/core.rb +17 -7
  20. data/lib/license_finder/decisions_factory.rb +11 -0
  21. data/lib/license_finder/license/templates/SimplifiedBSD.txt +1 -1
  22. data/lib/license_finder/license_aggregator.rb +11 -6
  23. data/lib/license_finder/logger.rb +2 -2
  24. data/lib/license_finder/package.rb +18 -16
  25. data/lib/license_finder/package_manager.rb +40 -47
  26. data/lib/license_finder/package_managers/bower.rb +8 -4
  27. data/lib/license_finder/package_managers/bundler.rb +8 -5
  28. data/lib/license_finder/package_managers/carthage.rb +4 -4
  29. data/lib/license_finder/package_managers/cocoa_pods.rb +2 -2
  30. data/lib/license_finder/package_managers/conan.rb +1 -1
  31. data/lib/license_finder/package_managers/gradle.rb +1 -1
  32. data/lib/license_finder/package_managers/maven.rb +1 -3
  33. data/lib/license_finder/package_managers/mix.rb +8 -4
  34. data/lib/license_finder/package_managers/npm.rb +5 -1
  35. data/lib/license_finder/package_managers/pip.rb +2 -2
  36. data/lib/license_finder/package_managers/rebar.rb +4 -4
  37. data/lib/license_finder/package_managers/yarn.rb +2 -2
  38. data/lib/license_finder/{packages → package_utils}/activation.rb +0 -0
  39. data/lib/license_finder/{package_managers → package_utils}/conan_info_parser.rb +1 -1
  40. data/lib/license_finder/{package_managers → package_utils}/gradle_dependency_finder.rb +0 -0
  41. data/lib/license_finder/{packages → package_utils}/license_files.rb +1 -1
  42. data/lib/license_finder/{packages → package_utils}/licensing.rb +1 -1
  43. data/lib/license_finder/{package_managers → package_utils}/maven_dependency_finder.rb +0 -0
  44. data/lib/license_finder/{packages → package_utils}/possible_license_file.rb +0 -0
  45. data/lib/license_finder/{package_managers → packages}/bower_package.rb +0 -0
  46. data/lib/license_finder/{package_managers → packages}/bundler_package.rb +0 -0
  47. data/lib/license_finder/{package_managers → packages}/carthage_package.rb +0 -0
  48. data/lib/license_finder/{package_managers → packages}/cocoa_pods_package.rb +0 -0
  49. data/lib/license_finder/{package_managers → packages}/conan_package.rb +0 -0
  50. data/lib/license_finder/{package_managers → packages}/go_package.rb +0 -0
  51. data/lib/license_finder/{package_managers → packages}/gradle_package.rb +0 -0
  52. data/lib/license_finder/{package_managers → packages}/maven_package.rb +0 -0
  53. data/lib/license_finder/packages/merged_package.rb +42 -0
  54. data/lib/license_finder/{package_managers → packages}/mix_package.rb +0 -0
  55. data/lib/license_finder/{package_managers → packages}/npm_package.rb +0 -0
  56. data/lib/license_finder/{package_managers → packages}/nuget_package.rb +0 -0
  57. data/lib/license_finder/{package_managers → packages}/pip_package.rb +0 -0
  58. data/lib/license_finder/{package_managers → packages}/rebar_package.rb +0 -0
  59. data/lib/license_finder/packages/yarn_package.rb +7 -0
  60. data/lib/license_finder/project_finder.rb +1 -1
  61. data/lib/license_finder/reports/csv_report.rb +1 -0
  62. data/lib/license_finder/reports/merged_report.rb +2 -0
  63. data/lib/license_finder/reports/templates/html_report.erb +8 -0
  64. data/lib/license_finder/reports/templates/markdown_report.erb +7 -0
  65. data/lib/license_finder/scanner.rb +38 -0
  66. data/lib/license_finder/version.rb +1 -1
  67. data/license_finder.gemspec +9 -2
  68. metadata +37 -101
  69. data/ci/tasks/get-version-and-tag.yml +0 -20
  70. data/features/features/cli/cli_spec.rb +0 -63
  71. data/features/features/configure/add_dependencies_spec.rb +0 -54
  72. data/features/features/configure/approve_dependencies_spec.rb +0 -61
  73. data/features/features/configure/assign_licenses_spec.rb +0 -35
  74. data/features/features/configure/blacklist_licenses_spec.rb +0 -30
  75. data/features/features/configure/ignore_dependencies_spec.rb +0 -35
  76. data/features/features/configure/ignore_groups_spec.rb +0 -46
  77. data/features/features/configure/name_project_spec.rb +0 -33
  78. data/features/features/configure/set_project_path_spec.rb +0 -17
  79. data/features/features/configure/whitelist_licenses_spec.rb +0 -38
  80. data/features/features/package_managers/bower_spec.rb +0 -14
  81. data/features/features/package_managers/carthage_spec.rb +0 -14
  82. data/features/features/package_managers/cocoapods_spec.rb +0 -14
  83. data/features/features/package_managers/conan_spec.rb +0 -11
  84. data/features/features/package_managers/dep_spec.rb +0 -15
  85. data/features/features/package_managers/glide_spec.rb +0 -26
  86. data/features/features/package_managers/godep_spec.rb +0 -17
  87. data/features/features/package_managers/govendor_spec.rb +0 -15
  88. data/features/features/package_managers/gradle_spec.rb +0 -34
  89. data/features/features/package_managers/gvt_spec.rb +0 -14
  90. data/features/features/package_managers/maven_spec.rb +0 -22
  91. data/features/features/package_managers/mix_spec.rb +0 -16
  92. data/features/features/package_managers/npm_spec.rb +0 -14
  93. data/features/features/package_managers/nuget_spec.rb +0 -14
  94. data/features/features/package_managers/pip_spec.rb +0 -14
  95. data/features/features/package_managers/rebar_spec.rb +0 -14
  96. data/features/features/package_managers/yarn_spec.rb +0 -14
  97. data/features/features/report/composite_spec.rb +0 -28
  98. data/features/features/report/csv_spec.rb +0 -18
  99. data/features/features/report/diff_spec.rb +0 -203
  100. data/features/features/report/html_spec.rb +0 -51
  101. data/features/features/report/java_groups_spec.rb +0 -11
  102. data/features/features/report/subproject_spec.rb +0 -63
  103. data/features/fixtures/Cartfile +0 -1
  104. data/features/fixtures/Podfile +0 -3
  105. data/features/fixtures/alternate-build-file-gradle/build-alt.gradle +0 -16
  106. data/features/fixtures/alternate-build-file-gradle/settings.gradle +0 -1
  107. data/features/fixtures/build.gradle +0 -16
  108. data/features/fixtures/conanfile.txt +0 -11
  109. data/features/fixtures/file-based-libs-gradle/build.gradle +0 -16
  110. data/features/fixtures/file-based-libs-gradle/libs/data.json-0.2.3.jar +0 -0
  111. data/features/fixtures/gopath/src/github.com/pivotal/foo/Godeps/Godeps.json +0 -16
  112. data/features/fixtures/gopath/src/github.com/pivotal/foo/Godeps/Readme +0 -5
  113. data/features/fixtures/gopath/src/github.com/pivotal/foo/foo.go +0 -6
  114. data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.lock +0 -14
  115. data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.toml +0 -7
  116. data/features/fixtures/gopath_dep/src/foo-dep/bar/bar.go +0 -10
  117. data/features/fixtures/gopath_dep/src/foo-dep/foo.go +0 -7
  118. data/features/fixtures/gopath_dep/src/foo-dep/vendor/a/b/LICENSE +0 -1
  119. data/features/fixtures/gopath_glide/src/glide.lock +0 -9
  120. data/features/fixtures/gopath_glide/src/glide.yaml +0 -6
  121. data/features/fixtures/gopath_glide_without_src/glide.lock +0 -9
  122. data/features/fixtures/gopath_glide_without_src/glide.yaml +0 -6
  123. data/features/fixtures/gopath_govendor/src/vendor/vendor.json +0 -19
  124. data/features/fixtures/gopath_gvt/src/vendor/manifest +0 -22
  125. data/features/fixtures/gradle-wrapper/build.gradle +0 -16
  126. data/features/fixtures/gradle-wrapper/gradlew +0 -8
  127. data/features/fixtures/gradle-wrapper/gradlew.bat +0 -9
  128. data/features/fixtures/maven-wrapper/mvnw +0 -3
  129. data/features/fixtures/maven-wrapper/mvnw.cmd +0 -7
  130. data/features/fixtures/maven-wrapper/pom.xml +0 -37
  131. data/features/fixtures/mix.exs +0 -22
  132. data/features/fixtures/multi-module-gradle/build.gradle +0 -12
  133. data/features/fixtures/multi-module-gradle/module1/build.gradle +0 -3
  134. data/features/fixtures/multi-module-gradle/module2/build.gradle +0 -3
  135. data/features/fixtures/multi-module-gradle/settings.gradle +0 -1
  136. data/features/fixtures/nuget/.nuget/.keep +0 -0
  137. data/features/fixtures/nuget/Fun.Test/packages.config +0 -4
  138. data/features/fixtures/nuget/Fun/packages.config +0 -5
  139. data/features/fixtures/pom.xml +0 -19
  140. data/features/fixtures/rebar.config +0 -12
  141. data/features/fixtures/single-module-gradle/build.gradle +0 -16
  142. data/features/support/feature_helper.rb +0 -15
  143. data/features/support/testing_dsl.rb +0 -564
  144. data/lib/license_finder/package_managers/merged_package.rb +0 -95
  145. data/license_finder-2.1.2.gem +0 -0
@@ -1,16 +0,0 @@
1
- plugins {
2
- id 'com.github.hierynomus.license' version '0.14.0'
3
- }
4
-
5
- apply plugin: 'java'
6
-
7
- sourceCompatibility = 1.5
8
- version = '1.0'
9
-
10
- repositories {
11
- mavenCentral()
12
- }
13
-
14
- dependencies {
15
- compile 'junit:junit:4.11'
16
- }
@@ -1,15 +0,0 @@
1
- # These are integration tests, so reaching directly into LicenseFinder is forbidden
2
- # DO NOT:
3
- # require 'rubygems'
4
- # require 'bundler/setup'
5
- # require 'license_finder'
6
-
7
- require_relative 'testing_dsl'
8
-
9
- RSpec.configure do |rspec|
10
- rspec.default_formatter = 'doc'
11
-
12
- rspec.before(:each) do
13
- LicenseFinder::TestingDSL::Paths.reset_projects!
14
- end
15
- end
@@ -1,564 +0,0 @@
1
- require 'delegate'
2
- require 'English'
3
-
4
- module LicenseFinder
5
- module TestingDSL
6
- class User
7
- def run_license_finder(path = nil, options = '')
8
- if path
9
- execute_command_in_path("license_finder --quiet #{options}", Paths.project("my_app/#{path}"))
10
- else
11
- execute_command "license_finder --quiet #{options}"
12
- end
13
- end
14
-
15
- def create_empty_project(name = 'my_app')
16
- EmptyProject.create(name)
17
- end
18
-
19
- def create_ruby_app(name = 'my_app')
20
- BundlerProject.create(name)
21
- end
22
-
23
- def create_gem(name, options)
24
- GemProject.create(name, options)
25
- end
26
-
27
- def create_gem_in_path(name, path, options)
28
- GemProject.create_in_path(name, path, options)
29
- end
30
-
31
- def execute_command(command)
32
- execute_command_in_path(command, Paths.project)
33
- end
34
-
35
- def execute_command_outside_project(command)
36
- execute_command_in_path(command, Paths.root)
37
- end
38
-
39
- def seeing?(content)
40
- @output.include? content
41
- end
42
-
43
- def seeing_once?(content)
44
- @output.scan(/#{Regexp.escape content}/).size == 1
45
- end
46
-
47
- def seeing_line?(content)
48
- seeing_something_like? /^#{Regexp.escape content}$/
49
- end
50
-
51
- def seeing_something_like?(regex)
52
- !!(@output =~ regex)
53
- end
54
-
55
- def receiving_exit_code?(code)
56
- @exit_code == code
57
- end
58
-
59
- def view_html
60
- execute_command 'license_finder report --format html'
61
- HtmlReport.from_string(@output)
62
- end
63
-
64
- private
65
-
66
- def execute_command_in_path(command, path)
67
- @output, @exit_code = path.shell_out(command, true)
68
- end
69
- end
70
-
71
- require 'forwardable'
72
- class Project
73
- extend Forwardable
74
- def_delegators :project_dir, :shell_out, :add_to_file, :install_fixture
75
-
76
- attr_reader :name
77
-
78
- def self.create(name = 'my_app')
79
- project = new(name)
80
- project.add_dep
81
- project.install
82
- project
83
- end
84
-
85
- def initialize(name = 'my_app')
86
- @name = name
87
- project_dir.make
88
- end
89
-
90
- def add_dep; end
91
-
92
- def install; end
93
-
94
- def project_dir
95
- Paths.project(name)
96
- end
97
-
98
- def clone(fixture_name)
99
- FileUtils.mkpath(Paths.my_app.join(fixture_name))
100
- FileUtils.cp_r(Paths.fixtures.join(fixture_name), Paths.my_app)
101
- end
102
- end
103
-
104
- class EmptyProject < Project
105
- end
106
-
107
- class PipProject < Project
108
- def add_dep
109
- add_to_file('requirements.txt', 'rsa==3.1.4')
110
- end
111
-
112
- def install
113
- shell_out('pip install -r requirements.txt --user')
114
- end
115
- end
116
-
117
- class NpmProject < Project
118
- def add_dep
119
- add_to_file('package.json', '{"dependencies" : {"http-server": "0.6.1"}}')
120
- end
121
-
122
- def install
123
- shell_out('npm install 2>/dev/null')
124
- end
125
- end
126
-
127
- class BowerProject < Project
128
- def add_dep
129
- add_to_file('bower.json', '{"name": "my_app", "dependencies" : {"gmaps": "0.2.30"}}')
130
- end
131
-
132
- def install
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"}}')
141
- end
142
- end
143
-
144
- class MavenProject < Project
145
- def add_dep
146
- install_fixture('pom.xml')
147
- end
148
-
149
- def install
150
- shell_out('mvn install')
151
- end
152
- end
153
-
154
- class BareGradleProject < Project
155
- def add_dep
156
- install_fixture('build.gradle')
157
- end
158
- end
159
-
160
- class GradleProject < Project
161
- def add_dep
162
- clone('single-module-gradle')
163
- end
164
-
165
- class MultiModule < Project
166
- def add_dep
167
- clone('multi-module-gradle')
168
- end
169
- end
170
-
171
- class FileBasedLibs < Project
172
- def add_dep
173
- clone('file-based-libs-gradle')
174
- end
175
- end
176
- end
177
-
178
- class AlternateBuildFileGradleProject < Project
179
- def add_dep
180
- clone('alternate-build-file-gradle')
181
- end
182
- end
183
-
184
- class GoProject < Project
185
- def add_dep
186
- clone('gopath')
187
- end
188
-
189
- def install
190
- orig_gopath = ENV['GOPATH']
191
- ENV['GOPATH'] = "#{project_dir}/gopath"
192
- shell_out('godep restore')
193
- ENV['GOPATH'] = orig_gopath
194
- end
195
-
196
- def shell_out(command)
197
- ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath', 'src', 'github.com', 'pivotal', 'foo')).shell_out(command)
198
- end
199
- end
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 GlideProjectWithoutSrc < Project
219
- def add_dep
220
- clone('gopath_glide_without_src')
221
- end
222
-
223
- def install
224
- src_path = File.join(project_dir, 'gopath_glide_without_src', 'src')
225
- FileUtils.mkdir_p(src_path)
226
-
227
- orig_gopath = ENV['GOPATH']
228
- ENV['GOPATH'] = "#{project_dir}/gopath_glide_without_src"
229
- shell_out('glide install')
230
- ENV['GOPATH'] = orig_gopath
231
-
232
- FileUtils.rmdir(src_path)
233
- end
234
-
235
- def shell_out(command)
236
- ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_glide_without_src')).shell_out(command)
237
- end
238
- end
239
-
240
- class GvtProject < Project
241
- def add_dep
242
- clone('gopath_gvt')
243
- end
244
-
245
- def install
246
- orig_gopath = ENV['GOPATH']
247
- ENV['GOPATH'] = "#{project_dir}/gopath_gvt"
248
- shell_out('gvt restore')
249
- ENV['GOPATH'] = orig_gopath
250
- end
251
-
252
- def shell_out(command)
253
- ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_gvt', 'src')).shell_out(command)
254
- end
255
- end
256
-
257
- class DepProject < Project
258
- def add_dep
259
- clone('gopath_dep')
260
- end
261
-
262
- def install
263
- orig_gopath = ENV['GOPATH']
264
- ENV['GOPATH'] = "#{project_dir}/gopath_dep"
265
- shell_out('dep ensure')
266
- ENV['GOPATH'] = orig_gopath
267
- end
268
-
269
- def shell_out(command)
270
- ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_dep', 'src', 'foo-dep')).shell_out(command)
271
- end
272
- end
273
-
274
- class BrokenSymLinkDepProject < Project
275
- def add_dep
276
- clone('gopath_dep')
277
- end
278
-
279
- def install; end
280
-
281
- def shell_out(command)
282
- ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_dep', 'src', 'foo-dep')).shell_out(command)
283
- end
284
- end
285
-
286
- class GovendorProject < Project
287
- def add_dep
288
- clone('gopath_govendor')
289
- end
290
-
291
- def install
292
- orig_gopath = ENV['GOPATH']
293
- ENV['GOPATH'] = "#{project_dir}/gopath_govendor"
294
- shell_out('govendor sync')
295
- ENV['GOPATH'] = orig_gopath
296
- end
297
-
298
- def shell_out(command)
299
- ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath_govendor', 'src')).shell_out(command)
300
- end
301
- end
302
-
303
- class CompositeProject < Project
304
- def add_dep
305
- clone('single-module-gradle')
306
- clone('multi-module-gradle')
307
- end
308
- end
309
-
310
- class CocoaPodsProject < Project
311
- def add_dep
312
- install_fixture('Podfile')
313
- end
314
-
315
- def install
316
- shell_out('pod install --no-integrate')
317
- end
318
- end
319
-
320
- class CarthageProject < Project
321
- def add_dep
322
- install_fixture('Cartfile')
323
- end
324
-
325
- def install
326
- shell_out('carthage bootstrap')
327
- end
328
- end
329
-
330
- class ConanProject < Project
331
- def add_dep
332
- install_fixture('conanfile.txt')
333
- end
334
-
335
- def install
336
- shell_out('conan install')
337
- end
338
- end
339
-
340
- class RebarProject < Project
341
- def add_dep
342
- install_fixture('rebar.config')
343
- end
344
-
345
- def install
346
- shell_out('rebar get-deps')
347
- end
348
- end
349
-
350
- class MixProject < Project
351
- def add_dep
352
- install_fixture('mix.exs')
353
- end
354
-
355
- def install
356
- shell_out('mix local.hex --force')
357
- shell_out('mix local.rebar --force')
358
- shell_out('mix deps.get')
359
- shell_out('mix deps.compile')
360
- end
361
- end
362
-
363
- class NugetProject < Project
364
- def add_dep
365
- clone('nuget')
366
- end
367
- end
368
-
369
- class BundlerProject < Project
370
- def add_dep
371
- add_to_gemfile("source 'https://rubygems.org'")
372
- add_gem_to_gemfile('license_finder', path: Paths.root.to_s)
373
- end
374
-
375
- def install
376
- shell_out('bundle install')
377
- end
378
-
379
- def depend_on(gem, bundler_options = {})
380
- add_gem_to_gemfile(gem.name, bundler_options.merge(path: gem.project_dir.to_s))
381
- install
382
- end
383
-
384
- private
385
-
386
- def add_gem_to_gemfile(gem_name, options)
387
- add_to_gemfile("gem #{gem_name.inspect}, #{options.inspect}")
388
- end
389
-
390
- def add_to_gemfile(content)
391
- add_to_file('Gemfile', content)
392
- end
393
- end
394
-
395
- # lives adjacent to a BundlerProject, so has a different lifecycle from other Projects and doesn't inherit
396
- class GemProject
397
- def self.create(name, options)
398
- result = new(name)
399
- result.define(options)
400
- result
401
- end
402
-
403
- def self.create_in_path(name, path, options)
404
- result = new(name, path)
405
- result.define(options)
406
- result
407
- end
408
-
409
- def initialize(name, path = nil)
410
- @name = name
411
- @path = path
412
- project_dir.make
413
- end
414
-
415
- def define(options)
416
- project_dir.write_file("#{name}.gemspec", gemspec_string(options))
417
- end
418
-
419
- attr_reader :name, :path
420
-
421
- def project_dir
422
- if path
423
- Paths.project(path + '/' + name)
424
- else
425
- Paths.project(name)
426
- end
427
- end
428
-
429
- private
430
-
431
- def gemspec_string(options)
432
- dependencies = Array(options[:dependencies]).map do |dep|
433
- %(s.add_dependency "#{dep}")
434
- end.join("\n")
435
-
436
- <<-GEMSPEC
437
- Gem::Specification.new do |s|
438
- s.name = "#{name}"
439
- s.version = "#{options[:version] || '0.0.0'}"
440
- s.license = "#{options.fetch(:license)}"
441
- s.author = "license_finder tests"
442
- s.summary = "#{options[:summary]}"
443
- s.description = "#{options[:description]}"
444
- s.homepage = "#{options[:homepage]}"
445
- #{dependencies}
446
- end
447
- GEMSPEC
448
- end
449
- end
450
-
451
- require 'capybara'
452
- class HtmlReport < SimpleDelegator
453
- # delegates to the parsed html
454
-
455
- def self.from_string(str)
456
- new(Capybara.string(str))
457
- end
458
-
459
- def in_dep(dep_name)
460
- result = find("##{dep_name}")
461
- yield result if block_given?
462
- result
463
- end
464
-
465
- def approved?(dep_name)
466
- classes_of(dep_name).include? 'approved'
467
- end
468
-
469
- def unapproved?(dep_name)
470
- classes_of(dep_name).include? 'unapproved'
471
- end
472
-
473
- def titled?(title)
474
- find('h1').has_content? title
475
- end
476
-
477
- private
478
-
479
- def classes_of(dep_name)
480
- in_dep(dep_name)[:class].split(' ')
481
- end
482
- end
483
-
484
- class ProjectDir < SimpleDelegator
485
- # delegates to a Pathname
486
-
487
- def shell_out(command, allow_failures = false)
488
- Dir.chdir(self) { Shell.run(command, allow_failures) }
489
- end
490
-
491
- def add_to_file(filename, content)
492
- join(filename).open('a') { |file| file.puts content }
493
- end
494
-
495
- def write_file(filename, content)
496
- join(filename).open('w') { |file| file.write content }
497
- end
498
-
499
- def install_fixture(fixture_name)
500
- if RUBY_PLATFORM =~ /mswin|cygwin|mingw/
501
- FileUtils.cp(Paths.fixtures.join(fixture_name), join(fixture_name))
502
- else
503
- join(fixture_name).make_symlink Paths.fixtures.join(fixture_name)
504
- end
505
- end
506
-
507
- def make
508
- mkpath
509
- end
510
- end
511
-
512
- require 'pathname'
513
- module Paths
514
- extend self
515
-
516
- def root
517
- # where license_finder is installed
518
- ProjectDir.new(Pathname.new(__FILE__).dirname.join('..', '..').realpath)
519
- end
520
-
521
- def fixtures
522
- root.join('features', 'fixtures')
523
- end
524
-
525
- def projects
526
- root.join('tmp', 'projects')
527
- end
528
-
529
- def my_app
530
- root.join('tmp', 'projects', 'my_app')
531
- end
532
-
533
- def project(name = 'my_app')
534
- ProjectDir.new(projects.join(name))
535
- end
536
-
537
- def reset_projects!
538
- # only destroyed when a test starts, so you can poke around after a failure
539
- require 'fileutils'
540
- FileUtils.rmtree(projects) if projects.exist?
541
- projects.mkpath
542
- end
543
- end
544
-
545
- module Shell
546
- ERROR_MESSAGE_FORMAT = <<ERRORFORMAT.freeze
547
- Command failed: `%s`
548
- output: %s
549
- exit: %d
550
- ERRORFORMAT
551
-
552
- def self.run(command, allow_failures = false)
553
- output = `#{command} 2>&1`
554
- status = $CHILD_STATUS
555
- unless status.success? || allow_failures
556
- message = format ERROR_MESSAGE_FORMAT, command, output.chomp, status.exitstatus
557
- raise message
558
- end
559
-
560
- [output, status.exitstatus]
561
- end
562
- end
563
- end
564
- end