washout_builder 0.9.1 → 0.9.5
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.
- checksums.yaml +8 -8
- data/app/helpers/washout_builder_helper.rb +91 -30
- data/app/views/wash_with_html/doc.builder +13 -4
- data/lib/washout_builder/version.rb +1 -1
- data/lib/washout_builder.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjU0ZjQ2Mjc4MmQ5NjEwMGEwOWU3NzYxZjdmY2EwYjg0MGU5NGQzNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzljZDc0MjBkZGZhNmEyYzk2YTE3NTE4NTE3NWRmMGYyNzIyNjEyYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmNjNWRiODIxZGM3NmNmZmJhZjM3ZDZmMWMwYWM0MjQ3NWU5OGI0NDAyMDZi
|
10
|
+
ZWIzYWExNTQyOTY5NGI4OTNkZmVmMmM5OGVhZGFhMmExZmY0NmZmYWI5M2Nj
|
11
|
+
YmRjYmIyODc5Y2IwNjI3MmU4ODRhM2UyOWQ4MmFkM2VkMTA1MmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGMzY2YyOGQ1YjM1MTNhNzhkM2RiNGM1N2ZjODhhOTRjYmM0N2RiYzAxYTgw
|
14
|
+
OWNmNDM2NjkzYTUwMGM0OTMwYTA3YjNmMGE3ZDk5YmU1NmNlYjc0OWI1NWZm
|
15
|
+
OGI5NGUzYzJlYjY4ZDAyY2RhZjhmMDkxMzM5NTE1M2FkYTM0MDQ=
|
@@ -46,17 +46,17 @@ module WashoutBuilderHelper
|
|
46
46
|
bool_the_same = false
|
47
47
|
param_class = class_name.is_a?(Class) ? class_name : class_name.constantize rescue nil
|
48
48
|
unless param_class.nil?
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
ancestors = (param_class.ancestors - param_class.included_modules).delete_if{ |x| x.to_s.downcase == class_name.to_s.downcase || x.to_s == "ActiveRecord::Base" || x.to_s == "Object" || x.to_s =="BasicObject" || x.to_s == "WashOut::Type" }
|
50
|
+
unless ancestors.blank?
|
51
|
+
ancestor_structure = { ancestors[0].to_s.downcase => ancestors[0].columns_hash.inject({}) {|h, (k,v)| h["#{k}"]="#{v.type}".to_sym; h } }
|
52
|
+
ancestor_object = WashOut::Param.parse_def(@soap_config,ancestor_structure)[0]
|
53
|
+
bool_the_same = same_structure_as_ancestor?(param, ancestor_object)
|
54
|
+
unless bool_the_same
|
55
|
+
top_ancestors = get_class_ancestors(ancestor_class, defined)
|
56
|
+
defined << {:class =>ancestor_class.to_s, :obj =>ancestor_object , :ancestors => top_ancestors }
|
57
|
+
end
|
57
58
|
end
|
58
|
-
|
59
|
-
ancestors unless bool_the_same
|
59
|
+
ancestors unless bool_the_same
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -94,10 +94,62 @@ module WashoutBuilderHelper
|
|
94
94
|
defined.sort_by { |hash| hash[:class].downcase }.uniq unless defined.blank?
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
|
98
|
+
def remove_fault_type_inheritable_elements(param, keys)
|
99
|
+
get_virtus_model_structure(param).delete_if{|key,value| keys.include?(key) }
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
def get_fault_class_ancestors(fault, defined, debug = false)
|
107
|
+
bool_the_same = false
|
108
|
+
unless fault.nil?
|
109
|
+
ancestors = (fault.ancestors - fault.included_modules).delete_if{ |x| x.to_s.downcase == fault.to_s.downcase || x.to_s == "ActiveRecord::Base" || x.to_s == "Object" || x.to_s =="BasicObject" || x.to_s == "Exception" }
|
110
|
+
if ancestors.blank?
|
111
|
+
defined << {:fault => fault,:structure =>get_virtus_model_structure(fault) ,:ancestors => [] }
|
112
|
+
else
|
113
|
+
fault_structure = remove_fault_type_inheritable_elements(fault, get_virtus_model_structure(ancestors[0]).keys)
|
114
|
+
defined << {:fault => fault,:structure =>fault_structure ,:ancestors => ancestors }
|
115
|
+
get_fault_class_ancestors(ancestors[0], defined)
|
116
|
+
end
|
117
|
+
ancestors unless bool_the_same
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def get_virtus_model_structure(fault)
|
122
|
+
fault.attribute_set.inject({}) {|h, elem| h["#{elem.name}"]= { :primitive => "#{elem.primitive}", :options => elem.options }; h }
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def get_fault_types(map)
|
98
127
|
defined = map.select{|operation, formats| !formats[:raises].blank? }
|
99
128
|
defined = defined.collect {|operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten.select { |x| x.is_a?(Class) && x.ancestors.include?(WashOut::SOAPError) } unless defined.blank?
|
100
|
-
|
129
|
+
fault_types = []
|
130
|
+
defined << WashOut::SOAPError
|
131
|
+
defined.each{ |item| get_fault_class_ancestors(item, fault_types, true)} unless defined.blank?
|
132
|
+
fault_types = fault_types.sort_by { |hash| hash[:fault].to_s.downcase }.uniq unless fault_types.blank?
|
133
|
+
complex_types = []
|
134
|
+
fault_types.each do |hash|
|
135
|
+
hash[:structure].each do |attribute, attr_details|
|
136
|
+
if attr_details[:primitive].to_s.downcase == "array" && !WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:options][:member_type].primitive.to_s.downcase)
|
137
|
+
complex_class = attr_details[:options][:member_type].primitive
|
138
|
+
elsif attr_details[:primitive].to_s.downcase != "array" && !WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase)
|
139
|
+
complex_class = attr_details[:primitive]
|
140
|
+
end
|
141
|
+
|
142
|
+
param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
|
143
|
+
if !param_class.nil? && param_class.ancestors.include?(Virtus::Model::Core)
|
144
|
+
get_fault_class_ancestors(param_class, complex_types)
|
145
|
+
elsif !param_class.nil? && !param_class.ancestors.include?(Virtus::Model::Core)
|
146
|
+
raise RuntimeError, "Non-existent use of `#{param_class}` type name or this class does not use Virtus.model. Consider using classified types that include Virtus.mode for exception atribute types."
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
151
|
+
complex_types = complex_types.sort_by { |hash| hash[:fault].to_s.downcase }.uniq unless complex_types.blank?
|
152
|
+
[fault_types, complex_types]
|
101
153
|
end
|
102
154
|
|
103
155
|
def get_soap_action_names(map)
|
@@ -145,33 +197,42 @@ module WashoutBuilderHelper
|
|
145
197
|
end
|
146
198
|
end
|
147
199
|
|
148
|
-
def create_html_fault_types_details(xml,
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
200
|
+
def create_html_fault_types_details(xml, fault_types)
|
201
|
+
unless fault_types.blank?
|
202
|
+
|
203
|
+
fault_types.each { |hash|
|
204
|
+
create_html_virtus_model_type(xml, hash[:fault],hash[:structure], hash[:ancestors])
|
205
|
+
}
|
153
206
|
end
|
154
207
|
end
|
155
208
|
|
156
|
-
|
157
|
-
|
158
|
-
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
def create_html_virtus_model_type(xml, param, fault_structure, ancestors)
|
213
|
+
if param.is_a?(Class)
|
214
|
+
xml.h3 { |pre| pre << "#{param} #{ancestors.blank? ? "" : "<small>(extends <a href='##{ancestors[0].to_s.classify}'>#{ancestors[0].to_s.classify}</a>)</small>" } " }
|
159
215
|
xml.a("name" => "#{param}") {}
|
160
216
|
xml.ul("class" => "pre") {
|
161
|
-
|
217
|
+
|
162
218
|
|
163
|
-
fault_structure.each do |attribute,
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
219
|
+
fault_structure.each do |attribute, attr_details|
|
220
|
+
xml.li { |pre|
|
221
|
+
if WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase) || attr_details[:primitive] == "nilclass"
|
222
|
+
pre << "<span class='blue'>#{attr_details[:primitive].to_s.downcase == "nilclass" ? "string" : attr_details[:primitive].to_s.downcase }</span> <span class='bold'>#{attribute}</span>"
|
223
|
+
|
224
|
+
else
|
225
|
+
if attr_details[:primitive].to_s.downcase == "array"
|
226
|
+
attr_primitive = attr_details[:options][:member_type].primitive.to_s
|
227
|
+
|
228
|
+
attr_primitive = WashoutBuilder::Type::BASIC_TYPES.include?(attr_primitive.downcase) ? attr_primitive.downcase : attr_primitive
|
229
|
+
pre << "<a href='##{attr_primitive}'><span class='lightBlue'>Array of #{attr_primitive}</span></a> <span class='bold'>#{attribute}</span>"
|
168
230
|
else
|
169
|
-
pre << "<a href='##{
|
231
|
+
pre << "<a href='##{attr_details[:primitive] }'><span class='lightBlue'>#{attr_details[:primitive]}</span></a> <span class='bold'>#{attribute}</span>"
|
170
232
|
end
|
171
|
-
|
172
|
-
|
233
|
+
end
|
234
|
+
}
|
173
235
|
end
|
174
|
-
xml.li { |pre| pre << "<span class='blue'>string</span> <span class='bold'>backtrace</span>" }
|
175
236
|
}
|
176
237
|
end
|
177
238
|
end
|
@@ -51,6 +51,7 @@ xml.html( "xmlns" => "http://www.w3.org/1999/xhtml" ) {
|
|
51
51
|
|
52
52
|
xml.h2 "Index "
|
53
53
|
@complex_types = get_complex_types(@map)
|
54
|
+
@fault_types, @fault_complex_types = get_fault_types(@map)
|
54
55
|
unless @complex_types.blank?
|
55
56
|
xml.p "Complex Types: "
|
56
57
|
|
@@ -58,16 +59,21 @@ xml.html( "xmlns" => "http://www.w3.org/1999/xhtml" ) {
|
|
58
59
|
@complex_types.each do |hash|
|
59
60
|
xml.li { |y| y << "<a href='##{hash[:class]}'><span class='pre'>#{hash[:class]}</span></a>" }
|
60
61
|
end
|
62
|
+
unless @fault_complex_types.blank?
|
63
|
+
@fault_complex_types.each do |hash|
|
64
|
+
xml.li { |y| y << "<a href='##{hash[:fault].to_s}'><span class='pre'>#{hash[:fault].to_s}</span></a>" }
|
65
|
+
end
|
66
|
+
end
|
61
67
|
end
|
62
68
|
|
63
69
|
end
|
64
|
-
|
70
|
+
|
65
71
|
unless @fault_types.blank?
|
66
72
|
xml.p "Fault Types: "
|
67
73
|
|
68
74
|
xml.ul do
|
69
|
-
@fault_types.each do |
|
70
|
-
xml.li { |y| y << "<a href='##{
|
75
|
+
@fault_types.each do |hash|
|
76
|
+
xml.li { |y| y << "<a href='##{hash[:fault].to_s}'><span class='pre'>#{hash[:fault].to_s}</span></a>" }
|
71
77
|
end
|
72
78
|
end
|
73
79
|
end
|
@@ -89,9 +95,12 @@ xml.html( "xmlns" => "http://www.w3.org/1999/xhtml" ) {
|
|
89
95
|
xml.h2 "Complex types:"
|
90
96
|
create_html_complex_types(xml, @complex_types)
|
91
97
|
end
|
98
|
+
unless @fault_complex_types.blank?
|
99
|
+
create_html_fault_types_details(xml, @fault_complex_types)
|
100
|
+
end
|
92
101
|
unless @fault_types.blank?
|
93
102
|
xml.h2 "Fault types:"
|
94
|
-
create_html_fault_types_details(xml, @
|
103
|
+
create_html_fault_types_details(xml, @fault_types)
|
95
104
|
end
|
96
105
|
unless @methods.blank?
|
97
106
|
xml.h2 "Public methods:"
|
data/lib/washout_builder.rb
CHANGED