wash_out 0.9.2 → 0.11.0.beta.1

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +31 -4
  4. data/Appraisals +11 -10
  5. data/Gemfile +1 -1
  6. data/README.md +41 -7
  7. data/Rakefile +6 -7
  8. data/app/helpers/wash_out_helper.rb +59 -24
  9. data/app/views/{wash_with_soap → wash_out}/document/error.builder +0 -0
  10. data/app/views/{wash_with_soap → wash_out}/document/response.builder +0 -0
  11. data/app/views/{wash_with_soap → wash_out}/document/wsdl.builder +14 -14
  12. data/app/views/{wash_with_soap → wash_out}/rpc/error.builder +0 -0
  13. data/app/views/{wash_with_soap → wash_out}/rpc/response.builder +0 -0
  14. data/app/views/{wash_with_soap → wash_out}/rpc/wsdl.builder +15 -15
  15. data/gemfiles/rails_3.2.13.gemfile +21 -0
  16. data/gemfiles/rails_4.0.0.gemfile +20 -0
  17. data/gemfiles/rails_4.1.0.gemfile +20 -0
  18. data/gemfiles/rails_4.2.0.gemfile +20 -0
  19. data/gemfiles/rails_5.0.0.beta2.gemfile +19 -0
  20. data/lib/wash_out/dispatcher.rb +68 -38
  21. data/lib/wash_out/param.rb +14 -2
  22. data/lib/wash_out/router.rb +40 -21
  23. data/lib/wash_out/soap.rb +1 -0
  24. data/lib/wash_out/version.rb +1 -1
  25. data/lib/wash_out/wsse.rb +3 -3
  26. data/lib/wash_out.rb +17 -4
  27. data/spec/dummy/config/environments/test.rb +1 -0
  28. data/spec/fixtures/nested_refs_to_arrays.xml +19 -0
  29. data/spec/fixtures/ref_to_one_array.xml +11 -0
  30. data/spec/fixtures/refs_to_arrays.xml +16 -0
  31. data/spec/lib/wash_out/dispatcher_spec.rb +124 -17
  32. data/spec/lib/wash_out/middleware_spec.rb +8 -8
  33. data/spec/lib/wash_out/param_spec.rb +43 -11
  34. data/spec/lib/wash_out/router_spec.rb +33 -5
  35. data/spec/lib/wash_out/type_spec.rb +9 -9
  36. data/spec/lib/wash_out_spec.rb +160 -102
  37. data/spec/spec_helper.rb +24 -4
  38. metadata +19 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9149b2f9a1a04ad8d6ba859ef68f2dbf9db6d585
4
- data.tar.gz: 55936871f904cf8d45517312b4479a39a5a5e5d5
3
+ metadata.gz: 9d49adf22c0c16c3f0e8e3e2dcf694b7d6851920
4
+ data.tar.gz: c42b0da56ed90cd44e4d014aff450f3bef83325f
5
5
  SHA512:
