washout_builder 0.11.7 → 0.11.8

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
- MmUwZTg3Y2U4NGZjM2E2MTMzZmM4ODZkNzRhOGVkZWQzZDczZGIxNw==
4
+ YzcwZTFhNDc1MDQ4MDlkOTMzNDk2NjlkNjVjZDUzMmZiM2I1OGI1Nw==
5
5
  data.tar.gz: !binary |-
6
- MDg0MTNkNTg4ZjdhODI4ZDVkNTFiMjI3NWQ3ZTQyODQ4NzAxZmQyMg==
6
+ YzYzYmE5NmFjNDMyNmEyMTdiODhjMTE4NzBmNjUwZTE0NTcxNTA2YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Nzg2ZGFhOTAxMGMxYTZmN2IyNzQ4NDRkMDhkZTlmNmNlMDAwOTI0ZmY4ZDJl
10
- MmUyMDg1MGRmMmQ4NzJmNTA2NDNiNzFkNmJjZjRjYTQxYzZjNDM1MTM4NmU1
11
- NDRhN2RlNjAxODkwNDFhNDY4YWMwZjU3YTI2ZGJlYjVlNTM1ZmE=
9
+ ZjRkMTNlNjY4M2M0NTExYzMxOTE3NmU0ZDE4NjEyMzZjMmRiYzYzMWZmYjM2
10
+ YjQ3YTRkNGY5YmI3OWQ0ODAzNzQ3YzU2N2JlYTU0NzFmODA2MTRhMGNmNTE3
11
+ NGVkOGY3ZmQ3YWNjMmIwZmYyMzFjNmRkOWM1NzZlN2Q1MDBkODE=
12
12
  data.tar.gz: !binary |-
13
- NDBjMGMxMjdiZGYwMzQ1MDg5ZDU5OWY0NzM4NzBhOGFhYmViYWNhMGMxYWVi
14
- NjlhNzdiMTViMTZjZDlmMmVkZGVkZTQ2ZjVjMzI2OWI1NWQ2ZTExNzgyZDFj
15
- MjAzOTYwZmU1ZDJjNzYzYWFiMzBkYjE0MDg3NjQ5NWU4MzU1ZjY=
13
+ ZWJhZTUzNGQwYmY3Y2I2YmZkNjBlMjMwOTdhZjlkYzY5YmFkYWNmZTVhOWFh
14
+ ZmFmMDA3NTRmMWZkODc5N2M5NjhhMmU2OWQxNmNmMjM0MjM2OWU4ZDQ1ZTEz
15
+ NGFjODg1NWJhZTdjM2ViZTU4NmYwNDU4ZWU5OTBkYjhjMzQ0YTM=
@@ -2,6 +2,7 @@ require 'wash_out'
2
2
  require 'virtus'
3
3
  require 'washout_builder/soap'
4
4
  require 'washout_builder/engine'
5
+ require 'washout_builder/document/shared_complex_type'
5
6
  require 'washout_builder/document/complex_type'
6
7
  require 'washout_builder/document/virtus_model'
7
8
  require 'washout_builder/document/generator'
@@ -2,6 +2,7 @@ module WashoutBuilder
2
2
  module Document
3
3
  module ComplexType
4
4
  extend ActiveSupport::Concern
5
+ include WashoutBuilder::Document::SharedComplexType
5
6
 
6
7
 
7
8
  def get_complex_class_name(defined = [])
@@ -66,7 +67,7 @@ module WashoutBuilder
66
67
  if param_class.nil?
67
68
  return nil
68
69
  else
