washout_builder 0.16.1 → 0.16.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c4ed779a68919c6de832b667e05b4a0a5c8eec9
4
- data.tar.gz: 3c479cbcd085a9aa923c46c3c7737b2a3b1c4bd5
3
+ metadata.gz: e587370fb93a81cf2456594507efcc1f055cb379
4
+ data.tar.gz: 5feb9b3e018a09518eaa46fa6470ece3e9493637
5
5
  SHA512:
6
- metadata.gz: 784cac5094aa5d1837ea87ced703e72149b1843e06708d709e4f6ef90cfe4c95d97bc67464b8154c13870a1293850b4af61ddc472bd0134799fcf18a458694f5
7
- data.tar.gz: 17457f3526d84d4693eca8684ae3331e21188c3d723f73a40b1b465554f6c4627d83a998df657d5c8eff1f2aa41fc9b037cf2cf3c6b437bc38d13d9e4fb74009
6
+ metadata.gz: 1d0cca80bd2c5b310f5ec5be814ba0d3b1e92532ef412ddfb36485937b1094674b5cf6270a63ef0c830245261157fa6ec62da6eb73269bd92ce3417389cd5e3c
7
+ data.tar.gz: dd9fae3d9ca7521a48d8b6f07f9b8691be58edda88807b214cde181632ca401b31d2c242da04aec11ef4410661ee5938dd2a9bc6cb66dcfedaf2d5da0598acb0
@@ -1,3 +1,4 @@
1
+ # method that is used to show that a method can raise a exception in HTML documentation
1
2
  module WashoutBuilderFaultTypeHelper
2
3
  # checks if a complex attribute of a complex type SoapFault is array or not
3
4
  # if the attribute is an array will print also the type of the elements contained in the array
@@ -1,3 +1,4 @@
1
+ # helper that is used to show the arguments of a method with their types in HTML documentation
1
2
  module WashoutBuilderMethodArgumentsHelper
2
3
  # displays the parameter of a method as argument and determines if the parameter is basic type or complex type
3
4
  #
@@ -1,3 +1,4 @@
1
+ # helper that is used to list the method's return tyep as a LI element in HTML documentation
1
2
  module WashoutBuilderMethodListHelper
2
3
  # this method will create the return type of the method and check if the type is basic or complex type or array of types
3
4
  #
@@ -1,3 +1,4 @@
1
+ # helper that is used to create the return types of methods in HTML documentation
1
2
  module WashoutBuilderMethodReturnTypeHelper
2
3
  # this method will print the return type next to the method name
3
4
  # @see WashoutBuilder::Document::ComplexType#find_complex_class_name
@@ -30,8 +31,8 @@ module WashoutBuilderMethodReturnTypeHelper
30
31
  # @param [Array] pre The array that contains the html that will be appended to xml
31
32
  # @param [Array<WashOut::Param>] output An array of params that need to be displayed, will check the type of each and will display it accordingly if is complex type or not
32
33
  # @param [Class] complex_class the name of the complex class
33
-
34
- # @return [String]
34
+ #
35
+ # @return [void]
35
36
  #
36
37
  # @api public
37
38
  def html_public_method_complex_type(pre, output, complex_class)
@@ -40,7 +40,7 @@ end
40
40
  WashOut::Param.class_eval do
41
41
  def self.parse_builder_def(soap_config, definition)
42
42
  raise '[] should not be used in your params. Use nil if you want to mark empty set.' if definition == []
43
- return [] if definition.nil?
43
+ return [] if definition.blank?
44
44
 
45
45
  # the following lines was removed because when generating the documentation
46
46
  # the "source_class" attrtibute of the object was not the name of the class of the complex tyoe
@@ -49,6 +49,11 @@ module WashoutBuilder
49
49
  classified? ? get_class_ancestors(config, complex_class, defined) : nil
50
50
  end
51
51
 
