license_finder 2.0.4 → 2.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -4
  3. data/.travis/install_godep.sh +6 -0
  4. data/.travis/install_gradle.sh +1 -1
  5. data/.travis/install_rebar.sh +7 -5
  6. data/CHANGELOG.rdoc +13 -0
  7. data/CONTRIBUTING.md +16 -2
  8. data/README.md +41 -4
  9. data/Rakefile +8 -2
  10. data/features/features/{cli_spec.rb → cli/cli_spec.rb} +24 -18
  11. data/features/features/configure/add_dependencies_spec.rb +18 -1
  12. data/features/features/configure/approve_dependencies_spec.rb +31 -1
  13. data/features/features/configure/assign_licenses_spec.rb +18 -3
  14. data/features/features/configure/blacklist_licenses_spec.rb +30 -0
  15. data/features/features/configure/ignore_dependencies_spec.rb +1 -1
  16. data/features/features/configure/ignore_groups_spec.rb +16 -1
  17. data/features/features/configure/name_project_spec.rb +1 -1
  18. data/features/features/configure/set_project_path_spec.rb +1 -1
  19. data/features/features/configure/whitelist_licenses_spec.rb +1 -3
  20. data/features/features/package_managers/bower_spec.rb +1 -1
  21. data/features/features/package_managers/cocoapods_spec.rb +1 -1
  22. data/features/features/package_managers/godep_spec.rb +17 -0
  23. data/features/features/package_managers/gradle_spec.rb +18 -4
  24. data/features/features/package_managers/maven_spec.rb +1 -1
  25. data/features/features/package_managers/npm_spec.rb +1 -1
  26. data/features/features/package_managers/nuget_spec.rb +14 -0
  27. data/features/features/package_managers/pip_spec.rb +1 -1
  28. data/features/features/package_managers/rebar_spec.rb +1 -1
  29. data/features/features/report/composite_spec.rb +15 -0
  30. data/features/features/report/csv_spec.rb +1 -1
  31. data/features/features/report/diff_spec.rb +190 -0
  32. data/features/features/report/html_spec.rb +1 -1
  33. data/features/features/report/subproject_spec.rb +52 -0
  34. data/features/fixtures/file-based-libs-gradle/build.gradle +18 -0
  35. data/features/fixtures/file-based-libs-gradle/libs/data.json-0.2.3.jar +0 -0
  36. data/features/fixtures/gopath/src/github.com/pivotal/foo/Godeps/Godeps.json +16 -0
  37. data/features/fixtures/gopath/src/github.com/pivotal/foo/Godeps/Readme +5 -0
  38. data/features/fixtures/gopath/src/github.com/pivotal/foo/foo.go +6 -0
  39. data/features/fixtures/multi-module-gradle/build.gradle +18 -0
  40. data/features/fixtures/multi-module-gradle/module1/build.gradle +3 -0
  41. data/features/fixtures/multi-module-gradle/module2/build.gradle +3 -0
  42. data/features/fixtures/multi-module-gradle/settings.gradle +1 -0
  43. data/features/fixtures/nuget/Fun.Test/packages.config +4 -0
  44. data/features/fixtures/nuget/Fun/packages.config +5 -0
  45. data/features/fixtures/nuget/packages/Microsoft.AspNet.Mvc.4.0.30506.0/.keep +0 -0
  46. data/features/fixtures/nuget/packages/NUnit.2.6.4/.keep +0 -0
  47. data/features/fixtures/nuget/packages/Ninject.MVC4.3.2.1.0/.keep +0 -0
  48. data/features/fixtures/nuget/packages/repositories.config +6 -0
  49. data/features/fixtures/{build.gradle → single-module-gradle/build.gradle} +0 -0
  50. data/{spec → features/support}/feature_helper.rb +5 -1
  51. data/features/support/testing_dsl.rb +297 -212
  52. data/lib/license_finder/cli.rb +1 -0
  53. data/lib/license_finder/cli/base.rb +16 -3
  54. data/lib/license_finder/cli/blacklist.rb +30 -0
  55. data/lib/license_finder/cli/main.rb +62 -4
  56. data/lib/license_finder/configuration.rb +39 -8
  57. data/lib/license_finder/core.rb +13 -10
  58. data/lib/license_finder/decision_applier.rb +14 -9
  59. data/lib/license_finder/decisions.rb +24 -6
  60. data/lib/license_finder/diff.rb +47 -0
  61. data/lib/license_finder/license_aggregator.rb +25 -0
  62. data/lib/license_finder/package.rb +39 -6
  63. data/lib/license_finder/package_delta.rb +65 -0
  64. data/lib/license_finder/package_manager.rb +10 -3
  65. data/lib/license_finder/package_managers/bower.rb +3 -1
  66. data/lib/license_finder/package_managers/bundler.rb +18 -9
  67. data/lib/license_finder/package_managers/bundler_package.rb +6 -2
  68. data/lib/license_finder/package_managers/go_dep.rb +25 -0
  69. data/lib/license_finder/package_managers/go_package.rb +19 -0
  70. data/lib/license_finder/package_managers/go_workspace.rb +35 -0
  71. data/lib/license_finder/package_managers/gradle.rb +16 -17
  72. data/lib/license_finder/package_managers/gradle_dependency_finder.rb +13 -0
  73. data/lib/license_finder/package_managers/gradle_package.rb +6 -1
  74. data/lib/license_finder/package_managers/maven.rb +3 -1
  75. data/lib/license_finder/package_managers/merged_package.rb +43 -0
  76. data/lib/license_finder/package_managers/npm.rb +42 -24
  77. data/lib/license_finder/package_managers/nuget.rb +50 -0
  78. data/lib/license_finder/package_managers/nuget_package.rb +4 -0
  79. data/lib/license_finder/package_managers/pip_package.rb +1 -0
  80. data/lib/license_finder/package_managers/rebar.rb +2 -6
  81. data/lib/license_finder/platform.rb +4 -1
  82. data/lib/license_finder/project_finder.rb +56 -0
  83. data/lib/license_finder/report.rb +3 -2
  84. data/lib/license_finder/reports/csv_report.rb +6 -2
  85. data/lib/license_finder/reports/diff_report.rb +33 -0
  86. data/lib/license_finder/reports/merged_report.rb +13 -0
  87. data/lib/license_finder/version.rb +1 -1
  88. data/license_finder.gemspec +6 -2
  89. data/spec/dummy_app/Gemfile +6 -0
  90. data/spec/fixtures/all_pms/.envrc +0 -0
  91. data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
  92. data/spec/fixtures/all_pms/packages/.keep +0 -0
  93. data/spec/fixtures/composite/Gemfile +0 -0
  94. data/spec/fixtures/composite/nested_project/.envrc +8 -0
  95. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +16 -0
  96. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +5 -0
  97. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +6 -0
  98. data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
  99. data/spec/fixtures/composite/project1/Gemfile +0 -0
  100. data/spec/fixtures/composite/project2/package.json +0 -0
  101. data/spec/lib/license_finder/cli/approvals_spec.rb +1 -1
  102. data/spec/lib/license_finder/cli/blacklist_spec.rb +58 -0
  103. data/spec/lib/license_finder/cli/dependencies_spec.rb +1 -1
  104. data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +1 -1
  105. data/spec/lib/license_finder/cli/ignored_groups_spec.rb +1 -1
  106. data/spec/lib/license_finder/cli/licenses_spec.rb +1 -1
  107. data/spec/lib/license_finder/cli/main_spec.rb +113 -7
  108. data/spec/lib/license_finder/cli/project_name_spec.rb +1 -1
  109. data/spec/lib/license_finder/cli/whitelist_spec.rb +1 -1
  110. data/spec/lib/license_finder/configuration_spec.rb +63 -4
  111. data/spec/lib/license_finder/core_spec.rb +49 -0
  112. data/spec/lib/license_finder/decision_applier_spec.rb +101 -1
  113. data/spec/lib/license_finder/decisions_spec.rb +62 -0
  114. data/spec/lib/license_finder/diff_spec.rb +106 -0
  115. data/spec/lib/license_finder/license_aggregator_spec.rb +61 -0
  116. data/spec/lib/license_finder/package_delta_spec.rb +18 -0
  117. data/spec/lib/license_finder/package_managers/bower_spec.rb +8 -6
  118. data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +4 -2
  119. data/spec/lib/license_finder/package_managers/go_dep_spec.rb +72 -0
  120. data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +69 -0
  121. data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +9 -0
  122. data/spec/lib/license_finder/package_managers/gradle_spec.rb +94 -44
  123. data/spec/lib/license_finder/package_managers/maven_spec.rb +8 -6
  124. data/spec/lib/license_finder/package_managers/merged_package_spec.rb +52 -0
  125. data/spec/lib/license_finder/package_managers/npm_spec.rb +59 -20
  126. data/spec/lib/license_finder/package_managers/nuget_spec.rb +82 -0
  127. data/spec/lib/license_finder/package_managers/pip_package_spec.rb +1 -0
  128. data/spec/lib/license_finder/package_managers/rebar_spec.rb +12 -12
  129. data/spec/lib/license_finder/package_spec.rb +59 -2
  130. data/spec/lib/license_finder/project_finder_spec.rb +33 -0
  131. data/spec/lib/license_finder/reports/csv_report_spec.rb +9 -3
  132. data/spec/lib/license_finder/reports/diff_report_spec.rb +56 -0
  133. data/spec/lib/license_finder/reports/merged_report_spec.rb +21 -0
  134. metadata +82 -9
  135. data/.travis/install_virtualenv.sh +0 -9
