Skip to content

Commit

Permalink
Version 2.0.0 - stable
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Feb 29, 2020
1 parent 2922268 commit 1e244c5
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 86 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ end

If you don't set them and they are left with default nil values, you will have to use the old way, by manually mount the engine in the Rails routes configuration file (**config/routes.rb**) by following examples below.

NEW Improvements in version 2.0.0
---------------------------------

This release tries to fix some major bugs and introduces backward incompatible changes.
- The complex type list will contain now exactly same types used when doing an actual SOAP request
- Same for when listing the soap actions ( the return type and parameters ).

Initially the way the complex types were shown on the page was not correct, because it was not reflecting
the actual way the SOAP action receives its arguments when doing an actual SOAP request to that controller

The main issue was not handling correctly the classes that are inheriting from WashOut::Type.

This release tries to fix those issues.


NEW Improvements in version 1.4.0
---------------------------------

Expand Down
6 changes: 4 additions & 2 deletions app/helpers/washout_builder_complex_type_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# module that is used for constructing complex types in HTML-Documentation
module WashoutBuilderComplexTypeHelper
include WashoutBuilderSharedHelper
# this method is for printing the attributes of a complex type
# if the attributes are primitives this will show the attributes with blue color
# otherwise will call another method for printing the complex attribute
Expand Down Expand Up @@ -49,8 +50,9 @@ def html_safe(string)
def create_complex_element_type_html(pre, element, element_description)
complex_class = element.find_complex_class_name
return if complex_class.nil?
complex_class_content = element.multiplied ? "Array of #{complex_class}" : "#{complex_class}"
pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class_content}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
real_class = find_correct_complex_type(complex_class)
complex_class_content = element.multiplied ? "Array of #{real_class}" : "#{real_class}"
pre << "<a href='##{real_class}'><span class='lightBlue'>#{complex_class_content}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
pre << "&#8194;<span>#{html_safe(element_description)}</span>" unless element_description.blank?
pre
end
Expand Down
6 changes: 4 additions & 2 deletions app/helpers/washout_builder_method_arguments_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# helper that is used to show the arguments of a method with their types in HTML documentation
module WashoutBuilderMethodArgumentsHelper
include WashoutBuilderSharedHelper
# displays the parameter of a method as argument and determines if the parameter is basic type or complex type
#
# @see WashoutBuilder::Document::ComplexType#find_complex_class_name
Expand Down Expand Up @@ -37,8 +38,9 @@ def create_method_argument_element(pre, param, mlen)
# @api public
def create_method_argument_complex_element(pre, param, use_spacer, spacer, complex_class)
return if complex_class.nil?
argument_content = param.multiplied ? "Array of #{complex_class}" : "#{complex_class}"
pre << "#{use_spacer ? spacer : ''}<a href='##{complex_class}'><span class='lightBlue'>#{argument_content}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
real_class = find_correct_complex_type(complex_class)
argument_content = param.multiplied ? "Array of #{real_class}" : "#{real_class}"
pre << "#{use_spacer ? spacer : ''}<a href='##{real_class}'><span class='lightBlue'>#{argument_content}</span></a>&nbsp;<span class='bold'>#{param.name}</span>"
end

# this method will check if the current index of the argument is not last, will insert a comma then a break if the argument is followed by other arguments,
Expand Down
6 changes: 4 additions & 2 deletions app/helpers/washout_builder_method_list_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# helper that is used to list the method's return tyep as a LI element in HTML documentation
module WashoutBuilderMethodListHelper
include WashoutBuilderSharedHelper
# this method will create the return type of the method and check if the type is basic or complex type or array of types
#
# @param [Builder::XmlMarkup] xml the markup builder that is used to insert HTML line breaks or span elements
Expand All @@ -10,9 +11,10 @@ module WashoutBuilderMethodListHelper
#
# @api public
def create_return_complex_type_list_html(xml, complex_class, builder_out)
return_content = builder_out[0].multiplied ? "Array of #{complex_class}" : "#{complex_class}"
real_class = find_correct_complex_type(complex_class)
return_content = builder_out[0].multiplied ? "Array of #{real_class}" : "#{real_class}"
xml.span('class' => 'pre') do
xml.a('href' => "##{complex_class}") do |inner_xml|
xml.a('href' => "##{real_class}") do |inner_xml|
inner_xml.span('class' => 'lightBlue') do |y|
y << "#{return_content}"
end
Expand Down
8 changes: 5 additions & 3 deletions app/helpers/washout_builder_method_return_type_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# helper that is used to create the return types of methods in HTML documentation
module WashoutBuilderMethodReturnTypeHelper
include WashoutBuilderSharedHelper
# this method will print the return type next to the method name
# @see WashoutBuilder::Document::ComplexType#find_complex_class_name
# @see WashoutBuilder::Type::BASIC_TYPES
Expand Down Expand Up @@ -37,11 +38,12 @@ def create_html_public_method_return_type(xml, pre, output)
# @api public
def html_public_method_complex_type(pre, output, complex_class)
return if complex_class.nil?
real_class = find_correct_complex_type(complex_class)
if output[0].multiplied
complex_return_type = "Array of #{complex_class}"
complex_return_type = "Array of #{real_class}"
else
complex_return_type = "#{complex_class}"
complex_return_type = "#{real_class}"
end
pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_return_type}</span></a>"
pre << "<a href='##{real_class}'><span class='lightBlue'>#{complex_return_type}</span></a>"
end
end
29 changes: 29 additions & 0 deletions app/helpers/washout_builder_shared_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module WashoutBuilderSharedHelper
# When displaying a complex type that inherits from WashOut::Type
# we must use its descendant name to properly show the correct Type
# that can we used to make the actual request to the action
#
# @param [Class, String] complex_class the name of the complex type either as a string or a class
# @return [Class, String]
# @api public
def find_correct_complex_type(complex_class)
real_class = find_class_from_string(complex_class)
if real_class.present? && real_class.ancestors.include?( WashoutBuilder::Type.base_type_class)
descendant = WashoutBuilder::Type.base_param_class.parse_def(config, real_class.wash_out_param_map)[0]
descendant.find_complex_class_name
else
complex_class
end
end