52
+ # iterates through all the elements of the current object
53
+ # and constructs a hash that has as keys the element names and as value their type
54
+
55
+ # @return [Hash] THe hash that contains information about the structure of the current object as complex type
56
+ # @api public
52
57
  def find_param_structure
53
58
  map.each_with_object({}) do|item, memo|
54
59
  memo[item.name] = item.type
@@ -56,10 +61,25 @@ module WashoutBuilder
56
61
  end
57
62
  end
58
63
 
64
+ # removes from this current object the elements that are inherited from other objects
65
+ # and set the map of the curent object to the new value
66
+ #
67
+ # @param [Array<String>] keys An array with the keys that need to be removed from current object
68
+ # @return [void]
69
+ # @api public
59
70
  def remove_type_inheritable_elements(keys)
60
71
  self.map = map.delete_if { |element| keys.include?(element.name) }
61
72
  end
62
73
 
74
+ # Dirty hack to fix the first washout param type.
75
+ # This only applies if the first complex type is inheriting WashOutType
76
+ # its name should be set to its descendant and the map of the current object will be set to its descendant
77
+ # @see WashOut::Param#parse_builder_def
78
+ #
79
+ # @param [WashOut::SoapConfig] config an object that holds the soap configuration
80
+ # @param [Class, String] complex_class the name of the complex type either as a string or a class
81
+ # @return [void]
82
+ # @api public
63
83
  def fix_descendant_wash_out_type(config, complex_class)
64
84
  param_class = begin
65
85
  complex_class.is_a?(Class) ? complex_class : complex_class.constantize
@@ -72,6 +92,14 @@ module WashoutBuilder
72
92
  self.map = descendant.map
73
93
  end
74
94
 
95
+ # Method that is used to check if the current object has exactly same structure as one of his ancestors
96
+ # if it is true, will return true, otherwise will first remove the inheritated elements from his ancestor and then return false
97
+ # @see #find_param_structure
98
+ # @see #remove_type_inheritable_elements
99
+ #
100
+ # @param [WasOut::Param] ancestor The complex type that is used to compare to the current complex type
101
+ # @return [Boolean] returns true if both objects have same structure, otherwise will first remove the inheritated elements from his ancestor and then return false
102
+ # @api public
75
103
  def same_structure_as_ancestor?(ancestor)
76
104
  param_structure = find_param_structure
77
105
  ancestor_structure = ancestor.find_param_structure
@@ -83,6 +111,14 @@ module WashoutBuilder
83
111
  end
84
112
  end
85
113
 
114
+ # Mehod that is used to get the ancestors of the current complex type
115
+ # the method will not filter the results by rejecting the classes 'ActiveRecord::Base', 'Object', 'BasicObject', 'WashOut::Type'
116
+ # @see WashoutBuilder::Document::SharedComplexType#get_complex_type_ancestors
117
+ #
118
+ # @param [Class, String] class_name the name of the on object that is used to fetch his ancestors
119
+ # @return [Array<Class>] Returns an array with all the classes from each the object inherits from but filters the results and removes the classes
120
+ # 'ActiveRecord::Base', 'Object', 'BasicObject', 'WashOut::Type'
121
+ # @api public
86
122
  def get_ancestors(class_name)
87
123
  param_class = begin
88
124
  class_name.is_a?(Class) ? class_name : class_name.constantize
@@ -96,6 +132,14 @@ module WashoutBuilder
96
132
  end
97
133
  end
98
134
 
135
+ # Method used to fetch the descendants of the current object
136
+ # @see #get_nested_complex_types
137
+ # @see WashOutParam#struct?
138
+ #
139
+ # @param [WashOut::SoapConfig] config an object that holds the soap configuration
140
+ # @param [Array<Hash>] defined An Array with all the complex types that have been detected till now
141
+ # @return [Array<Hash>] An array with all the complex types that
142
+ # @api public
99
143
  def complex_type_descendants(config, defined)
100
144
  if struct?
101
145
  c_names = []