@@ -0,0 +1,5 @@
1
+ This directory tree is generated automatically by godep.
2
+
3
+ Please do not edit.
4
+
5
+ See https://github.com/tools/godep for more information.
@@ -0,0 +1,6 @@
1
+ package foo
2
+
3
+ import (
4
+ . "github.com/onsi/ginkgo"
5
+ . "github.com/onsi/gomega"
6
+ )
@@ -0,0 +1,18 @@
1
+ buildscript {
2
+ repositories {
3
+ mavenCentral()
4
+ }
5
+
6
+ dependencies {
7
+ classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.7.0'
8
+ }
9
+ }
10
+
11
+ allprojects {
12
+ apply plugin: 'java'
13
+ apply plugin: 'license'
14
+
15
+ repositories {
16
+ mavenCentral()
17
+ }
18
+ }
@@ -0,0 +1,3 @@
1
+ dependencies {
2
+ compile 'junit:junit:4.12'
3
+ }
@@ -0,0 +1,3 @@
1
+ dependencies {
2
+ compile 'org.mockito:mockito-core:1.9.5'
3
+ }
@@ -0,0 +1 @@
1
+ include ':module1', ':module2'
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <packages>
3
+ <package id="NUnit" version="2.6.4" targetFramework="net45" />
4
+ </packages>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <packages>
3
+ <package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net45" />
4
+ <package id="Ninject.MVC4" version="3.2.1.0" targetFramework="net45" />
5
+ </packages>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <repositories>
3
+ <repository path="..\Fun.Javascript.Test\packages.config" />
4
+ <repository path="..\Fun.Test\packages.config" />
5
+ <repository path="..\Fun\packages.config" />
6
+ </repositories>
@@ -4,8 +4,12 @@
4
4
  # require 'bundler/setup'
5
5
  # require 'license_finder'
6
6
 
7
- require './features/support/testing_dsl'
7
+ require_relative 'testing_dsl'
8
8
 
9
9
  RSpec.configure do |rspec|
10
10
  rspec.default_formatter = 'doc'
11
+
12
+ rspec.before(:each) do
13
+ LicenseFinder::TestingDSL::Paths.reset_projects!
14
+ end
11
15
  end
@@ -1,203 +1,282 @@
1
1
  require 'delegate'
2
2
 
3
- module LicenseFinder::TestingDSL
4
- class User
5
- def run_license_finder
6
- execute_command "license_finder --quiet"
7
- end
3
+ module LicenseFinder
4
+ module TestingDSL
5
+ class User
6
+ def run_license_finder(path = nil)
7
+ if path
8
+ execute_command_in_path('license_finder --quiet', Paths.project("my_app/#{path}"))
9
+ else
10
+ execute_command 'license_finder --quiet'
11
+ end
12
+ end
8
13
 
9
- def create_empty_project
10
- EmptyProject.create
11
- end
14
+ def create_empty_project(name = "my_app")
15
+ EmptyProject.create(name)
16
+ end
12
17
 
13
- def create_ruby_app
14
- BundlerProject.create
15
- end
18
+ def create_ruby_app(name = "my_app")
19
+ BundlerProject.create(name)
20
+ end
16
21
 
17
- def create_gem(name, options)
18
- GemProject.create(name, options)
19
- end
22
+ def create_gem(name, options)
23
+ GemProject.create(name, options)
24
+ end
20
25
 
