washout_builder 0.7.0 → 0.7.1

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
- MTk5MWM5OTYxNzU3YmI1NjI2ZTZkYTYxZWNjODkxMjk0ZWQwN2UwZA==
4
+ YzRiMTIyODljY2ViMjJhYTllMjU4YTg3MWVmMDM0MzM2MjJhOTA0MA==
5
5
  data.tar.gz: !binary |-
6
- ODU2MjM5ZjkxNmNkY2IxMGNkMzY3M2UyNmQ5OWFlMDhkMDU2MzAwZA==
6
+ M2E3NjEwZjNlZGE0ZWU5MDAwZDNjZDE0ZWE3NWQ5ZTJmMjk4ZTQ5YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDQyMjdlMjc4NjFlYTUyMWNkMjY2ZTg3NzM1NDhkYTdlMDA0MTM2YzU3ZWIx
10
- Y2FiM2M3NGE0ZTI1ZTZlYmJkZTkxNzI0NDNiNTAwYzZiZTMzOWFmODNiYTBi
11
- ZDFjOTNmOGRhZTEzNGM5YzNkMjViNjMzZGEyZjJiYzdlYjRjYzM=
9
+ OWZiZGVmNjM3MmM0Y2IyNmMyMzQ2NDdjOWJjOGMwNDAxNzNmOTI0MTMxNzg3
10
+ YTE3NmQwMzkwZTM0ZjMyMmI5OTZkN2ZlM2QxM2Q4ZjYwZWJmYWFjYzU0OTY5
11
+ NmFiN2MyZDQ3YjUxZjk1ZjU0ZThjMDc5M2EwZmNiZTY3NGU3ZWM=
12
12
  data.tar.gz: !binary |-
13
- YmE1NmI2NWUzYzYwNzU4MmVjZDc4NGYwMzY3ZDRhYTliNzFlZWNlMGNmNDI2
14
- YjgxNWQ5NTMzYjdiZDBhY2JlNmJjMTU5ZDhkMjIwODQwNzkxYzdmNTVmNWRh
15
- YjIyMWQwYWY2NGI2ZjhkNDg1MWY2ZGJiYTc0YTYyZTg5OTMyZWY=
13
+ ZTM2MDJiZmZkODVkZGZiZDQ3ZGQ5NDI3OTBkYzQwNmM4MDlkM2ExY2QxZTUx
14
+ NWY5NzNiMmViNTlkNTM1NDBkZjVmMzRkZTJkNGVmMmE2NmI2MzcxZDc0ZGNk
15
+ ZTljNTk5MTkzMjE1YzQwMGU0Nzk2MTg3MjhiMGEzMjk0MmIxYTY=
@@ -2,8 +2,9 @@ module WashoutBuilderHelper
2
2
  include WashOutHelper
3
3
 
4
4
  def get_complex_class_name(p, defined = [])
5
- complex_class = p.is_complex? ? p.basic_type.to_s.classify : nil
6
-
5
+ complex_class = p.struct? ? p.basic_type : nil
6
+ complex_class = complex_class.include?(".") ? complex_class.gsub(".","/").camelize : complex_class.to_s.classify unless complex_class.nil?
7
+
7
8
  unless complex_class.nil? || defined.blank?
8
9
 
9
10
  complex_obj_found = defined.detect {|hash| hash[:class] == complex_class}
@@ -12,7 +13,7 @@ module WashoutBuilderHelper
12
13
  raise RuntimeError, "Duplicate use of `#{p.basic_type}` type name. Consider using classified types."
13
14
  end
14
15
  end
15
-
16
+
16
17
  return complex_class
17
18
  end
18
19
 
@@ -47,7 +48,7 @@ module WashoutBuilderHelper
47
48
  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" }
48
49
  unless ancestors.blank?
49
50
  ancestor_structure = { ancestors[0].to_s.downcase => ancestors[0].columns_hash.inject({}) {|h, (k,v)| h["#{k}"]="#{v.type}".to_sym; h } }
50
- ancestor_object = WashoutBuilder::Param.parse_def(@soap_config,ancestor_structure)[0]
51
+ ancestor_object = WashOut::Param.parse_def(@soap_config,ancestor_structure)[0]
51
52
  bool_the_same = same_structure_as_ancestor?(param, ancestor_object)
52
53
  unless bool_the_same
53
54
  top_ancestors = get_class_ancestors(ancestor_class, defined)
@@ -61,8 +62,13 @@ module WashoutBuilderHelper
61
62
  def get_nested_complex_types(param, defined)
62
63
  defined = [] if defined.blank?
63
64
  complex_class = get_complex_class_name(param, defined)
