washout_builder 0.9.1 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTljZWJlOTljYmQyMmM1NzlkNDQ2NGIzZGQ4OTFiNmM2ZmMyOWFkNA==
4
+ ZjU0ZjQ2Mjc4MmQ5NjEwMGEwOWU3NzYxZjdmY2EwYjg0MGU5NGQzNA==
5
5
  data.tar.gz: !binary |-
6
- OTk2Y2FmNjZiMDhkYWEwYzJlODg1ZTgyMjZjOGFmZTdlM2JkMWI0NQ==
6
+ NzljZDc0MjBkZGZhNmEyYzk2YTE3NTE4NTE3NWRmMGYyNzIyNjEyYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzhhMGJiMTQzMWVjNTFiNDY4MDUxOGIyYzE3OTIxMzBkZWZlNDQ4OWQxOGZk
10
- ZjZlYjFiMGFjZDNhZWI0NzUyODA5OTUxZWQ3YjQ5YjI0OTY2M2JmZmUyNzQ2
11
- OTZkMTc5MDRlNGY3ZTI4OTI5ZmQ2ZmRmYjZlNWQxM2U5OWI5Zjk=
9
+ ZmNjNWRiODIxZGM3NmNmZmJhZjM3ZDZmMWMwYWM0MjQ3NWU5OGI0NDAyMDZi
10
+ ZWIzYWExNTQyOTY5NGI4OTNkZmVmMmM5OGVhZGFhMmExZmY0NmZmYWI5M2Nj
11
+ YmRjYmIyODc5Y2IwNjI3MmU4ODRhM2UyOWQ4MmFkM2VkMTA1MmM=
12
12
  data.tar.gz: !binary |-
13
- NjM4MjVjMTcxNzc1NGQ3NDZmNWNmNTliYWQwMGUzMjRiYmZiNDY5M2ZmZDc2
14
- YTg4NDU5Mzk4MjIxNzhhYjA1ZjhiNGQ1ODRjMzdhMmQ4YWU3M2U1YTU2ODBi
15
- YWQxNDc0NGRmYmYwYzc3ZTAzY2U0ZDUzMzMwOGExNzFhNzkxZGM=
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
- 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 }
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
- end
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
- def get_fault_types_names(map)
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
- defined.map{|item| item.to_s }.sort_by { |name| name.downcase }.uniq unless defined.blank?
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, map)
149
- defined = map.select{|operation, formats| !formats[:raises].blank? }
150
- unless defined.blank?
151
- defined = defined.collect {|operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten.sort_by { |item| item.class.to_s.downcase }.uniq
152
- defined.each { |fault| create_html_fault_type(xml, fault) }
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
- def create_html_fault_type(xml, param)
157
- if param.is_a?(Class) && param.ancestors.include?(WashOut::SOAPError)
158
- xml.h3 "#{param}"
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
- fault_structure = param.attribute_set.inject({}) {|h, elem| h["#{elem.name}"]= "#{elem.primitive.to_s.downcase}"; h }
217
+
162
218
 
163
- fault_structure.each do |attribute, attribute_type|
164
- if attribute!= 'backtrace'
165
- xml.li { |pre|
166
- if WashoutBuilder::Type::BASIC_TYPES.include?(attribute_type) || attribute_type == "nilclass"
167
- pre << "<span class='blue'>#{attribute_type == "nilclass" ? "string" : attribute_type }</span>&nbsp;<span class='bold'>#{attribute}</span>"
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>&nbsp;<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>&nbsp;<span class='bold'>#{attribute}</span>"
168
230
  else
169
- pre << "<a href='##{attribute_type}'><span class='lightBlue'>#{attribute_type}</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
231
+ pre << "<a href='##{attr_details[:primitive] }'><span class='lightBlue'>#{attr_details[:primitive]}</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
170
232
  end
171
- }
172
- end
233
+ end
234
+ }
173
235
  end
174
- xml.li { |pre| pre << "<span class='blue'>string</span>&nbsp;<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
- @fault_types = get_fault_types_names(@map)
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 |name|
70
- xml.li { |y| y << "<a href='##{name}'><span class='pre'>#{name}</span></a>" }
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, @map)
103
+ create_html_fault_types_details(xml, @fault_types)
95
104
  end
96
105
  unless @methods.blank?
97
106
  xml.h2 "Public methods:"
@@ -1,3 +1,3 @@
1
1
  module WashoutBuilder
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.5"
3
3
  end
@@ -25,11 +25,12 @@ end
25
25
 
26
26
 
27
27
 
28
- WashOut::SOAPError.send :include, Virtus.model
29
28
 
30
29
  WashOut::SOAPError.class_eval do
30
+ include Virtus.model
31
31
  attribute :code, Integer
32
32
  attribute :message, String
33
+ attribute :backtrace, String
33
34
  end
34
35
 
35
36
 
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.9.1
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada