jettywrapper 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9284e993f34211bfbb920de74e13dbfc8327f20e
4
- data.tar.gz: ab277642364c2c6e17534b3d58b1464fcf863b06
3
+ metadata.gz: 813ec58e9127d32a6aaed77b56e1c2cb31d1bdbb
4
+ data.tar.gz: 753964035ecaa0ed84892a19b1aab2b46b2895f8
5
5
  SHA512:
6
- metadata.gz: fd363055dde9350b69f31265f7c5fe2b101e5ffb6b9221ff8d494875acf99c511ad7f84691bde03e38148ce59a81142f21cd9eb4a5f0906813a7c3433c269aaf
7
- data.tar.gz: 0ade95cc7176e3bc4fb237bd23169307f74667c890bb6b46aee03753db7f8cdd209a27efd6c1d1555d0f4e8540b9ce5bbd03f31718b28b979af3220c42abfa7a
6
+ metadata.gz: aa1910b5f5bc64b14dafde8a86ab1e0350b6058b6c23f5a584c55ff284409d48533c148cf6bf218408a7d6c1587b4194e4895bb56da948ce496ab09427fbe67b
7
+ data.tar.gz: 38a177af1bf449317caa58cf8af91b2b5818a4b9cb7d48df7cb80ab79710dc37afe56042dcf97b89a0af7918ff56785fd9c6717b560f517af06b8dbbf2cb5d50
@@ -39,7 +39,8 @@ 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
- attr_writer :hydra_jetty_version, :url, :tmp_dir, :jetty_dir
42
+ attr_writer :hydra_jetty_version, :url, :tmp_dir, :jetty_dir, :env
43
+
43
44
  def hydra_jetty_version
44
45
  @hydra_jetty_version ||= 'v7.0.0'
45
46
  end
@@ -54,7 +55,7 @@ class Jettywrapper
54
55
  end
55
56
 
56
57
  def zip_file
57
- File.join tmp_dir, url.split('/').last
58
+ ENV['JETTY_ZIP'] || File.join(tmp_dir, url.split('/').last)
58
59
  end
59
60
 
60
61
  def jetty_dir
@@ -105,13 +106,30 @@ class Jettywrapper
105
106
 
106
107
  def app_root
107
108
  return @app_root if @app_root
108
- @app_root = Rails.root if defined?(Rails.root)
109
+ @app_root = Rails.root if defined?(Rails) and defined?(Rails.root)
109
110
  @app_root ||= APP_ROOT if defined?(APP_ROOT)
110
111
  @app_root ||= '.'
111
112
  end
112
113
 
113
114
  def env
114
- @env ||= defined?(Rails) ? Rails.env : ENV['environment'] || 'development'
115
+ @env ||= begin
116
+ case
117
+ when ENV['JETTYWRAPPER_ENV']
118
+ ENV['JETTYWRAPPER_ENV']
119
+ when defined?(Rails) && Rails.respond_to?(:env)
120
+ Rails.env
121
+ when ENV['RAILS_ENV']
122
+ ENV['RAILS_ENV']
123
+ when ENV['environment']
124
+ ENV['environment']
125
+ else
126
+ default_environment
127
+ end
128
+ end
129
+ end
130
+
131
+ def default_environment
132
+ 'development'
115
133
  end
116
134
 
117
135
  def load_config(config_name = env)
@@ -1,3 +1,3 @@
1
1
  class Jettywrapper
2
- VERSION = "1.6.0"
2
+ VERSION = "1.7.0"
3
3
  end
@@ -162,6 +162,47 @@ require 'rubygems'
162
162
  its(:app_root) {should == '.'}
163
163
  end
164
164
  end
165
+
166
+ describe "env" do
167
+ before do
168
+ ENV.delete('JETTYWRAPPER_ENV')
169
+ ENV.delete('RAILS_ENV')
170
+ ENV.delete('environment')
171
+ end
172
+
173
+ it "should have a setter" do
174
+ Jettywrapper.env = "abc"
175
+ expect(Jettywrapper.env).to eq "abc"
176
+ end
177
+
178
+ it "should load the ENV['JETTYWRAPPER_ENV']" do
179
+ ENV['JETTYWRAPPER_ENV'] = 'test'
180
+ ENV['RAILS_ENV'] = 'test2'
181
+ ENV['environment'] = 'test3'
182
+ expect(Jettywrapper.env).to eq "test"
183
+ end
184
+
185
+ it "should be the Rails environment" do
186
+ Rails = double(env: 'test')
187
+ expect(Jettywrapper.env).to eq "test"
188
+ end
189
+
190
+ it "should use the ENV['RAILS_ENV']" do
191
+ ENV['RAILS_ENV'] = 'test2'
192
+ ENV['environment'] = 'test3'
193
+ expect(Jettywrapper.env).to eq "test2"
194
+ end
195
+
196
+ it "should load the ENV['environment']" do
197
+ ENV['environment'] = 'test3'
198
+ expect(Jettywrapper.env).to eq "test3"
199
+ end
200
+
201
+ it "should default to 'development'" do
202
+ expect(Jettywrapper.env).to eq "development"
203
+ end
204
+
205
+ end
165
206
 
166
207
  context "config" do
167
208
  before 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: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer