wsdsl 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -0
- data/README.md +29 -0
- data/VERSION +1 -1
- data/lib/response.rb +14 -12
- data/spec/spec_helper.rb +6 -0
- data/spec/test_services.rb +19 -0
- data/spec/wsdsl_spec.rb +1 -0
- data/wsdsl.gemspec +15 -2
- metadata +48 -3
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -149,6 +149,35 @@ This library comes with a test suite requiring Ruby 1.9.2
|
|
149
149
|
The following gems need to be available:
|
150
150
|
Rspec, Rack, Sinatra
|
151
151
|
|
152
|
+
## RUBY 1.8 warning
|
153
|
+
|
154
|
+
This library was written for Ruby 1.9 and 1.8 support was added later on
|
155
|
+
via the backports libary and some tweaks. However, because unlike in
|
156
|
+
ruby 1.9, the hash insert order isn't kept in 1.8 the following syntax
|
157
|
+
isn't supported and the alternative version needs to be used:
|
158
|
+
|
159
|
+
service.response do |response|
|
160
|
+
response.element(:name => "player_creation_ratings") do |e|
|
161
|
+
e.attribute :id => :integer, :doc => "id doc"
|
162
|
+
e.attribute :is_accepted => :boolean, :doc => "is accepted doc"
|
163
|
+
e.attribute :name => :string, :doc => "name doc"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
Instead the following version should be used:
|
168
|
+
|
169
|
+
service.response do |response|
|
170
|
+
response.element(:name => "player_creation_ratings") do |e|
|
171
|
+
e.integer :id, :doc => "id doc"
|
172
|
+
e.boolean :is_accepted, :doc => "is accepted doc"
|
173
|
+
e.string :name, :doc => "name doc"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
Both code snippets do the exact same thing but the first version is 1.9
|
178
|
+
only.
|
179
|
+
|
180
|
+
|
152
181
|
|
153
182
|
## Copyright
|
154
183
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/lib/response.rb
CHANGED
@@ -173,14 +173,13 @@ class WSDSL
|
|
173
173
|
#
|
174
174
|
# @return [Array<WSDSL::Response::Attribute>]
|
175
175
|
# @api public
|
176
|
-
def attribute(opts)
|
177
|
-
raise ArgumentError unless opts.is_a?(Hash)
|
178
|
-
|
179
|
-
new_attribute = Attribute.new(opts)
|
176
|
+
def attribute(opts, extra_opts={})
|
177
|
+
raise ArgumentError unless opts.is_a?(Hash) && extra_opts.is_a?(Hash)
|
178
|
+
new_attribute = Attribute.new(opts, extra_opts)
|
180
179
|
@attributes << new_attribute
|
181
180
|
# document the attribute if description available
|
182
181
|
# we might want to have a placeholder message when a response attribute isn't defined
|
183
|
-
if opts.has_key?(:doc)
|
182
|
+
if opts.merge!(extra_opts).has_key?(:doc)
|
184
183
|
@doc.attribute(new_attribute.name, opts[:doc])
|
185
184
|
end
|
186
185
|
@attributes
|
@@ -299,7 +298,7 @@ class WSDSL
|
|
299
298
|
# @param [Symbol, String] name the name of the attribute.
|
300
299
|
# @param [Hash] opts the attribute options.
|
301
300
|
def string(name=nil, opts={})
|
302
|
-
attribute({name => :string}
|
301
|
+
attribute({name => :string}, opts)
|
303
302
|
end
|
304
303
|
|
305
304
|
# Shortcut to create a string attribute
|
@@ -307,7 +306,7 @@ class WSDSL
|
|
307
306
|
# @param [Symbol, String] name the name of the attribute.
|
308
307
|
# @param [Hash] opts the attribute options.
|
309
308
|
def integer(name=nil, opts={})
|
310
|
-
attribute({name => :integer}
|
309
|
+
attribute({name => :integer}, opts)
|
311
310
|
end
|
312
311
|
|
313
312
|
# Shortcut to create a string attribute
|
@@ -315,7 +314,7 @@ class WSDSL
|
|
315
314
|
# @param [Symbol, String] name the name of the attribute.
|
316
315
|
# @param [Hash] opts the attribute options.
|
317
316
|
def float(name=nil, opts={})
|
318
|
-
attribute({name => :float}
|
317
|
+
attribute({name => :float}, opts)
|
319
318
|
end
|
320
319
|
|
321
320
|
# Shortcut to create a string attribute
|
@@ -323,7 +322,7 @@ class WSDSL
|
|
323
322
|
# @param [Symbol, String] name the name of the attribute.
|
324
323
|
# @param [Hash] opts the attribute options.
|
325
324
|
def boolean(name=nil, opts={})
|
326
|
-
attribute({name => :boolean}
|
325
|
+
attribute({name => :boolean}, opts)
|
327
326
|
end
|
328
327
|
|
329
328
|
# Shortcut to create a string attribute
|
@@ -331,7 +330,7 @@ class WSDSL
|
|
331
330
|
# @param [Symbol, String] name the name of the attribute.
|
332
331
|
# @param [Hash] opts the attribute options.
|
333
332
|
def datetime(name=nil, opts={})
|
334
|
-
attribute({name => :datetime}
|
333
|
+
attribute({name => :datetime}, opts)
|
335
334
|
end
|
336
335
|
|
337
336
|
# Converts an element into a hash representation
|
@@ -422,14 +421,17 @@ class WSDSL
|
|
422
421
|
# name, type, doc, type
|
423
422
|
#
|
424
423
|
# @param [Hash, Array] o_params
|
424
|
+
# @param [Hash] o_extra_params A hash with extra params passed, needed to support Ruby 1.8 :(
|
425
425
|
#
|
426
426
|
# @api public
|
427
|
-
def initialize(o_params)
|
427
|
+
def initialize(o_params, o_extra_params={})
|
428
428
|
params = o_params.dup
|
429
|
+
extra_params = o_extra_params.dup
|
429
430
|
if params.is_a?(Hash)
|
430
431
|
@name, @type = params.shift
|
431
432
|
@doc = params.delete(:doc) if params.has_key?(:doc)
|
432
|
-
@
|
433
|
+
@doc ||= extra_params.delete(:doc) if extra_params.has_key?(:doc)
|
434
|
+
@opts = params.merge!(extra_params)
|
433
435
|
elsif params.is_a?(Array)
|
434
436
|
@name = params.shift
|
435
437
|
@type = params.shift
|
data/spec/spec_helper.rb
CHANGED
data/spec/test_services.rb
CHANGED
@@ -26,6 +26,8 @@ describe_service "services/test.xml" do |service|
|
|
26
26
|
|
27
27
|
# the response contains a list of player creation ratings each object in the list
|
28
28
|
|
29
|
+
=begin
|
30
|
+
#Format not supported by Ruby 1.8 due to hash insertion order not being maintained.
|
29
31
|
service.response do |response|
|
30
32
|
response.element(:name => "player_creation_ratings") do |e|
|
31
33
|
e.attribute :id => :integer, :doc => "id doc"
|
@@ -40,6 +42,23 @@ describe_service "services/test.xml" do |service|
|
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
45
|
+
=end
|
46
|
+
|
47
|
+
service.response do |response|
|
48
|
+
response.element(:name => "player_creation_ratings") do |e|
|
49
|
+
e.integer :id, :doc => "id doc"
|
50
|
+
e.boolean :is_accepted, :doc => "is accepted doc"
|
51
|
+
e.string :name, :doc => "name doc"
|
52
|
+
|
53
|
+
e.array :player_creation_rating, 'PlayerCreationRating' do |a|
|
54
|
+
a.string :comments, :doc => "comments doc"
|
55
|
+
a.integer :player_id, :doc => "player_id doc"
|
56
|
+
a.integer :rating, :doc => "rating doc"
|
57
|
+
a.string :username, :doc => "username doc"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
43
62
|
|
44
63
|
service.documentation do |doc|
|
45
64
|
# doc.overall <markdown description text>
|
data/spec/wsdsl_spec.rb
CHANGED
@@ -287,6 +287,7 @@ The most common way to use this service looks like that:
|
|
287
287
|
end
|
288
288
|
|
289
289
|
it "should have documentation for a response element attribute" do
|
290
|
+
p @service.response.elements.first.doc.inspect
|
290
291
|
@service.response.elements.first.doc.attributes.should_not be_empty
|
291
292
|
@service.response.elements.first.doc.attributes[:id].should == "id doc"
|
292
293
|
end
|
data/wsdsl.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "wsdsl"
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Aimonetti"]
|
12
|
-
s.date = "2012-01-
|
12
|
+
s.date = "2012-01-12"
|
13
13
|
s.description = "A Ruby DSL describing Web Services without implementation details."
|
14
14
|
s.email = "mattaimonetti@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
+
"Gemfile",
|
20
21
|
"LICENSE",
|
21
22
|
"README.md",
|
22
23
|
"Rakefile",
|
@@ -53,9 +54,21 @@ Gem::Specification.new do |s|
|
|
53
54
|
s.specification_version = 3
|
54
55
|
|
55
56
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
|
+
s.add_runtime_dependency(%q<jeweler>, [">= 0"])
|
58
|
+
s.add_runtime_dependency(%q<rspec>, [">= 0"])
|
59
|
+
s.add_runtime_dependency(%q<rack-test>, [">= 0"])
|
60
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 0"])
|
56
61
|
else
|
62
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
63
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
64
|
+
s.add_dependency(%q<rack-test>, [">= 0"])
|
65
|
+
s.add_dependency(%q<sinatra>, [">= 0"])
|
57
66
|
end
|
58
67
|
else
|
68
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
70
|
+
s.add_dependency(%q<rack-test>, [">= 0"])
|
71
|
+
s.add_dependency(%q<sinatra>, [">= 0"])
|
59
72
|
end
|
60
73
|
end
|
61
74
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wsdsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,52 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-01-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jeweler
|
16
|
+
requirement: &70320885201320 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70320885201320
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70320885200840 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70320885200840
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rack-test
|
38
|
+
requirement: &70320885200360 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70320885200360
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sinatra
|
49
|
+
requirement: &70320885199880 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70320885199880
|
14
58
|
description: A Ruby DSL describing Web Services without implementation details.
|
15
59
|
email: mattaimonetti@gmail.com
|
16
60
|
executables: []
|
@@ -19,6 +63,7 @@ extra_rdoc_files:
|
|
19
63
|
- LICENSE
|
20
64
|
- README.md
|
21
65
|
files:
|
66
|
+
- Gemfile
|
22
67
|
- LICENSE
|
23
68
|
- README.md
|
24
69
|
- Rakefile
|