65
+ param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
66
+ if !param_class.nil? && param_class.ancestors.include?(WashOut::Type)
67
+ param.name = param.map[0].name
68
+ param.map = param.map[0].map
69
+ end
64
70
  defined << {:class =>complex_class, :obj => param, :ancestors => param.classified? ? get_class_ancestors(param, complex_class, defined) : nil } unless complex_class.nil?
65
- if param.is_complex?
71
+ if param.struct?
66
72
  c_names = []
67
73
  param.map.each { |obj| c_names.concat(get_nested_complex_types(obj, defined)) }
68
74
  defined.concat(c_names)
@@ -102,7 +108,7 @@ module WashoutBuilderHelper
102
108
  xml.a( "name" => "#{class_name}") { }
103
109
  xml.h3 { |pre| pre << "#{class_name} #{ancestors.blank? ? "" : "<small>(extends <a href='##{ancestors[0].to_s.classify}'>#{ancestors[0].to_s.classify}</a>)</small>" } " }
104
110
 
105
- if param.is_a?(WashoutBuilder::Param)
111
+ if param.is_a?(WashOut::Param)
106
112
  xml.ul("class" => "pre") {
107
113
 
108
114
  param.map.each do |element|
@@ -140,7 +146,8 @@ module WashoutBuilderHelper
140
146
  end
141
147
 
142
148
  def create_html_fault_type(xml, param)
143
- if param.class.ancestors.include?(WashOut::Dispatcher::SOAPError)
149
+ ancestor_class = defined?(WashOut::Dispatcher::SOAPError) ? WashOut::Dispatcher::SOAPError : Washout::SoapError
150
+ if param.class.ancestors.include?(ancestor_class)
144
151
  xml.h3 "#{param.class}"
145
152
  xml.a("name" => "#{param.class}") {}
146
153
  xml.ul("class" => "pre") {
@@ -20,8 +20,8 @@ module WashoutBuilder
20
20
 
21
21
  current_action = self.soap_actions[action]
22
22
 
23
- current_action[:input] = WashoutBuilder::Param.parse_def(soap_config, options[:args])
24
- current_action[:output] = WashoutBuilder::Param.parse_def(soap_config, options[:return])
23
+ current_action[:input] = WashOut::Param.parse_builder_def(soap_config, options[:args])
24
+ current_action[:output] = WashOut::Param.parse_builder_def(soap_config, options[:return])
25
25
 
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module WashoutBuilder
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -1,7 +1,6 @@
1
1
  require 'wash_out'
2
2
 
3
3
  require 'washout_builder/soap'
4
- require 'washout_builder/param'
5
4
  require 'washout_builder/engine'
6
5
  require 'washout_builder/dispatcher'
7
6
  require 'washout_builder/type'
@@ -34,7 +33,7 @@ WashOut::Dispatcher::SOAPError.send :include, ActiveModel::MassAssignmentSecurit
34
33
  WashOut::SOAPError.send :include, ActiveModel::MassAssignmentSecurity if defined?(WashOut::SOAPError)
35
34
 
36
35
 
37
- if defined?(WashOut::Soap)
36
+ if defined?(WashOut::SOAP)
38
37
  WashOut::SOAP::ClassMethods.class_eval do
39
38
  alias_method :original_soap_action, :soap_action
40
39
  end
@@ -50,6 +49,30 @@ ActionController::Renderers.add :soap do |what, options|
50
49
  _render_soap(what, options)
51
50
  end
52
51
 
52
+ WashOut::Param.class_eval do
53
+
54
+ def self.parse_builder_def(soap_config, definition)
55
+ raise RuntimeError, "[] should not be used in your params. Use nil if you want to mark empty set." if definition == []
56
+ return [] if definition == nil
57
+
58
+ definition = { :value => definition } unless definition.is_a?(Hash)
59
+
60
+ definition.collect do |name, opt|
61
+ if opt.is_a? WashOut::Param
62
+ opt
63
+ elsif opt.is_a? Array
64
+ WashOut::Param.new(soap_config, name, opt[0], true)
65
+ else
66
+ WashOut::Param.new(soap_config, name, opt)
67
+ end
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+
74
+
75
+
53
76
  ActionController::Base.class_eval do
54
77
 
55
78
  # Define a SOAP service. The function has no required +options+:
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.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
@@ -61,7 +61,6 @@ files:
61
61
  - lib/washout_builder.rb
62
62
  - lib/washout_builder/dispatcher.rb
63
63
  - lib/washout_builder/engine.rb
64
- - lib/washout_builder/param.rb
65
64
  - lib/washout_builder/soap.rb
66
65
  - lib/washout_builder/type.rb
67
66
  - lib/washout_builder/version.rb
@@ -1,51 +0,0 @@
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