washout_builder 0.12.4 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +0 -1
- data/README.rdoc +1 -42
- data/app/helpers/washout_builder_helper.rb +1 -1
- data/lib/washout_builder/document/{virtus_model.rb → exception_model.rb} +37 -12
- data/lib/washout_builder/document/generator.rb +2 -2
- data/lib/washout_builder/version.rb +1 -1
- data/lib/washout_builder.rb +2 -19
- data/spec/lib/washout_builder/document/{virtus_model_spec.rb → exception_model_spec.rb} +3 -3
- data/spec/lib/washout_builder/document/generator_spec.rb +10 -28
- data/spec/lib/washout_builder_spec.rb +0 -3
- data/washout_builder.gemspec +0 -1
- metadata +4 -38
- data/spec/support/exceptions/another_exception.rb +0 -7
- data/spec/support/exceptions/base_exception.rb +0 -15
- data/spec/support/exceptions/custom2.rb +0 -7
- data/spec/support/exceptions/ex_model.rb +0 -8
- data/spec/support/exceptions/name_mod.rb +0 -5
- data/spec/support/exceptions/name_model.rb +0 -5
- data/spec/support/exceptions/value_object_model.rb +0 -8
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDQ2OGJiMzYxM2FkYWM5ZjZlNWViOWU1MjA3NWZiNGFlNDUyYjAyNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDlhOTM3MGFmNTEwZjk1YTM3NTlkYzM5MDE1ODBmMjlhMTcyYTU0OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGVhM2QzYTVmNzMyMjM4ZGJkN2RjY2EyNmQ4YzViMTZhYTBiNDUxOWQ3MzE2
|
10
|
+
ZGQ1Zjc1ZmIzNWU1NjFhOGRmZDIyOTIzNDQ2N2YxYzgwOTRmMjU1ZWFlOWEz
|
11
|
+
MjlkMDBkY2UzMzUzNmU5OTE3ZDQwMzRlMmE2YTZkMmMwNGMwZTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjhkZDU3YTAyNmE2MDFkMWUzODk2NzJlMmJmZWI0NmZhZjI5YTU1YjRhNzc3
|
14
|
+
OWZiMWVlNzAyMWEyNWI2MzY4NWNhYTdlNjdhNTRlNWM4YjkwYTI4NGE3YTNh
|
15
|
+
ZDY4ZDQ1ZjkxNTIwM2JhNTJlMjI4NmZmNDRhZmRlNjhhMGE0ODA=
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -25,7 +25,6 @@ The way WashOut is used is not modified, it just extends its functionality by ge
|
|
25
25
|
1. {Ruby 1.9.x or Ruby 2.0.x}[http://www.ruby-lang.org]
|
26
26
|
2. {Ruby on Rails}[http://rubyonrails.org].
|
27
27
|
3. {WashOut Gem version >= 0.9.1}[https://github.com/inossidabile/wash_out]
|
28
|
-
4. {Virtus Gem}[https://github.com/solnic/virtus]
|
29
28
|
|
30
29
|
= Compatibility
|
31
30
|
|
@@ -105,47 +104,7 @@ Here is an example :
|
|
105
104
|
:description => "some description about this method to show in the documentation"
|
106
105
|
|
107
106
|
|
108
|
-
The exception classes used <b>must inherit</b> from <tt>WashOut::Dispatcher::SOAPError</tt>, which has by default a error code and a message as attributes
|
109
|
-
|
110
|
-
The WashOut::SoapError now includes Virtus.model from +virtus+ gem. This way you can add attributes like this:
|
111
|
-
|
112
|
-
class MyCustomSoapError < WashOut::Dispatcher::SOAPError
|
113
|
-
|
114
|
-
attribute :custom_attribute, String
|
115
|
-
attribute :other_custom_attribute, Integer
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
You can also specify complex types like this:
|
120
|
-
|
121
|
-
class MyCustomSoapError < WashOut::Dispatcher::SOAPError
|
122
|
-
|
123
|
-
attribute :errors,Array[Integer]
|
124
|
-
attribute :custom, Array[MyCustomModel]
|
125
|
-
attribute :custom2, MyCustomModel
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
<b>The class MyCustomModel must include +Virtus.model+ or +Virtus.value_object+ or it must include at least one module that includes +Virtus.module+ if you want it to show up in the documentation!
|
130
|
-
Please checkout {Virtus Gem}[https://github.com/solnic/virtus] for further documentation!</b>
|
131
|
-
|
132
|
-
You can also use aggregation with another fault class exception like this:
|
133
|
-
|
134
|
-
class MyCustomSoapError < WashOut::Dispatcher::SOAPError
|
135
|
-
|
136
|
-
attribute :errors, Array[MyOtherCustomSoapError]
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
And you can also use inheritance between custom exception classes like this:
|
141
|
-
|
142
|
-
class MySecondCustomSoapError < MyCustomSoapError
|
143
|
-
|
144
|
-
atribute :option , String
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
And you will see in the documentation that the class +MySecondCustomSoapError+ will extend +MyCustomSoapError+
|
107
|
+
The exception classes used <b>must inherit</b> from <tt>WashOut::Dispatcher::SOAPError</tt>, which has by default a error code and a message as attributes .
|
149
108
|
|
150
109
|
= Testing
|
151
110
|
|
@@ -194,7 +194,6 @@ module WashoutBuilderHelper
|
|
194
194
|
end
|
195
195
|
|
196
196
|
def create_html_public_method_arguments(xml, pre, operation, formats)
|
197
|
-
xml.span("class" => "bold") {|y| y << "#{operation} (" }
|
198
197
|
mlen = formats[:builder_in].size
|
199
198
|
xml.br if mlen > 1
|
200
199
|
spacer = " "
|
@@ -234,6 +233,7 @@ module WashoutBuilderHelper
|
|
234
233
|
|
235
234
|
xml.p("class" => "pre"){ |pre|
|
236
235
|
create_html_public_method_return_type(xml,pre, formats)
|
236
|
+
xml.span("class" => "bold") {|y| y << "#{operation} (" }
|
237
237
|
create_html_public_method_arguments(xml, pre, operation, formats)
|
238
238
|
}
|
239
239
|
xml.p "#{formats[:description]}" if !formats[:description].blank?
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module WashoutBuilder
|
2
2
|
module Document
|
3
|
-
module
|
3
|
+
module ExceptionModel
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
include WashoutBuilder::Document::SharedComplexType
|
6
6
|
|
@@ -56,22 +56,47 @@ module WashoutBuilder
|
|
56
56
|
complex_class
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
|
60
|
+
def get_exception_attributes
|
61
|
+
attrs = self.instance_methods.find_all do |method|
|
62
|
+
method != :== &&
|
63
|
+
method != :! &&
|
64
|
+
self.instance_methods.include?(:"#{method}=")
|
65
|
+
end
|
66
|
+
attrs.concat(["message", "backtrace"])
|
67
|
+
end
|
68
|
+
|
69
|
+
|
60
70
|
def get_virtus_model_structure
|
61
|
-
|
71
|
+
h = {}
|
72
|
+
get_exception_attributes.each do |method_name|
|
73
|
+
primitive_type = case method_name.to_s.downcase
|
74
|
+
when "code"
|
75
|
+
"integer"
|
76
|
+
when "message", "backtrace"
|
77
|
+
"string"
|
78
|
+
else
|
79
|
+
"string"
|
80
|
+
end
|
81
|
+
h["#{method_name}"]= {
|
82
|
+
:primitive => "#{primitive_type}",
|
83
|
+
:member_type => nil
|
84
|
+
}
|
85
|
+
end
|
86
|
+
return h
|
62
87
|
end
|
63
88
|
|
64
89
|
|
65
90
|
def self.extract_nested_complex_types(complex_class, complex_types)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
91
|
+
unless complex_class.nil?
|
92
|
+
param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
|
93
|
+
if param_class.present? && WashoutBuilder::Type.valid_fault_class?(param_class)
|
94
|
+
param_class.send :extend, WashoutBuilder::Document::ExceptionModel
|
95
|
+
param_class.get_fault_class_ancestors( complex_types)
|
96
|
+
elsif param_class.present? && !WashoutBuilder::Type.valid_fault_class?(param_class)
|
97
|
+
raise RuntimeError, "Non-existent use of `#{param_class}` type name or this class does not inherit from SoapError. Consider using classified types that include SoapError for exception classes."
|
98
|
+
end
|
99
|
+
end
|
75
100
|
end
|
76
101
|
|
77
102
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative "./
|
1
|
+
require_relative "./exception_model"
|
2
2
|
module WashoutBuilder
|
3
3
|
module Document
|
4
4
|
class Generator
|
@@ -117,7 +117,7 @@ module WashoutBuilder
|
|
117
117
|
fault_types.each do |hash|
|
118
118
|
hash[:structure].each do |attribute, attr_details|
|
119
119
|
complex_class = hash[:fault].get_virtus_member_type_primitive(attr_details)
|
120
|
-
WashoutBuilder::Document::
|
120
|
+
WashoutBuilder::Document::ExceptionModel.extract_nested_complex_types(complex_class, complex_types)
|
121
121
|
end
|
122
122
|
end
|
123
123
|
complex_types
|
data/lib/washout_builder.rb
CHANGED
@@ -1,37 +1,20 @@
|
|
1
1
|
require 'wash_out'
|
2
|
-
require 'virtus'
|
3
2
|
require 'washout_builder/soap'
|
4
3
|
require 'washout_builder/engine'
|
5
4
|
require 'washout_builder/document/shared_complex_type'
|
6
5
|
require 'washout_builder/document/complex_type'
|
7
|
-
require 'washout_builder/document/
|
6
|
+
require 'washout_builder/document/exception_model'
|
8
7
|
require 'washout_builder/document/generator'
|
9
8
|
require 'washout_builder/type'
|
10
9
|
require 'washout_builder/version'
|
11
10
|
|
12
11
|
|
13
|
-
|
14
|
-
Virtus::InstanceMethods::Constructor.class_eval do
|
15
|
-
alias_method :original_initialize,:initialize
|
16
|
-
def initialize(attributes = nil)
|
17
|
-
if WashoutBuilder::Type.valid_fault_class?(self.class)
|
18
|
-
attributes = {:message => attributes} unless attributes.is_a?(Hash)
|
19
|
-
end
|
20
|
-
original_initialize(attributes)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
12
|
WashOut::Param.send :include, WashoutBuilder::Document::ComplexType
|
26
13
|
|
27
14
|
|
28
15
|
WashoutBuilder::Type.get_fault_classes.each do |exception_class|
|
29
16
|
exception_class.class_eval do
|
30
|
-
extend WashoutBuilder::Document::
|
31
|
-
include Virtus.model
|
32
|
-
attribute :code, Integer
|
33
|
-
attribute :message, String
|
34
|
-
attribute :backtrace, String
|
17
|
+
extend WashoutBuilder::Document::ExceptionModel
|
35
18
|
end
|
36
19
|
end
|
37
20
|
|
@@ -5,14 +5,14 @@ class SOAPError < WashOut::Dispatcher::SOAPError
|
|
5
5
|
|
6
6
|
end
|
7
7
|
|
8
|
-
describe WashoutBuilder::Document::
|
8
|
+
describe WashoutBuilder::Document::ExceptionModel do
|
9
9
|
|
10
10
|
let(:subject) { SOAPError}
|
11
11
|
|
12
12
|
|
13
13
|
|
14
14
|
it "gets the strcuture" do
|
15
|
-
subject.get_virtus_model_structure.should eq({"code"=>{:primitive=>"
|
15
|
+
subject.get_virtus_model_structure.should eq({"code"=>{:primitive=>"integer", :member_type=>nil}, "message"=>{:primitive=>"string", :member_type=>nil}, "backtrace"=>{:primitive=>"string", :member_type=>nil}})
|
16
16
|
end
|
17
17
|
|
18
18
|
it "gets the member type for arrays" do
|
@@ -29,7 +29,7 @@ describe WashoutBuilder::Document::VirtusModel do
|
|
29
29
|
|
30
30
|
|
31
31
|
it "gets the strcuture" do
|
32
|
-
subject.remove_fault_type_inheritable_elements(["code"]).should eq({ "message"=>{:primitive=>"
|
32
|
+
subject.remove_fault_type_inheritable_elements(["code"]).should eq({ "message"=>{:primitive=>"string", :member_type=>nil}, "backtrace"=>{:primitive=>"string", :member_type=>nil}})
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
#encoding:utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
mock_controller do
|
4
|
-
|
4
|
+
soap_service namespace: "/api/wsdl", description: "some description"
|
5
|
+
|
6
|
+
soap_action 'dispatcher_method', :args => nil, :return => nil
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def dispatcher_method
|
9
|
+
#nothing
|
10
|
+
end
|
11
|
+
end
|
10
12
|
|
11
13
|
describe WashoutBuilder::Document::Generator do
|
12
14
|
|
@@ -22,32 +24,12 @@ describe WashoutBuilder::Document::Generator do
|
|
22
24
|
}
|
23
25
|
}
|
24
26
|
let(:service_class) { ApiController }
|
25
|
-
let(:attributes) {
|
26
|
-
{
|
27
|
-
:config => soap_config,
|
28
|
-
:service_class => service_class,
|
29
|
-
:soap_actions => soap_actions
|
30
|
-
}}
|
31
|
-
|
32
27
|
before(:each) do
|
33
|
-
@document = WashoutBuilder::Document::Generator.new(
|
34
|
-
|
35
|
-
|
36
|
-
context "initialize" do
|
37
|
-
|
38
|
-
it "sets the config " do
|
39
|
-
@document.config.should eq(soap_config)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "sets the service_class " do
|
43
|
-
@document.service_class.should eq(service_class)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets the soap_actions " do
|
47
|
-
@document.soap_actions.should eq(soap_actions)
|
48
|
-
end
|
28
|
+
@document = WashoutBuilder::Document::Generator.new("api")
|
29
|
+
@document.stubs(:controller_class).returns(service_class)
|
49
30
|
|
50
31
|
end
|
32
|
+
|
51
33
|
|
52
34
|
|
53
35
|
context "namespace" do
|
data/washout_builder.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: washout_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
@@ -30,26 +30,6 @@ dependencies:
|
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.9.1
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: virtus
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ~>
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.0'
|
40
|
-
- - ! '>='
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 1.0.0
|
43
|
-
type: :runtime
|
44
|
-
prerelease: false
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - ~>
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '1.0'
|
50
|
-
- - ! '>='
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 1.0.0
|
53
33
|
description: ! 'WashOut Soap Service HTML-Documentation generator (extends WashOut
|
54
34
|
https://github.com/inossidabile/wash_out/) '
|
55
35
|
email: raoul_ice@yahoo.com
|
@@ -75,9 +55,9 @@ files:
|
|
75
55
|
- init.rb
|
76
56
|
- lib/washout_builder.rb
|
77
57
|
- lib/washout_builder/document/complex_type.rb
|
58
|
+
- lib/washout_builder/document/exception_model.rb
|
78
59
|
- lib/washout_builder/document/generator.rb
|
79
60
|
- lib/washout_builder/document/shared_complex_type.rb
|
80
|
-
- lib/washout_builder/document/virtus_model.rb
|
81
61
|
- lib/washout_builder/engine.rb
|
82
62
|
- lib/washout_builder/soap.rb
|
83
63
|
- lib/washout_builder/type.rb
|
@@ -110,8 +90,8 @@ files:
|
|
110
90
|
- spec/dummy/public/stylesheets/.gitkeep
|
111
91
|
- spec/dummy/script/rails
|
112
92
|
- spec/lib/washout_builder/document/complex_type_spec.rb
|
93
|
+
- spec/lib/washout_builder/document/exception_model_spec.rb
|
113
94
|
- spec/lib/washout_builder/document/generator_spec.rb
|
114
|
-
- spec/lib/washout_builder/document/virtus_model_spec.rb
|
115
95
|
- spec/lib/washout_builder/type_spec.rb
|
116
96
|
- spec/lib/washout_builder_spec.rb
|
117
97
|
- spec/spec_helper.rb
|
@@ -119,13 +99,6 @@ files:
|
|
119
99
|
- spec/support/complex_types/fluffy_container.rb
|
120
100
|
- spec/support/complex_types/project_type.rb
|
121
101
|
- spec/support/complex_types/test_type.rb
|
122
|
-
- spec/support/exceptions/another_exception.rb
|
123
|
-
- spec/support/exceptions/base_exception.rb
|
124
|
-
- spec/support/exceptions/custom2.rb
|
125
|
-
- spec/support/exceptions/ex_model.rb
|
126
|
-
- spec/support/exceptions/name_mod.rb
|
127
|
-
- spec/support/exceptions/name_model.rb
|
128
|
-
- spec/support/exceptions/value_object_model.rb
|
129
102
|
- washout_builder.gemspec
|
130
103
|
homepage: http://github.com/bogdanRada/washout_builder/
|
131
104
|
licenses:
|
@@ -180,8 +153,8 @@ test_files:
|
|
180
153
|
- spec/dummy/public/stylesheets/.gitkeep
|
181
154
|
- spec/dummy/script/rails
|
182
155
|
- spec/lib/washout_builder/document/complex_type_spec.rb
|
156
|
+
- spec/lib/washout_builder/document/exception_model_spec.rb
|
183
157
|
- spec/lib/washout_builder/document/generator_spec.rb
|
184
|
-
- spec/lib/washout_builder/document/virtus_model_spec.rb
|
185
158
|
- spec/lib/washout_builder/type_spec.rb
|
186
159
|
- spec/lib/washout_builder_spec.rb
|
187
160
|
- spec/spec_helper.rb
|
@@ -189,10 +162,3 @@ test_files:
|
|
189
162
|
- spec/support/complex_types/fluffy_container.rb
|
190
163
|
- spec/support/complex_types/project_type.rb
|
191
164
|
- spec/support/complex_types/test_type.rb
|
192
|
-
- spec/support/exceptions/another_exception.rb
|
193
|
-
- spec/support/exceptions/base_exception.rb
|
194
|
-
- spec/support/exceptions/custom2.rb
|
195
|
-
- spec/support/exceptions/ex_model.rb
|
196
|
-
- spec/support/exceptions/name_mod.rb
|
197
|
-
- spec/support/exceptions/name_model.rb
|
198
|
-
- spec/support/exceptions/value_object_model.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Dir["#{File.dirname(__FILE__)}/**/*.rb"].each { |f| require f }
|
2
|
-
class BaseException < AnotherException
|
3
|
-
|
4
|
-
attribute :custom_attribute, String
|
5
|
-
attribute :other_custom_attribute, Integer
|
6
|
-
attribute :errors,Array[Integer]
|
7
|
-
attribute :custom, Array[ExModel]
|
8
|
-
attribute :custom2, ExModel
|
9
|
-
attribute :errors_2, Array[Custom2]
|
10
|
-
attribute :error, Custom2
|
11
|
-
attribute :module, NameModel
|
12
|
-
attribute :geo, ValueObjectModel
|
13
|
-
|
14
|
-
end
|
15
|
-
|