washout_builder 0.12.2 → 0.12.3

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
- ZmFkODUwODE4Mzc4Y2IzMjU4Mjc4MWVjMmMzMTliNzQ4ZDY0YmI1OA==
4
+ MjNjZTU3M2FjMjU1NDg3NjNiZWZmYWNiMjJiZmQ0NzFmYTIxOTFiZg==
5
5
  data.tar.gz: !binary |-
6
- ODJlNjA2MDU1ZWM4ZTRjMmM1YmMyNmU0OTkxMWNhMmEyMjA1YjMwNA==
6
+ ZGRmY2YwNWQ3NDc0YzZiODY5ZDA0OTlmNjliMDFmZmVkOTk4YzFlNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjdjMWQ2OTc0ZDdmNmM1ZmVhNWE1NWQxODg3OTRkYjZiZWEwMmMxMmUyMGQw
10
- ZjQ4MWQ3NzFlZjI1MDQ2NDUxODNhZTNjNjJhNTk0MDQ5ZjA5YTdiZTdmYTk2
11
- Y2E5MGU0MDRiOGFiMDM2NzBhZGYxN2MyNzdjYTU1ODkyMmQ2Yjg=
9
+ M2RjOWJlYzMxNTU3NWE4OWFkZjAwMGFkYzUwMWIyYThlYTg4Nzg3NmNmNDg4
10
+ ZGMxZWU2ZmE1NDQ1MjBlNWI2OWYxY2UzYTU1MjYzZjUzZDEwNWFmZjg1MWZi
11
+ NzQyYTNkMWUxYTQ4ODJmOWE5OTEzMzAwZDg3MWJhM2MyOTRiZTA=
12
12
  data.tar.gz: !binary |-
13
- NDU3MTVmNmFiMTBkYWNjMGNjNmI2ZGZjNzhlMjdhZjI4OTMxNTljMmMwNDFl
14
- MWRkM2IyMGJlNjY5NzEwN2U5ZTEyNTFkNDZmZjNiODNhZTE2ZWYzMDVlMmE3
15
- YTJhOGZkOTBkNGFmNWZiZTNiZDJhNTJmNDQ3MTQ2OTQ0ZmViNDg=
13
+ MGE1ZDFiOWQ3NDJiOTdiOTY4MjM0ZTVmNTBmYzM5N2IyMzU0YjJkNTgxNGQ2
14
+ N2I5NDU5N2QyM2M3YzFiMjk0MjE0NjNmZmUxOWQ1MTRiYjBkYWJlMGQ4ZjZj
15
+ YWNhOWJkYjZhY2UwNzZkZTgwNDJhODY3MzhjOGQ5NmZlODY1NDQ=
@@ -5,7 +5,7 @@ class WashoutBuilder::WashoutBuilderController < ActionController::Base
5
5
  def all
6
6
  route = params[:name].present? ? controller_is_a_service?(params[:name]) : nil
7
7
  if route.present?
8
- @document = initialize_service_generator(route)
8
+ @document = WashoutBuilder::Document::Generator.new(route.defaults[:controller])
9
9
  render :template => "wash_with_html/doc", :layout => false,
10
10
  :content_type => 'text/html'
11
11
  else
@@ -17,16 +17,6 @@ class WashoutBuilder::WashoutBuilderController < ActionController::Base
17
17
  private
18
18
 
19
19
 
20
- def initialize_service_generator(route)
21
- controller_class_name = controller_class(route.defaults[:controller])
22
- WashoutBuilder::Document::Generator.new(
23
- :config => controller_class_name.soap_config,
24
- :service_class => controller_class_name,
25
- :soap_actions => controller_class_name.soap_actions
26
- )
27
- end
28
-
29
-
30
20
  def all_services
31
21
  @map_controllers = map_controllers
32
22
  @services = @map_controllers.blank? ? [] : @map_controllers.map do |controller_name|
@@ -14,7 +14,7 @@ require 'washout_builder/version'
14
14
  Virtus::InstanceMethods::Constructor.class_eval do
15
15
  alias_method :original_initialize,:initialize
16
16
  def initialize(attributes = nil)
17
- if self.class.ancestors.detect{ |fault| WashoutBuilder::Type.get_fault_classes.include?(fault) }.present? || WashoutBuilder::Type.get_fault_classes.include?(self.class)
17
+ if WashoutBuilder::Type.valid_fault_class?(self.class)
18
18
  attributes = {:message => attributes} unless attributes.is_a?(Hash)
19
19
  end
20
20
  original_initialize(attributes)
@@ -42,7 +42,7 @@ module WashoutBuilder
42
42
 
43
43
  def fix_descendant_wash_out_type(config, complex_class)
44
44
  param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
45
- if !param_class.nil? && param_class.ancestors.include?(WashOut::Type) && !map[0].nil?
45
+ if param_class.present? && param_class.ancestors.include?(WashOut::Type) && map[0].present?
46
46
  descendant = WashOut::Param.parse_builder_def(config, param_class.wash_out_param_map)[0]
47
47
  self.name = descendant.name
48
48
  self.map = descendant.map
@@ -1,29 +1,34 @@
1
+ require_relative "./virtus_model"
1
2
  module WashoutBuilder
2
3
  module Document
3
4
  class Generator
4
5
 
5
- @attrs = [:soap_actions, :config, :service_class]
6
+ @attrs = [:soap_actions, :config, :controller_name]
6
7
 
7
8
  attr_reader *@attrs
8
9
  attr_accessor *@attrs
9
10
 
