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.
- checksums.yaml +4 -4
- data/.travis.yml +6 -4
- data/.travis/install_godep.sh +6 -0
- data/.travis/install_gradle.sh +1 -1
- data/.travis/install_rebar.sh +7 -5
- data/CHANGELOG.rdoc +13 -0
- data/CONTRIBUTING.md +16 -2
- data/README.md +41 -4
- data/Rakefile +8 -2
- data/features/features/{cli_spec.rb → cli/cli_spec.rb} +24 -18
- data/features/features/configure/add_dependencies_spec.rb +18 -1
- data/features/features/configure/approve_dependencies_spec.rb +31 -1
- data/features/features/configure/assign_licenses_spec.rb +18 -3
- data/features/features/configure/blacklist_licenses_spec.rb +30 -0
- data/features/features/configure/ignore_dependencies_spec.rb +1 -1
- data/features/features/configure/ignore_groups_spec.rb +16 -1
- data/features/features/configure/name_project_spec.rb +1 -1
- data/features/features/configure/set_project_path_spec.rb +1 -1
- data/features/features/configure/whitelist_licenses_spec.rb +1 -3
- data/features/features/package_managers/bower_spec.rb +1 -1
- data/features/features/package_managers/cocoapods_spec.rb +1 -1
- data/features/features/package_managers/godep_spec.rb +17 -0
- data/features/features/package_managers/gradle_spec.rb +18 -4
- data/features/features/package_managers/maven_spec.rb +1 -1
- data/features/features/package_managers/npm_spec.rb +1 -1
- data/features/features/package_managers/nuget_spec.rb +14 -0
- data/features/features/package_managers/pip_spec.rb +1 -1
- data/features/features/package_managers/rebar_spec.rb +1 -1
- data/features/features/report/composite_spec.rb +15 -0
- data/features/features/report/csv_spec.rb +1 -1
- data/features/features/report/diff_spec.rb +190 -0
- data/features/features/report/html_spec.rb +1 -1
- data/features/features/report/subproject_spec.rb +52 -0
- data/features/fixtures/file-based-libs-gradle/build.gradle +18 -0
- data/features/fixtures/file-based-libs-gradle/libs/data.json-0.2.3.jar +0 -0
- data/features/fixtures/gopath/src/github.com/pivotal/foo/Godeps/Godeps.json +16 -0
- data/features/fixtures/gopath/src/github.com/pivotal/foo/Godeps/Readme +5 -0
- data/features/fixtures/gopath/src/github.com/pivotal/foo/foo.go +6 -0
- data/features/fixtures/multi-module-gradle/build.gradle +18 -0
- data/features/fixtures/multi-module-gradle/module1/build.gradle +3 -0
- data/features/fixtures/multi-module-gradle/module2/build.gradle +3 -0
- data/features/fixtures/multi-module-gradle/settings.gradle +1 -0
- data/features/fixtures/nuget/Fun.Test/packages.config +4 -0
- data/features/fixtures/nuget/Fun/packages.config +5 -0
- data/features/fixtures/nuget/packages/Microsoft.AspNet.Mvc.4.0.30506.0/.keep +0 -0
- data/features/fixtures/nuget/packages/NUnit.2.6.4/.keep +0 -0
- data/features/fixtures/nuget/packages/Ninject.MVC4.3.2.1.0/.keep +0 -0
- data/features/fixtures/nuget/packages/repositories.config +6 -0
- data/features/fixtures/{build.gradle → single-module-gradle/build.gradle} +0 -0
- data/{spec → features/support}/feature_helper.rb +5 -1
- data/features/support/testing_dsl.rb +297 -212
- data/lib/license_finder/cli.rb +1 -0
- data/lib/license_finder/cli/base.rb +16 -3
- data/lib/license_finder/cli/blacklist.rb +30 -0
- data/lib/license_finder/cli/main.rb +62 -4
- data/lib/license_finder/configuration.rb +39 -8
- data/lib/license_finder/core.rb +13 -10
- data/lib/license_finder/decision_applier.rb +14 -9
- data/lib/license_finder/decisions.rb +24 -6
- data/lib/license_finder/diff.rb +47 -0
- data/lib/license_finder/license_aggregator.rb +25 -0
- data/lib/license_finder/package.rb +39 -6
- data/lib/license_finder/package_delta.rb +65 -0
- data/lib/license_finder/package_manager.rb +10 -3
- data/lib/license_finder/package_managers/bower.rb +3 -1
- data/lib/license_finder/package_managers/bundler.rb +18 -9
- data/lib/license_finder/package_managers/bundler_package.rb +6 -2
- data/lib/license_finder/package_managers/go_dep.rb +25 -0
- data/lib/license_finder/package_managers/go_package.rb +19 -0
- data/lib/license_finder/package_managers/go_workspace.rb +35 -0
- data/lib/license_finder/package_managers/gradle.rb +16 -17
- data/lib/license_finder/package_managers/gradle_dependency_finder.rb +13 -0
- data/lib/license_finder/package_managers/gradle_package.rb +6 -1
- data/lib/license_finder/package_managers/maven.rb +3 -1
- data/lib/license_finder/package_managers/merged_package.rb +43 -0
- data/lib/license_finder/package_managers/npm.rb +42 -24
- data/lib/license_finder/package_managers/nuget.rb +50 -0
- data/lib/license_finder/package_managers/nuget_package.rb +4 -0
- data/lib/license_finder/package_managers/pip_package.rb +1 -0
- data/lib/license_finder/package_managers/rebar.rb +2 -6
- data/lib/license_finder/platform.rb +4 -1
- data/lib/license_finder/project_finder.rb +56 -0
- data/lib/license_finder/report.rb +3 -2
- data/lib/license_finder/reports/csv_report.rb +6 -2
- data/lib/license_finder/reports/diff_report.rb +33 -0
- data/lib/license_finder/reports/merged_report.rb +13 -0
- data/lib/license_finder/version.rb +1 -1
- data/license_finder.gemspec +6 -2
- data/spec/dummy_app/Gemfile +6 -0
- data/spec/fixtures/all_pms/.envrc +0 -0
- data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
- data/spec/fixtures/all_pms/packages/.keep +0 -0
- data/spec/fixtures/composite/Gemfile +0 -0
- data/spec/fixtures/composite/nested_project/.envrc +8 -0
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +16 -0
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +5 -0
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +6 -0
- data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
- data/spec/fixtures/composite/project1/Gemfile +0 -0
- data/spec/fixtures/composite/project2/package.json +0 -0
- data/spec/lib/license_finder/cli/approvals_spec.rb +1 -1
- data/spec/lib/license_finder/cli/blacklist_spec.rb +58 -0
- data/spec/lib/license_finder/cli/dependencies_spec.rb +1 -1
- data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +1 -1
- data/spec/lib/license_finder/cli/ignored_groups_spec.rb +1 -1
- data/spec/lib/license_finder/cli/licenses_spec.rb +1 -1
- data/spec/lib/license_finder/cli/main_spec.rb +113 -7
- data/spec/lib/license_finder/cli/project_name_spec.rb +1 -1
- data/spec/lib/license_finder/cli/whitelist_spec.rb +1 -1
- data/spec/lib/license_finder/configuration_spec.rb +63 -4
- data/spec/lib/license_finder/core_spec.rb +49 -0
- data/spec/lib/license_finder/decision_applier_spec.rb +101 -1
- data/spec/lib/license_finder/decisions_spec.rb +62 -0
- data/spec/lib/license_finder/diff_spec.rb +106 -0
- data/spec/lib/license_finder/license_aggregator_spec.rb +61 -0
- data/spec/lib/license_finder/package_delta_spec.rb +18 -0
- data/spec/lib/license_finder/package_managers/bower_spec.rb +8 -6
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +4 -2
- data/spec/lib/license_finder/package_managers/go_dep_spec.rb +72 -0
- data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +69 -0
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +9 -0
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +94 -44
- data/spec/lib/license_finder/package_managers/maven_spec.rb +8 -6
- data/spec/lib/license_finder/package_managers/merged_package_spec.rb +52 -0
- data/spec/lib/license_finder/package_managers/npm_spec.rb +59 -20
- data/spec/lib/license_finder/package_managers/nuget_spec.rb +82 -0
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +1 -0
- data/spec/lib/license_finder/package_managers/rebar_spec.rb +12 -12
- data/spec/lib/license_finder/package_spec.rb +59 -2
- data/spec/lib/license_finder/project_finder_spec.rb +33 -0
- data/spec/lib/license_finder/reports/csv_report_spec.rb +9 -3
- data/spec/lib/license_finder/reports/diff_report_spec.rb +56 -0
- data/spec/lib/license_finder/reports/merged_report_spec.rb +21 -0
- metadata +82 -9
- data/.travis/install_virtualenv.sh +0 -9
@@ -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 @@
|
|
1
|
+
include ':module1', ':module2'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -4,8 +4,12 @@
|
|
4
4
|
# require 'bundler/setup'
|
5
5
|
# require 'license_finder'
|
6
6
|
|
7
|
-
|
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
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
14
|
+
def create_empty_project(name = "my_app")
|
15
|
+
EmptyProject.create(name)
|
16
|
+
end
|
12
17
|
|
13
|
-
|
14
|
-
|
15
|
-
|
18
|
+
def create_ruby_app(name = "my_app")
|
19
|
+
BundlerProject.create(name)
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
def create_gem(name, options)
|
23
|
+
GemProject.create(name, options)
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
def create_gem_in_path(name, path, options)
|
27
|
+
GemProject.create_in_path(name, path, options)
|
28
|
+
end
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
def execute_command(command)
|
31
|
+
execute_command_in_path(command, Paths.project)
|
32
|
+
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
def execute_command_outside_project(command)
|
35
|
+
execute_command_in_path(command, Paths.root)
|
36
|
+
end
|
32
37
|
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
def seeing?(content)
|
39
|
+
@output.include? content
|
40
|
+
end
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
def seeing_once?(content)
|
43
|
+
@output.scan(/#{Regexp.escape content}/).size == 1
|
44
|
+
end
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
|
46
|
+
def seeing_line?(content)
|
47
|
+
seeing_something_like? /^#{Regexp.escape content}$/
|
48
|
+
end
|
44
49
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
50
|
+
def seeing_something_like?(regex)
|
51
|
+
@output =~ regex
|
52
|
+
end
|
49
53
|
|
50
|
-
|
54
|
+
def receiving_exit_code?(code)
|
55
|
+
@exit_code == code
|
56
|
+
end
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
def view_html
|
59
|
+
execute_command 'license_finder report --format html'
|
60
|
+
HtmlReport.from_string(@output)
|
61
|
+
end
|
56
62
|
|
57
|
-
|
58
|
-
class Project
|
59
|
-
extend Forwardable
|
60
|
-
def_delegators :project_dir, :shell_out, :add_to_file, :install_fixture
|
63
|
+
private
|
61
64
|
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
require 'forwardable'
|
71
|
+
class Project
|
72
|
+
extend Forwardable
|
73
|
+
def_delegators :project_dir, :shell_out, :add_to_file, :install_fixture
|
73
74
|
|
74
|
-
|
75
|
-
end
|
75
|
+
attr_reader :name
|
76
76
|
|
77
|
-
|
78
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
def initialize(name = "my_app")
|
85
|
+
@name = name
|
86
|
+
project_dir.make
|
87
|
+
end
|
84
88
|
|
85
|
-
|
86
|
-
|
89
|
+
def add_dep
|
90
|
+
end
|
87
91
|
|
88
|
-
|
89
|
-
|
90
|
-
add_to_file("requirements.txt", 'rsa==3.1.4')
|
91
|
-
end
|
92
|
+
def install
|
93
|
+
end
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
95
|
+
def project_dir
|
96
|
+
Paths.project(name)
|
97
|
+
end
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
-
|
104
|
-
shell_out("npm install 2>/dev/null")
|
105
|
+
class EmptyProject < Project
|
105
106
|
end
|
106
|
-
end
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
class PipProject < Project
|
109
|
+
def add_dep
|
110
|
+
add_to_file("requirements.txt", 'rsa==3.1.4')
|
111
|
+
end
|
112
112
|
|
113
|
-
|
114
|
-
|
113
|
+
def install
|
114
|
+
shell_out("pip install -r requirements.txt --user")
|
115
|
+
end
|
115
116
|
end
|
116
|
-
end
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
-
|
124
|
-
|
123
|
+
def install
|
124
|
+
shell_out("npm install 2>/dev/null")
|
125
|
+
end
|
125
126
|
end
|
126
|
-
end
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
135
|
-
|
136
|
-
|
133
|
+
def install
|
134
|
+
shell_out("bower install 2>/dev/null")
|
135
|
+
end
|
137
136
|
end
|
138
137
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
138
|
+
class MavenProject < Project
|
139
|
+
def add_dep
|
140
|
+
install_fixture("pom.xml")
|
141
|
+
end
|
143
142
|
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
def install
|
144
|
+
shell_out("mvn install")
|
145
|
+
end
|
147
146
|
end
|
148
147
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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
|
-
|
155
|
-
|
156
|
-
|
159
|
+
class FileBasedLibs < Project
|
160
|
+
def add_dep
|
161
|
+
clone('file-based-libs-gradle')
|
162
|
+
end
|
163
|
+
end
|
157
164
|
end
|
158
165
|
|
159
|
-
|
160
|
-
|
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
|
-
|
164
|
-
|
165
|
-
|
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
|
-
|
187
|
+
class CocoaPodsProject < Project
|
188
|
+
def add_dep
|
189
|
+
install_fixture("Podfile")
|
190
|
+
end
|
169
191
|
|
170
|
-
|
171
|
-
|
192
|
+
def install
|
193
|
+
shell_out("pod install --no-integrate")
|
194
|
+
end
|
172
195
|
end
|
173
|
-
end
|
174
196
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
result
|
180
|
-
end
|
197
|
+
class RebarProject < Project
|
198
|
+
def add_dep
|
199
|
+
install_fixture("rebar.config")
|
200
|
+
end
|
181
201
|
|
182
|
-
|
183
|
-
|
184
|
-
|
202
|
+
def install
|
203
|
+
shell_out("rebar get-deps")
|
204
|
+
end
|
185
205
|
end
|
186
206
|
|
187
|
-
|
188
|
-
|
207
|
+
class NugetProject < Project
|
208
|
+
def add_dep
|
209
|
+
clone('nuget')
|
210
|
+
end
|
189
211
|
end
|
190
212
|
|
191
|
-
|
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
|
-
|
194
|
-
|
234
|
+
def add_to_gemfile(content)
|
235
|
+
add_to_file("Gemfile", content)
|
236
|
+
end
|
195
237
|
end
|
196
238
|
|
197
|
-
|
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
|
-
|
200
|
-
|
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
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
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
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
300
|
+
def in_dep(dep_name)
|
301
|
+
result = find("##{dep_name}")
|
302
|
+
yield result if block_given?
|
303
|
+
result
|
304
|
+
end
|
225
305
|
|
226
|
-
|
227
|
-
|
228
|
-
|
306
|
+
def approved?(dep_name)
|
307
|
+
classes_of(dep_name).include? "approved"
|
308
|
+
end
|
229
309
|
|
230
|
-
|
231
|
-
|
232
|
-
|
310
|
+
def unapproved?(dep_name)
|
311
|
+
classes_of(dep_name).include? "unapproved"
|
312
|
+
end
|
233
313
|
|
234
|
-
|
235
|
-
|
236
|
-
|
314
|
+
def titled?(title)
|
315
|
+
find("h1").has_content? title
|
316
|
+
end
|
237
317
|
|
238
|
-
|
318
|
+
private
|
239
319
|
|
240
|
-
|
241
|
-
|
320
|
+
def classes_of(dep_name)
|
321
|
+
in_dep(dep_name)[:class].split(' ')
|
322
|
+
end
|
242
323
|
end
|
243
|
-
end
|
244
324
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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
|
-
|
251
|
-
|
252
|
-
|
330
|
+
def add_to_file(filename, content)
|
331
|
+
join(filename).open('a') { |file| file.puts content }
|
332
|
+
end
|
253
333
|
|
254
|
-
|
255
|
-
|
256
|
-
|
334
|
+
def write_file(filename, content)
|
335
|
+
join(filename).open('w') { |file| file.write content }
|
336
|
+
end
|
257
337
|
|
258
|
-
|
259
|
-
|
260
|
-
|
338
|
+
def install_fixture(fixture_name)
|
339
|
+
join(fixture_name).make_symlink Paths.fixtures.join(fixture_name)
|
340
|
+
end
|
261
341
|
|
262
|
-
|
263
|
-
|
342
|
+
def make
|
343
|
+
mkpath
|
344
|
+
end
|
264
345
|
end
|
265
|
-
end
|
266
346
|
|
267
|
-
|
268
|
-
|
269
|
-
|
347
|
+
require 'pathname'
|
348
|
+
module Paths
|
349
|
+
extend self
|
270
350
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
351
|
+
def root
|
352
|
+
# where license_finder is installed
|
353
|
+
ProjectDir.new(Pathname.new(__FILE__).dirname.join("..", "..").realpath)
|
354
|
+
end
|
275
355
|
|
276
|
-
|
277
|
-
|
278
|
-
|
356
|
+
def fixtures
|
357
|
+
root.join("features", "fixtures")
|
358
|
+
end
|
279
359
|
|
280
|
-
|
281
|
-
|
282
|
-
|
360
|
+
def projects
|
361
|
+
root.join("tmp", "projects")
|
362
|
+
end
|
283
363
|
|
284
|
-
|
285
|
-
|
286
|
-
|
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
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
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
|
-
|
296
|
-
|
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
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
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
|
-
|
394
|
+
return [output, status.exitstatus]
|
395
|
+
end
|
311
396
|
end
|
312
397
|
end
|
313
398
|
end
|