washout_builder 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTBjY2VlMDQ3YTc5N2ZjZWIzOTU5MWI5NDEwOTBmMTMzYWM2NDVmNg==
5
+ data.tar.gz: !binary |-
6
+ OTViODkwOTQyOTY2Y2I1MjI3YmI1Mzc4OTczMjRlZDVjOTViOGYxOQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MDZkYjlkZDFlMDEwYTEwNTJjMzMyOWQxYzk2YmYxYTUyZWUwNTA4MTZhZDU2
10
+ NWQ2NWFhOWQxYzIyMGY3ODg1MWIxZjIyOTI1MjM3YTBkYTNmNWZkYzQ1MzQ0
11
+ ODA5NzgxNzdiOTUzN2Q2NTE1NGU5ZGJhZDgxN2UwZjU4ZTRiNDE=
12
+ data.tar.gz: !binary |-
13
+ Yjg5MTQ5ZDM3ZDg3NjAxY2U0ZmQ0YTIyYmRhMmZhOWY1NmExNDM5YzA5Nzk1
14
+ OWM2YmU3MGM1NjgzMWYxOTgzYzk4N2FkZGE4NDQ2ZDk1YWE0Zjg1MjA4OGU1
15
+ OWMwMzQ5YWEzZjMxZGYyZTNlYzQzN2RmOWI0NjNlMTA2ZWI3NzI=
@@ -0,0 +1,17 @@
1
+ s.rbx/
2
+ .bundle/
3
+ *.gem
4
+ .idea/
5
+ .rvmrc
6
+ *.swp
7
+ log/*.log
8
+ pkg/
9
+ spec/dummy/db/*.sqlite3
10
+ spec/dummy/log/*.log
11
+ spec/dummy/tmp/
12
+ gemfiles
13
+ coverage
14
+ tags
15
+ Gemfile.lock
16
+ /nbproject/
17
+ /.git-rewrite/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,6 @@
1
+ before_install:
2
+ - gem install bundler
3
+ rvm:
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - 2.0.0
@@ -0,0 +1,15 @@
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"
11
+ end
12
+
13
+ appraise "rails-4.0.0" do
14
+ gem "rails", "4.0.0"
15
+ end
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+
6
+ gem 'wash_out', "~> 0.9.1"
7
+
8
+ gem 'wasabi'
9
+ gem 'savon', '>= 2.0.0'
10
+ gem 'httpi', :git => 'git://github.com/savonrb/httpi.git'
11
+
12
+ gem 'rspec-rails'
13
+ gem 'guard'
14
+ gem 'guard-rspec'
15
+ gem 'rb-fsevent'
16
+ gem 'appraisal'
17
+ gem 'tzinfo'
18
+ gem 'pry'
19
+ gem 'simplecov'
20
+ gem 'simplecov-summary'
21
+
@@ -0,0 +1,12 @@
1
+ # More info at https://github.com/guard/guard#readme
2
+
3
+ # Could be changed to whatever you want.
4
+ # See: https://github.com/guard/guard#notification
5
+ notification :off
6
+
7
+ guard 'rspec' do
8
+ watch %r{^spec/.+_spec\.rb$}
9
+ watch %r{lib/} do 'spec' end
10
+ end
11
+
12
+ # vim:ft=ruby
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 bogdanRada
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,116 @@
1
+ = washout_builder
2
+
3
+ = Overview
4
+ WashOutBuilder is a Soap Service Documentation generator (extends WashOut https://github.com/inossidabile/wash_out/)
5
+
6
+ The way WashOut is used is not modified, it just extends its functionality by providing html documentation
7
+
8
+ = Features
9
+
10
+ * Provides way of seeing the available services with links to documentation, endpoint and namespace
11
+ * Provides a human-readable HTML documentation generated for each service that you write
12
+ * Can also create custom exception classes and use them to send custom fault errors to the client application
13
+
14
+ = Screenshots (just an example)
15
+
16
+ * {Screenshot 1}[https://f.cloud.github.com/assets/1104923/1582604/53ad8c04-51f1-11e3-963c-fb6c58d0a6a6.png]
17
+ * {Screenshot 2}[https://f.cloud.github.com/assets/1104923/1563031/0efe630c-5058-11e3-8502-1e0b145de80c.png]
18
+ * {Screenshot 3}[https://f.cloud.github.com/assets/1104923/1563032/0f43ddb0-5058-11e3-91d1-35409d4017b0.png]
19
+
20
+ = Requirements
21
+
22
+ 1. {Ruby 1.9.x}[http://www.ruby-lang.org]
23
+ 2. {Ruby on Rails}[http://rubyonrails.org].
24
+ 3. {WashOut Gem v. 0.9.0}[https://github.com/inossidabile/wash_out]
25
+ 4. {Nori Gem}[https://github.com/savonrb/nori]
26
+
27
+ = Compatibility
28
+
29
+ Rails >3.0 only. MRI 1.9, 2.0, JRuby (--1.9).
30
+
31
+ 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.
32
+
33
+ Rubinius support temporarily dropped since 0.6.2 due to Rails 4 incompatibility.
34
+
35
+ = Setup
36
+
37
+ Type the following from the command line to install:
38
+
39
+ gem install washout_builder
40
+
41
+ Add the following to your Gemfile:
42
+
43
+ gem 'wash_out',"~> 0.9.0", git: 'git://github.com/inossidabile/wash_out.git'
44
+ gem "washout_builder"
45
+
46
+ it will automatically install also wash_out version 0.9.0 that is currently used
47
+
48
+ Please read {release details}[https://github.com/bogdanRada/washout_builder/releases] if you are upgrading. We break backward compatibility between large ticks but you can expect it to be specified at release notes.
49
+
50
+ = Usage
51
+
52
+ The way soap_actions, or reusable types are defined or how the configuration is made using WashOut(https://github.com/inossidabile/wash_out) haven't changed
53
+ You can still do everything that gem does .
54
+
55
+ when specifying the soap_action you can also pass a option for description and a list of exceptions that the method can raise at a certain moment.
56
+ The exception classes used must inherit from WashOut::SoapError and have accessible_attributes in order to show up in the documentation
57
+
58
+ Here is an example :
59
+
60
+ soap_action "find", :args => {:number => :integer} , :return => :boolean, :raises => [MyFirstExceptionClass, MySecondExceptionClass ] , :description => "some description about this method to show in the documentation"
61
+
62
+
63
+ In order to see the documentation you must write something like this in the routes (exactly like you would do when using only WashOut)
64
+
65
+ In the following file +config/routes.rb+ you can put this configuration
66
+
67
+ WashOutSample::Application.routes.draw do
68
+ wash_out :rumbas
69
+ wash_out :my_other_service
70
+ end
71
+
72
+ You can access the url +/washout+ and you will see a list with available services ( in our case there are only two : The RumbasController and MyOtherServiceController) with links to their documentation and where you can find the WSDL.
73
+
74
+ If you want to access directly the hml documentation that was generated for RumbasController you can do that by accessing url +/rumbas/doc+ And the WSDL will be available at +/rumbas/wsdl+
75
+
76
+ = Setup custom exceptions
77
+
78
+ There is a class WashOut::SoapError
79
+ This class has as attributes : a error_code, and a message.
80
+
81
+ If you only want to send a faultcode for your exception in the webservice application you can do this
82
+
83
+ class MyException < WashOut::SoapError; end
84
+
85
+ and then when you raise it in the code you can do this
86
+
87
+ raise MyException.new (1001, "damn! found a error") .
88
+
89
+ This exception is going to be catched by the gem and is going to send it to the client with the specified fault code and message
90
+
91
+ = Testing
92
+
93
+ To test, do the following:
94
+
95
+ 1. cd to the gem root.
96
+ 2. bundle install
97
+ 3. bundle exec rake
98
+
99
+ = Contributions
100
+
101
+ Please log all feedback/issues via {GitHub Issues}[http://github.com/bogdanRada/washout_builder/issues]. Thanks.
102
+
103
+ == Contributing to washout_builder
104
+
105
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
106
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
107
+ * Fork the project.
108
+ * Start a feature/bugfix branch.
109
+ * Commit and push until you are happy with your contribution.
110
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
111
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
112
+
113
+ == Copyright
114
+
115
+ Copyright (c) 2013 bogdanRada. See LICENSE.txt for
116
+ further details.
@@ -0,0 +1,14 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'appraisal'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
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
@@ -0,0 +1,34 @@
1
+ class WashoutBuilderController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def all
5
+ # get a list of unique controller names
6
+ controllers = Rails.application.routes.routes.map do |route|
7
+ if route.defaults[:action] == "_generate_doc"
8
+ {:class => "#{route.defaults[:controller]}_controller".camelize.constantize, :name => route.defaults[:controller] }
9
+ end
10
+ end.uniq.compact
11
+
12
+ @services = []
13
+ unless controllers.blank?
14
+ controllers.map do |hash|
15
+ namespace = hash[:class].soap_config.namespace
16
+ @services << {
17
+ :service_name => hash[:class].to_s.underscore.gsub("_controller", "").camelize ,
18
+ :namespace => namespace,
19
+ :endpoint => namespace.gsub("/wsdl", "/action"),
20
+ :documentation_url => "#{request.protocol}#{request.host_with_port}/#{hash[:name]}/doc",
21
+ }
22
+ end
23
+ end
24
+
25
+
26
+ render :template => "wash_with_html/all_services", :layout => false,
27
+ :content_type => 'text/html'
28
+
29
+ end
30
+
31
+
32
+
33
+
34
+ end
@@ -0,0 +1,302 @@
1
+ module WashoutBuilderHelper
2
+ include WashOutHelper
3
+
4
+ def get_complex_class_name(p, defined = [])
5
+ complex_class = nil
6
+ complex_class = p.basic_type.to_s.classify if p.is_complex?
7
+
8
+ if !complex_class.nil? && !defined.blank?
9
+
10
+ found = false
11
+ defined.each do |hash|
12
+ found = true if hash[:class] == complex_class
13
+ end
14
+ if found == true && p.struct? && !p.classified? && p.source_class_name.blank?
15
+ raise RuntimeError, "Duplicate use of `#{p.basic_type}` type name. Consider using classified types."
16
+ end
17
+ end
18
+
19
+ return complex_class
20
+ end
21
+
22
+
23
+ def get_nested_complex_types(param, defined)
24
+ defined = [] if defined.blank?
25
+ complex_class = get_complex_class_name(param, defined)
26
+ defined << {:class =>complex_class, :obj => param} unless complex_class.nil?
27
+ if param.is_complex?
28
+ c_names = []
29
+ param.map.each do |obj|
30
+ nested = get_nested_complex_types(obj, defined)
31
+ nested.each do |hash|
32
+ c_names << hash
33
+ end
34
+ end
35
+ defined.concat(c_names)
36
+ end
37
+ defined.sort_by { |hash| hash[:class].downcase }.uniq unless defined.blank?
38
+ end
39
+
40
+
41
+ def get_complex_types(map)
42
+ defined = []
43
+ map.each do |operation, formats|
44
+ (formats[:input] + formats[:output]).each do |p|
45
+ nested = get_nested_complex_types(p, defined)
46
+ nested.each do |hash|
47
+ defined << hash
48
+ end
49
+ end
50
+ end
51
+ defined << {:class =>"ValidationErrors", :obj => nil} unless get_fault_types_names(map).blank?
52
+ defined.sort_by { |hash| hash[:class].downcase }.uniq unless defined.blank?
53
+ end
54
+
55
+ def get_fault_types_names(map)
56
+ defined = []
57
+ map.each do |operation, formats|
58
+ faults = formats[:raises]
59
+ unless faults.blank?
60
+ faults = [formats[:raises]] if !faults.is_a?(Array)
61
+ faults.each do |p|
62
+ defined << p.to_s.classify
63
+ end
64
+ end
65
+ end
66
+ defined.sort_by { |name| name.downcase }.uniq unless defined.blank?
67
+ end
68
+
69
+ def get_soap_action_names(map)
70
+ defined = []
71
+ unless map.blank?
72
+ map.each do |operation, formats|
73
+ defined << operation.to_s
74
+ end
75
+ end
76
+ defined.sort_by { |name| name.downcase }.uniq unless defined.blank?
77
+ end
78
+
79
+
80
+
81
+ def create_html_complex_type_validation_errors(xml)
82
+ xml.a( "name" => "ValidationErrors") { }
83
+ xml.h3 "ValidationErrors"
84
+
85
+ xml.ul("class" => "pre") {
86
+ xml.li { |pre| pre << "<span class='blue'>string</span>&nbsp;<span class='bold'>related</span>" }
87
+ xml.li { |pre| pre << "<span class='blue'>string</span>&nbsp;<span class='bold'>message</span>" }
88
+ xml.li { |pre| pre << "<span class='blue'>Array of string</span>&nbsp;<span class='bold'>arguments</span>" }
89
+ }
90
+ end
91
+
92
+
93
+
94
+ def create_html_complex_types(xml, types)
95
+ types.each do |hash|
96
+ create_complex_type_html(xml, hash[:obj], hash[:class])
97
+ end
98
+ end
99
+
100
+
101
+
102
+ def create_complex_type_html(xml, param, class_name)
103
+ unless param.blank?
104
+ xml.a( "name" => "#{class_name}") { }
105
+ xml.h3 "#{class_name}"
106
+
107
+ if param.is_a?(WashoutBuilder::Param)
108
+ xml.ul("class" => "pre") {
109
+
110
+ param.map.each do |element|
111
+ # raise YAML::dump(element) if class_name.include?("ype") and element.name == "members"
112
+ xml.li { |pre|
113
+ if WashoutBuilder::Type::BASIC_TYPES.include?(element.type)
114
+ pre << "<span class='blue'>#{element.type}</span>&nbsp;<span class='bold'>#{element.name}</span>"
115
+ else
116
+ complex_class = get_complex_class_name(element)
117
+ unless complex_class.nil?
118
+ if element.multiplied == false
119
+ pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
120
+ else
121
+ pre << "<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
122
+ end
123
+ end
124
+ end
125
+ }
126
+
127
+ end
128
+
129
+ }
130
+
131
+ end
132
+ end
133
+ end
134
+
135
+ def create_html_fault_types_details(xml, map)
136
+ defined = []
137
+ unless map.blank?
138
+ map = map.sort_by { |operation, formats| formats[:raises].to_s.downcase }.uniq
139
+ map.each do |operation, formats|
140
+ faults = formats[:raises]
141
+ unless faults.blank?
142
+ faults = [formats[:raises]] if !faults.is_a?(Array)
143
+ faults.each do |p|
144
+ defined << p
145
+ end
146
+ end
147
+ end
148
+ end
149
+ unless defined.blank?
150
+ defined = defined.sort_by { |name| name.to_s.downcase }.uniq
151
+ defined.each do |fault|
152
+ create_html_fault_type(xml, fault)
153
+ end
154
+ end
155
+ end
156
+
157
+ def create_html_fault_type(xml, param)
158
+ xml.h3 "#{param}"
159
+ xml.a("name" => "#{param}") {}
160
+ xml.ul("class" => "pre") {
161
+ if param.ancestors.include?(WashoutBuilder::SoapFault)
162
+
163
+ param.accessible_attributes.each do |attribute|
164
+ xml.li { |pre|
165
+ if WashoutBuilder::Type::BASIC_TYPES.include?(attribute.class.name.downcase) && attribute != "errors"
166
+ pre << "<span class='blue'>#{attribute.class.name.downcase}</span>&nbsp;<span class='bold'>#{attribute}</span>"
167
+ elsif attribute == "errors"
168
+ pre << "<a href='#ValidationErrors'><span class='lightBlue'>Array of ValidationErrors</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
169
+ else
170
+ pre << "<a href='##{attribute.class.name}'><span class='lightBlue'>#{attribute.class.name}</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
171
+ end
172
+ }
173
+ end
174
+ xml.li { |pre| pre << "<span class='blue'>string</span>&nbsp;<span class='bold'>backtrace</span>" }
175
+ end
176
+ }
177
+ end
178
+
179
+ def create_html_public_methods(xml, map)
180
+ unless map.blank?
181
+ map =map.sort_by { |operation, formats| operation.downcase }.uniq
182
+
183
+ map.each do |operation, formats|
184
+ create_html_public_method(xml, operation, formats)
185
+ end
186
+ end
187
+ end
188
+
189
+
190
+
191
+ def create_html_public_method(xml, operation, formats)
192
+ # raise YAML::dump(formats[:input])
193
+ xml.h3 "#{operation}"
194
+ xml.a("name" => "#{operation}") {}
195
+
196
+
197
+ xml.p("class" => "pre"){ |pre|
198
+ if !formats[:output].nil?
199
+ if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:output][0].type)
200
+ xml.span("class" => "blue") { |y| y<< "#{formats[:output][0].type}" }
201
+ else
202
+ xml.a("href" => "##{formats[:output][0].type}") { |xml| xml.span("class" => "lightBlue") { |y| y<<"#{formats[:output][0].type}" } }
203
+ end
204
+ else
205
+ pre << "void"
206
+ end
207
+
208
+ xml.span("class" => "bold") {|y| y << "#{operation} (" }
209
+ mlen = formats[:input].size
210
+ xml.br if mlen > 1
211
+ spacer = "&nbsp;&nbsp;&nbsp;&nbsp;"
212
+ if mlen > 0
213
+ j=0
214
+ while j<mlen
215
+ param = formats[:input][j]
216
+ use_spacer = mlen > 1 ? true : false
217
+ if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
218
+ pre << "#{use_spacer ? spacer: ''}<span class='blue'>#{param.type}</span>&nbsp;<span class='bold'>#{param.name}</span>"
219
+ else
220
+ complex_class = get_complex_class_name(param)
221
+ unless complex_class.nil?
222
+ if param.multiplied == false
223
+ pre << "#{use_spacer ? spacer: ''}<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
224
+ else
225
+ pre << "#{use_spacer ? spacer: ''}<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
226
+ end
227
+ end
228
+ end
229
+ if j< (mlen-1)
230
+ xml.span ", "
231
+ end
232
+ if mlen > 1
233
+ xml.br
234
+ end
235
+ if (j+1) == mlen
236
+ xml.span("class" => "bold") {|y| y << ")" }
237
+ end
238
+ j+=1
239
+ end
240
+
241
+ end
242
+
243
+
244
+
245
+ }
246
+ xml.p "#{formats[:description]}" if !formats[:description].blank?
247
+ xml.p "Parameters:"
248
+
249
+ xml.ul {
250
+ j=0
251
+ mlen = formats[:input].size
252
+ while j<mlen
253
+ param = formats[:input][j]
254
+ xml.li("class" => "pre") { |pre|
255
+ if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
256
+ pre << "<span class='blue'>#{param.type}</span>&nbsp;<span class='bold'>#{param.name}</span>"
257
+ else
258
+ complex_class = get_complex_class_name(param)
259
+ unless complex_class.nil?
260
+ if param.multiplied == false
261
+ pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
262
+ else
263
+ pre << "<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
264
+ end
265
+ end
266
+ end
267
+ }
268
+ j+=1
269
+ end
270
+
271
+ }
272
+
273
+ xml.p "Return value:"
274
+ xml.ul {
275
+ xml.li {
276
+ if !formats[:output].nil?
277
+
278
+ if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:output][0].type)
279
+ xml.span("class" => "pre") { |xml| xml.span("class" => "blue") { |sp| sp << "#{formats[:output][0].type}" } }
280
+ else
281
+ xml.span("class" => "pre") { xml.a("href" => "##{formats[:output][0].type}") { |xml| xml.span("class" => "lightBlue") { |y| y<<"#{formats[:output][0].type}" } } }
282
+ end
283
+ else
284
+ xml.span("class" => "pre") { |sp| sp << "void" }
285
+ end
286
+
287
+ }
288
+ }
289
+ unless formats[:raises].blank?
290
+ faults = formats[:raises]
291
+ faults = [formats[:raises]] if !faults.is_a?(Array)
292
+
293
+ xml.p "Exceptions:"
294
+ xml.ul {
295
+ faults.each do |p|
296
+ xml.li("class" => "pre"){ |y| y<< "<a href='##{p.to_s.classify}'><span class='lightBlue'> #{p.to_s.classify}</span></a>" }
297
+ end
298
+ }
299
+ end
300
+ end
301
+
302
+ end
@@ -0,0 +1,51 @@
1
+ xml.instruct!
2
+ xml.declare! :DOCTYPE, :html, :PUBLIC, "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
3
+
4
+ xml.html( "xmlns" => "http://www.w3.org/1999/xhtml" ) {
5
+
6
+ xml.head {
7
+
8
+ xml.title "Available Services"
9
+
10
+ xml.style( "type"=>"text/css" ,"media" => "all" ) { xml.text! "
11
+ body{font-family:Calibri,Arial;background-color:#fefefe;}
12
+ .pre{font-family:Courier;}
13
+ .normal{font-family:Calibri,Arial;}
14
+ .bold{font-weight:bold;}
15
+ h1,h2,h3{font-family:Verdana,Times;}
16
+ h1{border-bottom:1px solid gray;}
17
+ h2{border-bottom:1px solid silver;}
18
+ h3{border-bottom:1px dashed silver;}
19
+ a{text-decoration:none;}
20
+ a:hover{text-decoration:underline;}
21
+ .blue{color:#3400FF;}
22
+ .lightBlue{color:#5491AF;}
23
+ "
24
+
25
+ }
26
+
27
+ xml.style( "type"=>"text/css", "media" => "print" ) { xml.text! "
28
+ .noprint{display:none;}
29
+ "
30
+
31
+ }
32
+
33
+
34
+ }
35
+
36
+
37
+ xml.body {
38
+ unless @services.blank?
39
+
40
+ @services.each do |service|
41
+ xml.h1 "#{service[:service_name]} Soap Webservice"
42
+ xml.p {|pre| pre << "Documentation URI: &nbsp;<a href='#{service[:documentation_url]}'><span class='pre'>#{service[:documentation_url]}</span></a>" }
43
+ xml.p {|pre| pre << "Endpoint URI: &nbsp;<span class='pre'>#{service[:endpoint]}</span>" }
44
+ xml.p {|pre| pre << "WSDL URI: &nbsp;<a href='#{service[:namespace]}'><span class='pre'>#{service[:namespace]}</span></a>" }
45
+ end
46
+ end
47
+
48
+ }
49
+
50
+
51
+ }
@@ -0,0 +1,118 @@
1
+ xml.instruct!
2
+ xml.declare! :DOCTYPE, :html, :PUBLIC, "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
3
+
4
+ xml.html( "xmlns" => "http://www.w3.org/1999/xhtml" ) {
5
+
6
+ xml.head {
7
+
8
+ xml.title "#{@service} interface description"
9
+
10
+ xml.style( "type"=>"text/css" ,"media" => "all" ) { xml.text! "
11
+ body{font-family:Calibri,Arial;background-color:#fefefe;}
12
+ .pre{font-family:Courier;}
13
+ .normal{font-family:Calibri,Arial;}
14
+ .bold{font-weight:bold;}
15
+ h1,h2,h3{font-family:Verdana,Times;}
16
+ h1{border-bottom:1px solid gray;}
17
+ h2{border-bottom:1px solid silver;}
18
+ h3{border-bottom:1px dashed silver;}
19
+ a{text-decoration:none;}
20
+ a:hover{text-decoration:underline;}
21
+ .blue{color:#3400FF;}
22
+ .lightBlue{color:#5491AF;}
23
+ "
24
+
25
+ }
26
+
27
+ xml.style( "type"=>"text/css", "media" => "print" ) { xml.text! "
28
+ .noprint{display:none;}
29
+ "
30
+
31
+ }
32
+
33
+
34
+ }
35
+
36
+ xml.body {
37
+
38
+
39
+ xml.h1 "#{ @service} Soap WebService interface description"
40
+
41
+ xml.p{ |y| y << "Endpoint URI:";
42
+ xml.span( "class" => "pre") { |y| y << "#{@endpoint}"};
43
+ }
44
+
45
+ xml.p{ |y| y << "WSDL URI:";
46
+ xml.span( "class" => "pre") {
47
+ xml.a( "href" => "#{@namespace}") { |y| y << "#{@namespace}" }
48
+ };}
49
+
50
+ unless @service_description.blank?
51
+ xml.h1 "#{@service}"
52
+ xml.p "#{@service_description}"
53
+ end
54
+
55
+ xml.div("class" => "noprint") {
56
+
57
+ xml.h2 "Index "
58
+ xml.p "Complex Types: "
59
+ @complex_types = get_complex_types(@map)
60
+ xml.ul do
61
+ @complex_types.each do |hash|
62
+ xml.li { |y| y << "<a href='##{hash[:class]}'><span class='pre'>#{hash[:class]}</span></a>" }
63
+ end
64
+ end
65
+
66
+
67
+ @fault_types = get_fault_types_names(@map)
68
+ unless @fault_types.blank?
69
+ xml.p "Fault Types: "
70
+
71
+ xml.ul do
72
+ @fault_types.each do |name|
73
+ xml.li { |y| y << "<a href='##{name}'><span class='pre'>#{name}</span></a>" }
74
+ end
75
+ end
76
+ end
77
+
78
+
79
+ methods = get_soap_action_names(@map)
80
+ unless methods.blank?
81
+ xml.p "Public Methods:"
82
+
83
+ xml.ul do
84
+ methods.each do |name|
85
+ xml.li { |y| y << "<a href='##{name}'><span class='pre'>#{name}</span></a>" }
86
+ end
87
+ end
88
+ end
89
+
90
+
91
+
92
+ }
93
+
94
+
95
+ xml.h2 "Complex types:"
96
+
97
+ create_html_complex_types(xml, @complex_types)
98
+
99
+
100
+
101
+ unless @fault_types.blank?
102
+ create_html_complex_type_validation_errors(xml)
103
+ xml.h2 "Fault types:"
104
+ create_html_fault_types_details(xml, @map)
105
+ end
106
+
107
+
108
+
109
+ xml.h2 "Public methods:"
110
+ create_html_public_methods(xml, @map)
111
+
112
+
113
+
114
+
115
+
116
+ }
117
+
118
+ }
@@ -0,0 +1,10 @@
1
+ xml.instruct!
2
+ xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envelope/' do
3
+ xml.tag! "soap:Body" do
4
+ xml.tag! "soap:Fault" do
5
+ xml.faultcode error_faultcode
6
+ xml.faultstring error_message
7
+ xml.errors errors
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
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 error_faultcode
7
+ xml.faultstring error_message
8
+ xml.errors errors
9
+ end
10
+ end
11
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'washout_builder'
@@ -0,0 +1,54 @@
1
+ require 'wash_out'
2
+
3
+ require 'washout_builder/soap'
4
+ require 'washout_builder/param'
5
+ require 'washout_builder/engine'
6
+ require 'washout_builder/dispatcher'
7
+ require 'washout_builder/type'
8
+
9
+
10
+ module ActionDispatch::Routing
11
+ class Mapper
12
+
13
+ alias_method :original_wash_out,:wash_out
14
+
15
+ # Adds the routes for a SOAP endpoint at +controller+.
16
+ def wash_out(controller_name, options={})
17
+ options.reverse_merge!(@scope) if @scope
18
+
19
+ match "#{controller_name}/doc" => "#{controller_name}#_generate_doc", :via => :get, :format => false
20
+ original_wash_out(controller_name, options)
21
+
22
+
23
+ end
24
+ end
25
+ end
26
+
27
+
28
+
29
+
30
+ Mime::Type.register "application/soap+xml", :soap
31
+ ActiveRecord::Base.send :extend, WashOut::Model if defined?(ActiveRecord)
32
+
33
+ WashOut::SOAP::ClassMethods.class_eval do
34
+ alias_method :original_soap_action, :soap_action
35
+ end
36
+
37
+ ActionController::Renderers.add :soap do |what, options|
38
+ _render_soap(what, options)
39
+ end
40
+
41
+ ActionController::Base.class_eval do
42
+
43
+ # Define a SOAP service. The function has no required +options+:
44
+ # but allow any of :parser, :namespace, :wsdl_style, :snakecase_input,
45
+ # :camelize_wsdl, :wsse_username, :wsse_password and :catch_xml_errors.
46
+ #
47
+ # Any of the the params provided allows for overriding the defaults
48
+ # (like supporting multiple namespaces instead of application wide such)
49
+ #
50
+ def self.soap_service(options={})
51
+ include WashoutBuilder::SOAP
52
+ self.soap_config = options
53
+ end
54
+ end
@@ -0,0 +1,44 @@
1
+ require 'nori'
2
+
3
+ module WashoutBuilder
4
+ # The WashoutBuilder::Dispatcher module should be included in a controller acting
5
+ # as a SOAP endpoint. It includes actions for generating WSDL and handling
6
+ # SOAP requests.
7
+ module Dispatcher
8
+ extend WashOut::Dispatcher
9
+
10
+ def _generate_doc
11
+ @map = self.class.soap_actions
12
+ @namespace = soap_config.namespace
13
+ @name = controller_path.gsub('/', '_')
14
+ @service = self.class.name.underscore.gsub("_controller", "").camelize
15
+ @endpoint = @namespace.gsub("/wsdl", "/action")
16
+
17
+ render :template => "wash_with_html/doc", :layout => false,
18
+ :content_type => 'text/html'
19
+ end
20
+
21
+ def self.included(controller)
22
+ controller.send :rescue_from, WashOut::Dispatcher::SOAPError, :with => :_render_soap_exception
23
+ controller.send :helper, :wash_out, :washout_builder
24
+ controller.send :before_filter, :_parse_soap_parameters, :except => [
25
+ :_generate_wsdl, :_generate_doc, :_invalid_action ]
26
+ controller.send :before_filter, :_authenticate_wsse, :except => [
27
+ :_generate_wsdl,:_generate_doc,:_invalid_action ]
28
+ controller.send :before_filter, :_map_soap_parameters, :except => [
29
+ :_generate_wsdl, :_generate_doc,:_invalid_action ]
30
+ controller.send :skip_before_filter, :verify_authenticity_token
31
+ controller.send :around_filter, :_catch_soap_faults
32
+ end
33
+
34
+ def _catch_soap_faults
35
+ yield
36
+ rescue => exception
37
+ if exception.class <= WashOut::Dispatcher::SOAPError
38
+ _render_soap_fault_exception(exception)
39
+ else
40
+ raise exception
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,13 @@
1
+ module WashoutBuilder
2
+ class Engine < ::Rails::Engine
3
+ config.wash_out = ActiveSupport::OrderedOptions.new
4
+ initializer "wash_out.configuration" do |app|
5
+ app.routes.append do
6
+ match "/washout" => "washout_builder#all", :via => :get, :format => false
7
+ end
8
+ if app.config.wash_out[:catch_xml_errors]
9
+ app.config.middleware.insert_after 'ActionDispatch::ShowExceptions', WashOut::Middleware
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,51 @@
1
+ module WashoutBuilder
2
+ class Param < WashOut::Param
3
+
4
+ attr_accessor :source_class_name
5
+
6
+ def initialize(soap_config, name, type, class_name, multiplied = false)
7
+ @source_class_name = class_name
8
+ super(soap_config, name, type, multiplied )
9
+ end
10
+
11
+ def self.parse_def(soap_config, definition)
12
+ raise RuntimeError, "[] should not be used in your params. Use nil if you want to mark empty set." if definition == []
13
+ return [] if definition == nil
14
+
15
+ definition_class_name = nil
16
+ if definition.is_a?(Class) && definition.ancestors.include?(WashOut::Type)
17
+ definition_class_name = definition.to_s.classify
18
+ definition = definition.wash_out_param_map
19
+ end
20
+
21
+ if [Array, Symbol].include?(definition.class)
22
+ definition = { :value => definition }
23
+ end
24
+
25
+ if definition.is_a? Hash
26
+ definition.map do |name, opt|
27
+ if opt.is_a? WashoutBuilder::Param
28
+ opt
29
+ elsif opt.is_a? Array
30
+ WashoutBuilder::Param.new(soap_config, name, opt[0],definition_class_name, true)
31
+ else
32
+ WashoutBuilder::Param.new(soap_config, name, opt, definition_class_name)
33
+ end
34
+ end
35
+ else
36
+ raise RuntimeError, "Wrong definition: #{definition.inspect}"
37
+ end
38
+ end
39
+
40
+ def basic_type
41
+ return source_class_name unless source_class_name.nil?
42
+ super
43
+ end
44
+
45
+ def is_complex?
46
+ !source_class_name.nil? || (struct? && classified? ) || struct?
47
+ end
48
+
49
+
50
+ end
51
+ end
@@ -0,0 +1,35 @@
1
+ require 'active_support/concern'
2
+
3
+ module WashoutBuilder
4
+ module SOAP
5
+ extend ActiveSupport::Concern
6
+ include WashOut::SOAP
7
+
8
+
9
+ module ClassMethods
10
+
11
+ # Define a SOAP action +action+. The function has two required +options+:
12
+ # :args and :return. Each is a type +definition+ of format described in
13
+ # WashOut::Param#parse_def.
14
+ #
15
+ # An optional option :to can be passed to allow for names of SOAP actions
16
+ # which are not valid Ruby function names.
17
+ def soap_action(action, options={})
18
+ original_soap_action(action, options)
19
+
20
+ current_action = self.soap_actions[action]
21
+
22
+ current_action[:input] = WashoutBuilder::Param.parse_def(soap_config, options[:args])
23
+ current_action[:output] = WashoutBuilder::Param.parse_def(soap_config, options[:return])
24
+
25
+ end
26
+ end
27
+
28
+
29
+ included do
30
+ include WashOut::Configurable
31
+ include WashoutBuilder::Dispatcher
32
+ self.soap_actions = {}
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ module WashoutBuilder
2
+ class Type < WashOut::Type
3
+
4
+
5
+ BASIC_TYPES=[
6
+ "string",
7
+ "integer",
8
+ "double",
9
+ "boolean",
10
+ "date",
11
+ "datetime",
12
+ "float",
13
+ "time"
14
+ ]
15
+
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module WashoutBuilder
2
+ VERSION = "0.3.5"
3
+ end
@@ -0,0 +1,68 @@
1
+ # Configure Rails Envinronment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require "simplecov"
5
+ SimpleCov.start do
6
+ add_filter 'spec'
7
+ add_group 'Library', 'lib'
8
+ add_group 'App', 'app'
9
+
10
+ at_exit do; end
11
+ end
12
+
13
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
14
+ require "rails/test_help"
15
+ require "rspec/rails"
16
+ require "pry"
17
+ require "savon"
18
+
19
+ Rails.backtrace_cleaner.remove_silencers!
20
+
21
+ # Load support files
22
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
23
+
24
+ RSpec.configure do |config|
25
+ require 'rspec/expectations'
26
+ config.include RSpec::Matchers
27
+
28
+ config.mock_with :rspec
29
+ config.before(:all) do
30
+ WashOut::Engine.config.wash_out = {
31
+ snakecase_input: false,
32
+ camelize_wsdl: false,
33
+ namespace: false
34
+ }
35
+ end
36
+
37
+ config.after(:suite) do
38
+ if SimpleCov.running
39
+ silence_stream(STDOUT) do
40
+ SimpleCov::Formatter::HTMLFormatter.new.format(SimpleCov.result)
41
+ end
42
+
43
+ SimpleCov::Formatter::SummaryFormatter.new.format(SimpleCov.result)
44
+ end
45
+ end
46
+ end
47
+
48
+ HTTPI.logger = Logger.new(open("/dev/null", 'w'))
49
+ HTTPI.adapter = :rack
50
+
51
+ HTTPI::Adapter::Rack.mount 'app', Dummy::Application
52
+ Dummy::Application.routes.draw do
53
+ wash_out :api
54
+ end
55
+
56
+ def mock_controller(options = {}, &block)
57
+ Object.send :remove_const, :ApiController if defined?(ApiController)
58
+ Object.send :const_set, :ApiController, Class.new(ApplicationController) {
59
+ soap_service options.reverse_merge({
60
+ snakecase_input: true,
61
+ camelize_wsdl: true,
62
+ namespace: false
63
+ })
64
+ class_exec &block if block
65
+ }
66
+
67
+ ActiveSupport::Dependencies::Reference.instance_variable_get(:'@store').delete('ApiController')
68
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path("../lib/washout_builder/version", __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "washout_builder"
5
+ s.version = WashoutBuilder::VERSION
6
+ s.platform = Gem::Platform::RUBY
7
+ s.summary = "WashOut Soap Service Documentation builder (extends WashOut https://github.com/inossidabile/wash_out/)"
8
+ s.email = "raoul_ice@yahoo.com"
9
+ s.homepage = "http://github.com/bogdanRada/washout_builder/"
10
+ s.description = "WashOut Soap Service Documentation builder (extends WashOut https://github.com/inossidabile/wash_out/) "
11
+ s.authors = ["bogdanRada"]
12
+ s.date = "2013-11-20"
13
+
14
+ s.licenses = ["MIT"]
15
+ s.files = `git ls-files`.split("\n")
16
+ s.require_paths = ["lib"]
17
+ s.add_dependency("nori", ">= 2.0.0")
18
+ s.add_dependency("wash_out", "= 0.9.1")
19
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: washout_builder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.5
5
+ platform: ruby
6
+ authors:
7
+ - bogdanRada
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nori
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: wash_out
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.1
41
+ description: ! 'WashOut Soap Service Documentation builder (extends WashOut https://github.com/inossidabile/wash_out/) '
42
+ email: raoul_ice@yahoo.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - .gitignore
48
+ - .rspec
49
+ - .travis.yml
50
+ - Appraisals
51
+ - Gemfile
52
+ - Guardfile
53
+ - LICENSE
54
+ - README.rdoc
55
+ - Rakefile
56
+ - app/controllers/washout_builder_controller.rb
57
+ - app/helpers/washout_builder_helper.rb
58
+ - app/views/wash_with_html/all_services.builder
59
+ - app/views/wash_with_html/doc.builder
60
+ - app/views/wash_with_soap/document/custom_error.builder
61
+ - app/views/wash_with_soap/rpc/custom_error.builder
62
+ - init.rb
63
+ - lib/washout_builder.rb
64
+ - lib/washout_builder/dispatcher.rb
65
+ - lib/washout_builder/engine.rb
66
+ - lib/washout_builder/param.rb
67
+ - lib/washout_builder/soap.rb
68
+ - lib/washout_builder/type.rb
69
+ - lib/washout_builder/version.rb
70
+ - spec/spec_helper.rb
71
+ - washout_builder.gemspec
72
+ homepage: http://github.com/bogdanRada/washout_builder/
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.7
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: WashOut Soap Service Documentation builder (extends WashOut https://github.com/inossidabile/wash_out/)
96
+ test_files: []