@@ -105,6 +149,17 @@ module WashoutBuilder
105
149
  defined
106
150
  end
107
151
 
152
+ # Recursive method that tries to identify all the nested descendants of the current object
153
+ # @see #find_complex_class_name
154
+ # @see #fix_descendant_wash_out_type
155
+ # @see #complex_type_hash
156
+ # @see #complex_type_ancestors
157
+ # @see #complex_type_descendants
158
+ #
159
+ # @param [WashOut::SoapConfig] config holds the soap configuration
160
+ # @param [Array<Hash>] defined An array with all the complex type structures that have been detected so far
161
+ # @return [Array<Hash>] An array with all the complex type that have been detected while iterating to all the descendants of the current object and also contains the previous ones
162
+ # @api public
108
163
  def get_nested_complex_types(config, defined)
109
164
  defined = [] if defined.blank?
110
165
  complex_class = find_complex_class_name(defined)
@@ -116,10 +171,23 @@ module WashoutBuilder
116
171
  defined.sort_by { |hash| hash[:class].to_s.downcase }.uniq unless defined.blank?
117
172
  end
118
173
 
174
+ # method that constructs the a hash with the name of the ancestor ( the class name) and as value its elemen structure
175
+ # @see WashOut::Type#wash_out_param_map
176
+ #
177
+ # @param [WashoutType] ancestors The class that inherits from WashoutType
178
+ # @return [Hash] A hash that has as a key the class name in downcase letters and as value the mapping of the class attributes
179
+ # @api public
119
180
  def ancestor_structure(ancestors)
120
181
  { ancestors[0].to_s.downcase => ancestors[0].wash_out_param_map }
121
182
  end
122
183
 
184
+ # Constructs the complex type information wuth its name, with the object itself and his ancestors
185
+ #
186
+ # @param [Class] class_name The name of the class
187
+ # @param [WashOut::Param] object The object itself
188
+ # @param [Array<Class>] ancestors An array with all the ancestors that the object inherits from
189
+ # @return [Hash] A hash with that contains the params sent to the method
190
+ # @api public
123
191
  def complex_type_hash(class_name, object, ancestors)
124
192
  {
125
193
  class: class_name,
@@ -128,6 +196,17 @@ module WashoutBuilder
128
196
  }
129
197
  end
130
198
 
199
+ # A recursive method that fetches the ancestors of a given class (that inherits from WashoutType)
200
+ # @see #get_ancestors
201
+ # @see WashOut::Param#parse_def
202
+ # @see #same_structure_as_ancestor?
203
+ # @see #complex_type_hash
204
+ #
205
+ # @param [WashOut::SoapConfig] config holds the soap configuration
206
+ # @param [Class] class_name The name of the class that is used for fetching the ancestors
207
+ # @param [Array<Hash>] defined An Array with all the complex types that have been detected so far
208
+ # @return [Array<Class>] An Array of classes from which the class that is sent as parameter inherits from
209
+ # @api public
131
210
  def get_class_ancestors(config, class_name, defined)
132
211
  ancestors = get_ancestors(class_name)
133
212
  return if ancestors.blank?
@@ -1,6 +1,7 @@
1
1
  require_relative './shared_complex_type'
2
2
  module WashoutBuilder
3
3
  module Document
4
+ # the class that is used for soap exceptions to build structure and find ancestors and descendants
4
5
  module ExceptionModel
5
6
  extend ActiveSupport::Concern
6
7
  include WashoutBuilder::Document::SharedComplexType
@@ -9,6 +10,16 @@ module WashoutBuilder
9
10
  base.send :include, WashoutBuilder::Document::SharedComplexType
10
11
  end
11
12
 
