wash_out 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +39 -41
- data/README.md +2 -0
- data/app/helpers/wash_out_helper.rb +21 -16
- data/lib/wash_out/dispatcher.rb +36 -11
- data/lib/wash_out/param.rb +9 -15
- data/lib/wash_out/version.rb +1 -1
- data/spec/wash_out_spec.rb +52 -1
- data/wash_out.gemspec +1 -1
- metadata +15 -13
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.3.2
|
4
|
+
|
5
|
+
* WashOut doesn't check existance of parameters anymore you should do it yourself from now
|
6
|
+
* Proper handling of blank parameters (#10)
|
7
|
+
* Proper handling of complex structures inside arrays (#9)
|
8
|
+
* Response performance improved
|
9
|
+
|
10
|
+
## 0.3.1
|
11
|
+
|
12
|
+
* Support of complex structures inside array
|
13
|
+
* Better Nori handling (no more dependency on Savon hijacking)
|
14
|
+
|
15
|
+
## 0.3.0
|
16
|
+
|
17
|
+
* The syntax for empty set (no input params or output params) changed from [] to nil.
|
18
|
+
* SOAP response format improved. All results are now wrapped into tns:messages instead of soap:Body.
|
19
|
+
* Arrays (minOccurs/maxOccurs) are now supported with `:foo => [:integer]` syntax.
|
data/Gemfile.lock
CHANGED
@@ -1,32 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wash_out (0.3.
|
4
|
+
wash_out (0.3.2)
|
5
5
|
nori
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionpack (3.1
|
11
|
-
activemodel (= 3.1
|
12
|
-
activesupport (= 3.1
|
10
|
+
actionpack (3.2.1)
|
11
|
+
activemodel (= 3.2.1)
|
12
|
+
activesupport (= 3.2.1)
|
13
13
|
builder (~> 3.0.0)
|
14
14
|
erubis (~> 2.7.0)
|
15
|
-
|
16
|
-
rack (~> 1.
|
15
|
+
journey (~> 1.0.1)
|
16
|
+
rack (~> 1.4.0)
|
17
17
|
rack-cache (~> 1.1)
|
18
|
-
rack-mount (~> 0.8.2)
|
19
18
|
rack-test (~> 0.6.1)
|
20
|
-
sprockets (~> 2.1.
|
21
|
-
activemodel (3.1
|
22
|
-
activesupport (= 3.1
|
19
|
+
sprockets (~> 2.1.2)
|
20
|
+
activemodel (3.2.1)
|
21
|
+
activesupport (= 3.2.1)
|
23
22
|
builder (~> 3.0.0)
|
23
|
+
activesupport (3.2.1)
|
24
24
|
i18n (~> 0.6)
|
25
|
-
activesupport (3.1.2)
|
26
25
|
multi_json (~> 1.0)
|
27
26
|
akami (1.0.0)
|
28
27
|
gyoku (>= 0.4.0)
|
29
|
-
appraisal (0.4.
|
28
|
+
appraisal (0.4.1)
|
30
29
|
bundler
|
31
30
|
rake
|
32
31
|
builder (3.0.0)
|
@@ -35,63 +34,62 @@ GEM
|
|
35
34
|
gyoku (0.4.4)
|
36
35
|
builder (>= 2.1.2)
|
37
36
|
hike (1.2.1)
|
38
|
-
httpi (0.9.
|
37
|
+
httpi (0.9.6)
|
39
38
|
rack
|
40
39
|
i18n (0.6.0)
|
41
|
-
|
42
|
-
json (1.6.
|
43
|
-
|
40
|
+
journey (1.0.3)
|
41
|
+
json (1.6.5)
|
42
|
+
json (1.6.5-java)
|
43
|
+
multi_json (1.1.0)
|
44
44
|
nokogiri (1.5.0)
|
45
45
|
nokogiri (1.5.0-java)
|
46
|
-
nori (1.0
|
47
|
-
rack (1.
|
46
|
+
nori (1.1.0)
|
47
|
+
rack (1.4.1)
|
48
48
|
rack-cache (1.1)
|
49
49
|
rack (>= 0.4)
|
50
|
-
rack-mount (0.8.3)
|
51
|
-
rack (>= 1.0.0)
|
52
50
|
rack-ssl (1.3.2)
|
53
51
|
rack
|
54
52
|
rack-test (0.6.1)
|
55
53
|
rack (>= 1.0)
|
56
|
-
railties (3.1
|
57
|
-
actionpack (= 3.1
|
58
|
-
activesupport (= 3.1
|
54
|
+
railties (3.2.1)
|
55
|
+
actionpack (= 3.2.1)
|
56
|
+
activesupport (= 3.2.1)
|
59
57
|
rack-ssl (~> 1.3.2)
|
60
58
|
rake (>= 0.8.7)
|
61
59
|
rdoc (~> 3.4)
|
62
60
|
thor (~> 0.14.6)
|
63
61
|
rake (0.9.2.2)
|
64
|
-
rdoc (3.
|
62
|
+
rdoc (3.12)
|
65
63
|
json (~> 1.4)
|
66
|
-
rspec (2.
|
67
|
-
rspec-core (~> 2.
|
68
|
-
rspec-expectations (~> 2.
|
69
|
-
rspec-mocks (~> 2.
|
70
|
-
rspec-core (2.
|
71
|
-
rspec-expectations (2.
|
64
|
+
rspec (2.8.0)
|
65
|
+
rspec-core (~> 2.8.0)
|
66
|
+
rspec-expectations (~> 2.8.0)
|
67
|
+
rspec-mocks (~> 2.8.0)
|
68
|
+
rspec-core (2.8.0)
|
69
|
+
rspec-expectations (2.8.0)
|
72
70
|
diff-lcs (~> 1.1.2)
|
73
|
-
rspec-mocks (2.
|
74
|
-
rspec-rails (2.
|
75
|
-
actionpack (
|
76
|
-
activesupport (
|
77
|
-
railties (
|
78
|
-
rspec (~> 2.
|
79
|
-
savon (0.9.
|
71
|
+
rspec-mocks (2.8.0)
|
72
|
+
rspec-rails (2.8.1)
|
73
|
+
actionpack (>= 3.0)
|
74
|
+
activesupport (>= 3.0)
|
75
|
+
railties (>= 3.0)
|
76
|
+
rspec (~> 2.8.0)
|
77
|
+
savon (0.9.9)
|
80
78
|
akami (~> 1.0)
|
81
79
|
builder (>= 2.1.2)
|
82
80
|
gyoku (>= 0.4.0)
|
83
81
|
httpi (~> 0.9)
|
84
82
|
nokogiri (>= 1.4.0)
|
85
|
-
nori (~> 1.
|
86
|
-
wasabi (~> 2.
|
87
|
-
sprockets (2.1.
|
83
|
+
nori (~> 1.1)
|
84
|
+
wasabi (~> 2.1)
|
85
|
+
sprockets (2.1.2)
|
88
86
|
hike (~> 1.2)
|
89
87
|
rack (~> 1.0)
|
90
88
|
tilt (~> 1.1, != 1.3.0)
|
91
89
|
thor (0.14.6)
|
92
90
|
tilt (1.3.3)
|
93
91
|
tzinfo (0.3.31)
|
94
|
-
wasabi (2.
|
92
|
+
wasabi (2.1.0)
|
95
93
|
nokogiri (>= 1.4.0)
|
96
94
|
|
97
95
|
PLATFORMS
|
data/README.md
CHANGED
@@ -12,6 +12,8 @@ Rails >3.0 only.
|
|
12
12
|
|
13
13
|
WashOut should work like a charm on CRuby 1.9.x.
|
14
14
|
|
15
|
+
![Travis CI](https://secure.travis-ci.org/roundlake/wash_out.png)
|
16
|
+
|
15
17
|
We do support CRuby 1.8.7. However it is not a goal and it is not well supported by our specs. According to
|
16
18
|
this fact it maybe sometimes broken from the start on major releases. You are welcome to hold on an old
|
17
19
|
version and give us enough issues and pull-requests to make it work.
|
@@ -1,24 +1,29 @@
|
|
1
1
|
module WashOutHelper
|
2
2
|
def wsdl_data(xml, params)
|
3
3
|
params.each do |param|
|
4
|
-
|
5
|
-
|
4
|
+
tag_name = "tns:#{param.name}"
|
5
|
+
|
6
|
+
if !param.struct?
|
7
|
+
if !param.multiplied
|
8
|
+
xml.tag! tag_name, param.value, "xsi:type" => param.namespaced_type
|
9
|
+
else
|
10
|
+
param.value.each do |v|
|
11
|
+
xml.tag! tag_name, v, "xsi:type" => param.namespaced_type
|
12
|
+
end
|
13
|
+
end
|
6
14
|
else
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
wsdl_data(xml, param.map)
|
15
|
+
if !param.multiplied
|
16
|
+
xml.tag! tag_name, "xsi:type" => param.namespaced_type do
|
17
|
+
wsdl_data(xml, param.map)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
param.map.each do |p|
|
21
|
+
xml.tag! tag_name, "xsi:type" => param.namespaced_type do
|
22
|
+
wsdl_data(xml, p.map)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
19
26
|
end
|
20
|
-
else
|
21
|
-
xml.tag! tag_name, value, "xsi:type" => param.namespaced_type
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
data/lib/wash_out/dispatcher.rb
CHANGED
@@ -24,19 +24,37 @@ module WashOut
|
|
24
24
|
Nori.convert_tags_to { |tag| tag.snakecase.to_sym }
|
25
25
|
|
26
26
|
params = Nori.parse(request.body)
|
27
|
-
xml_data = params[:envelope][:body][soap_action.underscore.to_sym]
|
27
|
+
xml_data = params[:envelope][:body][soap_action.underscore.to_sym] || {}
|
28
|
+
|
29
|
+
strip_empty_nodes = lambda{|hash|
|
30
|
+
hash.each do |key, value|
|
31
|
+
if value.is_a? Hash
|
32
|
+
value = value.delete_if{|key, value| key.to_s[0] == '@'}
|
33
|
+
|
34
|
+
if value.length > 0
|
35
|
+
hash[key] = strip_empty_nodes.call(value)
|
36
|
+
else
|
37
|
+
hash[key] = nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
hash
|
43
|
+
}
|
44
|
+
|
45
|
+
xml_data = strip_empty_nodes.call(xml_data)
|
28
46
|
|
29
47
|
# Reset Nori setup to project-space
|
30
48
|
Nori.strip_namespaces = strip
|
31
49
|
Nori.convert_tags_to convert
|
32
50
|
|
33
51
|
@_params = HashWithIndifferentAccess.new
|
34
|
-
(xml_data || {}).map do |opt, value|
|
35
|
-
unless opt.to_s.starts_with? '@'
|
36
|
-
param = action_spec[:in].find { |param| param.name.underscore.to_sym == opt }
|
37
|
-
raise SOAPError, "unknown parameter #{opt}" unless param
|
38
52
|
|
39
|
-
|
53
|
+
action_spec[:in].each do |param|
|
54
|
+
key = param.name.to_sym
|
55
|
+
|
56
|
+
if xml_data.has_key? key
|
57
|
+
@_params[param.name] = param.load(xml_data, key)
|
40
58
|
end
|
41
59
|
end
|
42
60
|
end
|
@@ -59,14 +77,21 @@ module WashOut
|
|
59
77
|
result = { 'value' => result } unless result.is_a? Hash
|
60
78
|
result = HashWithIndifferentAccess.new(result)
|
61
79
|
|
62
|
-
inject = lambda {|data,
|
63
|
-
spec
|
64
|
-
|
65
|
-
|
80
|
+
inject = lambda {|data, source_spec|
|
81
|
+
spec = source_spec.clone
|
82
|
+
|
83
|
+
spec.each_with_index do |param, i|
|
84
|
+
if param.struct? && !param.multiplied
|
85
|
+
spec[i].map = inject.call(data[param.name], param.map)
|
86
|
+
elsif param.struct? && param.multiplied
|
87
|
+
spec[i].map = data[param.name].map{|e| inject.call(e, param.map)}
|
66
88
|
else
|
67
|
-
|
89
|
+
spec[i] = param.flat_copy
|
90
|
+
spec[i].value = data[param.name]
|
68
91
|
end
|
69
92
|
end
|
93
|
+
|
94
|
+
return spec
|
70
95
|
}
|
71
96
|
|
72
97
|
render :template => 'wash_with_soap/response',
|
data/lib/wash_out/param.rb
CHANGED
@@ -25,18 +25,21 @@ module WashOut
|
|
25
25
|
|
26
26
|
# Converts a generic externally derived Ruby value, such as String or
|
27
27
|
# Hash, to a native Ruby object according to the definition of this type.
|
28
|
-
def load(data)
|
29
|
-
|
28
|
+
def load(data, key)
|
29
|
+
if !data.has_key? key
|
30
|
+
raise WashOut::Dispatcher::SOAPError, "Required SOAP parameter '#{key}' is missing"
|
31
|
+
end
|
30
32
|
|
33
|
+
data = data[key]
|
31
34
|
data = Array(data) if @multiplied
|
32
35
|
|
33
36
|
if struct?
|
34
37
|
if @multiplied
|
35
38
|
data.map do |x|
|
36
|
-
map_struct(x) { |param, elem| param.load(elem) }
|
39
|
+
map_struct(x) { |param, data, elem| param.load(data, elem) }
|
37
40
|
end
|
38
41
|
else
|
39
|
-
map_struct(data) { |param, elem| param.load(elem) }
|
42
|
+
map_struct(data) { |param, data, elem| param.load(data, elem) }
|
40
43
|
end
|
41
44
|
else
|
42
45
|
operation = case type
|
@@ -106,10 +109,8 @@ module WashOut
|
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
109
|
-
def
|
112
|
+
def flat_copy
|
110
113
|
copy = self.class.new(@name, @type.to_sym, @multiplied)
|
111
|
-
copy.map = @map.map{|x| x.clone}
|
112
|
-
copy
|
113
114
|
end
|
114
115
|
|
115
116
|
private
|
@@ -121,17 +122,10 @@ module WashOut
|
|
121
122
|
|
122
123
|
# RUBY18 Enumerable#each_with_object is better, but 1.9 only.
|
123
124
|
@map.map do |param|
|
124
|
-
struct[param.name] = yield param, data
|
125
|
+
struct[param.name] = yield param, data, param.name
|
125
126
|
end
|
126
127
|
|
127
128
|
struct
|
128
129
|
end
|
129
|
-
|
130
|
-
# Raise an appropriate exception if a required datum is missing.
|
131
|
-
def check_if_missing(data)
|
132
|
-
if data.nil?
|
133
|
-
raise WashOut::Dispatcher::SOAPError, "Required SOAP parameter '#{@name}' is missing"
|
134
|
-
end
|
135
|
-
end
|
136
130
|
end
|
137
131
|
end
|
data/lib/wash_out/version.rb
CHANGED
data/spec/wash_out_spec.rb
CHANGED
@@ -52,7 +52,7 @@ describe WashOut do
|
|
52
52
|
it "should allow definition of a simple action" do
|
53
53
|
lambda {
|
54
54
|
mock_controller do
|
55
|
-
soap_action "answer", :args => nil, :return => :
|
55
|
+
soap_action "answer", :args => nil, :return => :integer
|
56
56
|
end
|
57
57
|
}.should_not raise_exception
|
58
58
|
end
|
@@ -69,6 +69,32 @@ describe WashOut do
|
|
69
69
|
client.request(:answer).to_hash[:answer_response][:value].should == "42"
|
70
70
|
end
|
71
71
|
|
72
|
+
it "should respond to request with insufficient parameters" do
|
73
|
+
mock_controller do
|
74
|
+
soap_action "answer", :args => {:a => :integer}, :return => :integer
|
75
|
+
def answer
|
76
|
+
render :soap => "42"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
client = savon_instance
|
81
|
+
client.request(:answer).to_hash[:answer_response][:value].should == "42"
|
82
|
+
end
|
83
|
+
|
84
|
+
# it "should answer to request with empty parameter" do
|
85
|
+
# mock_controller do
|
86
|
+
# soap_action "answer", :args => {:a => :string}, :return => {:a => :string}
|
87
|
+
# def answer
|
88
|
+
# render :soap => {:a => params[:a]}
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# client = savon_instance
|
93
|
+
# client.request(:answer) do
|
94
|
+
# soap.body = { :a => '' }
|
95
|
+
# end.to_hash[:answer_response][:a].should == ''
|
96
|
+
# end
|
97
|
+
|
72
98
|
it "should answer to request with one parameter" do
|
73
99
|
mock_controller do
|
74
100
|
soap_action "checkAnswer", :args => :integer, :return => :boolean, :to => 'check_answer'
|
@@ -288,4 +314,29 @@ describe WashOut do
|
|
288
314
|
end
|
289
315
|
end
|
290
316
|
|
317
|
+
it "should handle return of complex structures inside arrays" do
|
318
|
+
mock_controller do
|
319
|
+
soap_action "rumba",
|
320
|
+
:args => nil,
|
321
|
+
:return => {
|
322
|
+
:rumbas => [{:zombies => :string, :puppies => :string}]
|
323
|
+
}
|
324
|
+
def rumba
|
325
|
+
render :soap =>
|
326
|
+
{:rumbas => [
|
327
|
+
{:zombies => "suck1", :puppies => "rock1" },
|
328
|
+
{:zombies => "suck2", :puppies => "rock2" }
|
329
|
+
]
|
330
|
+
}
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
savon_instance.request(:rumba)[:rumba_response].should == {
|
335
|
+
:rumbas => [
|
336
|
+
{:zombies => "suck1",:puppies => "rock1", :"@xsi:type"=>"tns:rumbas"},
|
337
|
+
{:zombies => "suck2", :puppies => "rock2", :"@xsi:type"=>"tns:rumbas" }
|
338
|
+
]
|
339
|
+
}
|
340
|
+
end
|
341
|
+
|
291
342
|
end
|
data/wash_out.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.summary = "Dead simple Rails 3 SOAP server library"
|
8
8
|
s.email = "boris@roundlake.ru"
|
9
|
-
s.homepage = "http://github.com/
|
9
|
+
s.homepage = "http://roundlake.github.com/wash_out/"
|
10
10
|
s.description = "Dead simple Rails 3 SOAP server library"
|
11
11
|
s.authors = ['Boris Staal', 'Peter Zotov']
|
12
12
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wash_out
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-03-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nori
|
17
|
-
requirement: &
|
17
|
+
requirement: &70132283257380 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70132283257380
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec-rails
|
28
|
-
requirement: &
|
28
|
+
requirement: &70132282141100 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70132282141100
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: appraisal
|
39
|
-
requirement: &
|
39
|
+
requirement: &70132282137260 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70132282137260
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: tzinfo
|
50
|
-
requirement: &
|
50
|
+
requirement: &70132282135480 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70132282135480
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: savon
|
61
|
-
requirement: &
|
61
|
+
requirement: &70132286104660 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70132286104660
|
70
70
|
description: Dead simple Rails 3 SOAP server library
|
71
71
|
email: boris@roundlake.ru
|
72
72
|
executables: []
|
@@ -74,7 +74,9 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
|
+
- .travis.yml
|
77
78
|
- Appraisals
|
79
|
+
- CHANGELOG.md
|
78
80
|
- Gemfile
|
79
81
|
- Gemfile.lock
|
80
82
|
- README.md
|
@@ -122,7 +124,7 @@ files:
|
|
122
124
|
- spec/support/httpi-rack.rb
|
123
125
|
- spec/wash_out_spec.rb
|
124
126
|
- wash_out.gemspec
|
125
|
-
homepage: http://github.com/
|
127
|
+
homepage: http://roundlake.github.com/wash_out/
|
126
128
|
licenses: []
|
127
129
|
post_install_message:
|
128
130
|
rdoc_options: []
|