washout_builder 0.15.8 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/washout_builder/washout_builder_controller.rb +74 -6
- data/app/helpers/washout_builder_complex_type_helper.rb +19 -0
- data/app/helpers/washout_builder_fault_type_helper.rb +59 -0
- data/app/helpers/washout_builder_method_arguments_helper.rb +46 -0
- data/app/helpers/washout_builder_method_list_helper.rb +21 -1
- data/app/helpers/washout_builder_method_return_type_helper.rb +22 -0
- data/app/views/wash_with_html/_complex_type.builder +3 -3
- data/lib/washout_builder/document/complex_type.rb +30 -5
- data/lib/washout_builder/soap.rb +7 -1
- data/lib/washout_builder/version.rb +2 -2
- data/spec/app/helpers/washout_builder_method_list_helper_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- data/washout_builder.gemspec +5 -5
- metadata +6 -8
- data/spec/support/fix_minitest.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1c2aab790ac673d734f1ee42eb6f963e28076f5
|
4
|
+
data.tar.gz: b36593c650e341398e4291a2c3a72910b83b61e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9441ed5ed24a575495ab3b7d81df35db6f38026f593cde6e2111fea264af5403bc8120949932f6643c1f84cd8549084104c2aa4ed9df0d30c47e04c8c61987df
|
7
|
+
data.tar.gz: c7d5b37ec709f09b289d656192d35825aabcb58ea6fe6ef9bc0d6beccec276282e52df75b545b334423864c1d0a76a4b3694a882e32ae4ee2aac55cdc0bf7bf3
|
@@ -1,12 +1,19 @@
|
|
1
1
|
require_relative '../../../lib/washout_builder/document/generator'
|
2
2
|
module WashoutBuilder
|
3
|
+
# controller that is used to prit all available services or print the documentation for a specific service
|
3
4
|
class WashoutBuilderController < ActionController::Base
|
4
5
|
protect_from_forgery
|
5
6
|
|
6
7
|
# Will show all api services if no name parameter is receiverd
|
7
|
-
# If a name parameter is present
|
8
|
+
# If a name parameter is present will try to use that and find a controller
|
8
9
|
# that was that name by camelcasing the name .
|
9
10
|
# IF a name is provided will show the documentation page for that controller
|
11
|
+
# @see #all_services
|
12
|
+
# @see WashoutBuilder::Document::Generator#new
|
13
|
+
#
|
14
|
+
# @return [void]
|
15
|
+
#
|
16
|
+
# @api public
|
10
17
|
def all
|
11
18
|
route = params[:name].present? ? controller_is_a_service?(params[:name]) : nil
|
12
19
|
if route.present?
|
@@ -14,7 +21,9 @@ module WashoutBuilder
|
|
14
21
|
render template: 'wash_with_html/doc', layout: false,
|
15
22
|
content_type: 'text/html'
|
16
23
|
else
|
17
|
-
all_services
|
24
|
+
@services = all_services
|
25
|
+
render template: 'wash_with_html/all_services', layout: false,
|
26
|
+
content_type: 'text/html'
|
18
27
|
end
|
19
28
|
end
|
20
29
|
|
@@ -22,9 +31,20 @@ module WashoutBuilder
|
|
22
31
|
|
23
32
|
# tries to find all services by searching through the rails controller
|
24
33
|
# and returns their namespace, endpoint and a documentation url
|
34
|
+
# @see map_controllers
|
35
|
+
#
|
36
|
+
#
|
37
|
+
# @return [Hash] options The hash that contains all information about available services
|
38
|
+
# @option options [String] :service_name (@see #controller_naming) The name of the controller that is a soap servive
|
39
|
+
# @option options [String]:namespace (@see #service_namespace ) The namespace of the soap service for that controller
|
40
|
+
# @option options [String] :endpoint (@see #service_endpoint ) The endpoint of the service controller
|
41
|
+
# @option options [String] :documentation_url (@see #service_documentation_url ) The url where the documentation can be seen in HTML
|
42
|
+
# for that service controller
|
43
|
+
#
|
44
|
+
# @api private
|
25
45
|
def all_services
|
26
46
|
@map_controllers = map_controllers { |route| route.defaults[:controller] }
|
27
|
-
@
|
47
|
+
@map_controllers.blank? ? [] : @map_controllers.map do |controller_name|
|
28
48
|
{
|
29
49
|
'service_name' => controller_naming(controller_name),
|
30
50
|
'namespace' => service_namespace(controller_name),
|
@@ -32,23 +52,39 @@ module WashoutBuilder
|
|
32
52
|
'documentation_url' => service_documentation_url(controller_name)
|
33
53
|
}
|
34
54
|
end
|
35
|
-
|
36
|
-
render template: 'wash_with_html/all_services', layout: false,
|
37
|
-
content_type: 'text/html'
|
38
55
|
end
|
39
56
|
|
40
57
|
# the way of converting from controller string in downcase in camelcase
|
58
|
+
# @param [String] controller The controller name in downcase letter
|
59
|
+
#
|
60
|
+
# @return [String] The controller name in camelcase letters
|
61
|
+
#
|
62
|
+
# @api private
|
41
63
|
def controller_naming(controller)
|
42
64
|
controller.camelize
|
43
65
|
end
|
44
66
|
|
45
67
|
# checking if a route has the action for generating WSDL
|
68
|
+
# @param [ActionDispatch::Journey::Route] route The route that is used to check if can respond to _generate_wsdl action
|
69
|
+
#
|
70
|
+
# @return [Boolean] Returns true if the route can respond to _generate_wsdl action
|
71
|
+
#
|
72
|
+
# @api private
|
46
73
|
def route_can_generate_wsdl?(route)
|
47
74
|
route.defaults[:action] == '_generate_wsdl'
|
48
75
|
end
|
49
76
|
|
50
77
|
# method for getting all controllers that have the generate wsdl action or finding out
|
51
78
|
# if a single controller is a soap service
|
79
|
+
# @see #route_can_generate_wsdl?
|
80
|
+
#
|
81
|
+
# @param [String] action The action is used to collect or find a particular route . Can only be *map* or *detect*
|
82
|
+
#
|
83
|
+
# @yield [ActionDispatch::Journey::Route] yield each route to the block while iterating through the routes
|
84
|
+
#
|
85
|
+
# @return [ActionDispatch::Journey::Route, Array<ActionDispatch::Journey::Route>] Can return either a collection of routes or a single route depending on the action
|
86
|
+
#
|
87
|
+
# @api private
|
52
88
|
def map_controllers(action = 'map')
|
53
89
|
res = Rails.application.routes.routes.send(action) do |route|
|
54
90
|
if route_can_generate_wsdl?(route)
|
@@ -60,6 +96,14 @@ module WashoutBuilder
|
|
60
96
|
end
|
61
97
|
|
62
98
|
# checking if a controller is a soap service
|
99
|
+
# @see #map_controllers
|
100
|
+
# @see #controller_naming
|
101
|
+
#
|
102
|
+
# @param [String] controller The controller that is used to check if it is soap service
|
103
|
+
#
|
104
|
+
# @return [Boolean] Returns true if we find a route that can generate wsdl and the name of the route matches the name of the controller
|
105
|
+
#
|
106
|
+
# @api private
|
63
107
|
def controller_is_a_service?(controller)
|
64
108
|
map_controllers('detect') do |route|
|
65
109
|
controller_naming(route.defaults[:controller]) == controller_naming(controller)
|
@@ -67,21 +111,45 @@ module WashoutBuilder
|
|
67
111
|
end
|
68
112
|
|
69
113
|
# getting the controller class from the controller string
|
114
|
+
# @see #controller_naming
|
115
|
+
#
|
116
|
+
# @param [String] controller The name of the controller
|
117
|
+
# @return [Class] the original controller class name
|
118
|
+
# @api private
|
70
119
|
def controller_class(controller)
|
71
120
|
controller_naming("#{controller}_controller").constantize
|
72
121
|
end
|
73
122
|
|
74
123
|
# retrieves the service namespace
|
124
|
+
# @see #controller_class
|
125
|
+
#
|
126
|
+
# the method receives the controlle name than will try to find the class name
|
127
|
+
# of the controller and use the soap configuration of the class to
|
128
|
+
# retrive the namespace of the soap service
|
129
|
+
#
|
130
|
+
# @param [String] controller_name The name of the controller
|
131
|
+
# @return [String] The namespace of the soap service that is used in that controller
|
132
|
+
#
|
133
|
+
# @api private
|
75
134
|
def service_namespace(controller_name)
|
76
135
|
controller_class(controller_name).soap_config.namespace
|
77
136
|
end
|
78
137
|
|
79
138
|
# the endpoint is based on the namespace followed by /action suffix
|
139
|
+
# @see #service_namespace
|
140
|
+
#
|
141
|
+
# @param [String] controller_name The name of the controller
|
142
|
+
# @return [String] The endpoint of the web service
|
143
|
+
# @api private
|
80
144
|
def service_endpoint(controller_name)
|
81
145
|
service_namespace(controller_name).gsub('/wsdl', '/action')
|
82
146
|
end
|
83
147
|
|
84
148
|
# constructs the documentation url for a specific web service
|
149
|
+
#
|
150
|
+
# @param [String] controller_name The name of the controller
|
151
|
+
# @return [String] The documentation url for the web service ( relative to base url)
|
152
|
+
# @api private
|
85
153
|
def service_documentation_url(controller_name)
|
86
154
|
"#{washout_builder.root_url}#{controller_naming(controller_name)}"
|
87
155
|
end
|
@@ -1,7 +1,17 @@
|
|
1
|
+
# module that is used for constructing complex types in HTML-Documentation
|
1
2
|
module WashoutBuilderComplexTypeHelper
|
2
3
|
# this method is for printing the attributes of a complex type
|
3
4
|
# if the attributes are primitives this will show the attributes with blue color
|
4
5
|
# otherwise will call another method for printing the complex attribute
|
6
|
+
# @see WashoutBuilder::Type::BASIC_TYPES
|
7
|
+
# @see #create_complex_element_type_html
|
8
|
+
#
|
9
|
+
# @param [Array] pre Array that contains the content that will be appended to the xml element li
|
10
|
+
# @param [WashOut::Param] element the element that needs to be printed
|
11
|
+
#
|
12
|
+
# @return [void]
|
13
|
+
#
|
14
|
+
# @api public
|
5
15
|
def create_element_type_html(pre, element)
|
6
16
|
element.type = 'string' if element.type == 'text'
|
7
17
|
element.type = 'integer' if element.type == 'int'
|
@@ -14,6 +24,15 @@ module WashoutBuilderComplexTypeHelper
|
|
14
24
|
|
15
25
|
# checks if a complex attribute of a complex type is a array or not
|
16
26
|
# and retrieves the complex class name of the attribute and prints it
|
27
|
+
# @see WashoutBuilder::Document::ComplexType#find_complex_class_name
|
28
|
+
# @see WashOutParam#multiplied
|
29
|
+
#
|
30
|
+
# @param [Array] pre Array that contains the content that will be appended to the xml element li
|
31
|
+
# @param [WashOut::Param] element the element that needs to be printed
|
32
|
+
#
|
33
|
+
# @return [void]
|
34
|
+
#
|
35
|
+
# @api public
|
17
36
|
def create_complex_element_type_html(pre, element)
|
18
37
|
complex_class = element.find_complex_class_name
|
19
38
|
return if complex_class.nil?
|
@@ -2,27 +2,71 @@ module WashoutBuilderFaultTypeHelper
|
|
2
2
|
# checks if a complex attribute of a complex type SoapFault is array or not
|
3
3
|
# if the attribute is an array will print also the type of the elements contained in the array
|
4
4
|
# otherwise will show the complex class of the attribute
|
5
|
+
#
|
6
|
+
# @param [Array] pre Array that contains the content that will be appended to the xml element li
|
7
|
+
# @param [Class] attr_primitive xml li element to which the html will be appended to
|
8
|
+
# @param [Boolean] array boolean that is used to know if ia primitive is a array of elements
|
9
|
+
#
|
10
|
+
# @return [void]
|
11
|
+
#
|
12
|
+
# @api public
|
5
13
|
def create_fault_model_complex_element_type(pre, attr_primitive, attribute, array)
|
6
14
|
attribute_primitive = array == true ? "Array of #{attr_primitive}" : "#{attr_primitive}"
|
7
15
|
pre << "<a href='##{attr_primitive}'><span class='lightBlue'> #{attribute_primitive}</span></a> <span class='bold'>#{attribute}</span>"
|
8
16
|
end
|
9
17
|
|
10
18
|
# if the attribute is an array this method is used to identify the type of the elements inside the array
|
19
|
+
# @see WashoutBuilder::Type::BASIC_TYPES
|
20
|
+
#
|
21
|
+
# @param [Hash] attr_details hash that contains the member type and determines if the member typs is complex or not
|
22
|
+
# @option attr_details [String] :member_type The member type of the element ( basic or complex type)
|
23
|
+
# @option attr_details [String]:primitive the primitive determines if is an array or not
|
24
|
+
#
|
25
|
+
# @return [string] if the member tyoe is basic will return the type in downcase letter else will return the member type exactly as it is
|
26
|
+
#
|
27
|
+
# @api public
|
11
28
|
def member_type_is_basic?(attr_details)
|
12
29
|
WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:member_type].to_s.downcase) ? attr_details[:member_type].to_s.downcase : attr_details[:member_type]
|
13
30
|
end
|
31
|
+
|
14
32
|
# checks is the attribute has a primitive value or a complex value
|
33
|
+
# @see WashoutBuilder::Type::BASIC_TYPES
|
34
|
+
#
|
35
|
+
# @param [Hash] attr_details hash that contains the member type and determines if the member typs is complex or not
|
36
|
+
# @option attr_details [String] :member_type The member type of the element ( basic or complex type)
|
37
|
+
# @option attr_details [String]:primitive the primitive determines if is an array or not
|
38
|
+
#
|
39
|
+
# @return [boolean]
|
40
|
+
#
|
41
|
+
# @api public
|
15
42
|
def primitive_type_is_basic?(attr_details)
|
16
43
|
WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase)
|
17
44
|
end
|
18
45
|
|
19
46
|
# if the attribute value is of type nil the documentation will show string
|
20
47
|
# otherwise the primitive value
|
48
|
+
# @param [Hash] attr_details hash that contains the member type and determines if the member typs is complex or not
|
49
|
+
# @option attr_details [String] :member_type The member type of the element ( basic or complex type)
|
50
|
+
# @option attr_details [String]:primitive the primitive determines if is an array or not
|
51
|
+
#
|
52
|
+
# @return [String] if the primitive is nilclass will return string , otherwise will return the primitive
|
53
|
+
#
|
54
|
+
# @api public
|
21
55
|
def get_primitive_type_string(attr_details)
|
22
56
|
attr_details[:primitive].to_s.downcase == 'nilclass' ? 'string' : attr_details[:primitive].to_s.downcase
|
23
57
|
end
|
24
58
|
|
25
59
|
# if the attribute is of type array the method identifies the type of the elements inside the array
|
60
|
+
#
|
61
|
+
# @see #member_type_is_basic?
|
62
|
+
#
|
63
|
+
# @param [Hash] attr_details hash that contains the member type and determines if the member typs is complex or not
|
64
|
+
# @option attr_details [String] :member_type The member type of the element ( basic or complex type)
|
65
|
+
# @option attr_details [String]:primitive the primitive determines if is an array or not
|
66
|
+
#
|
67
|
+
# @return [String] if the primitive is array will call another methiod to check the member type otherwise will return the primitive
|
68
|
+
#
|
69
|
+
# @api public
|
26
70
|
def get_member_type_string(attr_details)
|
27
71
|
attr_details[:primitive].to_s.downcase == 'array' ? member_type_is_basic?(attr_details) : attr_details[:primitive]
|
28
72
|
end
|
@@ -30,6 +74,21 @@ module WashoutBuilderFaultTypeHelper
|
|
30
74
|
# this method is used to print all attributes of a SoapFault element
|
31
75
|
# if the attribute value is a primitve value it will be shown in blue and will also show the type of the primitive
|
32
76
|
# if is a complex type will use another method for finding out the complex class
|
77
|
+
#
|
78
|
+
# @see #primitive_type_is_basic?
|
79
|
+
# @see #create_fault_model_complex_element_type
|
80
|
+
# @see #get_member_type_string
|
81
|
+
#
|
82
|
+
# @param [Array] pre Array that contains the content that will be appended to the xml element li
|
83
|
+
# @param [String] attribute The name of the attribute that needs to be printed
|
84
|
+
#
|
85
|
+
# @param [Hash] attr_details hash that contains the member type and determines if the member typs is complex or not
|
86
|
+
# @option attr_details [String] :member_type The member type of the element ( basic or complex type)
|
87
|
+
# @option attr_details [String]:primitive the primitive determines if is an array or not
|
88
|
+
#
|
89
|
+
# @return [String] if the primitive is basic or nil , will return the primitive type and the attribute with blue, otherwise will print the complex type and the attribute
|
90
|
+
#
|
91
|
+
# @api public
|
33
92
|
def create_html_fault_model_element_type(pre, attribute, attr_details)
|
34
93
|
if primitive_type_is_basic?(attr_details) || attr_details[:primitive] == 'nilclass'
|
35
94
|
pre << "<span class='blue'>#{get_primitive_type_string(attr_details)}</span> <span class='bold'>#{attribute}</span>"
|
@@ -1,4 +1,17 @@
|
|
1
1
|
module WashoutBuilderMethodArgumentsHelper
|
2
|
+
# displays the parameter of a method as argument and determines if the parameter is basic type or complex type
|
3
|
+
#
|
4
|
+
# @see WashoutBuilder::Document::ComplexType#find_complex_class_name
|
5
|
+
# @see #create_method_argument_complex_element
|
6
|
+
# @see WashoutBuilder::Type::BASIC_TYPES
|
7
|
+
#
|
8
|
+
# @param [Array] pre Array that contains the content that will be appended to the xml
|
9
|
+
# @param [WashOut::Param] param the parameter what needs to be displayed
|
10
|
+
# @param [Integer] mlen Determines if we need a spacer when appending the html or not
|
11
|
+
#
|
12
|
+
# @return [void]
|
13
|
+
#
|
14
|
+
# @api public
|
2
15
|
def create_method_argument_element(pre, param, mlen)
|
3
16
|
spacer = ' '
|
4
17
|
complex_class = param.find_complex_class_name
|
@@ -10,12 +23,33 @@ module WashoutBuilderMethodArgumentsHelper
|
|
10
23
|
end
|
11
24
|
end
|
12
25
|
|
26
|
+
# displayes an argument of a method as complex type and determines if is an array of types or not
|
27
|
+
#
|
28
|
+
# @param [Array] pre Array that contains the content that will be appended to the xml
|
29
|
+
# @param [WashOut::Param] param the parameter what needs to be displayed
|
30
|
+
# @param [Bololean] use_spacer Determines if we need a spacer when appending the html or not
|
31
|
+
# @param [String] spacer the spacer that needs to be prepended if use_spacer is true
|
32
|
+
# @param [Class] complex_class The name of the complex type
|
33
|
+
#
|
34
|
+
# @return [void]
|
35
|
+
#
|
36
|
+
# @api public
|
13
37
|
def create_method_argument_complex_element(pre, param, use_spacer, spacer, complex_class)
|
14
38
|
return if complex_class.nil?
|
15
39
|
argument_content = param.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
|
16
40
|
pre << "#{use_spacer ? spacer : ''}<a href='##{complex_class}'><span class='lightBlue'>#{argument_content}</span></a> <span class='bold'>#{param.name}</span>"
|
17
41
|
end
|
18
42
|
|
43
|
+
# 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,
|
44
|
+
# and if the current index is equal to the size of argyments, will display a ')' sign
|
45
|
+
#
|
46
|
+
# @param [Builder::XmlMarkup] xml the markup builder that is used to insert HTML line breaks or span elements
|
47
|
+
# @param [Integer] j the index of the previous argument that was displayed (
|
48
|
+
# @param [Integer] mlen This determines how many arguments the method that is displayed has
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
#
|
52
|
+
# @api public
|
19
53
|
def create_argument_element_spacer(xml, j, mlen)
|
20
54
|
if j < (mlen - 1)
|
21
55
|
xml.span ', '
|
@@ -27,6 +61,18 @@ module WashoutBuilderMethodArgumentsHelper
|
|
27
61
|
xml.span('class' => 'bold') { |y| y << ')' }
|
28
62
|
end
|
29
63
|
|
64
|
+
# this method will go through each of the arguments print them and then check if we need a spacer after it
|
65
|
+
#
|
66
|
+
# @see #create_method_argument_element
|
67
|
+
# @see #create_argument_element_spacer
|
68
|
+
#
|
69
|
+
# @param [Builder::XmlMarkup] xml the markup builder that is used to insert HTML line breaks or span elements
|
70
|
+
# @param [Array] pre The array that holds the html that will be appended to the xml
|
71
|
+
# @param [Array] input An array with arguments
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
#
|
75
|
+
# @api public
|
30
76
|
def create_html_public_method_arguments(xml, pre, input)
|
31
77
|
mlen = input.size
|
32
78
|
xml.br if mlen > 1
|
@@ -1,4 +1,13 @@
|
|
1
1
|
module WashoutBuilderMethodListHelper
|
2
|
+
# 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
|
+
# @param [Builder::XmlMarkup] xml the markup builder that is used to insert HTML line breaks or span elements
|
5
|
+
# @param [Array] complex_class The array that holds the html that will be appended to the xml
|
6
|
+
# @param [Array<WashOut::Param>] builder_out An array of params ( will contain a single position in the array) this is used to determine if the class is an array or not
|
7
|
+
#
|
8
|
+
# @return [String]
|
9
|
+
#
|
10
|
+
# @api public
|
2
11
|
def create_return_complex_type_list_html(xml, complex_class, builder_out)
|
3
12
|
return_content = builder_out[0].multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
|
4
13
|
xml.span('class' => 'pre') do
|
@@ -10,6 +19,17 @@ module WashoutBuilderMethodListHelper
|
|
10
19
|
end
|
11
20
|
end
|
12
21
|
|
22
|
+
# this method will go through each of the arguments print them and then check if we need a spacer after it
|
23
|
+
# @see WashoutBuilder::Document::ComplexType#find_complex_class_name
|
24
|
+
# @see WashoutBuilder::Type::BASIC_TYPES
|
25
|
+
# @see #create_return_complex_type_list_html
|
26
|
+
#
|
27
|
+
# @param [Builder::XmlMarkup] xml the markup builder that is used to insert HTML line breaks or span elements
|
28
|
+
# @param [Array<WashOut::Param>] output t 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
|
29
|
+
#
|
30
|
+
# @return [String]
|
31
|
+
#
|
32
|
+
# @api public
|
13
33
|
def create_return_type_list_html(xml, output)
|
14
34
|
if output.nil?
|
15
35
|
xml.span('class' => 'pre') { |sp| sp << 'void' }
|
@@ -22,7 +42,7 @@ module WashoutBuilderMethodListHelper
|
|
22
42
|
end
|
23
43
|
end
|
24
44
|
else
|
25
|
-
|
45
|
+
create_return_complex_type_list_html(xml, complex_class, output) unless complex_class.nil?
|
26
46
|
end
|
27
47
|
end
|
28
48
|
end
|
@@ -1,4 +1,16 @@
|
|
1
1
|
module WashoutBuilderMethodReturnTypeHelper
|
2
|
+
# this method will print the return type next to the method name
|
3
|
+
# @see WashoutBuilder::Document::ComplexType#find_complex_class_name
|
4
|
+
# @see WashoutBuilder::Type::BASIC_TYPES
|
5
|
+
# @see #html_public_method_complex_type
|
6
|
+
#
|
7
|
+
# @param [Builder::XmlMarkup] xml the markup builder that is used to insert HTML line breaks or span elements
|
8
|
+
# @param [Array] pre The array that contains the html that will be appended to xml
|
9
|
+
# @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
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @api public
|
2
14
|
def create_html_public_method_return_type(xml, pre, output)
|
3
15
|
if !output.nil?
|
4
16
|
complex_class = output[0].find_complex_class_name
|
@@ -12,6 +24,16 @@ module WashoutBuilderMethodReturnTypeHelper
|
|
12
24
|
end
|
13
25
|
end
|
14
26
|
|
27
|
+
# this method will go through each of the arguments print them and then check if we need a spacer after it
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# @param [Array] pre The array that contains the html that will be appended to xml
|
31
|
+
# @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
|
+
# @param [Class] complex_class the name of the complex class
|
33
|
+
|
34
|
+
# @return [String]
|
35
|
+
#
|
36
|
+
# @api public
|
15
37
|
def html_public_method_complex_type(pre, output, complex_class)
|
16
38
|
return if complex_class.nil?
|
17
39
|
if output[0].multiplied == false
|
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
2
|
unless object.blank?
|
3
3
|
xml.a( "name" => "#{class_name}") { }
|
4
|
-
xml.h3 { |pre| pre << "#{class_name} #{ancestors.blank? ? "" : "<small>(extends <a href='##{ancestors[0].to_s.classify}'>#{ancestors[0].to_s.classify}</a>)</small>" } " }
|
4
|
+
xml.h3 { |pre| pre << "#{class_name} #{ancestors.blank? ? "" : "<small>(extends <a href='##{ancestors[0].to_s.classify}'>#{ancestors[0].to_s.classify}</a>)</small>" } " }
|
5
|
+
|
5
6
|
|
6
|
-
|
7
7
|
if object.is_a?(WashOut::Param)
|
8
8
|
xml.ul("class" => "pre") {
|
9
9
|
object.map.each do |element|
|
@@ -13,4 +13,4 @@ unless object.blank?
|
|
13
13
|
end
|
14
14
|
}
|
15
15
|
end
|
16
|
-
end
|
16
|
+
end
|
@@ -1,21 +1,50 @@
|
|
1
1
|
require_relative './shared_complex_type'
|
2
2
|
module WashoutBuilder
|
3
|
+
# namespace of the class
|
3
4
|
module Document
|
5
|
+
# class that is used for current Washout::Param object to know his complex type name and structure and detect ancestors and descendants
|
4
6
|
module ComplexType
|
5
7
|
extend ActiveSupport::Concern
|
6
8
|
include WashoutBuilder::Document::SharedComplexType
|
7
9
|
|
10
|
+
# finds the complex class name of the current Washout::Param object and checks if is a duplicate
|
11
|
+
# @see #check_duplicate_complex_class
|
12
|
+
#
|
13
|
+
# @param [Array] defined Array that is used for when iterating through descendants and ancestors
|
14
|
+
#
|
15
|
+
# @return [Class] the complex type name of the current object
|
16
|
+
#
|
17
|
+
# @api public
|
8
18
|
def find_complex_class_name(defined = [])
|
9
19
|
complex_class = struct? ? basic_type.tr('.', '/').camelize : nil
|
10
20
|
check_duplicate_complex_class(defined, complex_class) unless complex_class.nil? || defined.blank?
|
11
21
|
complex_class
|
12
22
|
end
|
13
23
|
|
24
|
+
# checks if the complex class appears in the array of complex types
|
25
|
+
#
|
26
|
+
# @param [Array<Hash>] defined Array that is used for checking if a complex type is already defined
|
27
|
+
# @param [Class] complex_class the complex type name used for searching
|
28
|
+
#
|
29
|
+
# @return [Boolean] returns true or false if the complex type is found inside the array
|
30
|
+
#
|
31
|
+
# @api public
|
14
32
|
def check_duplicate_complex_class(defined, complex_class)
|
15
33
|
complex_obj_found = defined.find { |hash| hash[:class] == complex_class }
|
16
34
|
raise "Duplicate use of `#{basic_type}` type name. Consider using classified types." if !complex_obj_found.nil? && struct? && !classified?
|
17
35
|
end
|
18
36
|
|
37
|
+
# finds the complex class ancestors if the current object is classified, otherwise returns nil
|
38
|
+
# @see WashOut::Param#classified?
|
39
|
+
# @see #get_class_ancestors
|
40
|
+
#
|
41
|
+
# @param [WashOut::SoapConfig] config the configuration of the soap service
|
42
|
+
# @param [Clas] complex_class the complex type name of the object
|
43
|
+
# @param [Array<Hash>] defined An array that holds all the complex types found so far
|
44
|
+
#
|
45
|
+
# @return [Array<Class>, nil] returns nil if object not classified othewise an array of classes that are ancestors to curent object
|
46
|
+
#
|
47
|
+
# @api public
|
19
48
|
def complex_type_ancestors(config, complex_class, defined)
|
20
49
|
classified? ? get_class_ancestors(config, complex_class, defined) : nil
|
21
50
|
end
|
@@ -31,10 +60,6 @@ module WashoutBuilder
|
|
31
60
|
self.map = map.delete_if { |element| keys.include?(element.name) }
|
32
61
|
end
|
33
62
|
|
34
|
-
# def get_ancestor_structure
|
35
|
-
# {self.class.to_s.downcase => self.class.columns_hash.inject({}) {|h, (k,v)| h["#{k}"]="#{v.type}".to_sym; h } }
|
36
|
-
# end
|
37
|
-
|
38
63
|
def fix_descendant_wash_out_type(config, complex_class)
|
39
64
|
param_class = begin
|
40
65
|
complex_class.is_a?(Class) ? complex_class : complex_class.constantize
|
@@ -97,7 +122,7 @@ module WashoutBuilder
|
|
97
122
|
|
98
123
|
def complex_type_hash(class_name, object, ancestors)
|
99
124
|
{
|
100
|
-
|
125
|
+
class: class_name,
|
101
126
|
obj: object,
|
102
127
|
ancestors: ancestors
|
103
128
|
}
|
data/lib/washout_builder/soap.rb
CHANGED
@@ -7,13 +7,19 @@ module WashoutBuilder
|
|
7
7
|
include WashOut::Rails::Controller if defined?(WashOut::Rails::Controller)
|
8
8
|
|
9
9
|
module ClassMethods
|
10
|
-
attr_accessor :soap_actions
|
10
|
+
attr_accessor :soap_actions, :washout_builder_action
|
11
11
|
# Define a SOAP action +action+. The function has two required +options+:
|
12
12
|
# :args and :return. Each is a type +definition+ of format described in
|
13
13
|
# WashOut::Param#parse_def.
|
14
14
|
#
|
15
15
|
# An optional option :to can be passed to allow for names of SOAP actions
|
16
16
|
# which are not valid Ruby function names.
|
17
|
+
# @param [Symbol, Class] action the action that is requested
|
18
|
+
# @param [Hash] options the options used for
|
19
|
+
#
|
20
|
+
# @return [void]
|
21
|
+
#
|
22
|
+
# @api public
|
17
23
|
def soap_action(action, options = {})
|
18
24
|
original_soap_action(action, options)
|
19
25
|
|
@@ -45,7 +45,7 @@ describe WashoutBuilderMethodListHelper, type: :helper do
|
|
45
45
|
it 'returns complex type' do
|
46
46
|
expected = 'some expected string'
|
47
47
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
|
48
|
-
helper.expects(:
|
48
|
+
helper.expects(:create_return_complex_type_list_html).with(instance_of(Builder::XmlMarkup), complex_class, output).returns(expected)
|
49
49
|
result = helper.create_return_type_list_html(xml, output)
|
50
50
|
expect(result).to eq(expected)
|
51
51
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -34,7 +34,6 @@ require 'ostruct'
|
|
34
34
|
|
35
35
|
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
36
36
|
require File.expand_path('../../config/routes.rb', __FILE__)
|
37
|
-
require 'rails/test_help'
|
38
37
|
require 'rspec/rails'
|
39
38
|
require 'savon'
|
40
39
|
require 'wash_out'
|
@@ -48,7 +47,6 @@ Rails.backtrace_cleaner.remove_silencers!
|
|
48
47
|
# Load support files
|
49
48
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
50
49
|
|
51
|
-
FIxMinitest.disable_autorun
|
52
50
|
# Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
|
53
51
|
RSpec.configure do |config|
|
54
52
|
require 'rspec/expectations'
|
data/washout_builder.gemspec
CHANGED
@@ -10,13 +10,13 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = "WashOut Soap Service HTML-Documentation generator (extends WashOut https://github.com/inossidabile/wash_out/) "
|
11
11
|
s.authors = ["bogdanRada"]
|
12
12
|
s.date = Date.today
|
13
|
-
|
13
|
+
|
14
14
|
s.licenses = ["MIT"]
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = s.files.grep(/^(spec)/)
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.add_runtime_dependency 'wash_out', '~> 0.9.1', '>= 0.9.1'
|
19
|
-
|
19
|
+
|
20
20
|
s.add_development_dependency 'wasabi', '~> 3.5', '>= 3.5'
|
21
21
|
s.add_development_dependency 'savon', '~> 2.11', '>= 2.11'
|
22
22
|
s.add_development_dependency 'httpi', '~> 2.4', '>= 2.4'
|
@@ -34,12 +34,12 @@ Gem::Specification.new do |s|
|
|
34
34
|
# s.add_development_dependency 'codeclimate-test-reporter','~> 0.3', '>= 0.3'
|
35
35
|
# s.add_development_dependency 'rubyntlm','~> 0.3.4', '>= 0.3'
|
36
36
|
s.add_development_dependency 'rvm-tester','~> 1.1', '>= 1.1'
|
37
|
-
s.add_development_dependency 'wwtd','~> 0
|
38
|
-
|
37
|
+
s.add_development_dependency 'wwtd','~> 1.0', '>= 1.0'
|
38
|
+
|
39
39
|
s.add_development_dependency 'capybara', '~> 2.4', '>= 2.4'
|
40
40
|
s.add_development_dependency 'selenium-webdriver', '~> 2.41', '>= 2.41.0'
|
41
41
|
s.add_development_dependency 'headless','~> 2.2', '>= 2.2'
|
42
|
-
|
42
|
+
|
43
43
|
s.add_development_dependency 'rubocop', '~> 0.3', '>= 0.33'
|
44
44
|
s.add_development_dependency 'phare', '~> 0.7', '>= 0.7'
|
45
45
|
s.add_development_dependency 'yard', '~> 0.8.7', '>= 0.8.7'
|
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: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wash_out
|
@@ -316,20 +316,20 @@ dependencies:
|
|
316
316
|
requirements:
|
317
317
|
- - "~>"
|
318
318
|
- !ruby/object:Gem::Version
|
319
|
-
version: '0
|
319
|
+
version: '1.0'
|
320
320
|
- - ">="
|
321
321
|
- !ruby/object:Gem::Version
|
322
|
-
version: 0
|
322
|
+
version: '1.0'
|
323
323
|
type: :development
|
324
324
|
prerelease: false
|
325
325
|
version_requirements: !ruby/object:Gem::Requirement
|
326
326
|
requirements:
|
327
327
|
- - "~>"
|
328
328
|
- !ruby/object:Gem::Version
|
329
|
-
version: '0
|
329
|
+
version: '1.0'
|
330
330
|
- - ">="
|
331
331
|
- !ruby/object:Gem::Version
|
332
|
-
version: 0
|
332
|
+
version: '1.0'
|
333
333
|
- !ruby/object:Gem::Dependency
|
334
334
|
name: capybara
|
335
335
|
requirement: !ruby/object:Gem::Requirement
|
@@ -651,7 +651,6 @@ files:
|
|
651
651
|
- spec/support/complex_types/fluffy_container.rb
|
652
652
|
- spec/support/complex_types/project_type.rb
|
653
653
|
- spec/support/complex_types/test_type.rb
|
654
|
-
- spec/support/fix_minitest.rb
|
655
654
|
- washout_builder.gemspec
|
656
655
|
homepage: http://github.com/bogdanRada/washout_builder/
|
657
656
|
licenses:
|
@@ -719,5 +718,4 @@ test_files:
|
|
719
718
|
- spec/support/complex_types/fluffy_container.rb
|
720
719
|
- spec/support/complex_types/project_type.rb
|
721
720
|
- spec/support/complex_types/test_type.rb
|
722
|
-
- spec/support/fix_minitest.rb
|
723
721
|
has_rdoc:
|
@@ -1,38 +0,0 @@
|
|
1
|
-
|
2
|
-
module FIxMinitest
|
3
|
-
def self.disable_autorun
|
4
|
-
disable_auto_runner
|
5
|
-
override_minitest_run
|
6
|
-
override_minitest_unit_run
|
7
|
-
end
|
8
|
-
|
9
|
-
# rubocop:disable all
|
10
|
-
def self.override_minitest_run
|
11
|
-
Minitest.instance_eval do
|
12
|
-
def run(*)
|
13
|
-
FIxMinitest.run_mininitest
|
14
|
-
end
|
15
|
-
end if defined?(Minitest)
|
16
|
-
end
|
17
|
-
|
18
|
-
# rubocop:disable NestedMethodDefinition
|
19
|
-
def self.run_mininitest
|
20
|
-
case $ERROR_INFO
|
21
|
-
when SystemExit
|
22
|
-
$ERROR_INFO.status
|
23
|
-
else
|
24
|
-
true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
# rubocop:disable NestedMethodDefinition
|
28
|
-
def self.override_minitest_unit_run
|
29
|
-
Minitest::Unit.class_eval do
|
30
|
-
def run(*)
|
31
|
-
end
|
32
|
-
end if defined?(Minitest) && defined?(Minitest::Unit)
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.disable_auto_runner
|
36
|
-
Test::Unit::Runner.module_eval('@@stop_auto_run = true') if defined?(Test::Unit::Runner)
|
37
|
-
end
|
38
|
-
end
|