jettywrapper 1.4.0 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ec0896737d3b6280dd860cf58a545b7d2981a5f
4
- data.tar.gz: c07c9985c43d31605ad61466649cdecb62369995
3
+ metadata.gz: b12e576520a009e9adb542062694b56d04b43c90
4
+ data.tar.gz: c8457e8e27503f15772bf164cd30dc066c1a06ec
5
5
  SHA512:
6
- metadata.gz: cea4d28ccafdbc46d26899bc3b28dab6e0880e3d4108e7d78542407e8d1ff5d96ff06305e9db96ef139f887ac4d1a76140a05f465a0c9a97fe3f03e3fa4b0b99
7
- data.tar.gz: 49e83df77c93fdd816cd56cc2fba3d98440a9fe20ea9b5d43761803957fb3df9002a854733e9f9b1c7838173cce718afa28b90a7f7c9724a007ffe959850e506
6
+ metadata.gz: b3c49d92028f96b1d15db964f83f6cf87bfe06c397262dcad6a1a2441644801eae350b28b92770f162492f57697a39253c7f67becb234e0517603ec70bea6193
7
+ data.tar.gz: 5c8bd9fda2a2017a27e3d82409d93051278034dd9290497e90b4c473bac2ba9db857a047e414ad97628c8cd591b4b2d88c3b5a0afab2ccd31019b0457e49bfb8
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,113 @@
1
+ # How to Contribute
2
+
3
+ We want your help to make Project Hydra great.
4
+ There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
5
+
6
+ ## Hydra Project Intellectual Property Licensing and Ownership
7
+
8
+ All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
9
+ If the contributor works for an institution, the institution must have a Corporate Contributor License Agreement (cCLA) on file.
10
+
11
+ https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership
12
+
13
+ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
14
+
15
+ ## Contribution Tasks
16
+
17
+ * Reporting Issues
18
+ * Making Changes
19
+ * Submitting Changes
20
+ * Merging Changes
21
+
22
+ ### Reporting Issues
23
+
24
+ * Make sure you have a [GitHub account](https://github.com/signup/free)
25
+ * Submit a [Github issue](./issues) by:
26
+ * Clearly describing the issue
27
+ * Provide a descriptive summary
28
+ * Explain the expected behavior
29
+ * Explain the actual behavior
30
+ * Provide steps to reproduce the actual behavior
31
+
32
+ ### Making Changes
33
+
34
+ * Fork the repository on GitHub
35
+ * Create a topic branch from where you want to base your work.
36
+ * This is usually the master branch.
37
+ * To quickly create a topic branch based on master; `git branch fix/master/my_contribution master`
38
+ * Then checkout the new branch with `git checkout fix/master/my_contribution`.
39
+ * Please avoid working directly on the `master` branch.
40
+ * You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
41
+ * Make commits of logical units.
42
+ * Your commit should include a high level description of your work in HISTORY.textile
43
+ * Check for unnecessary whitespace with `git diff --check` before committing.
44
+ * Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
45
+ * If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages)
46
+
47
+ ```
48
+ Present tense short summary (50 characters or less)
49
+
50
+ More detailed description, if necessary. It should be wrapped to 72
51
+ characters. Try to be as descriptive as you can, even if you think that
52
+ the commit content is obvious, it may not be obvious to others. You
53
+ should add such description also if it's already present in bug tracker,
54
+ it should not be necessary to visit a webpage to check the history.
55
+
56
+ Include Closes #<issue-number> when relavent.
57
+
58
+ Description can have multiple paragraphs and you can use code examples
59
+ inside, just indent it with 4 spaces:
60
+
61
+ class PostsController
62
+ def index
63
+ respond_with Post.limit(10)
64
+ end
65
+ end
66
+
67
+ You can also add bullet points:
68
+
69
+ - you can use dashes or asterisks
70
+
71
+ - also, try to indent next line of a point for readability, if it's too
72
+ long to fit in 72 characters
73
+ ```
74
+
75
+ * Make sure you have added the necessary tests for your changes.
76
+ * Run _all_ the tests to assure nothing else was accidentally broken.
77
+ * When you are ready to submit a pull request
78
+
79
+ ### Submitting Changes
80
+
81
+ [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
82
+
83
+ * Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
84
+ * Make sure your branch is up to date with its parent branch (i.e. master)
85
+ * `git checkout master`
86
+ * `git pull --rebase`
87
+ * `git checkout <your-branch>`
88
+ * `git rebase master`
89
+ * It is likely a good idea to run your tests again.
90
+ * Squash the commits for your branch into one commit
91
+ * `git rebase --interactive HEAD~<number-of-commits>` ([See Github help](https://help.github.com/articles/interactive-rebase))
92
+ * To determine the number of commits on your branch: `git log master..<your-branch> --oneline | wc -l`
93
+ * Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on.
94
+ * Push your changes to a topic branch in your fork of the repository.
95
+ * Submit a pull request from your fork to the project.
96
+
97
+ ### Merging Changes
98
+
99
+ * It is considered "poor from" to merge your own request.
100
+ * Please take the time to review the changes and get a sense of what is being changed. Things to consider:
101
+ * Does the commit message explain what is going on?
102
+ * Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
103
+ * Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
104
+ * Did the Travis tests complete successfully?
105
+ * If you are uncertain, bring other contributors into the conversation by creating a comment that includes their @username.
106
+ * If you like the pull request, but want others to chime in, create a +1 comment and tag a user.
107
+
108
+ # Additional Resources
109
+
110
+ * [General GitHub documentation](http://help.github.com/)
111
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
112
+ * [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
113
+ * [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
data/README.textile CHANGED
@@ -1,5 +1,6 @@
1
1
  h1. jettywrapper
2
2
 
3
+ !https://travis-ci.org/projecthydra/jettywrapper.png?branch=master!:https://travis-ci.org/projecthydra/jettywrapper
3
4
 
4
5
  This gem is designed to make it easier to integrate a jetty servlet container into a rails project.
5
6
  Jettywrapper provides rake tasks for starting and stopping jetty, as well as a method (Jettywrapper.wrap) that will start the server before the block and stop the server after the block, which is useful for automated testing.
@@ -45,19 +46,11 @@ If you haven't already, clone the git repository
45
46
  cd jettywrapper
46
47
  </pre>
47
48
 
48
- If you're using RVM (recommended), use the .rvmrc
49
49
 
50
- <pre>
51
- source .rvmrc
52
- rvm list gemsets
53
- </pre>
54
-
55
- Install the gems and pull the submodules
50
+ Install the gems
56
51
 
57
52
  <pre>
58
53
  bundle install
59
- git submodule init
60
- git submodule update
61
54
  </pre>
62
55
 
63
56
  Run the tests
data/jettywrapper.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'bundler'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "jettywrapper"
8
- s.version = GEMVERSION
8
+ s.version = Jettywrapper::VERSION
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Chris Beer", "Justin Coyne", "Bess Sadler"]
11
11
  s.email = ["hydra-tech@googlegroups.com"]
@@ -1 +1,3 @@
1
- GEMVERSION = "1.4.0"
1
+ class Jettywrapper
2
+ VERSION = "1.5.0"
3
+ end
data/lib/jettywrapper.rb CHANGED
@@ -39,19 +39,16 @@ class Jettywrapper
39
39
  # Methods outside the class << self block must be called on Jettywrapper.instance, as instance methods.
40
40
  class << self
41
41
 
42
- def url=(url)
43
- @url = url
42
+ attr_writer :hydra_jetty_version, :url, :tmp_dir
43
+ def hydra_jetty_version
44
+ @hydra_jetty_version ||= 'v7.0.0'
44
45
  end
45
46
 
46
47
  def url
47
- @url ||= defined?(ZIP_URL) ? ZIP_URL : 'https://github.com/projecthydra/hydra-jetty/archive/new-solr-schema.zip'
48
+ @url ||= defined?(ZIP_URL) ? ZIP_URL : "https://github.com/projecthydra/hydra-jetty/archive/#{hydra_jetty_version}.zip"
48
49
  @url
49
50
  end
50
51
 
51
- def tmp_dir=(dir)
52
- @tmp_dir = dir
53
- end
54
-
55
52
  def tmp_dir
56
53
  @tmp_dir ||= 'tmp'
57
54
  end
@@ -64,12 +61,12 @@ class Jettywrapper
64
61
  'jetty'
65
62
  end
66
63
 
67
- def download(url = 'https://github.com/projecthydra/hydra-jetty/archive/new-solr-schema.zip')
68
- self.url = url
69
- logger.info "Downloading jetty..."
64
+ def download(url = nil)
65
+ self.url = url if url
66
+ logger.info "Downloading jetty at #{self.url} ..."
70
67
  FileUtils.mkdir tmp_dir unless File.exists? tmp_dir
71
- system "curl -L #{url} -o #{zip_file}"
72
- abort "Unable to download jetty from #{url}" unless $?.success?
68
+ system "curl -L #{self.url} -o #{zip_file}"
69
+ abort "Unable to download jetty from #{self.url}" unless $?.success?
73
70
  end
74
71
 
75
72
  def unzip
@@ -79,6 +76,10 @@ class Jettywrapper
79
76
  system "unzip -d #{tmp_save_dir} -qo #{zip_file}"
80
77
  abort "Unable to unzip #{zip_file} into tmp_save_dir/" unless $?.success?
81
78
 
79
+ # Remove the old jetty directory if it exists
80
+ system "rm -r #{jetty_dir}" if File.directory?(jetty_dir)
81
+
82
+ # Move the expanded zip file into the final destination.
82
83
  expanded_dir = expanded_zip_dir(tmp_save_dir)
83
84
  system "mv #{expanded_dir} #{jetty_dir}"
84
85
  abort "Unable to move #{expanded_dir} into #{jetty_dir}/" unless $?.success?
@@ -97,18 +98,15 @@ class Jettywrapper
97
98
 
98
99
  def reset_config
99
100
  @app_root = nil
101
+ @url = nil
102
+ @hydra_jetty_version = nil
100
103
  end
101
104
 
102
105
  def app_root
103
106
  return @app_root if @app_root
104
- if defined?(Rails.root)
105
- @app_root = Rails.root
106
- elsif defined?(APP_ROOT)
107
- @app_root = APP_ROOT
108
- else
109
- @app_root = '.'
110
- end
111
- @app_root
107
+ @app_root = Rails.root if defined?(Rails.root)
108
+ @app_root ||= APP_ROOT if defined?(APP_ROOT)
109
+ @app_root ||= '.'
112
110
  end
113
111
 
114
112
  def load_config
@@ -159,14 +157,8 @@ class Jettywrapper
159
157
  jetty_server = self.instance
160
158
  jetty_server.reset_process!
161
159
  jetty_server.quiet = params[:quiet].nil? ? true : params[:quiet]
162
- if defined?(Rails.root)
163
- base_path = Rails.root
164
- elsif defined?(APP_ROOT)
165
- base_path = APP_ROOT
166
- else
167
- raise "You must set either Rails.root, APP_ROOT or pass :jetty_home as a parameter so I know where jetty is" unless params[:jetty_home]
168
- end
169
- jetty_server.jetty_home = params[:jetty_home] || File.expand_path(File.join(base_path, 'jetty'))
160
+
161
+ jetty_server.jetty_home = params[:jetty_home] || File.expand_path(File.join(app_root, 'jetty'))
170
162
  jetty_server.solr_home = params[:solr_home] || File.join( jetty_server.jetty_home, "solr")
171
163
  jetty_server.port = params[:jetty_port] || 8888
172
164
  jetty_server.startup_wait = params[:startup_wait] || 5
@@ -9,10 +9,12 @@ namespace :jetty do
9
9
  Jettywrapper.download
10
10
  end
11
11
 
12
+ desc "unzip the downloaded jetty archive"
12
13
  task :unzip do
13
14
  Jettywrapper.unzip
14
15
  end
15
16
 
17
+ desc "remove the jetty directory and recreate it"
16
18
  task :clean do
17
19
  Jettywrapper.clean
18
20
  end
@@ -15,7 +15,7 @@ module Hydra
15
15
  it "starts" do
16
16
  jetty_params = {
17
17
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
18
- :startup_wait => 45,
18
+ :startup_wait => 90,
19
19
  :java_opts => ["-Xmx256m", '-XX:MaxPermSize=256m'],
20
20
  :jetty_port => TEST_JETTY_PORTS.first
21
21
  }
@@ -39,7 +39,7 @@ module Hydra
39
39
  it "won't start if it's already running" do
40
40
  jetty_params = {
41
41
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
42
- :startup_wait => 45,
42
+ :startup_wait => 90,
43
43
  :java_opts => ["-Xmx256m", '-XX:MaxPermSize=256m'],
44
44
  :jetty_port => TEST_JETTY_PORTS.first
45
45
  }
@@ -19,9 +19,13 @@ require 'rubygems'
19
19
  end
20
20
 
21
21
  context "downloading" do
22
+ after do
23
+ Jettywrapper.reset_config
24
+ end
25
+
22
26
  context "with default file" do
23
27
  it "should download the zip file" do
24
- Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/new-solr-schema.zip -o tmp/new-solr-schema.zip').and_return(system ('true'))
28
+ Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/v7.0.0.zip -o tmp/v7.0.0.zip').and_return(system ('true'))
25
29
  Jettywrapper.download
26
30
  end
27
31
  end
@@ -33,6 +37,13 @@ require 'rubygems'
33
37
  Jettywrapper.url.should == 'http://example.co/file.zip'
34
38
  end
35
39
  end
40
+ context "specifying the version" do
41
+ it "should download the zip file" do
42
+ Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/v9.9.9.zip -o tmp/v9.9.9.zip').and_return(system ('true'))
43
+ Jettywrapper.hydra_jetty_version = 'v9.9.9'
44
+ Jettywrapper.download
45
+ end
46
+ end
36
47
  end
37
48
 
38
49
  context "unzip" do
@@ -42,9 +53,10 @@ require 'rubygems'
42
53
  context "with default file" do
43
54
  it "should download the zip file" do
44
55
  File.should_receive(:exists?).and_return(true)
45
- Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/hydra-jetty-new-solr-schema')
46
- Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/new-solr-schema.zip').and_return(system ('true'))
47
- Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/hydra-jetty-new-solr-schema jetty').and_return(system ('true'))
56
+ Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/hydra-jetty-v7.0.0')
57
+ Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/v7.0.0.zip').and_return(system ('true'))
58
+ Jettywrapper.should_receive(:system).with('rm -r jetty').and_return(system ('true'))
59
+ Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/hydra-jetty-v7.0.0 jetty').and_return(system ('true'))
48
60
  Jettywrapper.unzip
49
61
  end
50
62
  end
@@ -57,6 +69,7 @@ require 'rubygems'
57
69
  File.should_receive(:exists?).and_return(true)
58
70
  Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/interal_dir')
59
71
  Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/file.zip').and_return(system ('true'))
72
+ Jettywrapper.should_receive(:system).with('rm -r jetty').and_return(system ('true'))
60
73
  Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/interal_dir jetty').and_return(system ('true'))
61
74
  Jettywrapper.unzip
62
75
  end
@@ -84,7 +97,7 @@ require 'rubygems'
84
97
  its(:url) {should == 'http://example.com/bar.zip'}
85
98
  end
86
99
  context "when url is not set" do
87
- its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/new-solr-schema.zip'}
100
+ its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/v7.0.0.zip'}
88
101
  end
89
102
  end
90
103
 
@@ -186,11 +199,6 @@ require 'rubygems'
186
199
  ts.jetty_opts.should == @jetty_params[:jetty_opts]
187
200
  end
188
201
 
189
- # passing in a hash is no longer optional
190
- it "raises an error when called without a :jetty_home value" do
191
- lambda { ts = Jettywrapper.configure }.should raise_exception
192
- end
193
-
194
202
  it "should override nil params with defaults" do
195
203
  jetty_params = {
196
204
  :quiet => nil,
@@ -231,7 +239,7 @@ require 'rubygems'
231
239
  :jetty_home => '/tmp'
232
240
  }
233
241
  ts = Jettywrapper.configure(jetty_params)
234
- Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>5454))
242
+ Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>5454))
235
243
  ts.stop
236
244
  ts.start
237
245
  ts.pid.should eql(5454)
@@ -244,7 +252,7 @@ require 'rubygems'
244
252
  }
245
253
  ts = Jettywrapper.configure(jetty_params)
246
254
  ts.stop
247
- Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>2323))
255
+ Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2323))
248
256
  swp = Jettywrapper.start(jetty_params)
