washout_builder 0.4.4 → 0.5.0

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
- NjRkMjYxZTUwYzZmZDM2NGFlMDQzM2NhZWFhZGQ2Njc5MGUyNGE3ZQ==
4
+ OGUxZmRiZjBjZmIwNzQ4NGIyYTg5N2Y3ZDJmNjNlODRkMjQxODYxMw==
5
5
  data.tar.gz: !binary |-
6
- ZDgxOWMzZGY5YmI3ZTc1NGE4NzExMjliN2ZkMTk3NjZkMTFlYTg3YQ==
6
+ N2ZmOWM2ZjIzYTVlNDc3YjA4MDRmODI2YWIyNWJiNjhkZDI3MDBhZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjIwMTIxNjkwMzdkZmFiYzNmNmQ0YjM4Nzg5YTdkZGMxMGU4YWQ0OGEyMjk1
10
- YThlNTlkNzM0YmU0MGQ1MDVmOWQ1YTNhNjAxYTMxYTY2NzkzZGIzMGY4Y2Qz
11
- NWNlODE5MTY3MmVkMjZhZmNlYWY1MDFiMDQ0ZWVhNDJiNjc1MmI=
9
+ NjY2ZmE3NjZkZWQxNWQ1YWZmNTg5NDY0NGYwMjQ3MjQzMTQ0Njg3NzNjZTQy
10
+ NTljYzNhNGViOTAzNzU2ZTlmYzdhYWQ5OWQ5MDlhODFkZDJlMTMwMmJjYjU2
11
+ ZjJjZGY3MTdmMDMzYjE3MDc2NjU0YThiYjViMGNiMzQwNzg5ZTU=
12
12
  data.tar.gz: !binary |-
13
- ZGEwYTU2OTJkZTY0Mjg5Y2ZjOTgyYjBjNTcyN2U2ZTdjMTA5MzhiODVkOTYw
14
- MTIxZTU4ZDllNTc3OTc0ODYwNGZkODEwNWRkMjJjYzA4YmFkOTQ1YTI3Y2Nj
15
- YzdiZTRhY2M4ZjZkOTQ4ZTNjY2VjYjRjNDVjNDViOGRlZDc2MmM=
13
+ ZWZkODA5ZTBmZGY5YzQ2YzBjZWNlMDY3NTdiMjQ1NGUwOGU3ZmVlOTRjOTdh
14
+ NWUwMzE3YzFlZDYzODQzZjM3Y2RhOTY0NGU5ZGVmNDViMGMwYzAwMDhhNjNj
15
+ NDRlMDk2ZmUxODg1YjZmZDlmNWExMzFjYjA1ZDUzYjA0OTM2ZGI=
@@ -17,11 +17,58 @@ module WashoutBuilderHelper
17
17
  return complex_class
18
18
  end
19
19
 
20
+
21
+ def get_param_structure(param)
22
+ param.map.inject({}) {|h,element| h[element.name] = element.type;h }
23
+ end
24
+
25
+
26
+ def remove_type_inheritable_elements(param, keys)
27
+ param.map.delete_if{|element| keys.include?(element.name) }
28
+ end
29
+
30
+
31
+ def same_structure_as_ancestor?(param, ancestor)
32
+ param_structure = get_param_structure(param)
33
+ ancestor_structure = get_param_structure(ancestor)
34
+ if param_structure.keys == ancestor_structure.keys
35
+ return true
36
+ else
37
+ remove_type_inheritable_elements(param, ancestor_structure.keys)
38
+ return false
39
+ end
40
+ end
41
+
42
+
43
+
44
+
45
+ def get_class_ancestors(param,class_name, defined)
46
+ bool_the_same = false
47
+ param_class = class_name.is_a?(Class) ? class_name : class_name.constantize
48
+ ancestors = param_class.ancestors - param_class.included_modules
49
+ ancestors.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_class = ancestors[0]
52
+ ancestor_structure = {ancestor_class.to_s.downcase => ancestor_class.columns_hash.inject({}) {|h, (k,v)| h["#{k}"]="#{v.type}".to_sym; h } }
53
+ ancestor_object = WashoutBuilder::Param.parse_def(@soap_config,ancestor_structure)[0]
54
+ bool_the_same = same_structure_as_ancestor?(param, ancestor_object)
55
+ unless bool_the_same
56
+ top_ancestors = get_class_ancestors(ancestor_class, defined)
57
+ defined << {:class =>ancestor_class.to_s, :obj =>ancestor_object , :ancestors => top_ancestors }
58
+ end
59
+ end
60
+ ancestors unless bool_the_same
61
+ end
62
+
20
63
 
21
64
  def get_nested_complex_types(param, defined)
22
65
  defined = [] if defined.blank?
23
66
  complex_class = get_complex_class_name(param, defined)
24
- defined << {:class =>complex_class, :obj => param} unless complex_class.nil?
67
+ if param.classified?
68
+ defined << {:class =>complex_class, :obj => param, :ancestors => get_class_ancestors(param, complex_class, defined)} unless complex_class.nil?
69
+ else
70
+ defined << {:class =>complex_class, :obj => param} unless complex_class.nil?
71
+ end
25
72
  if param.is_complex?
26
73
  c_names = []
27
74
  param.map.each do |obj|
@@ -57,21 +104,22 @@ module WashoutBuilderHelper
57
104
 
58
105
  def create_html_complex_types(xml, types)
59
106
  types.each do |hash|
60
- create_complex_type_html(xml, hash[:obj], hash[:class])
107
+ create_complex_type_html(xml, hash[:obj], hash[:class], hash[:ancestors])
61
108
  end
62
109
  end
63
110
 
64
111
 
65
112
 
66
- def create_complex_type_html(xml, param, class_name)
113
+ def create_complex_type_html(xml, param, class_name, ancestors)
67
114
  unless param.blank?
68
115
  xml.a( "name" => "#{class_name}") { }
69
- xml.h3 "#{class_name}"
116
+ xml.h3 { |pre| pre << "#{class_name} #{ancestors.blank? ? "" : "(extends <a href='##{ancestors[0].to_s.classify}'> #{ancestors[0].to_s.classify} )</a>" } " }
70
117
 
71
118
  if param.is_a?(WashoutBuilder::Param)
72
119
  xml.ul("class" => "pre") {
73
-
120
+
74
121
  param.map.each do |element|
122
+ element.type = "string" if element.type == "text"
75
123
  # raise YAML::dump(element) if class_name.include?("ype") and element.name == "members"
76
124
  xml.li { |pre|
77
125
  if WashoutBuilder::Type::BASIC_TYPES.include?(element.type)
@@ -13,6 +13,7 @@ module WashoutBuilder
13
13
  @name = controller_path.gsub('/', '_')
14
14
  @service = self.class.name.underscore.gsub("_controller", "").camelize
15
15
  @endpoint = @namespace.gsub("/wsdl", "/action")
16
+ @soap_config = soap_config
16
17
 
17
18
  render :template => "wash_with_html/doc", :layout => false,
18
19
  :content_type => 'text/html'
@@ -1,3 +1,3 @@
1
1
  module WashoutBuilder
2
- VERSION = "0.4.4"
2
+ VERSION = "0.5.0"
3
3
  end
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.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada