washout_builder 1.7.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/app/helpers/washout_builder_complex_type_helper.rb +4 -2
- data/app/helpers/washout_builder_method_arguments_helper.rb +4 -2
- data/app/helpers/washout_builder_method_list_helper.rb +4 -2
- data/app/helpers/washout_builder_method_return_type_helper.rb +5 -3
- data/app/helpers/washout_builder_shared_helper.rb +29 -0
- data/lib/washout_builder.rb +0 -1
- data/lib/washout_builder/document/complex_type.rb +2 -21
- data/lib/washout_builder/soap.rb +2 -2
- data/lib/washout_builder/version.rb +3 -3
- metadata +3 -3
- data/lib/washout_builder/param.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f24387c3759bd5136368bba80e629f8e86c916fd42c0b97f8108cf3adc89a33
|
4
|
+
data.tar.gz: 0f63bda842effeb14e2fae1847734c9ec62533589d71e58b1b8bb01761a052b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a08d8be0d183473151a22f78d9eca0779f827d69cd6d049cb354070c1012a46015f147cf6b5dc5738e22de99c61e1fe791d5e05ba4021b38a16e01ce6c63587
|
7
|
+
data.tar.gz: fe79fedbef7cafc76fdd0e11e9838c22df2f64470654e65ee367d8f4c34dbb226106ddc05dd366a07de55d68d754d41094c4d73cd37e2d84c7c42fe9a6c24635
|
data/README.md
CHANGED
@@ -37,6 +37,21 @@ end
|
|
37
37
|
|
38
38
|
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.
|
39
39
|
|
40
|
+
NEW Improvements in version 2.0.0
|
41
|
+
---------------------------------
|
42
|
+
|
43
|
+
This release tries to fix some major bugs and introduces backward incompatible changes.
|
44
|
+
- The complex type list will contain now exactly same types used when doing an actual SOAP request
|
45
|
+
- Same for when listing the soap actions ( the return type and parameters ).
|
46
|
+
|
47
|
+
Initially the way the complex types were shown on the page was not correct, because it was not reflecting
|
48
|
+
the actual way the SOAP action receives its arguments when doing an actual SOAP request to that controller
|
49
|
+
|
50
|
+
The main issue was not handling correctly the classes that are inheriting from WashOut::Type.
|
51
|
+
|
52
|
+
This release tries to fix those issues.
|
53
|
+
|
54
|
+
|
40
55
|
NEW Improvements in version 1.4.0
|
41
56
|
---------------------------------
|
42
57
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# module that is used for constructing complex types in HTML-Documentation
|
2
2
|
module WashoutBuilderComplexTypeHelper
|
3
|
+
include WashoutBuilderSharedHelper
|
3
4
|
# this method is for printing the attributes of a complex type
|
4
5
|
# if the attributes are primitives this will show the attributes with blue color
|
5
6
|
# otherwise will call another method for printing the complex attribute
|
@@ -49,8 +50,9 @@ module WashoutBuilderComplexTypeHelper
|
|
49
50
|
def create_complex_element_type_html(pre, element, element_description)
|
50
51
|
complex_class = element.find_complex_class_name
|
51
52
|
return if complex_class.nil?
|
52
|
-
|
53
|
-
|
53
|
+
real_class = find_correct_complex_type(complex_class)
|
54
|
+
complex_class_content = element.multiplied ? "Array of #{real_class}" : "#{real_class}"
|
55
|
+
pre << "<a href='##{real_class}'><span class='lightBlue'>#{complex_class_content}</span></a> <span class='bold'>#{element.name}</span>"
|
54
56
|
pre << " <span>#{html_safe(element_description)}</span>" unless element_description.blank?
|
55
57
|
pre
|
56
58
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# helper that is used to show the arguments of a method with their types in HTML documentation
|
2
2
|
module WashoutBuilderMethodArgumentsHelper
|
3
|
+
include WashoutBuilderSharedHelper
|
3
4
|
# displays the parameter of a method as argument and determines if the parameter is basic type or complex type
|
4
5
|
#
|
5
6
|
# @see WashoutBuilder::Document::ComplexType#find_complex_class_name
|
@@ -37,8 +38,9 @@ module WashoutBuilderMethodArgumentsHelper
|
|
37
38
|
# @api public
|
38
39
|
def create_method_argument_complex_element(pre, param, use_spacer, spacer, complex_class)
|
39
40
|
return if complex_class.nil?
|
40
|
-
|
41
|
-
|
41
|
+
real_class = find_correct_complex_type(complex_class)
|
42
|
+
argument_content = param.multiplied ? "Array of #{real_class}" : "#{real_class}"
|
43
|
+
pre << "#{use_spacer ? spacer : ''}<a href='##{real_class}'><span class='lightBlue'>#{argument_content}</span></a> <span class='bold'>#{param.name}</span>"
|
42
44
|
end
|
43
45
|
|
44
46
|
# 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,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# helper that is used to list the method's return tyep as a LI element in HTML documentation
|
2
2
|
module WashoutBuilderMethodListHelper
|
3
|
+
include WashoutBuilderSharedHelper
|
3
4
|
# this method will create the return type of the method and check if the type is basic or complex type or array of types
|
4
5
|
#
|
5
6
|
# @param [Builder::XmlMarkup] xml the markup builder that is used to insert HTML line breaks or span elements
|
@@ -10,9 +11,10 @@ module WashoutBuilderMethodListHelper
|
|
10
11
|
#
|
11
12
|
# @api public
|
12
13
|
def create_return_complex_type_list_html(xml, complex_class, builder_out)
|
13
|
-
|
14
|
+
real_class = find_correct_complex_type(complex_class)
|
15
|
+
return_content = builder_out[0].multiplied ? "Array of #{real_class}" : "#{real_class}"
|
14
16
|
xml.span('class' => 'pre') do
|
15
|
-
xml.a('href' => "##{
|
17
|
+
xml.a('href' => "##{real_class}") do |inner_xml|
|
16
18
|
inner_xml.span('class' => 'lightBlue') do |y|
|
17
19
|
y << "#{return_content}"
|
18
20
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# helper that is used to create the return types of methods in HTML documentation
|
2
2
|
module WashoutBuilderMethodReturnTypeHelper
|
3
|
+
include WashoutBuilderSharedHelper
|
3
4
|
# this method will print the return type next to the method name
|
4
5
|
# @see WashoutBuilder::Document::ComplexType#find_complex_class_name
|
5
6
|
# @see WashoutBuilder::Type::BASIC_TYPES
|
@@ -37,11 +38,12 @@ module WashoutBuilderMethodReturnTypeHelper
|
|
37
38
|
# @api public
|
38
39
|
def html_public_method_complex_type(pre, output, complex_class)
|
39
40
|
return if complex_class.nil?
|
41
|
+
real_class = find_correct_complex_type(complex_class)
|
40
42
|
if output[0].multiplied
|
41
|
-
complex_return_type = "Array of #{
|
43
|
+
complex_return_type = "Array of #{real_class}"
|
42
44
|
else
|
43
|
-
complex_return_type = "#{
|
45
|
+
complex_return_type = "#{real_class}"
|
44
46
|
end
|
45
|
-
pre << "<a href='##{
|
47
|
+
pre << "<a href='##{real_class}'><span class='lightBlue'>#{complex_return_type}</span></a>"
|
46
48
|
end
|
47
49
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module WashoutBuilderSharedHelper
|
2
|
+
# When displaying a complex type that inherits from WashOut::Type
|
3
|
+
# we must use its descendant name to properly show the correct Type
|
4
|
+
# that can we used to make the actual request to the action
|
5
|
+
#
|
6
|
+
# @param [Class, String] complex_class the name of the complex type either as a string or a class
|
7
|
+
# @return [Class, String]
|
8
|
+
# @api public
|
9
|
+
def find_correct_complex_type(complex_class)
|
10
|
+
real_class = find_class_from_string(complex_class)
|
11
|
+
if real_class.present? && real_class.ancestors.include?( WashoutBuilder::Type.base_type_class)
|
12
|
+
descendant = WashoutBuilder::Type.base_param_class.parse_def(config, real_class.wash_out_param_map)[0]
|
13
|
+
descendant.find_complex_class_name
|
14
|
+
else
|
15
|
+
complex_class
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Tries to constantize a string or a class to return the class
|
20
|
+
#
|
21
|
+
# @param [String] complex_class A string that contains the name of a class
|
22
|
+
# @return [Class, nil] returns the class if it is classes_defined otherwise nil
|
23
|
+
# @api public
|
24
|
+
def find_class_from_string(complex_class)
|
25
|
+
complex_class.is_a?(Class) ? complex_class : complex_class.constantize
|
26
|
+
rescue
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
data/lib/washout_builder.rb
CHANGED
@@ -71,25 +71,6 @@ module WashoutBuilder
|
|
71
71
|
self.map = map.delete_if { |element| keys.include?(element.name) }
|
72
72
|
end
|
73
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
|
83
|
-
def fix_descendant_wash_out_type(config, complex_class)
|
84
|
-
param_class = find_class_from_string(complex_class)
|
85
|
-
base_param_class = WashoutBuilder::Type.base_param_class
|
86
|
-
base_type_class = WashoutBuilder::Type.base_type_class
|
87
|
-
return if base_param_class.blank? || base_type_class.blank?
|
88
|
-
return unless param_class.present? && param_class.ancestors.include?(base_type_class) && map[0].present?
|
89
|
-
descendant = base_param_class.parse_builder_def(config, param_class.wash_out_param_map)[0]
|
90
|
-
self.name = descendant.name
|
91
|
-
self.map = descendant.map
|
92
|
-
end
|
93
74
|
|
94
75
|
# Description of method
|
95
76
|
#
|
@@ -172,8 +153,8 @@ module WashoutBuilder
|
|
172
153
|
def get_nested_complex_types(config, classes_defined)
|
173
154
|
classes_defined = [] if classes_defined.blank?
|
174
155
|
complex_class = find_complex_class_name(classes_defined)
|
175
|
-
|
176
|
-
|
156
|
+
real_class = find_class_from_string(complex_class)
|
157
|
+
if complex_class.present? && (real_class.blank? || (real_class.present? && !real_class.ancestors.include?( WashoutBuilder::Type.base_type_class)))
|
177
158
|
classes_defined << complex_type_hash(complex_class, self, complex_type_ancestors(config, complex_class, classes_defined))
|
178
159
|
end
|
179
160
|
classes_defined = complex_type_descendants(config, classes_defined)
|
data/lib/washout_builder/soap.rb
CHANGED
@@ -37,8 +37,8 @@ module WashoutBuilder
|
|
37
37
|
current_action = soap_actions[action]
|
38
38
|
base_param_class = WashoutBuilder::Type.base_param_class
|
39
39
|
return if base_param_class.blank?
|
40
|
-
current_action[:builder_in] = base_param_class.
|
41
|
-
current_action[:builder_out] = base_param_class.
|
40
|
+
current_action[:builder_in] = base_param_class.parse_def(soap_config, options[:args])
|
41
|
+
current_action[:builder_out] = base_param_class.parse_def(soap_config, options[:return])
|
42
42
|
current_action[:args_description] = options[:args_description].present? && options[:args_description].is_a?(Hash) ? options[:args_description].stringify_keys : {}
|
43
43
|
current_action
|
44
44
|
end
|
@@ -8,11 +8,11 @@ module WashoutBuilder
|
|
8
8
|
# the module that is used to generate the gem version
|
9
9
|
module VERSION
|
10
10
|
# the major version of the gem
|
11
|
-
MAJOR =
|
11
|
+
MAJOR = 2
|
12
12
|
# the minor version of the gem
|
13
|
-
MINOR =
|
13
|
+
MINOR = 0
|
14
14
|
# the tiny version of the gem
|
15
|
-
TINY =
|
15
|
+
TINY = 0
|
16
16
|
# if the version should be a prerelease
|
17
17
|
PRE = nil
|
18
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: washout_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wash_out
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- app/helpers/washout_builder_method_arguments_helper.rb
|
63
63
|
- app/helpers/washout_builder_method_list_helper.rb
|
64
64
|
- app/helpers/washout_builder_method_return_type_helper.rb
|
65
|
+
- app/helpers/washout_builder_shared_helper.rb
|
65
66
|
- app/views/wash_with_html/_complex_type.builder
|
66
67
|
- app/views/wash_with_html/_fault_type.builder
|
67
68
|
- app/views/wash_with_html/_public_method.builder
|
@@ -92,7 +93,6 @@ files:
|
|
92
93
|
- lib/washout_builder/document/shared_complex_type.rb
|
93
94
|
- lib/washout_builder/engine.rb
|
94
95
|
- lib/washout_builder/env_checker.rb
|
95
|
-
- lib/washout_builder/param.rb
|
96
96
|
- lib/washout_builder/router.rb
|
97
97
|
- lib/washout_builder/soap.rb
|
98
98
|
- lib/washout_builder/type.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module WashoutBuilder
|
2
|
-
# module that extends the base WashoutParam to allow parsing of definitions for building documentation
|
3
|
-
module Param
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
# Method that receives the arguments for a soap action (input or output) and tries to parse the definition (@see WashOutParam#parse_def)
|
7
|
-
#
|
8
|
-
# the following lines was removed from original method because when generating the documentation
|
9
|
-
# the "source_class" attrtibute of the object was not the name of the class of the complex tyoe
|
10
|
-
# but instead was the name given in the hash
|
11
|
-
#
|
12
|
-
# if definition.is_a?(Class) && definition.ancestors.include?(WashOut::Type)
|
13
|
-
# definition = definition.wash_out_param_map
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# @example Given the class ProjectType as a "definition" argument, the complex type name should be ProjectType and not "project"
|
17
|
-
# class ProjectType < WashOut::Type
|
18
|
-
# map :project => {
|
19
|
-
# :name => :string,
|
20
|
-
# :description => :string,
|
21
|
-
# :users => [{:mail => :string }],
|
22
|
-
# }
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# @see WashoutBuilder::SOAP#soap_action
|
27
|
-
# @see WashOutParam#initialize
|
28
|
-
#
|
29
|
-
# @param [WasOut::SoapConfig] soap_config Holds the soap configuration for the entire web service
|
30
|
-
# @param [Object] definition Any type of object ( this is passed from the soap action)
|
31
|
-
#
|
32
|
-
# @return [Type] description of returned object
|
33
|
-
def parse_builder_def(soap_config, definition)
|
34
|
-
raise '[] should not be used in your params. Use nil if you want to mark empty set.' if definition == []
|
35
|
-
return [] if definition.blank?
|
36
|
-
|
37
|
-
definition = { value: definition } unless definition.is_a?(Hash) # for arrays and symbols
|
38
|
-
|
39
|
-
definition.map do |name, opt|
|
40
|
-
if opt.is_a? self
|
41
|
-
opt
|
42
|
-
elsif opt.is_a? Array
|
43
|
-
new(soap_config, name, opt[0], true)
|
44
|
-
else
|
45
|
-
new(soap_config, name, opt)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|