jettywrapper 1.8.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +5 -1
- data/lib/jettywrapper.rb +6 -10
- data/lib/jettywrapper/version.rb +1 -1
- data/spec/lib/jettywrapper_spec.rb +52 -50
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90d0380f37306e0ca328c5a86d1dd304c7141e65
|
4
|
+
data.tar.gz: 8ee2ed933249ff1a268575048a1d920040566e0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6c80ca97aa9f89f0c76882557f957596735b2f48dd923960a8e5afc68ed47ecf1b1072385a2a56a1e4038d3f1437dbe37262301b352d3470fc5dcbcf944393a
|
7
|
+
data.tar.gz: 8d82e591a1cd4d1a70ad37f449e88ad55dcd79744815b23f457b2d525da5e246b56af77ddc517b450a7f63a1901420c6ae1fe0756ee4a5f76f12bbafd731b71f
|
data/History.txt
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
2.0.0
|
2
|
+
Jettywrapper.start should trigger unzip [Chris Beer (@cbeer)]
|
3
|
+
Jettywrapper should support Fedora 4 by using hydra-jetty 8.1.1 [Mike Giarlo (@mjgiarlo)]
|
4
|
+
|
1
5
|
1.8.0
|
2
|
-
|
6
|
+
Removed mediashelf-loggable dependency [Justin Coyne]
|
3
7
|
|
4
8
|
1.4.0
|
5
9
|
Download jetty from a zip file
|
data/lib/jettywrapper.rb
CHANGED
@@ -12,14 +12,12 @@ require 'logger'
|
|
12
12
|
|
13
13
|
Dir[File.expand_path(File.join(File.dirname(__FILE__),"tasks/*.rake"))].each { |ext| load ext } if defined?(Rake)
|
14
14
|
|
15
|
-
|
16
15
|
# Jettywrapper is a Singleton class, so you can only create one jetty instance at a time.
|
17
16
|
class Jettywrapper
|
18
17
|
|
19
18
|
include Singleton
|
20
19
|
include ActiveSupport::Benchmarkable
|
21
20
|
|
22
|
-
|
23
21
|
attr_accessor :jetty_home # Jetty's home directory
|
24
22
|
attr_accessor :port # Jetty's port. Default is 8888. Note that attribute is named port, but params passed in expect :jetty_port
|
25
23
|
attr_accessor :startup_wait # How many seconds to wait for jetty to spin up. Default is 5.
|
@@ -34,7 +32,6 @@ class Jettywrapper
|
|
34
32
|
self.base_path = self.class.app_root
|
35
33
|
end
|
36
34
|
|
37
|
-
|
38
35
|
# Methods inside of the class << self block can be called directly on Jettywrapper, as class methods.
|
39
36
|
# Methods outside the class << self block must be called on Jettywrapper.instance, as instance methods.
|
40
37
|
class << self
|
@@ -42,7 +39,7 @@ class Jettywrapper
|
|
42
39
|
attr_writer :hydra_jetty_version, :url, :tmp_dir, :jetty_dir, :env
|
43
40
|
|
44
41
|
def hydra_jetty_version
|
45
|
-
@hydra_jetty_version ||= '
|
42
|
+
@hydra_jetty_version ||= 'v8.1.1'
|
46
43
|
end
|
47
44
|
|
48
45
|
def url
|
@@ -63,6 +60,7 @@ class Jettywrapper
|
|
63
60
|
end
|
64
61
|
|
65
62
|
def download(url = nil)
|
63
|
+
return if File.exists? zip_file
|
66
64
|
self.url = url if url
|
67
65
|
logger.info "Downloading jetty at #{self.url} ..."
|
68
66
|
FileUtils.mkdir tmp_dir unless File.exists? tmp_dir
|
@@ -161,7 +159,6 @@ class Jettywrapper
|
|
161
159
|
config[config_name] || config['default'.freeze]
|
162
160
|
end
|
163
161
|
|
164
|
-
|
165
162
|
# Set the jetty parameters. It accepts a Hash of symbols.
|
166
163
|
# @param [Hash<Symbol>] params
|
167
164
|
# :jetty_home Required. Jetty's home direcotry
|
@@ -185,7 +182,6 @@ class Jettywrapper
|
|
185
182
|
return jetty_server
|
186
183
|
end
|
187
184
|
|
188
|
-
|
189
185
|
# Wrap the tests. Startup jetty, yield to the test task, capture any errors, shutdown
|
190
186
|
# jetty, and return the error.
|
191
187
|
# @example Using this method in a rake task
|
@@ -230,9 +226,10 @@ class Jettywrapper
|
|
230
226
|
# @example
|
231
227
|
# Jettywrapper.start(:jetty_home => '/path/to/jetty', :jetty_port => '8983')
|
232
228
|
def start(params)
|
233
|
-
|
234
|
-
|
235
|
-
|
229
|
+
unzip unless File.exists? jetty_dir
|
230
|
+
Jettywrapper.configure(params)
|
231
|
+
Jettywrapper.instance.start
|
232
|
+
return Jettywrapper.instance
|
236
233
|
end
|
237
234
|
|
238
235
|
# Convenience method for configuring and starting jetty with one command. Note
|
@@ -428,7 +425,6 @@ class Jettywrapper
|
|
428
425
|
end
|
429
426
|
end
|
430
427
|
|
431
|
-
|
432
428
|
# The fully qualified path to the pid_file
|
433
429
|
def pid_path
|
434
430
|
#need to memoize this, becasuse the base path could be relative and the cwd can change in the yield block of wrap
|
data/lib/jettywrapper/version.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'rubygems'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
describe Jettywrapper do
|
5
|
-
|
6
|
-
# JETTY1 =
|
6
|
+
|
7
|
+
# JETTY1 =
|
7
8
|
before(:all) do
|
8
9
|
@jetty_params = {
|
9
10
|
:quiet => false,
|
@@ -12,7 +13,7 @@ require 'rubygems'
|
|
12
13
|
:solr_home => "/path/to/solr",
|
13
14
|
:startup_wait => 0,
|
14
15
|
:java_opts => ["-Xmx256m"],
|
15
|
-
:jetty_opts => ["/path/to/jetty_xml", "/path/to/other_jetty_xml"]
|
16
|
+
:jetty_opts => ["/path/to/jetty_xml", "/path/to/other_jetty_xml"]
|
16
17
|
}
|
17
18
|
|
18
19
|
Jettywrapper.logger.level=3
|
@@ -25,7 +26,8 @@ require 'rubygems'
|
|
25
26
|
context "downloading" do
|
26
27
|
context "with default file" do
|
27
28
|
it "should download the zip file" do
|
28
|
-
|
29
|
+
FileUtils.rm "tmp/v8.1.1.zip", force: true
|
30
|
+
Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/v8.1.1.zip -o tmp/v8.1.1.zip').and_return(system ('true'))
|
29
31
|
Jettywrapper.download
|
30
32
|
end
|
31
33
|
end
|
@@ -53,10 +55,10 @@ require 'rubygems'
|
|
53
55
|
context "with default file" do
|
54
56
|
it "should download the zip file" do
|
55
57
|
File.should_receive(:exists?).and_return(true)
|
56
|
-
Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/hydra-jetty-
|
57
|
-
Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/
|
58
|
+
Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/hydra-jetty-v8.1.1')
|
59
|
+
Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/v8.1.1.zip').and_return(system ('true'))
|
58
60
|
Jettywrapper.should_receive(:system).with('rm -r jetty').and_return(system ('true'))
|
59
|
-
Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/hydra-jetty-
|
61
|
+
Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/hydra-jetty-v8.1.1 jetty').and_return(system ('true'))
|
60
62
|
Jettywrapper.unzip
|
61
63
|
end
|
62
64
|
end
|
@@ -97,7 +99,7 @@ require 'rubygems'
|
|
97
99
|
its(:url) {should == 'http://example.com/bar.zip'}
|
98
100
|
end
|
99
101
|
context "when url is not set" do
|
100
|
-
its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/
|
102
|
+
its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/v8.1.1.zip'}
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
@@ -162,46 +164,46 @@ require 'rubygems'
|
|
162
164
|
its(:app_root) {should == '.'}
|
163
165
|
end
|
164
166
|
end
|
165
|
-
|
167
|
+
|
166
168
|
describe "env" do
|
167
169
|
before do
|
168
170
|
ENV.delete('JETTYWRAPPER_ENV')
|
169
171
|
ENV.delete('RAILS_ENV')
|
170
172
|
ENV.delete('environment')
|
171
173
|
end
|
172
|
-
|
174
|
+
|
173
175
|
it "should have a setter" do
|
174
176
|
Jettywrapper.env = "abc"
|
175
|
-
expect(Jettywrapper.env).to eq "abc"
|
177
|
+
expect(Jettywrapper.env).to eq "abc"
|
176
178
|
end
|
177
|
-
|
179
|
+
|
178
180
|
it "should load the ENV['JETTYWRAPPER_ENV']" do
|
179
181
|
ENV['JETTYWRAPPER_ENV'] = 'test'
|
180
182
|
ENV['RAILS_ENV'] = 'test2'
|
181
183
|
ENV['environment'] = 'test3'
|
182
184
|
expect(Jettywrapper.env).to eq "test"
|
183
185
|
end
|
184
|
-
|
186
|
+
|
185
187
|
it "should be the Rails environment" do
|
186
188
|
Rails = double(env: 'test')
|
187
189
|
expect(Jettywrapper.env).to eq "test"
|
188
190
|
end
|
189
|
-
|
191
|
+
|
190
192
|
it "should use the ENV['RAILS_ENV']" do
|
191
193
|
ENV['RAILS_ENV'] = 'test2'
|
192
194
|
ENV['environment'] = 'test3'
|
193
195
|
expect(Jettywrapper.env).to eq "test2"
|
194
196
|
end
|
195
|
-
|
197
|
+
|
196
198
|
it "should load the ENV['environment']" do
|
197
199
|
ENV['environment'] = 'test3'
|
198
200
|
expect(Jettywrapper.env).to eq "test3"
|
199
201
|
end
|
200
|
-
|
202
|
+
|
201
203
|
it "should default to 'development'" do
|
202
204
|
expect(Jettywrapper.env).to eq "development"
|
203
205
|
end
|
204
|
-
|
206
|
+
|
205
207
|
end
|
206
208
|
|
207
209
|
context "config" do
|
@@ -245,7 +247,7 @@ require 'rubygems'
|
|
245
247
|
config[:a].should == 1
|
246
248
|
end
|
247
249
|
end
|
248
|
-
|
250
|
+
|
249
251
|
context "instantiation" do
|
250
252
|
it "can be instantiated" do
|
251
253
|
ts = Jettywrapper.instance
|
@@ -253,7 +255,7 @@ require 'rubygems'
|
|
253
255
|
end
|
254
256
|
|
255
257
|
it "can be configured with a params hash" do
|
256
|
-
ts = Jettywrapper.configure(@jetty_params)
|
258
|
+
ts = Jettywrapper.configure(@jetty_params)
|
257
259
|
ts.quiet.should == false
|
258
260
|
ts.jetty_home.should == "/path/to/jetty"
|
259
261
|
ts.port.should == @jetty_params[:jetty_port]
|
@@ -272,7 +274,7 @@ require 'rubygems'
|
|
272
274
|
:jetty_opts => nil
|
273
275
|
}
|
274
276
|
|
275
|
-
ts = Jettywrapper.configure(jetty_params)
|
277
|
+
ts = Jettywrapper.configure(jetty_params)
|
276
278
|
ts.quiet.should == true
|
277
279
|
ts.jetty_home.should == "/path/to/jetty"
|
278
280
|
ts.port.should == 8888
|
@@ -280,9 +282,9 @@ require 'rubygems'
|
|
280
282
|
ts.startup_wait.should == 5
|
281
283
|
ts.jetty_opts.should == []
|
282
284
|
end
|
283
|
-
|
285
|
+
|
284
286
|
it "passes all the expected values to jetty during startup" do
|
285
|
-
ts = Jettywrapper.configure(@jetty_params)
|
287
|
+
ts = Jettywrapper.configure(@jetty_params)
|
286
288
|
command = ts.jetty_command
|
287
289
|
command.should include("-Dsolr.solr.home=#{@jetty_params[:solr_home]}")
|
288
290
|
command.should include("-Djetty.port=#{@jetty_params[:jetty_port]}")
|
@@ -296,24 +298,24 @@ require 'rubygems'
|
|
296
298
|
command = ts.jetty_command
|
297
299
|
command.should include("-Dsolr.solr.home=/path\\ with\\ spaces/to/solr")
|
298
300
|
end
|
299
|
-
|
301
|
+
|
300
302
|
it "has a pid if it has been started" do
|
301
303
|
jetty_params = {
|
302
304
|
:jetty_home => '/tmp'
|
303
305
|
}
|
304
|
-
ts = Jettywrapper.configure(jetty_params)
|
306
|
+
ts = Jettywrapper.configure(jetty_params)
|
305
307
|
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>5454))
|
306
308
|
ts.stop
|
307
309
|
ts.start
|
308
310
|
ts.pid.should eql(5454)
|
309
311
|
ts.stop
|
310
312
|
end
|
311
|
-
|
313
|
+
|
312
314
|
it "can pass params to a start method" do
|
313
315
|
jetty_params = {
|
314
316
|
:jetty_home => '/tmp', :jetty_port => 8777
|
315
317
|
}
|
316
|
-
ts = Jettywrapper.configure(jetty_params)
|
318
|
+
ts = Jettywrapper.configure(jetty_params)
|
317
319
|
ts.stop
|
318
320
|
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2323))
|
319
321
|
swp = Jettywrapper.start(jetty_params)
|
@@ -321,11 +323,11 @@ require 'rubygems'
|
|
321
323
|
swp.pid_file.should eql("_tmp_test.pid")
|
322
324
|
swp.stop
|
323
325
|
end
|
324
|
-
|
326
|
+
|
325
327
|
it "can get the status for a given jetty instance" do
|
326
328
|
# Don't actually start jetty, just fake it
|
327
329
|
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>12345))
|
328
|
-
|
330
|
+
|
329
331
|
jetty_params = {
|
330
332
|
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
|
331
333
|
}
|
@@ -335,7 +337,7 @@ require 'rubygems'
|
|
335
337
|
Jettywrapper.is_jetty_running?(jetty_params).should eql(true)
|
336
338
|
Jettywrapper.stop(jetty_params)
|
337
339
|
end
|
338
|
-
|
340
|
+
|
339
341
|
it "can get the pid for a given jetty instance" do
|
340
342
|
# Don't actually start jetty, just fake it
|
341
343
|
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>54321))
|
@@ -348,7 +350,7 @@ require 'rubygems'
|
|
348
350
|
Jettywrapper.pid(jetty_params).should eql(54321)
|
349
351
|
Jettywrapper.stop(jetty_params)
|
350
352
|
end
|
351
|
-
|
353
|
+
|
352
354
|
it "can pass params to a stop method" do
|
353
355
|
jetty_params = {
|
354
356
|
:jetty_home => '/tmp', :jetty_port => 8777
|
@@ -356,11 +358,11 @@ require 'rubygems'
|
|
356
358
|
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2323))
|
357
359
|
swp = Jettywrapper.start(jetty_params)
|
358
360
|
(File.file? swp.pid_path).should eql(true)
|
359
|
-
|
361
|
+
|
360
362
|
swp = Jettywrapper.stop(jetty_params)
|
361
363
|
(File.file? swp.pid_path).should eql(false)
|
362
364
|
end
|
363
|
-
|
365
|
+
|
364
366
|
describe "creates a pid file" do
|
365
367
|
let(:ts) { Jettywrapper.configure(@jetty_params) }
|
366
368
|
describe "when the environment isn't set" do
|
@@ -376,17 +378,17 @@ require 'rubygems'
|
|
376
378
|
end
|
377
379
|
end
|
378
380
|
end
|
379
|
-
|
381
|
+
|
380
382
|
it "knows where its pid file should be written" do
|
381
|
-
ts = Jettywrapper.configure(@jetty_params)
|
383
|
+
ts = Jettywrapper.configure(@jetty_params)
|
382
384
|
ts.pid_dir.should eql(File.expand_path("#{ts.base_path}/tmp/pids"))
|
383
385
|
end
|
384
|
-
|
386
|
+
|
385
387
|
it "writes a pid to a file when it is started" do
|
386
388
|
jetty_params = {
|
387
389
|
:jetty_home => '/tmp'
|
388
390
|
}
|
389
|
-
ts = Jettywrapper.configure(jetty_params)
|
391
|
+
ts = Jettywrapper.configure(jetty_params)
|
390
392
|
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2222))
|
391
393
|
ts.stop
|
392
394
|
ts.pid_file?.should eql(false)
|
@@ -396,49 +398,49 @@ require 'rubygems'
|
|
396
398
|
pid_from_file = File.open( ts.pid_path ) { |f| f.gets.to_i }
|
397
399
|
pid_from_file.should eql(2222)
|
398
400
|
end
|
399
|
-
|
401
|
+
|
400
402
|
end # end of instantiation context
|
401
|
-
|
403
|
+
|
402
404
|
context "logging" do
|
403
405
|
it "has a logger" do
|
404
|
-
ts = Jettywrapper.configure(@jetty_params)
|
406
|
+
ts = Jettywrapper.configure(@jetty_params)
|
405
407
|
ts.logger.should be_kind_of(Logger)
|
406
408
|
end
|
407
|
-
|
408
|
-
end # end of logging context
|
409
|
-
|
409
|
+
|
410
|
+
end # end of logging context
|
411
|
+
|
410
412
|
context "wrapping a task" do
|
411
413
|
it "wraps another method" do
|
412
414
|
Jettywrapper.any_instance.stub(:start).and_return(true)
|
413
415
|
Jettywrapper.any_instance.stub(:stop).and_return(true)
|
414
|
-
error = Jettywrapper.wrap(@jetty_params) do
|
416
|
+
error = Jettywrapper.wrap(@jetty_params) do
|
415
417
|
end
|
416
418
|
error.should eql(false)
|
417
419
|
end
|
418
|
-
|
420
|
+
|
419
421
|
it "configures itself correctly when invoked via the wrap method" do
|
420
422
|
Jettywrapper.any_instance.stub(:start).and_return(true)
|
421
423
|
Jettywrapper.any_instance.stub(:stop).and_return(true)
|
422
|
-
error = Jettywrapper.wrap(@jetty_params) do
|
423
|
-
ts = Jettywrapper.instance
|
424
|
+
error = Jettywrapper.wrap(@jetty_params) do
|
425
|
+
ts = Jettywrapper.instance
|
424
426
|
ts.quiet.should == @jetty_params[:quiet]
|
425
427
|
ts.jetty_home.should == "/path/to/jetty"
|
426
428
|
ts.port.should == @jetty_params[:jetty_port]
|
427
429
|
ts.solr_home.should == "/path/to/solr"
|
428
|
-
ts.startup_wait.should == 0
|
430
|
+
ts.startup_wait.should == 0
|
429
431
|
end
|
430
432
|
error.should eql(false)
|
431
433
|
end
|
432
|
-
|
434
|
+
|
433
435
|
it "captures any errors produced" do
|
434
436
|
Jettywrapper.any_instance.stub(:start).and_return(true)
|
435
437
|
Jettywrapper.any_instance.stub(:stop).and_return(true)
|
436
438
|
Jettywrapper.instance.logger.should_receive(:error).with("*** Error starting jetty: this is an expected error message")
|
437
|
-
expect { error = Jettywrapper.wrap(@jetty_params) do
|
439
|
+
expect { error = Jettywrapper.wrap(@jetty_params) do
|
438
440
|
raise "this is an expected error message"
|
439
441
|
end }.to raise_error "this is an expected error message"
|
440
442
|
end
|
441
|
-
|
443
|
+
|
442
444
|
end # end of wrapping context
|
443
445
|
|
444
446
|
context "quiet mode", :quiet => true do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jettywrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: logger
|
@@ -174,9 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: 1.3.6
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.4.3
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Convenience tasks for working with jetty from within a ruby project.
|
181
181
|
test_files: []
|
182
|
-
has_rdoc:
|