69
- (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" }
70
+ get_complex_type_ancestors(param_class, ["ActiveRecord::Base", "Object", "BasicObject", "WashOut::Type" ])
70
71
  end
71
72
  end
72
73
 
@@ -34,8 +34,8 @@ module WashoutBuilder
34
34
  soap_actions.map { |operation, formats| operation }
35
35
  end
36
36
 
37
- def sort_fault_types(types)
38
- types.sort_by { |hash| hash[:fault].to_s.downcase }.uniq {|hash| hash[:fault] } unless types.blank?
37
+ def sort_complex_types(types, type)
38
+ types.sort_by { |hash| hash[type.to_sym].to_s.downcase }.uniq {|hash| hash[type.to_sym] } unless types.blank?
39
39
  end
40
40
 
41
41
 
@@ -70,7 +70,7 @@ module WashoutBuilder
70
70
  (input_types + output_types).each do |p|
71
71
  defined.concat(p.get_nested_complex_types(config, defined))
72
72
  end
73
- defined.sort_by { |hash| hash[:class].to_s.downcase }.uniq{|hash| hash[:class] } unless defined.blank?
73
+ defined = sort_complex_types(defined, "class")
74
74
  end
75
75
 
76
76
 
@@ -79,25 +79,42 @@ module WashoutBuilder
79
79
  end
80
80
 
81
81
  def exceptions_raised
82
- actions = actions_with_exceptions
83
- faults= actions.collect {|operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten.select { |x| (x.is_a?(Class) && x.ancestors.detect{ |fault| WashoutBuilder::Type.get_fault_classes.include?(fault) }.present?) || (x.is_a?(Class) && WashoutBuilder::Type.get_fault_classes.include?(x)) } unless actions.blank?
84
- if faults.blank?
85
- faults = [WashoutBuilder::Type.get_fault_classes.first]
82
+ actions_with_exceptions.collect {|operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten
83
+ end
84
+
85
+ def fault_classes
86
+ WashoutBuilder::Type.get_fault_classes
87
+ end
88
+
89
+ def has_ancestor_fault?(fault_class)
90
+ fault_class.ancestors.detect{ |fault| fault_classes.include?(fault) }.present?
91
+ end
92
+
93
+ def valid_fault_class?(fault)
94
+ fault.is_a?(Class) && ( has_ancestor_fault?(fault) || fault_classes.include?(fault))
95
+ end
96
+
97
+ def filter_exceptions_raised
98
+ exceptions_raised.select { |x| valid_fault_class?(x) } unless actions_with_exceptions.blank?
99
+ end
100
+
101
+ def get_complex_fault_types(fault_types)
102
+ defined = filter_exceptions_raised
103
+ if defined.blank?
104
+ defined = [fault_classes.first]
86
105
  else
87
- faults << WashoutBuilder::Type.get_fault_classes.first
106
+ defined << fault_classes.first
88
107
  end
89
- faults
108
+ defined.each{ |exception_class| exception_class.get_fault_class_ancestors( fault_types, true)} unless defined.blank?
109
+ fault_types
90
110
  end
91
111
 
92
-
93
112
  def fault_types
94
- defined = exceptions_raised
95
- fault_types = []
96
- defined.each{ |exception_class| exception_class.get_fault_class_ancestors( fault_types, true)} unless defined.blank?
113
+ fault_types = get_complex_fault_types([])
97
114
  complex_types = extract_nested_complex_types_from_exceptions(fault_types)
98
- complex_types.delete_if{ |hash| fault_types << hash if (hash[:fault].is_a?(Class) && hash[:fault].ancestors.detect{ |fault| WashoutBuilder::Type.get_fault_classes.include?(fault) }.present?) || (hash[:fault].is_a?(Class) && WashoutBuilder::Type.get_fault_classes.include?(hash[:fault])) } unless complex_types.blank?
99
- fault_types = sort_fault_types(fault_types)
100
- complex_types = sort_fault_types(complex_types)
115
+ complex_types.delete_if{ |hash| fault_types << hash if valid_fault_class?(hash[:fault]) } unless complex_types.blank?
116
+ fault_types = sort_complex_types(fault_types, "fault")
117
+ complex_types = sort_complex_types(complex_types, "fault")
101
118
  [fault_types, complex_types]
102
119
  end
103
120
 
@@ -0,0 +1,11 @@
1
+ module WashoutBuilder
2
+ module Document
3
+ module SharedComplexType
4
+
5
+ def get_complex_type_ancestors(class_name, array)
6
+ (class_name.ancestors - class_name.included_modules).delete_if{ |x| x.to_s.downcase == class_name.to_s.downcase || array.include?(x.to_s) }
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,11 @@ module WashoutBuilder
2
2
  module Document
3
3
  module VirtusModel
4
4
  extend ActiveSupport::Concern
5
+ include WashoutBuilder::Document::SharedComplexType
6
+
7
+ def self.included(base)
8
+ base.send :include, WashoutBuilder::Document::SharedComplexType
9
+ end
5
10
 
6
11
  def get_fault_class_ancestors( defined, debug = false)
7
12
  bool_the_same = false
@@ -21,7 +26,7 @@ module WashoutBuilder
21
26
  end
22
27
 
23
28
  def fault_ancestors
24
- (self.ancestors - self.included_modules).delete_if{ |x| x.to_s.downcase == self.to_s.downcase || x.to_s == "ActiveRecord::Base" || x.to_s == "Object" || x.to_s =="BasicObject" || x.to_s == "Exception" }
29
+ get_complex_type_ancestors(self, ["ActiveRecord::Base", "Object", "BasicObject", "Exception" ])
25
30
  end
26
31
 
27
32
  def fault_ancestor_hash( structure, ancestors)
@@ -1,3 +1,3 @@
1
1
  module WashoutBuilder
2
- VERSION = "0.11.7"
2
+ VERSION = "0.11.8"
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.11.7
4
+ version: 0.11.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
@@ -77,6 +77,7 @@ files:
77
77
  - lib/washout_builder/dispatcher.rb
78
78
  - lib/washout_builder/document/complex_type.rb
79
79
  - lib/washout_builder/document/generator.rb
80
+ - lib/washout_builder/document/shared_complex_type.rb
80
81
  - lib/washout_builder/document/virtus_model.rb
81
82
  - lib/washout_builder/engine.rb
82
83
  - lib/washout_builder/soap.rb