nogara-wash_out 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.gitignore +9 -0
  2. data/.travis.yml +3 -0
  3. data/Appraisals +7 -0
  4. data/CHANGELOG.md +79 -0
  5. data/Gemfile +5 -0
  6. data/Gemfile.lock +118 -0
  7. data/LICENSE +22 -0
  8. data/README.md +181 -0
  9. data/Rakefile +14 -0
  10. data/app/helpers/wash_out_helper.rb +64 -0
  11. data/app/views/wash_with_soap/error.builder +10 -0
  12. data/app/views/wash_with_soap/response.builder +13 -0
  13. data/app/views/wash_with_soap/wsdl.builder +68 -0
  14. data/gemfiles/rails-3.0.11.gemfile +8 -0
  15. data/gemfiles/rails-3.0.11.gemfile.lock +130 -0
  16. data/gemfiles/rails-3.1.3.gemfile +8 -0
  17. data/gemfiles/rails-3.1.3.gemfile.lock +141 -0
  18. data/init.rb +1 -0
  19. data/lib/wash_out.rb +35 -0
  20. data/lib/wash_out/dispatcher.rb +206 -0
  21. data/lib/wash_out/engine.rb +30 -0
  22. data/lib/wash_out/model.rb +25 -0
  23. data/lib/wash_out/param.rb +176 -0
  24. data/lib/wash_out/router.rb +36 -0
  25. data/lib/wash_out/soap.rb +40 -0
  26. data/lib/wash_out/type.rb +28 -0
  27. data/lib/wash_out/version.rb +3 -0
  28. data/lib/wash_out/wsse.rb +79 -0
  29. data/spec/dummy/Rakefile +7 -0
  30. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  31. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  32. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  33. data/spec/dummy/config.ru +4 -0
  34. data/spec/dummy/config/application.rb +42 -0
  35. data/spec/dummy/config/boot.rb +10 -0
  36. data/spec/dummy/config/environment.rb +5 -0
  37. data/spec/dummy/config/environments/development.rb +23 -0
  38. data/spec/dummy/config/environments/test.rb +30 -0
  39. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  40. data/spec/dummy/config/initializers/inflections.rb +10 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  42. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  43. data/spec/dummy/config/initializers/session_store.rb +8 -0
  44. data/spec/dummy/config/locales/en.yml +5 -0
  45. data/spec/dummy/config/routes.rb +58 -0
  46. data/spec/dummy/public/404.html +26 -0
  47. data/spec/dummy/public/422.html +26 -0
  48. data/spec/dummy/public/500.html +26 -0
  49. data/spec/dummy/public/favicon.ico +0 -0
  50. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  51. data/spec/dummy/script/rails +6 -0
  52. data/spec/spec_helper.rb +51 -0
  53. data/spec/support/httpi-rack.rb +46 -0
  54. data/spec/wash_out/dispatcher_spec.rb +65 -0
  55. data/spec/wash_out/param_spec.rb +26 -0
  56. data/spec/wash_out/type_spec.rb +23 -0
  57. data/spec/wash_out_spec.rb +686 -0
  58. data/wash_out.gemspec +21 -0
  59. metadata +183 -0