13
+ # A recursive function that retrives all the ancestors of the current exception class
14
+ # @see #fault_ancestors
15
+ # @see #fault_ancestor_hash
16
+ # @see #find_fault_model_structure
17
+ # @see #fault_without_inheritable_elements
18
+ #
19
+ # @param [Array<Hash>] defined An array that contains all the information about all the exception classes found so far
20
+ # @param [Boolean] _debug = false An optional parameter used for debugging purposes
21
+ # @return [Array<Class>] Array with all the exception classes from which the current exception class inherits from
22
+ # @api public
12
23
  def get_fault_class_ancestors(defined, _debug = false)
13
24
  bool_the_same = false
14
25
  ancestors = fault_ancestors
@@ -21,22 +32,52 @@ module WashoutBuilder
21
32
  ancestors unless bool_the_same
22
33
  end
23
34
 
35
+ # Removes the inheritable elements from current object that are inherited from the class send as argument
36
+ # @see #remove_fault_type_inheritable_elements
37
+ #
38
+ # @param [Class] ancestors describe ancestors
39
+ # @return [Type] description of returned object
40
+ # @api public
24
41
  def fault_without_inheritable_elements(ancestors)
25
42
  remove_fault_type_inheritable_elements(ancestors[0].find_fault_model_structure.keys)
26
43
  end
27
44
 
45
+ # Retrieves all the ancestors of the current exception class except ActiveRecord::Base', 'Object', 'BasicObject', 'Exception'
46
+ #
47
+ # @return [Array<Class>] Returns an array with all the classes from which the current exception class inherits from
48
+ # @api public
28
49
  def fault_ancestors
29
50
  get_complex_type_ancestors(self, ['ActiveRecord::Base', 'Object', 'BasicObject', 'Exception'])
30
51
  end
31
52
 
53
+ # constructs the structure of the current exception class by holding the instance, the structure, and its ancestors
54
+ #
55
+ # @param [Hash] structure A hash that contains the structure of the current exception class (@see #find_fault_model_structure)
56
+ # @param [Array<Class>] ancestors An array with all the exception classes from which the current object inherits from
57
+ # @return [Hash] options The hash that contains information about the current exception class
58
+ # @option options [WashoutBuilder::Document::ExceptionModel] :fault The current exception class that extends WashoutBuilder::Document::ExceptionModel
59
+ # @option options [Hash]:structure An hash that contains as keys the atribute names and as value the primitive and member type of that attributre
60
+ # @option options [Array<Class>] :ancestors An array with all the classes from which current class is inheriting from
61
+ # @api public
32
62
  def fault_ancestor_hash(structure, ancestors)
33
63
  { fault: self, structure: structure, ancestors: ancestors }
34
64
  end
35
65
 
66
+ # Removes the atributes that are send as argument
67
+ # @see #find_fault_model_structure
68
+ #
69
+ # @param [Array<String>] keys The keys that have to be removed from the model structure
70
+ # @return [Hash] An hash that contains as keys the atribute names and as value the primitive and member type of that attribute
71
+ # @api public
36
72
  def remove_fault_type_inheritable_elements(keys)
37
73
  find_fault_model_structure.delete_if { |key, _value| keys.include?(key) }
38
74
  end
39
75
 
76
+ # Dirty hack to determine if a method has both a setter and a getter and not basic method inherited from Object class
77
+ #
78
+ # @param [String] method The method thats needs to be verified
79
+ # @return [Boolean] Returns true if current class responds to the method and has both a setter and a getter for that method and the method is not inherited from Object class
80
+ # @api public
40
81
  def check_valid_fault_method?(method)
41
82
  method != :== && method != :! &&
42
83
  (instance_methods.include?(:"#{method}=") ||
@@ -44,6 +85,10 @@ module WashoutBuilder
44
85
  )
45
86
  end
46
87
 
88
+ # tries to fins all instance methods that have both a setter and a getter of the curent class
89
+ # @see #check_valid_fault_method?
90
+ # @return [Array<String>] An array with all the atrributes and instance methods that have both a setter and a getter
91
+ # @api public
47
92
  def find_fault_attributes
48
93
  attrs = []
49
94
  attrs = instance_methods(nil).map do |method|
