playerconnect-wsdsl 0.2.8 → 0.2.9
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/README.md +0 -6
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/params_verification.rb +33 -8
- data/playerconnect-wsdsl.gemspec +2 -2
- data/spec/params_verification_spec.rb +5 -5
- metadata +2 -2
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ Jeweler::Tasks.new do |gem|
|
|
11
11
|
gem.description = %Q{A Ruby DSL describing Web Services without implementation details.}
|
12
12
|
gem.email = "sdod"
|
13
13
|
gem.authors = ["Team SDOD"]
|
14
|
-
gem.version = "0.2.
|
14
|
+
gem.version = "0.2.9"
|
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.9
|
data/lib/params_verification.rb
CHANGED
@@ -49,9 +49,11 @@ module ParamsVerification
|
|
49
49
|
unless ignore_unexpected
|
50
50
|
unexpected_params?(params, service_params.param_names)
|
51
51
|
end
|
52
|
+
|
53
|
+
# Create a duplicate of the params hash that uses symbols as keys,
|
54
|
+
# while preserving the original hash
|
55
|
+
updated_params = symbolify_keys(params)
|
52
56
|
|
53
|
-
# dupe the params so we don't modify the passed value
|
54
|
-
updated_params = params.dup
|
55
57
|
# Required param verification
|
56
58
|
service_params.list_required.each do |rule|
|
57
59
|
updated_params = validate_required_rule(rule, updated_params)
|
@@ -84,13 +86,34 @@ module ParamsVerification
|
|
84
86
|
unexpected_params?(params[key], namespaced.param_names)
|
85
87
|
end
|
86
88
|
end
|
87
|
-
|
89
|
+
|
88
90
|
updated_params
|
89
91
|
end
|
90
|
-
|
91
|
-
|
92
|
+
|
93
|
+
|
92
94
|
private
|
93
|
-
|
95
|
+
|
96
|
+
# Create a copy of hash that enforces the usage of symbols as keys
|
97
|
+
#
|
98
|
+
#
|
99
|
+
# @params [Hash] The hash to copy
|
100
|
+
#
|
101
|
+
# @return [Hash] A copy of the given hash, but with all keys forced to be symbols
|
102
|
+
#
|
103
|
+
# @api private
|
104
|
+
def self.symbolify_keys(a_hash={})
|
105
|
+
new_hash = {}
|
106
|
+
a_hash.each do |k,v|
|
107
|
+
if v.class.to_s =~ /^Hash/
|
108
|
+
new_hash[k.to_sym] = symbolify_keys(v)
|
109
|
+
else
|
110
|
+
new_hash[k.to_sym] = v
|
111
|
+
end
|
112
|
+
end
|
113
|
+
new_hash
|
114
|
+
end
|
115
|
+
|
116
|
+
|
94
117
|
# Validate a required rule against a list of params passed.
|
95
118
|
#
|
96
119
|
#
|
@@ -103,7 +126,8 @@ module ParamsVerification
|
|
103
126
|
#
|
104
127
|
# @api private
|
105
128
|
def self.validate_required_rule(rule, params, namespace=nil)
|
106
|
-
param_name = rule.name.
|
129
|
+
param_name = rule.name.to_sym
|
130
|
+
namespace = namespace.to_sym if namespace
|
107
131
|
|
108
132
|
param_value, namespaced_params = extract_param_values(params, param_name, namespace)
|
109
133
|
# puts "verify #{param_name} params, current value: #{param_value}"
|
@@ -175,7 +199,8 @@ module ParamsVerification
|
|
175
199
|
#
|
176
200
|
# @api private
|
177
201
|
def self.run_optional_rule(rule, params, namespace=nil)
|
178
|
-
param_name = rule.name.
|
202
|
+
param_name = rule.name.to_sym
|
203
|
+
namespace = namespace.to_sym if namespace
|
179
204
|
|
180
205
|
param_value, namespaced_params = extract_param_values(params, param_name, namespace)
|
181
206
|
|
data/playerconnect-wsdsl.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
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.9"
|
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-
|
12
|
+
s.date = %q{2011-08-04}
|
13
13
|
s.description = %q{A Ruby DSL describing Web Services without implementation details.}
|
14
14
|
s.email = %q{sdod}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -22,16 +22,16 @@ describe ParamsVerification do
|
|
22
22
|
|
23
23
|
it "should set the default value for an optional param" do
|
24
24
|
params = @valid_params.dup
|
25
|
-
params[
|
25
|
+
params[:timestamp].should be_nil
|
26
26
|
returned_params = ParamsVerification.validate!(params, @service.defined_params)
|
27
|
-
returned_params[
|
27
|
+
returned_params[:timestamp].should_not be_nil
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should set the default value for a namespace optional param" do
|
31
31
|
params = {'framework' => 'RSpec', 'version' => '1.02', 'user' => {'id' => '123'}}
|
32
|
-
params[
|
32
|
+
params[:user].should be_nil
|
33
33
|
returned_params = ParamsVerification.validate!(params, @service.defined_params)
|
34
|
-
returned_params[
|
34
|
+
returned_params[:user][:mailing_list].should be_true
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should raise an exception when a required param is missing" do
|
@@ -45,7 +45,7 @@ describe ParamsVerification do
|
|
45
45
|
service.should_not be_nil
|
46
46
|
params = {'seq' => "a,b,c,d,e,g"}
|
47
47
|
validated = ParamsVerification.validate!(params, service.defined_params)
|
48
|
-
validated[
|
48
|
+
validated[:seq].should == %W{a b c d e g}
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should not raise an exception if a req array param doesn't contain a comma" do
|
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.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-08-04 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby DSL describing Web Services without implementation details.
|
15
15
|
email: sdod
|