torquebox-configure 2.0.0.cr1-java → 2.0.0-java
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.
- data/lib/torquebox/configuration/global.rb +22 -2
- data/lib/torquebox/configuration.rb +19 -2
- data/lib/torquebox-configure.jar +0 -0
- data/lib/torquebox-configure.rb +2 -2
- data/spec/global_spec.rb +35 -0
- metadata +8 -8
@@ -48,6 +48,7 @@ module TorqueBox
|
|
48
48
|
:injection => OptionsEntry.with_settings(:validate => {
|
49
49
|
:required => [{ :enabled => [true, false] }]
|
50
50
|
}),
|
51
|
+
:config => OptionsEntry,
|
51
52
|
:job => ThingWithOptionsEntry.with_settings(:discrete => true,
|
52
53
|
:validate => {
|
53
54
|
:required => [:cron],
|
@@ -194,18 +195,37 @@ module TorqueBox
|
|
194
195
|
end
|
195
196
|
end
|
196
197
|
|
197
|
-
|
198
|
+
ruby_to_java( metadata )
|
199
|
+
end
|
200
|
+
|
201
|
+
def ruby_to_java(object)
|
202
|
+
r = object
|
203
|
+
case ( object )
|
204
|
+
when Hash
|
205
|
+
r = hash_to_hashmap(object)
|
206
|
+
when Array
|
207
|
+
r = array_to_arraylist(object)
|
208
|
+
end
|
209
|
+
r
|
198
210
|
end
|
199
211
|
|
200
212
|
def hash_to_hashmap(hash)
|
201
213
|
hashmap = java.util.HashMap.new
|
202
214
|
hash.each do |key, value|
|
203
|
-
value =
|
215
|
+
value = ruby_to_java( value )
|
204
216
|
hashmap[key.to_s] = value
|
205
217
|
end
|
206
218
|
hashmap
|
207
219
|
end
|
208
220
|
|
221
|
+
def array_to_arraylist(array)
|
222
|
+
arraylist = java.util.ArrayList.new
|
223
|
+
array.each do |value|
|
224
|
+
arraylist.add( ruby_to_java( value ) )
|
225
|
+
end
|
226
|
+
arraylist
|
227
|
+
end
|
228
|
+
|
209
229
|
protected
|
210
230
|
def unique_name(name, set, suffix = nil)
|
211
231
|
name = "#{name}-#{suffix}" if suffix
|
@@ -29,7 +29,7 @@ module TorqueBox
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.const_missing(name)
|
32
|
-
FakeConstant.new( name )
|
32
|
+
FakeConstant.new( name ).to_const
|
33
33
|
end
|
34
34
|
|
35
35
|
class Entry < BlankSlate
|
@@ -79,7 +79,8 @@ module TorqueBox
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def self.const_missing(name)
|
82
|
-
|
82
|
+
puts "CONST_MISSING #{name}"
|
83
|
+
FakeConstant.new( name ).to_const
|
83
84
|
end
|
84
85
|
|
85
86
|
def self.with_settings(options)
|
@@ -171,6 +172,22 @@ module TorqueBox
|
|
171
172
|
class FakeConstant
|
172
173
|
def initialize(name)
|
173
174
|
@name = name.to_s
|
175
|
+
puts "MODULE #{name}"
|
176
|
+
s = <<-END
|
177
|
+
module ::#{name}
|
178
|
+
def self.const_missing(k)
|
179
|
+
FakeConstant.new( "#{name}::" + k.to_s )
|
180
|
+
end
|
181
|
+
end
|
182
|
+
END
|
183
|
+
|
184
|
+
puts "eval #{s}"
|
185
|
+
eval s
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
def to_const
|
190
|
+
eval @name
|
174
191
|
end
|
175
192
|
|
176
193
|
def to_s
|
data/lib/torquebox-configure.jar
CHANGED
Binary file
|
data/lib/torquebox-configure.rb
CHANGED
data/spec/global_spec.rb
CHANGED
@@ -277,6 +277,19 @@ describe "TorqueBox.configure using the GlobalConfiguration" do
|
|
277
277
|
|
278
278
|
config['<root>']['service'].should == [['AService', { }], ['AService', { }]]
|
279
279
|
end
|
280
|
+
|
281
|
+
it "should allow service configuration with a block" do
|
282
|
+
config = TorqueBox.configure do
|
283
|
+
service 'AConfiguredService' do
|
284
|
+
config do
|
285
|
+
food :biscuit
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
config['<root>']['service'].should == [["AConfiguredService", {"config"=>{:food=>:biscuit}}]]
|
291
|
+
end
|
292
|
+
|
280
293
|
end
|
281
294
|
|
282
295
|
describe '#stomp' do
|
@@ -332,6 +345,15 @@ describe "TorqueBox.configure using the GlobalConfiguration" do
|
|
332
345
|
config['<root>']['job'].should == [['AJob', { :cron => '1234' }], ['AJob', { :cron => '1234' }]]
|
333
346
|
end
|
334
347
|
|
348
|
+
it "should allow jobs in modules" do
|
349
|
+
config = TorqueBox.configure do
|
350
|
+
job 'One::AJob', :cron => '1234'
|
351
|
+
job 'Two::AJob', :cron => '1234'
|
352
|
+
end
|
353
|
+
|
354
|
+
config['<root>']['job'].should == [['One::AJob', { :cron => '1234' }], ['Two::AJob', { :cron => '1234' }]]
|
355
|
+
end
|
356
|
+
|
335
357
|
it "should allow cron to be set in a block" do
|
336
358
|
lambda {
|
337
359
|
TorqueBox.configure do
|
@@ -351,6 +373,19 @@ describe "TorqueBox.configure using the GlobalConfiguration" do
|
|
351
373
|
}.should raise_error(TorqueBox::Configuration::ConfigurationError)
|
352
374
|
end
|
353
375
|
|
376
|
+
it "should allow job configuration with a block" do
|
377
|
+
config = TorqueBox.configure do
|
378
|
+
job 'AConfiguredJob' do
|
379
|
+
cron '123'
|
380
|
+
config do
|
381
|
+
food :biscuit
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
config['<root>']['job'].should == [["AConfiguredJob", {:cron=>"123", "config"=>{:food=>:biscuit}}]]
|
387
|
+
end
|
388
|
+
|
354
389
|
end
|
355
390
|
|
356
391
|
describe "#to_metadata_hash" do
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torquebox-configure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 2.0.0
|
4
|
+
prerelease:
|
5
|
+
version: 2.0.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- The TorqueBox Team
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-03-
|
13
|
+
date: 2012-03-31 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: blankslate
|
@@ -48,14 +48,14 @@ files:
|
|
48
48
|
- lib/torquebox-configure.jar
|
49
49
|
- lib/torquebox-configure.rb
|
50
50
|
- lib/gem_hook.rb
|
51
|
-
- lib/torquebox/configuration.rb
|
52
51
|
- lib/torquebox/configure.rb
|
52
|
+
- lib/torquebox/configuration.rb
|
53
53
|
- lib/torquebox/configuration/validator.rb
|
54
54
|
- lib/torquebox/configuration/global.rb
|
55
|
-
- spec/options_macros.rb
|
56
55
|
- spec/validator_spec.rb
|
57
56
|
- spec/global_spec.rb
|
58
|
-
|
57
|
+
- spec/options_macros.rb
|
58
|
+
homepage: http://torquebox.org/
|
59
59
|
licenses:
|
60
60
|
- lgpl
|
61
61
|
post_install_message:
|
@@ -72,9 +72,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- - "
|
75
|
+
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: "0"
|
78
78
|
requirements: []
|
79
79
|
|
80
80
|
rubyforge_project:
|