249
257
  swp.pid.should eql(2323)
250
258
  swp.pid_file.should eql("_tmp.pid")
@@ -256,7 +264,7 @@ require 'rubygems'
256
264
  # return true if it's running, otherwise return false
257
265
  it "can get the status for a given jetty instance" do
258
266
  # Don't actually start jetty, just fake it
259
- Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>12345))
267
+ Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>12345))
260
268
 
261
269
  jetty_params = {
262
270
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
@@ -270,7 +278,7 @@ require 'rubygems'
270
278
 
271
279
  it "can get the pid for a given jetty instance" do
272
280
  # Don't actually start jetty, just fake it
273
- Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>54321))
281
+ Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>54321))
274
282
  jetty_params = {
275
283
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
276
284
  }
@@ -285,7 +293,7 @@ require 'rubygems'
285
293
  jetty_params = {
286
294
  :jetty_home => '/tmp', :jetty_port => 8777
287
295
  }
288
- Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>2323))
296
+ Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2323))
289
297
  swp = Jettywrapper.start(jetty_params)
290
298
  (File.file? swp.pid_path).should eql(true)
291
299
 
@@ -308,7 +316,7 @@ require 'rubygems'
308
316
  :jetty_home => '/tmp'
309
317
  }
310
318
  ts = Jettywrapper.configure(jetty_params)
311
- Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>2222))
319
+ Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2222))
312
320
  ts.stop
313
321
  ts.pid_file?.should eql(false)
314
322
  ts.start
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: 1.4.0
4
+ version: 1.5.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: 2013-03-08 00:00:00.000000000 Z
13
+ date: 2013-10-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: logger
@@ -148,7 +148,9 @@ extra_rdoc_files: []
148
148
  files:
149
149
  - .gitignore
150
150
  - .gitmodules
151
+ - .rspec
151
152
  - .travis.yml
153
+ - CONTRIBUTING.md
152
154
  - Gemfile
153
155
  - History.txt
154
156
  - README.textile
@@ -182,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
184
  version: 1.3.6
183
185
  requirements: []
184
186
  rubyforge_project:
185
- rubygems_version: 2.0.0
187
+ rubygems_version: 2.0.3
186
188
  signing_key:
187
189
  specification_version: 4
188
190
  summary: Convenience tasks for working with jetty from within a ruby project.