# Tries to constantize a string or a class to return the class
#
# @param [String] complex_class A string that contains the name of a class
# @return [Class, nil] returns the class if it is classes_defined otherwise nil
# @api public
def find_class_from_string(complex_class)
complex_class.is_a?(Class) ? complex_class : complex_class.constantize
rescue
nil
end
end
1 change: 0 additions & 1 deletion lib/washout_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def wash_out(controller_name, options={})
base_param_class = WashoutBuilder::Type.base_param_class
if base_param_class.present?
base_param_class.class_eval do
extend WashoutBuilder::Param
include WashoutBuilder::Document::ComplexType
end
end
Expand Down
23 changes: 2 additions & 21 deletions lib/washout_builder/document/complex_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,6 @@ def remove_type_inheritable_elements(keys)
self.map = map.delete_if { |element| keys.include?(element.name) }
end

# Dirty hack to fix the first washout param type.
# This only applies if the first complex type is inheriting WashOutType
# its name should be set to its descendant and the map of the current object will be set to its descendant
# @see WashOut::Param#parse_builder_def
#
# @param [WashOut::SoapConfig] config an object that holds the soap configuration
# @param [Class, String] complex_class the name of the complex type either as a string or a class
# @return [void]
# @api public
def fix_descendant_wash_out_type(config, complex_class)
param_class = find_class_from_string(complex_class)
base_param_class = WashoutBuilder::Type.base_param_class
base_type_class = WashoutBuilder::Type.base_type_class
return if base_param_class.blank? || base_type_class.blank?
return unless param_class.present? && param_class.ancestors.include?(base_type_class) && map[0].present?
descendant = base_param_class.parse_builder_def(config, param_class.wash_out_param_map)[0]
self.name = descendant.name
self.map = descendant.map
end

# Description of method
#
Expand Down Expand Up @@ -172,8 +153,8 @@ def complex_type_descendants(config, classes_defined)
def get_nested_complex_types(config, classes_defined)
classes_defined = [] if classes_defined.blank?
complex_class = find_complex_class_name(classes_defined)
fix_descendant_wash_out_type(config, complex_class)
unless complex_class.nil?
real_class = find_class_from_string(complex_class)
if complex_class.present? && (real_class.blank? || (real_class.present? && !real_class.ancestors.include?( WashoutBuilder::Type.base_type_class)))
classes_defined << complex_type_hash(complex_class, self, complex_type_ancestors(config, complex_class, classes_defined))
end
classes_defined = complex_type_descendants(config, classes_defined)
Expand Down
50 changes: 0 additions & 50 deletions lib/washout_builder/param.rb

This file was deleted.

4 changes: 2 additions & 2 deletions lib/washout_builder/soap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def builder_soap_action(action, options = {})
current_action = soap_actions[action]
base_param_class = WashoutBuilder::Type.base_param_class
return if base_param_class.blank?
current_action[:builder_in] = base_param_class.parse_builder_def(soap_config, options[:args])
current_action[:builder_out] = base_param_class.parse_builder_def(soap_config, options[:return])
current_action[:builder_in] = base_param_class.parse_def(soap_config, options[:args])
current_action[:builder_out] = base_param_class.parse_def(soap_config, options[:return])
current_action[:args_description] = options[:args_description].present? && options[:args_description].is_a?(Hash) ? options[:args_description].stringify_keys : {}
current_action
end
Expand Down
6 changes: 3 additions & 3 deletions lib/washout_builder/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def self.gem_version
# the module that is used to generate the gem version
module VERSION
# the major version of the gem
MAJOR = 1
MAJOR = 2
# the minor version of the gem
MINOR = 7
MINOR = 0
# the tiny version of the gem
TINY = 5
TINY = 0
# if the version should be a prerelease
PRE = nil

Expand Down

0 comments on commit 1e244c5

Please sign in to comment.