6
- metadata.gz: 5e2798c550e16322bb72de0dfa08c0e3a18ec3d292b481fc905d36f72d4b51a60bd889a583b723fc54081a484520c260a07e8b28dab1bb9babfa10f115e76e4b
7
- data.tar.gz: 08821de12b76c9fc9f4c79ddc381279ebddfa7c42d6a197e9a7b7528f94044b46927edffab4bf9bb7dfcb090e4678effe80ef1e61cfd4cdee6c339dd0ed64090
6
+ metadata.gz: 9f2dd4239ee3fa9e449bd0903c977b5f2457382ee363cb3d1404d102f5fd0b531fe8f0e32dcee5cc6a5ff14996d60b37bb565ad702b913ac2ed344fbde90ea83
7
+ data.tar.gz: c9045dd957a04e6751b9ed5ffc2a28fdc6c1d4a1c4eff7a57d8564699423a442a4975fe8c6c4cac7a451a19cd3eeda112ba8357cd0e19228d838e4d8ffcabdb4
data/.gitignore CHANGED
@@ -11,7 +11,7 @@ pkg/
11
11
  spec/dummy/db/*.sqlite3
12
12
  spec/dummy/log/*.log
13
13
  spec/dummy/tmp/
14
- gemfiles
14
+ gemfiles/*.lock
15
15
  coverage
16
16
  tags
17
17
  Gemfile.lock
data/.travis.yml CHANGED
@@ -1,7 +1,34 @@
1
- before_install:
2
- - gem install bundler
1
+ script: bundle exec rspec
2
+ gemfile:
3
+ - gemfiles/rails_3.2.13.gemfile
4
+ - gemfiles/rails_4.0.0.gemfile
5
+ - gemfiles/rails_4.1.0.gemfile
6
+ - gemfiles/rails_4.2.0.gemfile
7
+ - gemfiles/rails_5.0.0.beta2.gemfile
3
8
  rvm:
4
9
  - 1.9.3
5
- - jruby-19mode
6
10
  - 2.0.0
7
- - 2.1.0
11
+ - 2.1.8
12
+ - 2.2.4
13
+ - 2.3.0
14
+ - jruby
15
+ matrix:
16
+ exclude:
17
+ - rvm: 2.2.4
18
+ gemfile: gemfiles/rails_3.2.13.gemfile
19
+ - rvm: 2.3.0
20
+ gemfile: gemfiles/rails_3.2.13.gemfile
21
+ - rvm: 1.9.3
22
+ gemfile: gemfiles/rails_4.2.0.gemfile
23
+ - rvm: jruby
24
+ gemfile: gemfiles/rails_4.2.0.gemfile
25
+ - rvm: 1.9.3
26
+ gemfile: gemfiles/rails_5.0.0.beta2.gemfile
27
+ - rvm: 2.0.0
28
+ gemfile: gemfiles/rails_5.0.0.beta2.gemfile
29
+ - rvm: 2.1.8
30
+ gemfile: gemfiles/rails_5.0.0.beta2.gemfile
31
+ - rvm: jruby
32
+ gemfile: gemfiles/rails_5.0.0.beta2.gemfile
33
+ before_install:
34
+ - gem update bundler
data/Appraisals CHANGED
@@ -1,23 +1,24 @@
1
- appraise "rails-3.2.8" do
2
- gem "rails", "3.2.8"
3
- end
4
-
5
- appraise "rails-3.1.3" do
6
- gem "rails", "3.1.3"
7
- end
8
-
9
- appraise "rails-3.2.12" do
10
- gem "rails", "3.2.12"
1
+ appraise "rails-3.2.13" do
2
+ gem "rails", "3.2.13"
3
+ gem "test-unit"
4
+ gem "listen", "< 3.1.0"
11
5
  end
12
6
 
13
7
  appraise "rails-4.0.0" do
14
8
  gem "rails", "4.0.0"
9
+ gem "listen", "< 3.1.0"
15
10
  end
16
11
 
17
12
  appraise "rails-4.1.0" do
18
13
  gem "rails", "4.1.0"
14
+ gem "listen", "< 3.1.0"
19
15
  end
20
16
 
21
17
  appraise "rails-4.2.0" do
22
18
  gem "rails", "4.2.0"
19
+ gem "listen", "< 3.1.0"
23
20
  end
21
+
22
+ appraise "rails-5.0.0.beta2" do
23
+ gem "rails", "5.0.0.beta2"
24
+ end
data/Gemfile CHANGED
@@ -14,4 +14,4 @@ gem 'appraisal'
14
14
  gem 'tzinfo'
15
15
  gem 'pry'
16
16
  gem 'simplecov'
17
- gem 'simplecov-summary'
17
+ gem 'simplecov-summary'
data/README.md CHANGED
@@ -10,11 +10,7 @@ But if you have a chance, please [http://stopsoap.com/](http://stopsoap.com/).
10
10
 
11
11
  ## Compatibility
12
12
 
13
- Rails >3.0 only. MRI 1.9, 2.0, JRuby (--1.9).
14
-
15
- Ruby 1.8 is not officially supported since 0.5.3. We will accept further compatibilty pull-requests but no upcoming versions will be tested against it.
16
-
17
- Rubinius support temporarily dropped since 0.6.2 due to Rails 4 incompatibility.
13
+ Rails 3.2.13 and higher (if you are using SOAP and still on Ruby 1.9 - that's just too much evil, sorry)
18
14
 
19
15
  ## Installation
20
16
 
@@ -75,9 +71,47 @@ class RumbasController < ApplicationController
75
71
  :args => { :data => [:integer] },
76
72
  :return => [:boolean]
77
73
  def integers_to_boolean
78
- render :soap => params[:data].map{|x| x ? 1 : 0}
74
+ render :soap => params[:data].map{|i| i > 0}
79
75
  end
80
76
 
77
+ # Params from XML attributes;
78
+ # e.g. for a request to the 'AddCircle' action:
79
+ # <soapenv:Envelope>
80
+ # <soapenv:Body>
81
+ # <AddCircle>
82
+ # <Circle radius="5.0">
83
+ # <Center x="10" y="12" />
84
+ # </Circle>
85
+ # </AddCircle>
86
+ # </soapenv:Body>
87
+ # </soapenv:Envelope>
88
+ soap_action "AddCircle",
89
+ :args => { :circle => { :center => { :@x => :integer,
90
+ :@y => :integer },
91
+ :@radius => :double } },
92
+ :return => nil, # [] for wash_out below 0.3.0
93
+ :to => :add_circle
94
+ def add_circle
95
+ circle = params[:circle]
96
+ Circle.new(circle[:center][:x], circle[:center][:y], circle[:radius])
97
+
98
+ render :soap => nil
99
+ end
100
+
101
+ # With a customised input tag name, in case params are wrapped;
102
+ # e.g. for a request to the 'IntegersToBoolean' action:
103
+ # <soapenv:Envelope>
104
+ # <soapenv:Body>
105
+ # <MyRequest> <!-- not <IntegersToBoolean> -->
106
+ # <Data>...</Data>
107
+ # </MyRequest>
108
+ # </soapenv:Body>
109
+ # </soapenv:Envelope>
110
+ soap_action "integers_to_boolean",
111
+ :args => { :my_request => { :data => [:integer] } },
112
+ :as => 'MyRequest',
113
+ :return => [:boolean]
114
+
81
115
  # You can use all Rails features like filtering, too. A SOAP controller
82
116
  # is just like a normal controller with a special routing.
83
117
  before_filter :dump_parameters
@@ -122,7 +156,7 @@ inside separate classes for the complex ones. Here's the way to do that:
122
156
  class Fluffy < WashOut::Type
123
157
  map :universe => {
124
158
  :name => :string,
125
- :age => :int
159
+ :age => :integer
126
160
  }
127
161
  end
128
162
 
data/Rakefile CHANGED
@@ -5,10 +5,9 @@ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- desc "Default: run the unit tests."
9
- task :default => [:all]
10
-
11
- desc 'Test the plugin under all supported Rails versions.'
12
- task :all => ["appraisal:install"] do |t|
13
- exec('rake appraisal spec')
14
- end
8
+ task :console do
9
+ require "action_controller/railtie"
10
+ require "rails/test_unit/railtie"
11
+ Bundler.require
12
+ binding.pry
13
+ end
@@ -3,37 +3,57 @@ module WashOutHelper
3
3
  def wsdl_data_options(param)
4
4
  case controller.soap_config.wsdl_style
5
5
  when 'rpc'
6
- { :"xsi:type" => param.namespaced_type }
6
+ if param.map.present? || param.value
7
+ { :"xsi:type" => param.namespaced_type }
8
+ else
9
+ { :"xsi:nil" => true }
10
+ end
7
11
  when 'document'
8
12
  { }
9
13
  end
10
14
  end
11
15
 
16
+ def wsdl_data_attrs(param)
17
+ param.map.reduce({}) do |memo, p|
18
+ if p.respond_to?(:attribute?) && p.attribute?
19
+ memo.merge p.attr_name => p.value
20
+ else
21
+ memo
22
+ end
23
+ end
24
+ end
25
+
12
26
  def wsdl_data(xml, params)
13
27
  params.each do |param|
28
+ next if param.attribute?
29
+
14
30
  tag_name = param.name
15
31
  param_options = wsdl_data_options(param)
32
+ param_options.merge! wsdl_data_attrs(param)
16
33
 
17
- if !param.struct?
18
- if !param.multiplied
19
- xml.tag! tag_name, param.value, param_options
34
+ if param.struct?
35
+ if param.multiplied
36
+ param.map.each do |p|
37
+ attrs = wsdl_data_attrs p
38
+ if p.is_a?(Array) || p.map.size > attrs.size
39
+ blk = proc { wsdl_data(xml, p.map) }
40
+ end
41
+ attrs.reject! { |_, v| v.nil? }
42
+ xml.tag! tag_name, param_options.merge(attrs), &blk
43
+ end
20
44
  else
21
- param.value = [] unless param.value.is_a?(Array)
22
- param.value.each do |v|
23
- xml.tag! tag_name, v, param_options
45
+ xml.tag! tag_name, param_options do
46
+ wsdl_data(xml, param.map)
24
47
  end
25
48
  end
26
49
  else
27
- if !param.multiplied
28
- xml.tag! tag_name, param_options do
29
- wsdl_data(xml, param.map)
50
+ if param.multiplied
51
+ param.value = [] unless param.value.is_a?(Array)
52
+ param.value.each do |v|
53
+ xml.tag! tag_name, v, param_options
30
54
  end
31
55
  else
32
- param.map.each do |p|
33
- xml.tag! tag_name, param_options do
34
- wsdl_data(xml, p.map)
35
- end
36
- end
56
+ xml.tag! tag_name, param.value, param_options
37
57
  end
38
58
  end
39
59
  end
@@ -45,12 +65,27 @@ module WashOutHelper
45
65
  if param.struct?
46
66
  if !defined.include?(param.basic_type)
47
67
  xml.tag! "xsd:complexType", :name => param.basic_type do
48
- xml.tag! "xsd:sequence" do
49
- param.map.each do |value|
50
- more << value if value.struct?
51
- xml.tag! "xsd:element", wsdl_occurence(value, false, :name => value.name, :type => value.namespaced_type)
68
+ attrs, elems = [], []
69
+ param.map.each do |value|
70
+ more << value if value.struct?
71
+ if value.attribute?
72
+ attrs << value
73
+ else
74
+ elems << value
52
75
  end
53
76
  end
77
+
78
+ if elems.any?
79
+ xml.tag! "xsd:sequence" do
80
+ elems.each do |value|
81
+ xml.tag! "xsd:element", wsdl_occurence(value, false, :name => value.name, :type => value.namespaced_type)
82
+ end
83
+ end
84
+ end
85
+
86
+ attrs.each do |value|
87
+ xml.tag! "xsd:attribute", wsdl_occurence(value, false, :name => value.attr_name, :type => value.namespaced_type)
88
+ end
54
89
  end
55
90
 
56
91
  defined << param.basic_type
@@ -65,11 +100,11 @@ module WashOutHelper
65
100
  end
66
101
 
67
102
  def wsdl_occurence(param, inject, extend_with = {})
68
- data = !param.multiplied ? {} : {
69
- "#{'xsi:' if inject}minOccurs" => 0,
70
- "#{'xsi:' if inject}maxOccurs" => 'unbounded'
71
- }
72
-
103
+ data = {"#{'xsi:' if inject}nillable" => 'true'}
104
+ if param.multiplied
105
+ data["#{'xsi:' if inject}minOccurs"] = 0
106
+ data["#{'xsi:' if inject}maxOccurs"] = 'unbounded'
107
+ end
73
108
  extend_with.merge(data)
74
109
  end
75
110
  end
@@ -19,6 +19,19 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
19
19
  end
20
20
  end
21
21
 
22
+ @map.each do |operation, formats|
23
+ xml.message :name => "#{operation}" do
24
+ formats[:in].each do |p|
25
+ xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
26
+ end
27
+ end
28
+ xml.message :name => formats[:response_tag] do
29
+ formats[:out].each do |p|
30
+ xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
31
+ end
32
+ end
33
+ end
34
+
22
35
  xml.portType :name => "#{@name}_port" do
23
36
  @map.each do |operation, formats|
24
37
  xml.operation :name => operation do
@@ -49,20 +62,7 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
49
62
 
50
63
  xml.service :name => "service" do
51
64
  xml.port :name => "#{@name}_port", :binding => "tns:#{@name}_binding" do
52
- xml.tag! "soap:address", :location => send("#{@name}_action_url")
53
- end
54
- end
55
-
56
- @map.each do |operation, formats|
57
- xml.message :name => "#{operation}" do
58
- formats[:in].each do |p|
59
- xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
60
- end
61
- end
62
- xml.message :name => formats[:response_tag] do
63
- formats[:out].each do |p|
64
- xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
65
- end
65
+ xml.tag! "soap:address", :location => WashOut::Router.url(request, @name)
66
66
  end
67
67
  end
68
68
  end
@@ -19,6 +19,19 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
19
19
  end
20
20
  end
21
21
 
22
+ @map.each do |operation, formats|
23
+ xml.message :name => "#{operation}" do
24
+ formats[:in].each do |p|
25
+ xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
26
+ end
27
+ end
28
+ xml.message :name => formats[:response_tag] do
29
+ formats[:out].each do |p|
30
+ xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
31
+ end
32
+ end
33
+ end
34
+
22
35
  xml.portType :name => "#{@name}_port" do
23
36
  @map.each do |operation, formats|
24
37
  xml.operation :name => operation do
@@ -49,20 +62,7 @@ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
49
62
 
50
63
  xml.service :name => "service" do
51
64
  xml.port :name => "#{@name}_port", :binding => "tns:#{@name}_binding" do
52
- xml.tag! "soap:address", :location => send("#{@name}_action_url")
53
- end
54
- end
55
-
56
- @map.each do |operation, formats|
57
- xml.message :name => "#{operation}" do
58
- formats[:in].each do |p|
59
- xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
60
- end
61
- end
62
- xml.message :name => formats[:response_tag] do
63
- formats[:out].each do |p|
64
- xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
65
- end
65
+ xml.tag! "soap:address", :location => WashOut::Router.url(request, @name)
66
66
  end
67
67
  end
68
- end
68
+ end
@@ -0,0 +1,21 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "wasabi"
6
+ gem "savon", ">= 2.0.0"
7
+ gem "httpi"
8
+ gem "rspec-rails"
9
+ gem "guard"
10
+ gem "guard-rspec"
11
+ gem "rb-fsevent"
12
+ gem "appraisal"
13
+ gem "tzinfo"
14
+ gem "pry"
15
+ gem "simplecov"
16
+ gem "simplecov-summary"
17
+ gem "rails", "3.2.13"
18
+ gem "test-unit"
19
+ gem "listen", "< 3.1.0"
20
+
21
+ gemspec :path => "../"
@@ -0,0 +1,20 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "wasabi"
6
+ gem "savon", ">= 2.0.0"
7
+ gem "httpi"
8
+ gem "rspec-rails"
9
+ gem "guard"
10
+ gem "guard-rspec"
11
+ gem "rb-fsevent"
12
+ gem "appraisal"
13
+ gem "tzinfo"
14
+ gem "pry"
15
+ gem "simplecov"
16
+ gem "simplecov-summary"
17
+ gem "rails", "4.0.0"
18
+ gem "listen", "< 3.1.0"
19
+
20
+ gemspec :path => "../"
@@ -0,0 +1,20 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "wasabi"
6
+ gem "savon", ">= 2.0.0"
7
+ gem "httpi"
8
+ gem "rspec-rails"
9
+ gem "guard"
10
+ gem "guard-rspec"
11
+ gem "rb-fsevent"
12
+ gem "appraisal"
13
+ gem "tzinfo"
14
+ gem "pry"
15
+ gem "simplecov"
16
+ gem "simplecov-summary"
17
+ gem "rails", "4.1.0"
18
+ gem "listen", "< 3.1.0"
19
+
20
+ gemspec :path => "../"
@@ -0,0 +1,20 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "wasabi"
6
+ gem "savon", ">= 2.0.0"
7
+ gem "httpi"
8
+ gem "rspec-rails"
9
+ gem "guard"
10
+ gem "guard-rspec"
11
+ gem "rb-fsevent"
12
+ gem "appraisal"
13
+ gem "tzinfo"
14
+ gem "pry"
15
+ gem "simplecov"
16
+ gem "simplecov-summary"
17
+ gem "rails", "4.2.0"
18
+ gem "listen", "< 3.1.0"
19
+
20
+ gemspec :path => "../"
@@ -0,0 +1,19 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "wasabi"
6
+ gem "savon", ">= 2.0.0"
7
+ gem "httpi"
8
+ gem "rspec-rails"
9
+ gem "guard"
10
+ gem "guard-rspec"
11
+ gem "rb-fsevent"
12
+ gem "appraisal"
13
+ gem "tzinfo"
14
+ gem "pry"
15
+ gem "simplecov"
16
+ gem "simplecov-summary"
17
+ gem "rails", "5.0.0.beta2"
18
+
19
+ gemspec :path => "../"