Skip to content

Commit

Permalink
Merge pull request #42 from projecthydra/update-hydra-jetty
Browse files Browse the repository at this point in the history
Updating to use hydra-jetty/master
  • Loading branch information
carolyncole committed Feb 24, 2015
2 parents dfac77f + 214573b commit 2fe4a10
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 69 deletions.
70 changes: 70 additions & 0 deletions README.md
@@ -0,0 +1,70 @@
# Jettywrapper [![Version](https://badge.fury.io/gh/projecthydra%2Fjettywrapper.png)](http://badge.fury.io/gh/projecthydra%2Fjettywrapper) [![Build Status](https://travis-ci.org/projecthydra/jettywrapper.png?branch=master)](https://travis-ci.org/projecthydra/jettywrapper)

This gem is designed to make it easier to integrate a jetty servlet container into a rails project.
Jettywrapper provides rake tasks for starting and stopping jetty, as well as the method `Jettywrapper.wrap` that will start
the server before the block and stop the server after the block, which is useful for automated testing.

By default, Jettywrapper is designed to work with Rails projects that use the Hydra gem, and downloads an instance of a
[hydra-jetty](https://github.com/projecthydra/hydra-jetty) project zipfile. However, it can be configured to
download any Jetty-based project on Github.

Jettywrapper supports

* ruby 2.0.0
* ruby 1.9.3
* ruby 1.8.7
* ree 1.8.7
* jruby 1.6.6+

## Configuring Jettywrapper

Jettywrapper starts the process with a list of options that you can specify in `config/jetty.yml`, otherwise a default is used.
You can provide a per-environment configuration, or you can have a default configuration which will be used when a per-environment
configuration is not specified. Such a configuration might look like:

default:
 jetty_port: 8983
 java_opts:
   - "-XX:MaxPermSize=128m"
   - "-Xmx256m"

You can also configure a specific version of hydra-jetty. This is placed in your codebase, usually in a rake task

Jettywrapper.hydra_jetty_version = "v1.2.3"

Alternatively, you can use a completely different Jetty-based repository, Hydra-related or not

Jettywrapper.url = "https://github.com/myorg/my-jetty/archive/master.zip"

The name of the zip file can either be a branch name, such as master or develop, or the tag name of a released version.
Basically, any url that Github provides as a *.zip file will work.

## Example rake task

```ruby
require 'jettywrapper'
Jettywrapper.url = "https://github.com/myorg/my-jetty/archive/testing-feature-branch.zip"
desc "Hudson build"
task :hudson do
jetty_params = Jettywrapper.load_config.merge({:jetty_home => File.expand_path(File.dirname(__FILE__) + '/../jetty')})
error = Jettywrapper.wrap(jetty_params) do
Rake::Task["spec"].invoke
end
raise "test failures: #{error}" if error
end
```

## Testing the gem

If you haven't already, clone the git repository

git clone git@github.com:projecthydra/jettywrapper.git
cd jettywrapper

Install the gems

bundle install

Run the tests

rake
64 changes: 0 additions & 64 deletions README.textile

This file was deleted.

2 changes: 1 addition & 1 deletion lib/jettywrapper.rb
Expand Up @@ -42,7 +42,7 @@ class << self
attr_writer :hydra_jetty_version, :url, :tmp_dir, :jetty_dir, :env

def hydra_jetty_version
@hydra_jetty_version ||= 'v8.1.1'
@hydra_jetty_version ||= 'master'
end

def url
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/jettywrapper_spec.rb
Expand Up @@ -21,13 +21,13 @@

before do
Jettywrapper.reset_config
FileUtils.rm "tmp/v8.1.1.zip", force: true
FileUtils.rm "tmp/master.zip", force: true
end

context "downloading" do
context "with default file" do
it "should download the zip file" do
expect(Jettywrapper).to receive(:open).with('https://github.com/projecthydra/hydra-jetty/archive/v8.1.1.zip').and_return(system ('true'))
expect(Jettywrapper).to receive(:open).with('https://github.com/projecthydra/hydra-jetty/archive/master.zip').and_return(system ('true'))
Jettywrapper.download
end
end
Expand Down Expand Up @@ -56,7 +56,7 @@
it "should download the zip file" do
expect(File).to receive(:exists?).and_return(true)
expect(Jettywrapper).to receive(:expanded_zip_dir).and_return('tmp/jetty_generator/interal_dir')
expect(Zip::File).to receive(:open).with('tmp/v8.1.1.zip').and_return(true)
expect(Zip::File).to receive(:open).with('tmp/master.zip').and_return(true)
expect(FileUtils).to receive(:remove_dir).with('jetty',true).and_return(true)
expect(FileUtils).to receive(:mv).with('tmp/jetty_generator/interal_dir','jetty').and_return(true)
Jettywrapper.unzip
Expand Down Expand Up @@ -99,7 +99,7 @@
its(:url) {should == 'http://example.com/bar.zip'}
end
context "when url is not set" do
its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/v8.1.1.zip'}
its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/master.zip'}
end
end

Expand Down

0 comments on commit 2fe4a10

Please sign in to comment.