21
- def execute_command(command)
22
- execute_command_in_path(command, Paths.project)
23
- end
26
+ def create_gem_in_path(name, path, options)
27
+ GemProject.create_in_path(name, path, options)
28
+ end
24
29
 
25
- def execute_command_outside_project(command)
26
- execute_command_in_path(command, Paths.root)
27
- end
30
+ def execute_command(command)
31
+ execute_command_in_path(command, Paths.project)
32
+ end
28
33
 
29
- def seeing?(content)
30
- @output.include? content
31
- end
34
+ def execute_command_outside_project(command)
35
+ execute_command_in_path(command, Paths.root)
36
+ end
32
37
 
33
- def seeing_line?(content)
34
- seeing_something_like? /^#{Regexp.escape content}$/
35
- end
38
+ def seeing?(content)
39
+ @output.include? content
40
+ end
36
41
 
37
- def seeing_something_like?(regex)
38
- @output =~ regex
39
- end
42
+ def seeing_once?(content)
43
+ @output.scan(/#{Regexp.escape content}/).size == 1
44
+ end
40
45
 
41
- def receiving_exit_code?(code)
42
- @exit_code == code
43
- end
46
+ def seeing_line?(content)
47
+ seeing_something_like? /^#{Regexp.escape content}$/
48
+ end
44
49
 
45
- def view_html
46
- execute_command 'license_finder report --format html'
47
- HtmlReport.from_string(@output)
48
- end
50
+ def seeing_something_like?(regex)
51
+ @output =~ regex
52
+ end
49
53
 
50
- private
54
+ def receiving_exit_code?(code)
55
+ @exit_code == code
56
+ end
51
57
 
52
- def execute_command_in_path(command, path)
53
- @output, @exit_code = path.shell_out(command, true)
54
- end
55
- end
58
+ def view_html
59
+ execute_command 'license_finder report --format html'
60
+ HtmlReport.from_string(@output)
61
+ end
56
62
 
57
- require 'forwardable'
58
- class Project
59
- extend Forwardable
60
- def_delegators :project_dir, :shell_out, :add_to_file, :install_fixture
63
+ private
61
64
 
62
- def self.create
63
- project = new
64
- project.add_dep
65
- project.install
66
- project
65
+ def execute_command_in_path(command, path)
66
+ @output, @exit_code = path.shell_out(command, true)
67
+ end
67
68
  end
68
69
 
69
- def initialize
70
- Paths.reset_projects!
71
- project_dir.make
72
- end
70
+ require 'forwardable'
71
+ class Project
72
+ extend Forwardable
73
+ def_delegators :project_dir, :shell_out, :add_to_file, :install_fixture
73
74
 
74
- def add_dep
75
- end
75
+ attr_reader :name
76
76
 
77
- def install
78
- end
77
+ def self.create(name = "my_app")
78
+ project = new(name)
79
+ project.add_dep
80
+ project.install
81
+ project
82
+ end
79
83
 
80
- def project_dir
81
- Paths.project
82
- end
83
- end
84
+ def initialize(name = "my_app")
85
+ @name = name
86
+ project_dir.make
87
+ end
84
88
 
85
- class EmptyProject < Project
86
- end
89
+ def add_dep
90
+ end
87
91
 
88
- class PipProject < Project
89
- def add_dep
90
- add_to_file("requirements.txt", 'rsa==3.1.4')
91
- end
92
+ def install
93
+ end
92
94
 
93
- def install
94
- shell_out("pip install -r requirements.txt")
95
- end
96
- end
95
+ def project_dir
96
+ Paths.project(name)
97
+ end
97
98
 
98
- class NpmProject < Project
99
- def add_dep
100
- add_to_file("package.json", '{"dependencies" : {"http-server": "0.6.1"}}')
99
+ def clone(fixture_name)
100
+ FileUtils.mkpath(Paths.my_app.join(fixture_name))
101
+ FileUtils.cp_r(Paths.fixtures.join(fixture_name), Paths.my_app)
102
+ end
101
103
  end
102
104
 
103
- def install
104
- shell_out("npm install 2>/dev/null")
105
+ class EmptyProject < Project
105
106
  end
106
- end
107
107
 
108
- class BowerProject < Project
109
- def add_dep
110
- add_to_file('bower.json', '{"name": "my_app", "dependencies" : {"gmaps": "0.2.30"}}')
111
- end
108
+ class PipProject < Project
109
+ def add_dep
110
+ add_to_file("requirements.txt", 'rsa==3.1.4')
111
+ end
112
112
 
113
- def install
114
- shell_out("bower install 2>/dev/null")
113
+ def install
114
+ shell_out("pip install -r requirements.txt --user")
115
+ end
115
116
  end
116
- end
117
117
 
118
- class MavenProject < Project
119
- def add_dep
120
- install_fixture("pom.xml")
121
- end
118
+ class NpmProject < Project
119
+ def add_dep
120
+ add_to_file("package.json", '{"dependencies" : {"http-server": "0.6.1"}}')
121
+ end
122
122
 
123
- def install
124
- shell_out("mvn install")
123
+ def install
124
+ shell_out("npm install 2>/dev/null")
125
+ end
125
126
  end
126
- end
127
127
 
128
- class GradleProject < Project
129
- def add_dep
130
- install_fixture("build.gradle")
131
- end
132
- end
128
+ class BowerProject < Project
129
+ def add_dep
130
+ add_to_file('bower.json', '{"name": "my_app", "dependencies" : {"gmaps": "0.2.30"}}')
131
+ end
133
132
 
134
- class CocoaPodsProject < Project
135
- def add_dep
136
- install_fixture("Podfile")
133
+ def install
134
+ shell_out("bower install 2>/dev/null")
135
+ end
137
136
  end
138
137
 
139
- def install
140
- shell_out("pod install --no-integrate")
141
- end
142
- end
138
+ class MavenProject < Project
139
+ def add_dep
140
+ install_fixture("pom.xml")
141
+ end
143
142
 
144
- class RebarProject < Project
145
- def add_dep
146
- install_fixture("rebar.config")
143
+ def install
144
+ shell_out("mvn install")
145
+ end
147
146
  end
148
147
 
149
- def install
150
- shell_out("rebar get-deps")
151
- end
152
- end
148
+ class GradleProject < Project
149
+ def add_dep
150
+ clone('single-module-gradle')
151
+ end
152
+
153
+ class MultiModule < Project
154
+ def add_dep
155
+ clone('multi-module-gradle')
156
+ end
157
+ end
153
158
 
154
- class BundlerProject < Project
155
- def add_dep
156
- add_to_bundler('license_finder', path: Paths.root.to_s)
159
+ class FileBasedLibs < Project
160
+ def add_dep
161
+ clone('file-based-libs-gradle')
162
+ end
163
+ end
157
164
  end
158
165
 
159
- def install
160
- shell_out("bundle install")
166
+ class GoProject < Project
167
+ def add_dep
168
+ clone('gopath')
169
+ end
170
+
171
+ def install
172
+ shell_out("GOPATH=#{project_dir}/gopath godep restore")
173
+ end
174
+
175
+ def shell_out(command)
176
+ ProjectDir.new(Paths.root.join('tmp', 'projects', 'my_app', 'gopath', 'src', 'github.com', 'pivotal', 'foo')).shell_out(command)
177
+ end
161
178
  end
162
179
 
163
- def depend_on(gem, bundler_options = {})
164
- add_to_bundler(gem.name, bundler_options.merge(path: gem.project_dir.to_s))
165
- install
180
+ class CompositeProject < Project
181
+ def add_dep
182
+ clone('single-module-gradle')
183
+ clone('multi-module-gradle')
184
+ end
166
185
  end
167
186
 
168
- private
187
+ class CocoaPodsProject < Project
188
+ def add_dep
189
+ install_fixture("Podfile")
190
+ end
169
191
 
170
- def add_to_bundler(gem_name, options)
171
- add_to_file("Gemfile", "gem #{gem_name.inspect}, #{options.inspect}")
192
+ def install
193
+ shell_out("pod install --no-integrate")
194
+ end
172
195
  end
173
- end
174
196
 
175
- class GemProject # lives adjacent to a BundlerProject, so has a different lifecycle from other Projects and doesn't inherit
176
- def self.create(name, options)
177
- result = new(name)
178
- result.define(options)
179
- result
180
- end
197
+ class RebarProject < Project
198
+ def add_dep
199
+ install_fixture("rebar.config")
200
+ end
181
201
 
182
- def initialize(name)
183
- @name = name
184
- project_dir.make
202
+ def install
203
+ shell_out("rebar get-deps")
204
+ end
185
205
  end
186
206
 
187
- def define(options)
188
- project_dir.write_file("#{name}.gemspec", gemspec_string(options))
207
+ class NugetProject < Project
208
+ def add_dep
209
+ clone('nuget')
210
+ end
189
211
  end
190
212
 
191
- attr_reader :name
213
+ class BundlerProject < Project
214
+ def add_dep
215
+ add_to_gemfile("source 'https://rubygems.org'")
216
+ add_gem_to_gemfile('license_finder', path: Paths.root.to_s)
217
+ end
218
+
219
+ def install
220
+ shell_out("bundle install")
221
+ end
222
+
223
+ def depend_on(gem, bundler_options = {})
224
+ add_gem_to_gemfile(gem.name, bundler_options.merge(path: gem.project_dir.to_s))
225
+ install
226
+ end
227
+
228
+ private
229
+
230
+ def add_gem_to_gemfile(gem_name, options)
231
+ add_to_gemfile("gem #{gem_name.inspect}, #{options.inspect}")
232
+ end
192
233
 
193
- def project_dir
194
- Paths.project(name)
234
+ def add_to_gemfile(content)
235
+ add_to_file("Gemfile", content)
236
+ end
195
237
  end
196
238
 
197
- private
239
+ class GemProject # lives adjacent to a BundlerProject, so has a different lifecycle from other Projects and doesn't inherit
240
+ def self.create(name, options)
241
+ result = new(name)
242
+ result.define(options)
243
+ result
244
+ end
245
+
246
+ def self.create_in_path(name, path, options)
247
+ result = new(name, path)
248
+ result.define(options)
249
+ result
250
+ end
251
+
252
+ def initialize(name, path = nil)
253
+ @name = name
254
+ @path = path
255
+ project_dir.make
256
+ end
257
+
258
+ def define(options)
259
+ project_dir.write_file("#{name}.gemspec", gemspec_string(options))
260
+ end
261
+
262
+ attr_reader :name, :path
198
263
 
199
- def gemspec_string(options)
200
- <<-GEMSPEC
264
+ def project_dir
265
+ if path
266
+ Paths.project(path + '/' + name)
267
+ else
268
+ Paths.project(name)
269
+ end
270
+ end
271
+
272
+ private
273
+
274
+ def gemspec_string(options)
275
+ dependencies = Array(options[:dependencies]).map do |dep|
276
+ %[s.add_dependency "#{dep}"]
277
+ end.join("\n")
278
+
279
+ <<-GEMSPEC
201
280
  Gem::Specification.new do |s|
202
281
  s.name = "#{name}"
203
282
  s.version = "#{options[:version] || "0.0.0"}"
@@ -206,108 +285,114 @@ module LicenseFinder::TestingDSL
206
285
  s.summary = "#{options[:summary]}"
207
286
  s.description = "#{options[:description]}"
208
287
  s.homepage = "#{options[:homepage]}"
288
+ #{dependencies}
289
+ end
290
+ GEMSPEC
209
291
  end
210
- GEMSPEC
211
292
  end
212
- end
213
293
 
214
- require 'capybara'
215
- class HtmlReport < SimpleDelegator # delegates to the parsed html
216
- def self.from_string(str)
217
- new(Capybara.string(str))
218
- end
294
+ require 'capybara'
295
+ class HtmlReport < SimpleDelegator # delegates to the parsed html
296
+ def self.from_string(str)
297
+ new(Capybara.string(str))
298
+ end
219
299
 
220
- def in_dep(dep_name)
221
- result = find("##{dep_name}")
222
- yield result if block_given?
223
- result
224
- end
300
+ def in_dep(dep_name)
301
+ result = find("##{dep_name}")
302
+ yield result if block_given?
303
+ result
304
+ end
225
305
 
226
- def approved?(dep_name)
227
- classes_of(dep_name).include? "approved"
228
- end
306
+ def approved?(dep_name)
307
+ classes_of(dep_name).include? "approved"
308
+ end
229
309
 
230
- def unapproved?(dep_name)
231
- classes_of(dep_name).include? "unapproved"
232
- end
310
+ def unapproved?(dep_name)
311
+ classes_of(dep_name).include? "unapproved"
312
+ end
233
313
 
234
- def titled?(title)
235
- find("h1").has_content? title
236
- end
314
+ def titled?(title)
315
+ find("h1").has_content? title
316
+ end
237
317
 
238
- private
318
+ private
239
319
 
240
- def classes_of(dep_name)
241
- in_dep(dep_name)[:class].split(' ')
320
+ def classes_of(dep_name)
321
+ in_dep(dep_name)[:class].split(' ')
322
+ end
242
323
  end
243
- end
244
324
 
245
- class ProjectDir < SimpleDelegator # delegates to a Pathname
246
- def shell_out(command, allow_failures = false)
247
- Shell.run("cd #{self} && #{command}", allow_failures)
248
- end
325
+ class ProjectDir < SimpleDelegator # delegates to a Pathname
326
+ def shell_out(command, allow_failures = false)
327
+ Dir.chdir(self) { Shell.run(command, allow_failures) }
328
+ end
249
329
 
250
- def add_to_file(filename, content)
251
- join(filename).open('a') { |file| file.puts content }
252
- end
330
+ def add_to_file(filename, content)
331
+ join(filename).open('a') { |file| file.puts content }
332
+ end
253
333
 
254
- def write_file(filename, content)
255
- join(filename).open('w') { |file| file.write content }
256
- end
334
+ def write_file(filename, content)
335
+ join(filename).open('w') { |file| file.write content }
336
+ end
257
337
 
258
- def install_fixture(fixture_name)
259
- join(fixture_name).make_symlink Paths.fixtures.join(fixture_name)
260
- end
338
+ def install_fixture(fixture_name)
339
+ join(fixture_name).make_symlink Paths.fixtures.join(fixture_name)
340
+ end
261
341
 
262
- def make
263
- mkpath
342
+ def make
343
+ mkpath
344
+ end
264
345
  end
265
- end
266
346
 
267
- require 'pathname'
268
- module Paths
269
- extend self
347
+ require 'pathname'
348
+ module Paths
349
+ extend self
270
350
 
271
- def root
272
- # where license_finder is installed
273
- ProjectDir.new(Pathname.new(__FILE__).dirname.join("..", "..").realpath)
274
- end
351
+ def root
352
+ # where license_finder is installed
353
+ ProjectDir.new(Pathname.new(__FILE__).dirname.join("..", "..").realpath)
354
+ end
275
355
 
276
- def fixtures
277
- root.join("features", "fixtures")
278
- end
356
+ def fixtures
357
+ root.join("features", "fixtures")
358
+ end
279
359
 
280
- def projects
281
- root.join("tmp", "projects")
282
- end
360
+ def projects
361
+ root.join("tmp", "projects")
362
+ end
283
363
 
284
- def project(name = "my_app")
285
- ProjectDir.new(projects.join(name))
286
- end
364
+ def my_app
365
+ root.join("tmp", "projects", "my_app")
366
+ end
367
+
368
+ def project(name = "my_app")
369
+ ProjectDir.new(projects.join(name))
370
+ end
287
371
 
288
- def reset_projects!
289
- # only destroyed when a test starts, so you can poke around after a failure
290
- projects.rmtree if projects.exist?
291
- projects.mkpath
372
+ def reset_projects!
373
+ # only destroyed when a test starts, so you can poke around after a failure
374
+ projects.rmtree if projects.exist?
375
+ projects.mkpath
376
+ end
292
377
  end
293
- end
294
378
 
295
- module Shell
296
- ERROR_MESSAGE_FORMAT = <<EOM
379
+ module Shell
380
+ ERROR_MESSAGE_FORMAT = <<EOM
297
381
  Command failed: `%s`
298
382
  output: %s
299
383
  exit: %d
300
384
  EOM
301
385
 
302
- def self.run(command, allow_failures = false)
303
- output = `#{command} 2>&1`
304
- status = $?
305
- unless status.success? || allow_failures
306
- message = sprintf ERROR_MESSAGE_FORMAT, command, output.chomp, status.exitstatus
307
- raise RuntimeError.new(message)
308
- end
386
+ def self.run(command, allow_failures = false)
387
+ output = `#{command} 2>&1`
388
+ status = $?
389
+ unless status.success? || allow_failures
390
+ message = sprintf ERROR_MESSAGE_FORMAT, command, output.chomp, status.exitstatus
391
+ raise RuntimeError.new(message)
392
+ end
309
393
 
310
- return [output, status.exitstatus]
394
+ return [output, status.exitstatus]
395
+ end
311
396
  end
312
397
  end
313
398
  end