@@ -53,6 +98,11 @@ module WashoutBuilder
53
98
  attrs.concat(%w(message backtrace))
54
99
  end
55
100
 
101
+ # Dirty hack to get the type of an atribute. Considering all other attributes as string type
102
+ #
103
+ # @param [String] method_name The name of the attribute to use
104
+ # @return [String] Returns the type of the attribute , Currently returns "integer" for attribute "code" and "string" for all others
105
+ # @api public
56
106
  def get_fault_type_method(method_name)
57
107
  case method_name.to_s.downcase
58
108
  when 'code'
@@ -64,6 +114,12 @@ module WashoutBuilder
64
114
  end
65
115
  end
66
116
 
117
+ # Description of method
118
+ # @see #find_fault_attributes
119
+ # @see #get_fault_type_method
120
+ #
121
+ # @return [Hash] An hash that contains as keys the atribute names and as value the primitive and member type of that attribute
122
+ # @api public
67
123
  def find_fault_model_structure
68
124
  h = {}
69
125
  find_fault_attributes.each do |method_name|
@@ -1,9 +1,26 @@
1
1
  require_relative './exception_model'
2
2
  module WashoutBuilder
3
3
  module Document
4
+ # class that is used to generate HTML documentation for a soap service
4
5
  class Generator
6
+ # class that is used to generate HTML documentation for a soap service
7
+ #
8
+ # @!attribute soap_actions
9
+ # @return [Hash] Hash that contains all the actions to which the web service responds to and information about them
10
+ #
11
+ # @!attribute config
12
+ # @return [WashOut::SoapConfig] holds the soap configuration for the soap service
13
+ #
14
+ # @!attribute controller_name
15
+ # @return [String] The name of the controller that acts like a soap service
5
16
  attr_accessor :soap_actions, :config, :controller_name
6
17
 
18
+ # Method used to initialize the instance of object
19
+ # @see #controller_class
20
+ #
21
+ # @param [String] controller The name of the controller that acts like a soap service
22
+ # @return [void]
23
+ # @api public
7
24
  def initialize(controller)
8
25
  controller_class_name = controller_class(controller)
9
26
  self.config = controller_class_name.soap_config
@@ -11,34 +28,69 @@ module WashoutBuilder
11
28
  self.controller_name = controller
12
29
  end
13
30
 
31
+ # Returns the namespace used for the controller by using the soap configuration of the controller
32
+ #
33
+ # @return [String] description of returned object
34
+ # @api public
14
35
  def namespace
15
36
  config.respond_to?(:namespace) ? config.namespace : nil
16
37
  end
17
38
 
39
+ # Retrives the class of the controller by using its name
40
+ #
41
+ # @param [String] controller The name of the controller
42
+ # @return [Class] Returns the class of the controller
43
+ # @api public
18
44
  def controller_class(controller)
19
45
  "#{controller}_controller".camelize.constantize
20
46
  end
21
47
 
48
+ # Retrieves the endpoint of the soap service based on its namespace
49
+ # @see #namespace
50
+ #
51
+ # @return [String] Returns the current soap service's endpoint based on its namespace
52
+ # @api public
22
53
  def endpoint
23
54
  namespace.blank? ? nil : namespace.gsub('/wsdl', '/action')
24
55
  end
25
56
 
57
+ # Returns the service name using camelcase letter
58
+ #
59
+ # @return [String] Returns the service name using camelcase letter
60
+ # @api public
26
61
  def service
27
62
  controller_name.blank? ? nil : controller_name.camelize
28
63
  end
29
64
 
65
+ # Returns the service description if the service can respond to description method
66
+ #
67
+ # @return [String] Returns the service description if the service can respond to description method
68
+ # @api public
30
69
  def service_description
31
70
  config.respond_to?(:description) ? config.description : nil
32
71
  end
33
72
 
