wash_out 0.3.3 → 0.3.4
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/CHANGELOG.md +7 -1
- data/Gemfile.lock +1 -1
- data/README.md +7 -2
- data/app/views/wash_with_soap/wsdl.builder +1 -1
- data/lib/wash_out/dispatcher.rb +13 -10
- data/lib/wash_out/engine.rb +15 -0
- data/lib/wash_out/version.rb +1 -1
- data/spec/wash_out_spec.rb +35 -13
- metadata +12 -12
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.3.4
|
4
|
+
|
5
|
+
* WSDL generation fixed to support complex structures for return values
|
6
|
+
* Configuration moved to OrderedOptions with proper Engine binding
|
7
|
+
* `snakecase` configuration directive added: if set to false, wash_out won't modify params keys
|
8
|
+
|
3
9
|
## 0.3.3
|
4
10
|
|
5
11
|
* Tiny fixes in wash_out behavior with inline arrays (#11, #12)
|
@@ -21,4 +27,4 @@
|
|
21
27
|
|
22
28
|
* The syntax for empty set (no input params or output params) changed from [] to nil.
|
23
29
|
* SOAP response format improved. All results are now wrapped into tns:messages instead of soap:Body.
|
24
|
-
* Arrays (minOccurs/maxOccurs) are now supported with `:foo => [:integer]` syntax.
|
30
|
+
* Arrays (minOccurs/maxOccurs) are now supported with `:foo => [:integer]` syntax.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -122,10 +122,15 @@ result.to_hash # => {:value=>"123abc"}
|
|
122
122
|
|
123
123
|
Take a look at [WashOut sample application](https://github.com/roundlake/wash_out-sample).
|
124
124
|
|
125
|
-
|
125
|
+
Configuration
|
126
126
|
---------
|
127
127
|
|
128
|
-
Use `config.
|
128
|
+
Use `config.wash_out...` inside your environment configuration to setup WashOut.
|
129
|
+
|
130
|
+
Available properties are:
|
131
|
+
|
132
|
+
* **namespace**: SOAP namespace to use. Default is `urn:WashOut`.
|
133
|
+
* **snakecase**: Determines if WashOut should modify parameters keys to snakecase. Default is true.
|
129
134
|
|
130
135
|
License
|
131
136
|
-------
|
@@ -11,7 +11,7 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
|
|
11
11
|
xml.types do
|
12
12
|
xml.tag! "xsd:schema", :targetNamespace => @namespace do
|
13
13
|
@map.each do |operation, formats|
|
14
|
-
formats[:in].each do |p|
|
14
|
+
(formats[:in] + formats[:out]).each do |p|
|
15
15
|
wsdl_type xml, p
|
16
16
|
end
|
17
17
|
end
|
data/lib/wash_out/dispatcher.rb
CHANGED
@@ -9,11 +9,6 @@ module WashOut
|
|
9
9
|
# response.
|
10
10
|
class SOAPError < Exception; end
|
11
11
|
|
12
|
-
def namespace
|
13
|
-
namespace = ActionView::Base.washout_namespace if defined?(ActionView::Base)
|
14
|
-
namespace ||= 'urn:WashOut'
|
15
|
-
end
|
16
|
-
|
17
12
|
# This filter parses the SOAP request and puts it into +params+ array.
|
18
13
|
def _parse_soap_parameters
|
19
14
|
soap_action = request.env['wash_out.soap_action']
|
@@ -23,10 +18,18 @@ module WashOut
|
|
23
18
|
strip = Nori.strip_namespaces?
|
24
19
|
convert = Nori.convert_tags?
|
25
20
|
Nori.strip_namespaces = true
|
26
|
-
|
21
|
+
|
22
|
+
if WashOut::Engine.snakecase
|
23
|
+
Nori.convert_tags_to { |tag| tag.snakecase.to_sym }
|
24
|
+
else
|
25
|
+
Nori.convert_tags_to { |tag| tag.to_sym }
|
26
|
+
end
|
27
27
|
|
28
28
|
params = Nori.parse(request.body)
|
29
|
-
|
29
|
+
|
30
|
+
xml_data = params.values_at(:envelope, :Envelope).compact.first
|
31
|
+
xml_data = xml_data.values_at(:body, :Body).compact.first
|
32
|
+
xml_data = xml_data.values_at(soap_action.underscore.to_sym, soap_action.to_sym).compact.first || {}
|
30
33
|
|
31
34
|
strip_empty_nodes = lambda{|hash|
|
32
35
|
hash.each do |key, value|
|
@@ -64,7 +67,7 @@ module WashOut
|
|
64
67
|
# This action generates the WSDL for defined SOAP methods.
|
65
68
|
def _generate_wsdl
|
66
69
|
@map = self.class.soap_actions
|
67
|
-
@namespace = namespace
|
70
|
+
@namespace = WashOut::Engine.namespace
|
68
71
|
@name = controller_path.gsub('/', '_')
|
69
72
|
|
70
73
|
render :template => 'wash_with_soap/wsdl'
|
@@ -72,9 +75,9 @@ module WashOut
|
|
72
75
|
|
73
76
|
# Render a SOAP response.
|
74
77
|
def _render_soap(result, options)
|
75
|
-
@namespace = namespace
|
78
|
+
@namespace = WashOut::Engine.namespace
|
76
79
|
@operation = soap_action = request.env['wash_out.soap_action']
|
77
|
-
action_spec = self.class.soap_actions[soap_action][:out]
|
80
|
+
action_spec = self.class.soap_actions[soap_action][:out]
|
78
81
|
|
79
82
|
result = { 'value' => result } unless result.is_a? Hash
|
80
83
|
result = HashWithIndifferentAccess.new(result)
|
data/lib/wash_out/engine.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
module WashOut
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
+
class << self
|
4
|
+
attr_accessor :namespace
|
5
|
+
attr_accessor :snakecase
|
6
|
+
end
|
7
|
+
|
8
|
+
self.namespace = 'urn:WashOut'
|
9
|
+
self.snakecase = false
|
10
|
+
|
11
|
+
config.wash_out = ActiveSupport::OrderedOptions.new
|
12
|
+
|
13
|
+
initializer "wash_out.configuration" do |app|
|
14
|
+
app.config.wash_out.each do |key, value|
|
15
|
+
self.class.send "#{key}=", value
|
16
|
+
end
|
17
|
+
end
|
3
18
|
end
|
4
19
|
end
|
data/lib/wash_out/version.rb
CHANGED
data/spec/wash_out_spec.rb
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe WashOut do
|
6
|
+
before(:each) do
|
7
|
+
WashOut::Engine.snakecase = true
|
8
|
+
WashOut::Engine.namespace = false
|
9
|
+
end
|
10
|
+
|
6
11
|
it "should be valid" do
|
7
12
|
WashOut.should be_a(Module)
|
8
13
|
end
|
@@ -81,19 +86,19 @@ describe WashOut do
|
|
81
86
|
client.request(:answer).to_hash[:answer_response][:value].should == "42"
|
82
87
|
end
|
83
88
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
89
|
+
it "should answer to request with empty parameter" do
|
90
|
+
mock_controller do
|
91
|
+
soap_action "answer", :args => {:a => :string}, :return => {:a => :string}
|
92
|
+
def answer
|
93
|
+
render :soap => {:a => params[:a]}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
client = savon_instance
|
98
|
+
client.request(:answer) do
|
99
|
+
soap.body = { :a => '' }
|
100
|
+
end.to_hash[:answer_response][:a].should == {:"@xsi:type"=>"xsd:string"}
|
101
|
+
end
|
97
102
|
|
98
103
|
it "should answer to request with one parameter" do
|
99
104
|
mock_controller do
|
@@ -112,6 +117,23 @@ describe WashOut do
|
|
112
117
|
end.to_hash[:check_answer_response][:value].should == false
|
113
118
|
end
|
114
119
|
|
120
|
+
it "should handle snakecase option properly" do
|
121
|
+
WashOut::Engine.snakecase = false
|
122
|
+
|
123
|
+
mock_controller do
|
124
|
+
soap_action "rocknroll", :args => {:ZOMG => :string}, :return => nil
|
125
|
+
def rocknroll
|
126
|
+
params["ZOMG"].should == "yam!"
|
127
|
+
render :soap => nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
client = savon_instance
|
132
|
+
client.request(:rocknroll) do
|
133
|
+
soap.body = { "ZOMG" => 'yam!' }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
115
137
|
it "should answer to request with two parameter" do
|
116
138
|
mock_controller do
|
117
139
|
soap_action "funky", :args => { :a => :integer, :b => :string }, :return => :string
|
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.4
|
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-03-
|
13
|
+
date: 2012-03-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nori
|
17
|
-
requirement: &
|
17
|
+
requirement: &70189925216220 !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: *70189925216220
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec-rails
|
28
|
-
requirement: &
|
28
|
+
requirement: &70189925215640 !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: *70189925215640
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: appraisal
|
39
|
-
requirement: &
|
39
|
+
requirement: &70189925215120 !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: *70189925215120
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: tzinfo
|
50
|
-
requirement: &
|
50
|
+
requirement: &70189925214560 !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: *70189925214560
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: savon
|
61
|
-
requirement: &
|
61
|
+
requirement: &70189925214060 !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: *70189925214060
|
70
70
|
description: Dead simple Rails 3 SOAP server library
|
71
71
|
email: boris@roundlake.ru
|
72
72
|
executables: []
|