playerconnect-wsdsl 0.3.9 → 0.4.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.
- data/VERSION +1 -1
- data/lib/response_exceptions.rb +43 -0
- data/lib/wsdsl.rb +22 -1
- data/playerconnect-wsdsl.gemspec +2 -1
- data/spec/params_verification_spec.rb +8 -0
- data/spec/test_services.rb +13 -0
- metadata +2 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class WSDSL
|
2
|
+
|
3
|
+
class ResponseExceptions
|
4
|
+
|
5
|
+
attr_reader :list
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@list = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def document(klass, doc)
|
12
|
+
@list << Doc.new(klass, doc)
|
13
|
+
end
|
14
|
+
|
15
|
+
def classes
|
16
|
+
@list.collect(&:klass)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
# ResponseException::Doc DSL class
|
22
|
+
# @api public
|
23
|
+
class Doc
|
24
|
+
|
25
|
+
# The exception class
|
26
|
+
#
|
27
|
+
# @return [Exception]
|
28
|
+
# @api public
|
29
|
+
attr_reader :klass
|
30
|
+
|
31
|
+
# The documentation for the exception
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
# @api public
|
35
|
+
attr_reader :doc
|
36
|
+
|
37
|
+
def initialize(klass, doc='')
|
38
|
+
@klass = klass
|
39
|
+
@doc = doc
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/lib/wsdsl.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.expand_path('inflection', File.dirname(__FILE__))
|
2
2
|
require File.expand_path('params', File.dirname(__FILE__))
|
3
3
|
require File.expand_path('response', File.dirname(__FILE__))
|
4
|
+
require File.expand_path('response_exceptions', File.dirname(__FILE__))
|
4
5
|
require File.expand_path('documentation', File.dirname(__FILE__))
|
5
6
|
require File.expand_path('ws_list', File.dirname(__FILE__))
|
6
7
|
|
@@ -111,6 +112,12 @@ class WSDSL
|
|
111
112
|
# @api public
|
112
113
|
# @since 0.1
|
113
114
|
attr_reader :extra
|
115
|
+
|
116
|
+
# Array of exception classes
|
117
|
+
#
|
118
|
+
# @return [Class]
|
119
|
+
# @api public
|
120
|
+
attr_reader :exceptions
|
114
121
|
|
115
122
|
# Service constructor which is usually used via {Kernel#describe_service}
|
116
123
|
#
|
@@ -122,6 +129,7 @@ class WSDSL
|
|
122
129
|
@defined_params = WSDSL::Params.new
|
123
130
|
@doc = WSDSL::Documentation.new
|
124
131
|
@response = WSDSL::Response.new
|
132
|
+
@exceptions = WSDSL::ResponseExceptions.new
|
125
133
|
@name = extract_service_root_name(url)
|
126
134
|
if WSDSL.use_pluralized_controllers
|
127
135
|
base_name = ExtlibCopy::Inflection.pluralize(ExtlibCopy::Inflection.singular(name))
|
@@ -288,7 +296,20 @@ class WSDSL
|
|
288
296
|
@formats
|
289
297
|
end
|
290
298
|
|
291
|
-
# Sets
|
299
|
+
# Sets or returns the known exceptions
|
300
|
+
# @param [Class] exception_classes Known response exceptions
|
301
|
+
#
|
302
|
+
# @return [Array<Class>] List of known exception classes
|
303
|
+
# @api public
|
304
|
+
def exceptions
|
305
|
+
if block_given?
|
306
|
+
yield(@exceptions)
|
307
|
+
else
|
308
|
+
@exceptions
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
# Sets and/or returns the service known exceptions
|
292
313
|
# @param [String, Symbol] a Action to use for the service, such as :show
|
293
314
|
#
|
294
315
|
# @return [Symbol] The service action
|
data/playerconnect-wsdsl.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "playerconnect-wsdsl"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Team SDOD"]
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/params.rb",
|
32
32
|
"lib/params_verification.rb",
|
33
33
|
"lib/response.rb",
|
34
|
+
"lib/response_exceptions.rb",
|
34
35
|
"lib/ws_list.rb",
|
35
36
|
"lib/wsdsl.rb",
|
36
37
|
"playerconnect-wsdsl.gemspec",
|
@@ -139,4 +139,12 @@ describe ParamsVerification do
|
|
139
139
|
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should raise_exception
|
140
140
|
end
|
141
141
|
|
142
|
+
it "should not mutate nested params to a serialized ruby object" do
|
143
|
+
service = WSList.all.find{|s| s.url == "services/test_deep_nested_params"}
|
144
|
+
service.should_not be_nil
|
145
|
+
params = {"analytics"=>{"accountId"=>"456", "events"=>[{"eventInfo"=>"asdf", "eventInfo2"=>"asdf"}, {"eventInfo"=>"asdfasdf", "eventInfo2"=>"asdfasdf"}], "sessionId"=>"123"}}
|
146
|
+
validated = ParamsVerification.validate!(params, service.defined_params)
|
147
|
+
validated[:analytics][:events].should be == params['analytics']['events']
|
148
|
+
end
|
149
|
+
|
142
150
|
end
|
data/spec/test_services.rb
CHANGED
@@ -75,6 +75,19 @@ describe_service "services" do |service|
|
|
75
75
|
|
76
76
|
end
|
77
77
|
|
78
|
+
describe_service "services/test_deep_nested_params" do |service|
|
79
|
+
service.formats :json
|
80
|
+
service.http_verb :post
|
81
|
+
|
82
|
+
service.params do |p|
|
83
|
+
p.namespace :analytics do |a|
|
84
|
+
a.string :accountId, :required => true
|
85
|
+
a.string :sessionId, :required => true
|
86
|
+
a.string :events, :required => true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
78
91
|
describe_service "services/array_param" do |s|
|
79
92
|
s.formats :xml
|
80
93
|
s.http_verb :post
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playerconnect-wsdsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/params.rb
|
114
114
|
- lib/params_verification.rb
|
115
115
|
- lib/response.rb
|
116
|
+
- lib/response_exceptions.rb
|
116
117
|
- lib/ws_list.rb
|
117
118
|
- lib/wsdsl.rb
|
118
119
|
- playerconnect-wsdsl.gemspec
|