73
+ # returns a collection of all operation that the service responds to
74
+ #
75
+ # @return [Array<String>] returns a collection of all operation that the service responds to
76
+ # @api public
34
77
  def operations
35
78
  soap_actions.map { |operation, _formats| operation }
36
79
  end
37
80
 
81
+ # returns the operations of a service by sorting them alphabetically and removes duplicates
82
+ #
83
+ # @return [Array<String>] returns a collection of all operation that the service responds to sorted alphabetically
84
+ # @api public
38
85
  def sorted_operations
39
86
  soap_actions.sort_by { |operation, _formats| operation.downcase }.uniq unless soap_actions.blank?
40
87
  end
41
88
 
89
+ # Returns the exceptions that a specific operation can raise
90
+ #
91
+ # @param [String] operation_name describe operation_name
92
+ # @return [Array<Class>] returns an array with all the exception classes that the operation send as argument can raise
93
+ # @api public
42
94
  def operation_exceptions(operation_name)
43
95
  hash_object = soap_actions.find { |operation, _formats| operation.to_s.downcase == operation_name.to_s.downcase }
44
96
  return if hash_object.blank?
@@ -47,10 +99,23 @@ module WashoutBuilder
47
99
  faults.select { |x| WashoutBuilder::Type.valid_fault_class?(x) }
48
100
  end
49
101
 
102
+ # Sorts a hash by a key alphabetically
103
+ #
104
+ # @param [Hash] types Any kind of hash
105
+ # @option types [String, Symbol] :type The name of the key should be the same as the second argument
106
+ # @param [String, Symbol] type The key that is used for sorting alphabetically
107
+ # @return [Hash] options Same hash sorted alphabetically by the specified key and without duplicates
108
+ # @option options [String, Symbol] :type The name of the key should be the same as the second argument
109
+ # @api public
50
110
  def sort_complex_types(types, type)
51
111
  types.sort_by { |hash| hash[type.to_sym].to_s.downcase }.uniq { |hash| hash[type.to_sym] } unless types.blank?
52
112
  end
53
113
 
114
+ # Returns either the input arguments of a operation or the output types of that operation depending on the argument
115
+ #
116
+ # @param [String] type The type of the arguments that need to be returned ("input" or anything else )
117
+ # @return [Array<WashOutParam>, Array<Error>] If the argument is "input" will return the arguments of the operation , ottherwise the return type
118
+ # @api public
54
119
  def argument_types(type)
55
120
  format_type = (type == 'input') ? 'builder_in' : 'builder_out'
56
121
  types = []
@@ -64,18 +129,35 @@ module WashoutBuilder
64
129
  types
65
130
  end
66
131
 
132
+ # Returns the arguments of all operations
133
+ # @see #argument_types
134
+ # @return [Array<WashOut::Param>] An array with all the arguments types of all operations the service responds to
135
+ # @api public
67
136
  def input_types
68
137
  argument_types('input')
69
138
  end
70
139
 
140
+ # Returns the arguments of all operations
141
+ # @see #argument_types
142
+ # @return [Array<Error>] An array with all the exceptions that all operations can raise
143
+ # @api public
71
144
  def output_types
72
145
  argument_types('output')
73
146
  end
74
147
 
148
+ # Returns the names of all operations sorted alphabetically
149
+ #
150
+ # @return [Array<String>] An array with all the names of all operations sorted alphabetically
151
+ # @api public
75
152
  def all_soap_action_names
76
153
  operations.map(&:to_s).sort_by(&:downcase).uniq unless soap_actions.blank?
77
154
  end
78
155
 
156
+ # Returns all the complex types sorted alphabetically
157
+ # @see WashoutBuilder::Document::ComplexType#get_nested_complex_types
158
+
159
+ # @return [Array<WashOut::Param>] Returns an array with all the complex types sorted alphabetically
160
+ # @api public
79
161
  def complex_types
80
162
  defined = []
81
163
  (input_types + output_types).each do |p|