@@ -0,0 +1,64 @@
1
+ module WashOutHelper
2
+ def wsdl_data(xml, params)
3
+ params.each do |param|
4
+ tag_name = 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 = [] unless param.value.is_a?(Array)
11
+ param.value.each do |v|
12
+ xml.tag! tag_name, v, "xsi:type" => param.namespaced_type
13
+ end
14
+ end
15
+ else
16
+ if !param.multiplied
17
+ xml.tag! tag_name, "xsi:type" => param.namespaced_type do
18
+ wsdl_data(xml, param.map)
19
+ end
20
+ else
21
+ param.map.each do |p|
22
+ xml.tag! tag_name, "xsi:type" => param.namespaced_type do
23
+ wsdl_data(xml, p.map)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ def wsdl_type(xml, param, defined=[])
32
+ more = []
33
+
34
+ if param.struct?
35
+ if !defined.include?(param.basic_type)
36
+ xml.tag! "xsd:complexType", :name => param.basic_type do
37
+ xml.tag! "xsd:sequence" do
38
+ param.map.each do |value|
39
+ more << value if value.struct?
40
+ xml.tag! "xsd:element", wsdl_occurence(value, false, :name => value.name, :type => value.namespaced_type)
41
+ end
42
+ end
43
+ end
44
+
45
+ defined << param.basic_type
46
+ elsif !param.classified?
47
+ raise RuntimeError, "Duplicate use of `#{param.basic_type}` type name. Consider using classified types."
48
+ end
49
+ end
50
+
51
+ more.each do |p|
52
+ wsdl_type xml, p, defined
53
+ end
54
+ end
55
+
56
+ def wsdl_occurence(param, inject, extend_with = {})
57
+ data = !param.multiplied ? {} : {
58
+ "#{'xsi:' if inject}minOccurs" => 0,
59
+ "#{'xsi:' if inject}maxOccurs" => 'unbounded'
60
+ }
61
+
62
+ extend_with.merge(data)
63
+ end
64
+ end
@@ -0,0 +1,10 @@
1
+ xml.instruct!
2
+ xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envelope/',
3
+ "xmlns:xsi" => 'http://www.w3.org/2001/XMLSchema-instance' do
4
+ xml.tag! "soap:Body" do
5
+ xml.tag! "soap:Fault", :encodingStyle => 'http://schemas.xmlsoap.org/soap/encoding/' do
6
+ xml.faultcode "Server", 'xsi:type' => 'xsd:QName'
7
+ xml.faultstring error_message, 'xsi:type' => 'xsd:string'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ xml.instruct!
2
+ xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envelope/',
3
+ "xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema',
4
+ "xmlns:xsi" => 'http://www.w3.org/2001/XMLSchema-instance',
5
+ "xmlns:tns" => @namespace do
6
+ xml.tag! "soap:Body" do
7
+ key = "tns:#{@operation}#{WashOut::Engine.camelize_wsdl ? 'Response' : '_response'}"
8
+
9
+ xml.tag! key do
10
+ wsdl_data xml, result
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,68 @@
1
+ xml.instruct!
2
+ xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
3
+ 'xmlns:tns' => @namespace,
4
+ 'xmlns:soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
5
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
6
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
7
+ 'xmlns:soap-enc' => 'http://schemas.xmlsoap.org/soap/encoding/',
8
+ 'xmlns:wsdl' => 'http://schemas.xmlsoap.org/wsdl/',
9
+ 'name' => @name,
10
+ 'targetNamespace' => @namespace do
11
+ xml.types do
12
+ xml.tag! "schema", :targetNamespace => @namespace, :xmlns => 'http://www.w3.org/2001/XMLSchema' do
13
+ defined = []
14
+ @map.each do |operation, formats|
15
+ (formats[:in] + formats[:out]).each do |p|
16
+ wsdl_type xml, p, defined
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ xml.portType :name => "#{@name}_port" do
23
+ @map.keys.each do |operation|
24
+ xml.operation :name => operation do
25
+ xml.input :message => "tns:#{operation}"
26
+ xml.output :message => "tns:#{operation}#{WashOut::Engine.camelize_wsdl ? 'Response' : '_response'}"
27
+ end
28
+ end
29
+ end
30
+
31
+ xml.binding :name => "#{@name}_binding", :type => "tns:#{@name}_port" do
32
+ xml.tag! "soap:binding", :style => 'rpc', :transport => 'http://schemas.xmlsoap.org/soap/http'
33
+ @map.keys.each do |operation|
34
+ xml.operation :name => operation do
35
+ xml.tag! "soap:operation", :soapAction => operation
36
+ xml.input do
37
+ xml.tag! "soap:body",
38
+ :use => "encoded", :encodingStyle => 'http://schemas.xmlsoap.org/soap/encoding/',
39
+ :namespace => @namespace
40
+ end
41
+ xml.output do
42
+ xml.tag! "soap:body",
43
+ :use => "encoded", :encodingStyle => 'http://schemas.xmlsoap.org/soap/encoding/',
44
+ :namespace => @namespace
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ xml.service :name => "service" do
51
+ xml.port :name => "#{@name}_port", :binding => "tns:#{@name}_binding" do
52
+ xml.tag! "soap:address", :location => url_for(:action => '_action', :only_path => false)
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 => "#{operation}#{WashOut::Engine.camelize_wsdl ? 'Response' : '_response'}" do
63
+ formats[:out].each do |p|
64
+ xml.part wsdl_occurence(p, true, :name => p.name, :type => p.namespaced_type)
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "pry"
6
+ gem "rails", "3.0.11"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,130 @@
1
+ PATH
2
+ remote: /Users/inossidabile/Sites/wash_out
3
+ specs:
4
+ wash_out (0.5.2)
5
+ nori
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.11)
12
+ actionpack (= 3.0.11)
13
+ mail (~> 2.2.19)
14
+ actionpack (3.0.11)
15
+ activemodel (= 3.0.11)
16
+ activesupport (= 3.0.11)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.5.0)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.14)
22
+ rack-test (~> 0.5.7)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.11)
25
+ activesupport (= 3.0.11)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.5.0)
28
+ activerecord (3.0.11)
29
+ activemodel (= 3.0.11)
30
+ activesupport (= 3.0.11)
31
+ arel (~> 2.0.10)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.11)
34
+ activemodel (= 3.0.11)
35
+ activesupport (= 3.0.11)
36
+ activesupport (3.0.11)
37
+ akami (1.0.0)
38
+ gyoku (>= 0.4.0)
39
+ appraisal (0.4.0)
40
+ bundler
41
+ rake
42
+ arel (2.0.10)
43
+ builder (2.1.2)
44
+ coderay (1.0.7)
45
+ diff-lcs (1.1.3)
46
+ erubis (2.6.6)
47
+ abstract (>= 1.0.0)
48
+ gyoku (0.4.4)
49
+ builder (>= 2.1.2)
50
+ httpi (0.9.5)
51
+ rack
52
+ i18n (0.5.0)
53
+ json (1.6.3)
54
+ mail (2.2.19)
55
+ activesupport (>= 2.3.6)
56
+ i18n (>= 0.4.0)
57
+ mime-types (~> 1.16)
58
+ treetop (~> 1.4.8)
59
+ method_source (0.8)
60
+ mime-types (1.17.2)
61
+ nokogiri (1.5.0)
62
+ nori (1.0.2)
63
+ polyglot (0.3.3)
64
+ pry (0.9.10)
65
+ coderay (~> 1.0.5)
66
+ method_source (~> 0.8)
67
+ slop (~> 3.3.1)
68
+ rack (1.2.4)
69
+ rack-mount (0.6.14)
70
+ rack (>= 1.0.0)
71
+ rack-test (0.5.7)
72
+ rack (>= 1.0)
73
+ rails (3.0.11)
74
+ actionmailer (= 3.0.11)
75
+ actionpack (= 3.0.11)
76
+ activerecord (= 3.0.11)
77
+ activeresource (= 3.0.11)
78
+ activesupport (= 3.0.11)
79
+ bundler (~> 1.0)
80
+ railties (= 3.0.11)
81
+ railties (3.0.11)
82
+ actionpack (= 3.0.11)
83
+ activesupport (= 3.0.11)
84
+ rake (>= 0.8.7)
85
+ rdoc (~> 3.4)
86
+ thor (~> 0.14.4)
87
+ rake (0.9.2.2)
88
+ rdoc (3.12)
89
+ json (~> 1.4)
90
+ rspec (2.7.0)
91
+ rspec-core (~> 2.7.0)
92
+ rspec-expectations (~> 2.7.0)
93
+ rspec-mocks (~> 2.7.0)
94
+ rspec-core (2.7.1)
95
+ rspec-expectations (2.7.0)
96
+ diff-lcs (~> 1.1.2)
97
+ rspec-mocks (2.7.0)
98
+ rspec-rails (2.7.0)
99
+ actionpack (~> 3.0)
100
+ activesupport (~> 3.0)
101
+ railties (~> 3.0)
102
+ rspec (~> 2.7.0)
103
+ savon (0.9.7)
104
+ akami (~> 1.0)
105
+ builder (>= 2.1.2)
106
+ gyoku (>= 0.4.0)
107
+ httpi (~> 0.9)
108
+ nokogiri (>= 1.4.0)
109
+ nori (~> 1.0)
110
+ wasabi (~> 2.0)
111
+ slop (3.3.2)
112
+ thor (0.14.6)
113
+ treetop (1.4.10)
114
+ polyglot
115
+ polyglot (>= 0.3.1)
116
+ tzinfo (0.3.31)
117
+ wasabi (2.0.0)
118
+ nokogiri (>= 1.4.0)
119
+
120
+ PLATFORMS
121
+ ruby
122
+
123
+ DEPENDENCIES
124
+ appraisal
125
+ pry
126
+ rails (= 3.0.11)
127
+ rspec-rails
128
+ savon
129
+ tzinfo
130
+ wash_out!
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "pry"
6
+ gem "rails", "3.1.3"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,141 @@
1
+ PATH
2
+ remote: /Users/inossidabile/Sites/wash_out
3
+ specs:
4
+ wash_out (0.5.2)
5
+ nori
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.1.3)
11
+ actionpack (= 3.1.3)
12
+ mail (~> 2.3.0)
13
+ actionpack (3.1.3)
14
+ activemodel (= 3.1.3)
15
+ activesupport (= 3.1.3)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ i18n (~> 0.6)
19
+ rack (~> 1.3.5)
20
+ rack-cache (~> 1.1)
21
+ rack-mount (~> 0.8.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.0.3)
24
+ activemodel (3.1.3)
25
+ activesupport (= 3.1.3)
26
+ builder (~> 3.0.0)
27
+ i18n (~> 0.6)
28
+ activerecord (3.1.3)
29
+ activemodel (= 3.1.3)
30
+ activesupport (= 3.1.3)
31
+ arel (~> 2.2.1)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.1.3)
34
+ activemodel (= 3.1.3)
35
+ activesupport (= 3.1.3)
36
+ activesupport (3.1.3)
37
+ multi_json (~> 1.0)
38
+ akami (1.0.0)
39
+ gyoku (>= 0.4.0)
40
+ appraisal (0.4.0)
41
+ bundler
42
+ rake
43
+ arel (2.2.1)
44
+ builder (3.0.0)
45
+ coderay (1.0.7)
46
+ diff-lcs (1.1.3)
47
+ erubis (2.7.0)
48
+ gyoku (0.4.4)
49
+ builder (>= 2.1.2)
50
+ hike (1.2.1)
51
+ httpi (0.9.5)
52
+ rack
53
+ i18n (0.6.0)
54
+ json (1.6.3)
55
+ mail (2.3.0)
56
+ i18n (>= 0.4.0)
57
+ mime-types (~> 1.16)
58
+ treetop (~> 1.4.8)
59
+ method_source (0.8)
60
+ mime-types (1.17.2)
61
+ multi_json (1.0.4)
62
+ nokogiri (1.5.0)
63
+ nori (1.0.2)
64
+ polyglot (0.3.3)
65
+ pry (0.9.10)
66
+ coderay (~> 1.0.5)
67
+ method_source (~> 0.8)
68
+ slop (~> 3.3.1)
69
+ rack (1.3.5)
70
+ rack-cache (1.1)
71
+ rack (>= 0.4)
72
+ rack-mount (0.8.3)
73
+ rack (>= 1.0.0)
74
+ rack-ssl (1.3.2)
75
+ rack
76
+ rack-test (0.6.1)
77
+ rack (>= 1.0)
78
+ rails (3.1.3)
79
+ actionmailer (= 3.1.3)
80
+ actionpack (= 3.1.3)
81
+ activerecord (= 3.1.3)
82
+ activeresource (= 3.1.3)
83
+ activesupport (= 3.1.3)
84
+ bundler (~> 1.0)
85
+ railties (= 3.1.3)
86
+ railties (3.1.3)
87
+ actionpack (= 3.1.3)
88
+ activesupport (= 3.1.3)
89
+ rack-ssl (~> 1.3.2)
90
+ rake (>= 0.8.7)
91
+ rdoc (~> 3.4)
92
+ thor (~> 0.14.6)
93
+ rake (0.9.2.2)
94
+ rdoc (3.12)
95
+ json (~> 1.4)
96
+ rspec (2.7.0)
97
+ rspec-core (~> 2.7.0)
98
+ rspec-expectations (~> 2.7.0)
99
+ rspec-mocks (~> 2.7.0)
100
+ rspec-core (2.7.1)
101
+ rspec-expectations (2.7.0)
102
+ diff-lcs (~> 1.1.2)
103
+ rspec-mocks (2.7.0)
104
+ rspec-rails (2.7.0)
105
+ actionpack (~> 3.0)
106
+ activesupport (~> 3.0)
107
+ railties (~> 3.0)
108
+ rspec (~> 2.7.0)
109
+ savon (0.9.7)
110
+ akami (~> 1.0)
111
+ builder (>= 2.1.2)
112
+ gyoku (>= 0.4.0)
113
+ httpi (~> 0.9)
114
+ nokogiri (>= 1.4.0)
115
+ nori (~> 1.0)
116
+ wasabi (~> 2.0)
117
+ slop (3.3.2)
118
+ sprockets (2.0.3)
119
+ hike (~> 1.2)
120
+ rack (~> 1.0)
121
+ tilt (~> 1.1, != 1.3.0)
122
+ thor (0.14.6)
123
+ tilt (1.3.3)
124
+ treetop (1.4.10)
125
+ polyglot
126
+ polyglot (>= 0.3.1)
127
+ tzinfo (0.3.31)
128
+ wasabi (2.0.0)
129
+ nokogiri (>= 1.4.0)
130
+
131
+ PLATFORMS
132
+ ruby
133
+
134
+ DEPENDENCIES
135
+ appraisal
136
+ pry
137
+ rails (= 3.1.3)
138
+ rspec-rails
139
+ savon
140
+ tzinfo
141
+ wash_out!