10
- def initialize(attrs = {})
11
- self.config = attrs[:config]
12
- self.service_class = attrs[:service_class]
13
- self.soap_actions = attrs[:soap_actions]
11
+ def initialize(controller)
12
+ controller_class_name = controller_class(controller)
13
+ self.config =controller_class_name.soap_config
14
+ self.soap_actions = controller_class_name.soap_actions
15
+ self.controller_name = controller
14
16
  end
15
17
 
16
18
  def namespace
17
- config.namespace
19
+ config.respond_to?(:namespace) ? config.namespace : nil
18
20
  end
19
21
 
20
-
22
+ def controller_class(controller)
23
+ "#{controller}_controller".camelize.constantize
24
+ end
25
+
21
26
  def endpoint
22
- namespace.gsub("/wsdl", "/action")
27
+ namespace.blank? ? nil : namespace.gsub("/wsdl", "/action")
23
28
  end
24
29
 
25
30
  def service
26
- service_class.name.underscore.gsub("_controller", "").camelize
31
+ controller_name.blank? ? nil : controller_name.camelize
27
32
  end
28
33
 
29
34
  def service_description
@@ -35,7 +40,7 @@ module WashoutBuilder
35
40
  end
36
41
 
37
42
  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?
43
+ types.sort_by { |hash| hash[type.to_sym].to_s.downcase }.uniq {|hash| hash[type.to_sym] } unless types.blank?
39
44
  end
40
45
 
41
46
 
@@ -75,35 +80,24 @@ module WashoutBuilder
75
80
 
76
81
 
77
82
  def actions_with_exceptions
78
- soap_actions.select{|operation, formats| !formats[:raises].blank? }
83
+ soap_actions.select{|operation, formats| !formats[:raises].blank? }
79
84
  end
80
85
 
81
86
  def exceptions_raised
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))
87
+ actions_with_exceptions.collect {|operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten
95
88
  end
96
-
89
+
90
+
97
91
  def filter_exceptions_raised
98
- exceptions_raised.select { |x| valid_fault_class?(x) } unless actions_with_exceptions.blank?
92
+ exceptions_raised.select { |x| WashoutBuilder::Type.valid_fault_class?(x) } unless actions_with_exceptions.blank?
99
93
  end
100
94
 
101
95
  def get_complex_fault_types(fault_types)
102
96
  defined = filter_exceptions_raised
103
97
  if defined.blank?
104
- defined = [fault_classes.first]
98
+ defined = [WashoutBuilder::Type.get_fault_classes.first]
105
99
  else
106
- defined << fault_classes.first
100
+ defined << WashoutBuilder::Type.get_fault_classes.first
107
101
  end
108
102
  defined.each{ |exception_class| exception_class.get_fault_class_ancestors( fault_types, true)} unless defined.blank?
109
103
  fault_types
@@ -112,7 +106,7 @@ module WashoutBuilder
112
106
  def fault_types
113
107
  fault_types = get_complex_fault_types([])
114
108
  complex_types = extract_nested_complex_types_from_exceptions(fault_types)
115
- complex_types.delete_if{ |hash| fault_types << hash if valid_fault_class?(hash[:fault]) } unless complex_types.blank?
109
+ complex_types.delete_if{ |hash| fault_types << hash if WashoutBuilder::Type.valid_fault_class?(hash[:fault]) } unless complex_types.blank?
116
110
  fault_types = sort_complex_types(fault_types, "fault")
117
111
  complex_types = sort_complex_types(complex_types, "fault")
118
112
  [fault_types, complex_types]
@@ -123,20 +117,12 @@ module WashoutBuilder
123
117
  fault_types.each do |hash|
124
118
  hash[:structure].each do |attribute, attr_details|
125
119
  complex_class = hash[:fault].get_virtus_member_type_primitive(attr_details)
126
- unless complex_class.nil?
127
- param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
128
- if !param_class.nil? && param_class.ancestors.include?(Virtus::Model::Core)
129
- param_class.send :extend, WashoutBuilder::Document::VirtusModel
130
- param_class.get_fault_class_ancestors( complex_types)
131
- elsif !param_class.nil? && !param_class.ancestors.include?(Virtus::Model::Core)
132
- 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."
133
- end
134
- end
135
- end
120
+ WashoutBuilder::Document::VirtusModel.extract_nested_complex_types(complex_class, complex_types)
121
+ end
136
122
  end
137
123
  complex_types
138
124
  end
139
-
125
+
140
126
 
141
127
 
142
128
 
@@ -62,6 +62,18 @@ module WashoutBuilder
62
62
  end
63
63
 
64
64
 
65
+ def self.extract_nested_complex_types(complex_class, complex_types)
66
+ unless complex_class.nil?
67
+ param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
68
+ if param_class.present? && param_class.ancestors.include?(Virtus::Model::Core)
69
+ param_class.send :extend, WashoutBuilder::Document::VirtusModel
70
+ param_class.get_fault_class_ancestors( complex_types)
71
+ elsif param_class.present? && !param_class.ancestors.include?(Virtus::Model::Core)
72
+ 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."
73
+ end
74
+ end
75
+ end
76
+
65
77
  end
66
78
  end
67
79
  end
@@ -21,6 +21,15 @@ module WashoutBuilder
21
21
  return faults
22
22
  end
23
23
 
24
+
25
+ def self.has_ancestor_fault?(fault_class)
26
+ fault_class.ancestors.detect{ |fault| get_fault_classes.include?(fault) }.present?
27
+ end
28
+
29
+ def self.valid_fault_class?(fault)
30
+ fault.is_a?(Class) && ( has_ancestor_fault?(fault) || get_fault_classes.include?(fault))
31
+ end
32
+
24
33
 
25
34
  end
26
35
  end
@@ -1,3 +1,3 @@
1
1
  module WashoutBuilder
2
- VERSION = "0.12.2"
2
+ VERSION = "0.12.3"
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.12.2
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada