playerconnect-wsdsl 0.2.2 → 0.2.3
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/.rvmrc_example +2 -2
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/wsdsl.rb +22 -14
- data/playerconnect-wsdsl.gemspec +3 -3
- data/spec/wsdsl_spec.rb +44 -44
- metadata +3 -3
data/.rvmrc_example
CHANGED
@@ -2,7 +2,7 @@ gemset_name=wsdsl
|
|
2
2
|
ruby_version=1.9.2-p180
|
3
3
|
rubygems_version=1.8.5
|
4
4
|
# specify multiple gems with spaces ex: ('foo 1.2.3' 'bar 5.6.7')
|
5
|
-
gems=('jeweler 1.6.4' 'rspec 2.6.0' 'yard 0.7.2')
|
5
|
+
gems=('jeweler 1.6.4' 'rspec 2.6.0' 'yard 0.7.2' 'rack-test 0.5.7' 'sinatra 1.2.0')
|
6
6
|
|
7
7
|
export GIT_SSL_NO_VERIFY=true
|
8
8
|
|
@@ -12,4 +12,4 @@ for g in "${gems[@]}"; do
|
|
12
12
|
read n v <<< $(echo $g | awk '{print $1 " " $2}')
|
13
13
|
gem list ${n} -v${v} -i >> /dev/null
|
14
14
|
[ $? -eq 0 ] || gem install ${n} -v${v} --no-ri --no-rdoc
|
15
|
-
done
|
15
|
+
done
|
data/Rakefile
CHANGED
@@ -9,9 +9,9 @@ Jeweler::Tasks.new do |gem|
|
|
9
9
|
gem.license = "MIT"
|
10
10
|
gem.summary = %Q{Web Service DSL}
|
11
11
|
gem.description = %Q{A Ruby DSL describing Web Services without implementation details.}
|
12
|
-
gem.email = "sdod
|
12
|
+
gem.email = "sdod"
|
13
13
|
gem.authors = ["Team SDOD"]
|
14
|
-
gem.version = "0.2.
|
14
|
+
gem.version = "0.2.3"
|
15
15
|
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
16
16
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
17
17
|
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/wsdsl.rb
CHANGED
@@ -76,18 +76,6 @@ class WSDSL
|
|
76
76
|
# @api public
|
77
77
|
attr_reader :controller
|
78
78
|
|
79
|
-
# Name of the controller action associated with the service
|
80
|
-
#
|
81
|
-
# @return [String]
|
82
|
-
# @api public
|
83
|
-
attr_accessor :action
|
84
|
-
|
85
|
-
# Name of the controller associated with the service
|
86
|
-
#
|
87
|
-
# @return [String]
|
88
|
-
# @api public
|
89
|
-
attr_accessor :controller_name
|
90
|
-
|
91
79
|
# Name of the service
|
92
80
|
#
|
93
81
|
# @return [String]
|
@@ -238,7 +226,7 @@ class WSDSL
|
|
238
226
|
def enable_ssl
|
239
227
|
@ssl = true
|
240
228
|
end
|
241
|
-
|
229
|
+
|
242
230
|
# Mark the current service as not accepting any params.
|
243
231
|
# This is purely for expressing the developer's objective since
|
244
232
|
# by default an error is raise if no params are defined and some
|
@@ -273,7 +261,27 @@ class WSDSL
|
|
273
261
|
f_types.each{|f| @formats << f unless @formats.include?(f) }
|
274
262
|
@formats
|
275
263
|
end
|
276
|
-
|
264
|
+
|
265
|
+
# Sets and/or returns the service action
|
266
|
+
# @param [String, Symbol] a Action to use for the service, such as :show
|
267
|
+
#
|
268
|
+
# @return Symbol The service action
|
269
|
+
# @api public
|
270
|
+
def action(a=nil)
|
271
|
+
@action = a.to_sym if a
|
272
|
+
@action
|
273
|
+
end
|
274
|
+
|
275
|
+
# Sets and/or returns the controller name
|
276
|
+
# @param [String, Symbol] cn Controller name to use for the service
|
277
|
+
#
|
278
|
+
# @return String The controller name
|
279
|
+
# @api public
|
280
|
+
def controller_name(cn=nil)
|
281
|
+
@controller_name = cn.to_s if cn
|
282
|
+
@controller_name
|
283
|
+
end
|
284
|
+
|
277
285
|
# Sets the accepted HTTP verbs or return it if nothing is passed.
|
278
286
|
#
|
279
287
|
# @return [String, Symbol]
|
data/playerconnect-wsdsl.gemspec
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{playerconnect-wsdsl}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Team SDOD}]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-10}
|
13
13
|
s.description = %q{A Ruby DSL describing Web Services without implementation details.}
|
14
|
-
s.email = %q{sdod
|
14
|
+
s.email = %q{sdod}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
17
|
"README.md"
|
data/spec/wsdsl_spec.rb
CHANGED
@@ -9,15 +9,15 @@ describe WSDSL do
|
|
9
9
|
|
10
10
|
it "should have an url" do
|
11
11
|
# dummy test since that's how we found the service, but oh well
|
12
|
-
@service.url.should == 'services/test.xml'
|
12
|
+
@service.url.should be == 'services/test.xml'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should have some http verbs defined" do
|
16
|
-
@service.verb.should == :get
|
16
|
+
@service.verb.should be == :get
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should have supported formats defined" do
|
20
|
-
@service.formats.should == [:xml, :json]
|
20
|
+
@service.formats.should be == [:xml, :json]
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should have params info" do
|
@@ -25,76 +25,76 @@ describe WSDSL do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should have direct access to the required params" do
|
28
|
-
@service.required_rules.should == @service.params.list_required
|
28
|
+
@service.required_rules.should be == @service.params.list_required
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should have direct access to the optional params" do
|
32
|
-
@service.optional_rules.should == @service.params.list_optional
|
32
|
+
@service.optional_rules.should be == @service.params.list_optional
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should have direct access to the nested params" do
|
36
|
-
@service.nested_params.should == @service.params.namespaced_params
|
36
|
+
@service.nested_params.should be == @service.params.namespaced_params
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should set the controller accordingly" do
|
40
40
|
@service.controller_name.should_not be_nil
|
41
|
-
@service.controller_name.should == 'ServicesController'
|
41
|
+
@service.controller_name.should be == 'ServicesController'
|
42
42
|
service = WSDSL.new("preferences.xml")
|
43
|
-
service.name.should == 'preferences'
|
44
|
-
ExtlibCopy.classify('preferences').should == 'Preferences'
|
45
|
-
service.controller_name.should == 'PreferencesController'
|
43
|
+
service.name.should be == 'preferences'
|
44
|
+
ExtlibCopy.classify('preferences').should be == 'Preferences'
|
45
|
+
service.controller_name.should be == 'PreferencesController'
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should set the action accordingly" do
|
49
49
|
@service.action.should_not be_nil
|
50
|
-
@service.action.should == 'test'
|
50
|
+
@service.action.should be == 'test'
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should support restful routes based on the HTTP verb" do
|
54
54
|
service = WSList.all.find{|s| s.url == "services.xml"}
|
55
55
|
service.should_not be_nil
|
56
|
-
service.http_verb.should == :put
|
56
|
+
service.http_verb.should be == :put
|
57
57
|
service.action.should_not be_nil
|
58
|
-
service.controller_name.should == 'ServicesController'
|
59
|
-
service.action.should == 'update'
|
58
|
+
service.controller_name.should be == 'ServicesController'
|
59
|
+
service.action.should be == 'update'
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should have a default action" do
|
63
63
|
service = WSDSL.new('spec_test.xml')
|
64
|
-
service.action.should == 'list'
|
64
|
+
service.action.should be == 'list'
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should route to show when an id is the last passed param" do
|
68
68
|
service = WSDSL.new("players/:id.xml")
|
69
|
-
service.action.should == 'show'
|
69
|
+
service.action.should be == 'show'
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should support some extra attributes" do
|
73
73
|
service = WSDSL.new("players/:id.xml")
|
74
74
|
service.extra[:custom_name] = 'fooBar'
|
75
|
-
service.extra[:custom_name].should == 'fooBar'
|
75
|
+
service.extra[:custom_name].should be == 'fooBar'
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should respect the global controller pluralization flag" do
|
79
79
|
WSDSL.use_pluralized_controllers = true
|
80
80
|
service = WSDSL.new("player/:id.xml")
|
81
|
-
service.controller_name.should == "PlayersController"
|
81
|
+
service.controller_name.should be == "PlayersController"
|
82
82
|
service = WSDSL.new("players/:id.xml")
|
83
|
-
service.controller_name.should == "PlayersController"
|
83
|
+
service.controller_name.should be == "PlayersController"
|
84
84
|
WSDSL.use_pluralized_controllers = false
|
85
85
|
service = WSDSL.new("player/:id.xml")
|
86
|
-
service.controller_name.should == "PlayerController"
|
86
|
+
service.controller_name.should be == "PlayerController"
|
87
87
|
end
|
88
88
|
|
89
89
|
|
90
90
|
it "should let overwrite the controller name and action after initialization" do
|
91
91
|
describe_service "players/:id.xml" do |service|
|
92
|
-
service.controller_name
|
93
|
-
service.action
|
92
|
+
service.controller_name "CustomController"
|
93
|
+
service.action :foo
|
94
94
|
end
|
95
95
|
service = WSList.all.find{|s| s.url == "players/:id.xml"}
|
96
|
-
service.controller_name.should == "CustomController"
|
97
|
-
service.action.should ==
|
96
|
+
service.controller_name.should be == "CustomController"
|
97
|
+
service.action.should be == :foo
|
98
98
|
end
|
99
99
|
|
100
100
|
describe WSDSL::Params do
|
@@ -106,23 +106,23 @@ describe WSDSL do
|
|
106
106
|
it "should have the possibility to have a space name" do
|
107
107
|
@sparams.should respond_to(:space_name)
|
108
108
|
service_params = WSDSL::Params.new(:space_name => 'spec_test')
|
109
|
-
service_params.space_name.should == 'spec_test'
|
109
|
+
service_params.space_name.should be == 'spec_test'
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should have a list of required param rules" do
|
113
113
|
@sparams.list_required.should be_an_instance_of(Array)
|
114
|
-
@sparams.list_required.length.should == 1
|
114
|
+
@sparams.list_required.length.should be == 1
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should have a list of optional param rules" do
|
118
118
|
@sparams.list_optional.should be_an_instance_of(Array)
|
119
|
-
@sparams.list_optional.length.should == 4
|
119
|
+
@sparams.list_optional.length.should be == 4
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should have a list of namespaced param rules" do
|
123
123
|
@sparams.namespaced_params.should be_an_instance_of(Array)
|
124
|
-
@sparams.namespaced_params.length.should == 1
|
125
|
-
@sparams.namespaced_params.first.space_name.should == :user
|
124
|
+
@sparams.namespaced_params.length.should be == 1
|
125
|
+
@sparams.namespaced_params.first.space_name.should be == :user
|
126
126
|
end
|
127
127
|
|
128
128
|
describe WSDSL::Params::Rule do
|
@@ -132,12 +132,12 @@ describe WSDSL do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should have a name" do
|
135
|
-
@rule.name.should == :framework
|
135
|
+
@rule.name.should be == :framework
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should have options" do
|
139
|
-
@rule.options[:type].should == :string
|
140
|
-
@rule.options[:in].should == WSDSLSpecOptions
|
139
|
+
@rule.options[:type].should be == :string
|
140
|
+
@rule.options[:in].should be == WSDSLSpecOptions
|
141
141
|
@rule.options[:null].should be_false
|
142
142
|
end
|
143
143
|
end
|
@@ -155,13 +155,13 @@ describe WSDSL do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it "should have an overall description" do
|
158
|
-
@doc.desc.strip.should == "This is a test service used to test the framework."
|
158
|
+
@doc.desc.strip.should be == "This is a test service used to test the framework."
|
159
159
|
end
|
160
160
|
|
161
161
|
it "should have a list of params doc" do
|
162
162
|
@doc.params_doc.should be_an_instance_of(Hash)
|
163
|
-
@doc.params_doc.keys.sort.should == [:framework, :version]
|
164
|
-
@doc.params_doc[:framework].should == "The test framework used, could be one of the two following: #{WSDSLSpecOptions.join(", ")}."
|
163
|
+
@doc.params_doc.keys.sort.should be == [:framework, :version]
|
164
|
+
@doc.params_doc[:framework].should be == "The test framework used, could be one of the two following: #{WSDSLSpecOptions.join(", ")}."
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should allow to define namespaced params doc" do
|
@@ -172,14 +172,14 @@ describe WSDSL do
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
service.doc.namespaced_params.should_not be_empty
|
175
|
-
ns = service.doc.namespaced_params.find{|
|
175
|
+
ns = service.doc.namespaced_params.find{|nsp| nsp.name == :preference}
|
176
176
|
ns.should_not be_nil
|
177
|
-
ns.params[:id].should == "Ze id."
|
177
|
+
ns.params[:id].should be == "Ze id."
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should have an optional list of examples" do
|
181
181
|
@doc.examples.should be_an_instance_of(Array)
|
182
|
-
@doc.examples.first.should == <<-DOC
|
182
|
+
@doc.examples.first.should be == <<-DOC
|
183
183
|
The most common way to use this service looks like that:
|
184
184
|
http://example.com/services/test.xml?framework=rspec&version=2.0.0
|
185
185
|
DOC
|
@@ -192,19 +192,19 @@ The most common way to use this service looks like that:
|
|
192
192
|
it "should have documentation for the response elements via the response itself" do
|
193
193
|
@service.response.elements.first.should_not be_nil
|
194
194
|
@service.response.elements.first.doc.should_not be_nil
|
195
|
-
@service.response.elements.first.doc.name.should == "player_creation_ratings"
|
195
|
+
@service.response.elements.first.doc.name.should be == "player_creation_ratings"
|
196
196
|
end
|
197
197
|
|
198
198
|
it "should have documentation for a response element attribute" do
|
199
199
|
@service.response.elements.first.doc.attributes.should_not be_empty
|
200
|
-
@service.response.elements.first.doc.attributes[:id].should == "id doc"
|
200
|
+
@service.response.elements.first.doc.attributes[:id].should be == "id doc"
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should have documentation for a response element array" do
|
204
204
|
element = @service.response.elements.first
|
205
205
|
element.arrays.should_not be_empty
|
206
|
-
element.arrays.first.name.should == "player_creation_rating"
|
207
|
-
element.arrays.first.obj_type.should == "PlayerCreationRating"
|
206
|
+
element.arrays.first.name.should be == "player_creation_rating"
|
207
|
+
element.arrays.first.obj_type.should be == "PlayerCreationRating"
|
208
208
|
element.arrays.first.attributes.should_not be_empty
|
209
209
|
end
|
210
210
|
|
@@ -213,8 +213,8 @@ The most common way to use this service looks like that:
|
|
213
213
|
array = element.arrays.first
|
214
214
|
attribute = array.attributes.find{|att| att.name == :comments }
|
215
215
|
attribute.should_not be_nil
|
216
|
-
attribute.name.should == :comments # just in case we change the way to find the attribute
|
217
|
-
attribute.doc.should == "comments doc"
|
216
|
+
attribute.name.should be == :comments # just in case we change the way to find the attribute
|
217
|
+
attribute.doc.should be == "comments doc"
|
218
218
|
end
|
219
219
|
|
220
220
|
end
|
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-07-
|
12
|
+
date: 2011-07-10 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby DSL describing Web Services without implementation details.
|
15
|
-
email: sdod
|
15
|
+
email: sdod
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files:
|