@@ -84,18 +166,38 @@ module WashoutBuilder
84
166
  defined = sort_complex_types(defined, 'class')
85
167
  end
86
168
 
169
+ # Returns an array with all the operations that can raise an exception at least or more
170
+ #
171
+ # @return [Array<String>] Returns an array with all the names of all operations that can raise an exception or more
172
+ # @api public
87
173
  def actions_with_exceptions
88
174
  soap_actions.select { |_operation, formats| !formats[:raises].blank? }
89
175
  end
90
176
 
177
+ # Returns all the exception raised by all operations
178
+ # @see #actions_with_exceptions
179
+ #
180
+ # @return [Array<Class>] Returns an array with all the exception classes that are raised by all operations
181
+ # @api public
91
182
  def exceptions_raised
92
183
  actions_with_exceptions.map { |_operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten
93
184
  end
94
185
 
186
+ # Fiters the exceptions raised by checking if they classes inherit from WashOout::SoapError
187
+ # @see #exceptions_raised
188
+ # @return [Array<Class>] returns the exceptions that are raised by all operations filtering only the ones that inherit from WashOut::SoapError
189
+ # @api public
95
190
  def filter_exceptions_raised
96
191
  exceptions_raised.select { |x| WashoutBuilder::Type.valid_fault_class?(x) } unless actions_with_exceptions.blank?
97
192
  end
98
193
 
194
+ # Retuens all the exception classes that can be raised by all operations with their ancestors also
195
+ # @see #filter_exceptions_raised
196
+ # @see WashoutBuilder::Document::ExceptionModel#get_fault_class_ancestors
197
+ #
198
+ # @param [Array<Class>] base_fault_array An array with the base exception classes from which we try to identify their ancestors
199
+ # @return [Array>Class>] Returns all the exception classes that can be raised by all operations with their ancestors also
200
+ # @api public
99
201
  def get_complex_fault_types(base_fault_array)
100
202
  fault_types = []
101
203
  defined = filter_exceptions_raised
@@ -104,6 +206,13 @@ module WashoutBuilder
104
206
  fault_types
105
207
  end
106
208
 
209
+ # Returns all the exception classes raised by all operations sorted alphabetically
210
+ # @see WashoutBuilder::Type#all_fault_classes
211
+ # @see #get_complex_fault_types
212
+ # @see #sort_complex_types
213
+ #
214
+ # @return [Array<Class>] Returns all the exception classes that can be raised by all operations with their ancestors also sorted alphabetically
215
+ # @api public
107
216
  def fault_types
108
217
  base_fault = [WashoutBuilder::Type.all_fault_classes.first]
109
218
  fault_types = get_complex_fault_types(base_fault)
@@ -1,6 +1,12 @@
1
1
  module WashoutBuilder
2
2
  module Document
3
+ # module that is used for both complex types and exception class to find their ancestors and filter out some of the ancestors
3
4
  module SharedComplexType
5
+ # Method that is used to fetch the ancestors of a class and fiter the ancestors that are present in the second argument
6
+ #
7
+ # @param [Class] class_name The class that is used to fetch the ancestors for
8
+ # @param [Array<Class>] array The array of classes that should be fitered from the ancestors if they are present
9
+ # @return [Array<Class>] The classes from which the class given as first argument inherits from but filtering the classes passed as second argument
4
10
  def get_complex_type_ancestors(class_name, array)
5
11
  (class_name.ancestors - class_name.included_modules).delete_if { |x| x.to_s.downcase == class_name.to_s.downcase || array.include?(x.to_s) }
6
12
  end
@@ -1,4 +1,5 @@
1
1
  module WashoutBuilder
2
+ # the engine that is used to mount inside the rails application
2
3
  class Engine < ::Rails::Engine
3
4
  isolate_namespace WashoutBuilder
4
5
  initializer 'washout_builder.configuration' do |_app|
@@ -1,13 +1,24 @@
1
1
  require 'active_support/concern'
2
2
 
3
3
  module WashoutBuilder
4
+ # the module that is used for soap actions to parse their definition and hold the infoirmation about
5
+ # their arguments and return types
4
6
  module SOAP
5
7
  extend ActiveSupport::Concern
6
8
  include WashOut::SOAP if defined?(WashOut::SOAP)
7
9
  include WashOut::Rails::Controller if defined?(WashOut::Rails::Controller)
8
10
 
11
+ # module that is used to define a soap action for a controller
9
12
  module ClassMethods
13
+ # module that is used to define a soap action for a controller
14
+ #
15
+ # @!attribute soap_actions
16
+ # @return [Hash] Hash that contains all the actions to which the web service responds to and information about them
17
+ #
18
+ # @!attribute washout_builder_action
19
+ # @return [String] holds the action of the controller
10
20
  attr_accessor :soap_actions, :washout_builder_action
21
+
11
22
  # Define a SOAP action +action+. The function has two required +options+:
12
23
  # :args and :return. Each is a type +definition+ of format described in
13
24
  # WashOut::Param#parse_def.
@@ -1,7 +1,13 @@
1
1
  module WashoutBuilder
2
+ # class that is used to define the basic types and the basic exception classes that should be considered
2
3
  class Type
4
+ # the basic types that are considered when checking an object type
3
5
  BASIC_TYPES = %w(string integer double boolean date datetime float time int)
4
6
 
7
+ # returns all the exception classes that should be considered to be detected
8
+ #
9
+ # @return [Array<Class>] returns all the exception classes that should be considered to be detected
10
+ # @api public
5
11
  def self.all_fault_classes
6
12
  faults = []
7
13
  faults << WashOut::SOAPError if defined?(WashOut::SOAPError)
@@ -10,10 +16,21 @@ module WashoutBuilder
10
16
  faults
11
17
  end
12
18
 
19
+ # Checks if a exception class inherits from the basic ones
20
+ # @see #all_fault_classes
21
+ #
22
+ # @param [Class] fault_class the exception class that needs to be checks if has as ancestor one of the base classes
23
+ # @return [Boolean] Returns true if the class inherits from the basic classes or false otherwise
24
+ # @api public
13
25
  def self.ancestor_fault?(fault_class)
14
26
  fault_class.ancestors.find { |fault| all_fault_classes.include?(fault) }.present?
15
27
  end
16
28
 
29
+ # Checks if a exception class is valid, by checking if either is a basic exception class or has as ancerstor one ot the base classes
30
+ #
31
+ # @param [Class] fault The exception class that needs to be checks if has as ancestor one of the base classes or is one of them
32
+ # @return [Boolean] Returns true if the class inherits from the basic classes or is one of them, otherwise false
33
+ # @api public
17
34
  def self.valid_fault_class?(fault)
18
35
  fault.is_a?(Class) && (ancestor_fault?(fault) || all_fault_classes.include?(fault))
19
36
  end
@@ -1,14 +1,22 @@
1
- module WashoutBuilder # Returns the version of the currently loaded Rails as a <tt>Gem::Version</tt>
1
+ # Returns the version of the currently loaded gem as a <tt>Gem::Version</tt>
2
+ module WashoutBuilder
3
+ # Returns the version of the currently loaded gem as a <tt>Gem::Version</tt>
2
4
  def self.gem_version
3
5
  Gem::Version.new VERSION::STRING
4
6
  end
5
7
 
8
+ # the module that is used to generate the gem version
6
9
  module VERSION
10
+ # the major version of the gem
7
11
  MAJOR = 0
12
+ # the minor version of the gem
8
13
  MINOR = 16
9
- TINY = 1
14
+ # the tiny version of the gem
15
+ TINY = 2
16
+ # if the version should be a e
10
17
  PRE = nil
11
18
 
19
+ # the full version of the gem composed from major minor tiny and prerelease versions
12
20
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
13
21
  end
14
22
  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.16.1
4
+ version: 0.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada