washout_builder 0.13.2 → 0.13.3
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 +8 -8
- data/app/helpers/washout_builder_complex_type_helper.rb +26 -0
- data/app/helpers/washout_builder_fault_type_helper.rb +25 -0
- data/app/helpers/washout_builder_method_arguments_helper.rb +41 -0
- data/app/helpers/washout_builder_method_list_helper.rb +38 -0
- data/app/helpers/washout_builder_method_return_type_helper.rb +20 -0
- data/app/views/wash_with_html/_complex_type.builder +14 -0
- data/app/views/wash_with_html/_fault_type.builder +9 -0
- data/app/views/wash_with_html/_public_method.builder +36 -0
- data/app/views/wash_with_html/doc.builder +14 -7
- data/lib/washout_builder/document/exception_model.rb +31 -20
- data/lib/washout_builder/document/generator.rb +13 -0
- data/lib/washout_builder/version.rb +1 -1
- data/spec/app/helpers/washout_builder_complex_type_helper_spec.rb +8 -0
- data/spec/lib/washout_builder/document/exception_model_spec.rb +6 -5
- metadata +11 -4
- data/app/helpers/washout_builder_helper.rb +0 -245
- data/spec/app/helpers/washout_builder_helper_spec.rb +0 -8
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDQ4NTEwNjQwOGY4ZjA3NmY2MmE3MzA2MjNlZGFhY2FkNDJlOGFjNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGU0MjUxMGVlMWIxODc1MGE3ODY2ZDY1Njc1NWZmOTlmMzAwY2ExNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWQ0OTQyZjUwNzFiZWZjN2EyOGJhZTJkZDU4YTk1NWViNTM0ODBmOWQ0ZGU5
|
10
|
+
YWNjNTMwMTMwMzQ2YjUwMDhkYTRmYzA2MGZjYmE0OGUyMTllZWI3MzVkZTcy
|
11
|
+
ZjEyNDRhZGJiYmQ4ZTU0NzVjMTg5OTkxMjc4ZDY3NmE0NWVmOTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2YxYTQ5ZWQyMDA0NTJlMjMwNTdiOTRhYjM5ZDk1M2IzOGQwZmQwZWI2ZDg3
|
14
|
+
ZmVjODhlOWU1MTA2YzE4MzI5MjE1NDhmZDA0MmMxOGVhZjIwZTkwNTk4NjEw
|
15
|
+
NWE5MmRkZjI0ZjIxMzAxNzY3M2UwMTk5M2Y1ZTNmMzJmMTNkOTI=
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module WashoutBuilderComplexTypeHelper
|
2
|
+
|
3
|
+
def create_complex_type_element_html(xml, element)
|
4
|
+
element.type = "string" if element.type == "text"
|
5
|
+
element.type = "integer" if element.type == "int"
|
6
|
+
xml.li { |pre|
|
7
|
+
if WashoutBuilder::Type::BASIC_TYPES.include?(element.type)
|
8
|
+
pre << "<span class='blue'>#{element.type}</span> <span class='bold'>#{element.name}</span>"
|
9
|
+
else
|
10
|
+
create_element_type_html(pre, element)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_element_type_html(pre, element)
|
16
|
+
complex_class = element.get_complex_class_name
|
17
|
+
unless complex_class.nil?
|
18
|
+
complex_class_content = element.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
|
19
|
+
pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class_content}</span></a> <span class='bold'>#{element.name}</span>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module WashoutBuilderFaultTypeHelper
|
2
|
+
|
3
|
+
def create_fault_model_complex_element_type(pre, attr_primitive, attribute, array)
|
4
|
+
attribute_primitive = array == true ? "Array of #{attr_primitive}" : "#{attr_primitive}"
|
5
|
+
pre << "<a href='##{attr_primitive}'><span class='lightBlue'> #{attribute_primitive}</span></a> <span class='bold'>#{attribute}</span>"
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
def create_html_fault_model_element_type(xml, attribute, attr_details)
|
10
|
+
xml.li { |pre|
|
11
|
+
if WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase) || attr_details[:primitive] == "nilclass"
|
12
|
+
pre << "<span class='blue'>#{attr_details[:primitive].to_s.downcase == "nilclass" ? "string" : attr_details[:primitive].to_s.downcase }</span> <span class='bold'>#{attribute}</span>"
|
13
|
+
|
14
|
+
else
|
15
|
+
if attr_details[:primitive].to_s.downcase == "array"
|
16
|
+
|
17
|
+
attr_primitive = WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:member_type].to_s.downcase) ? attr_details[:member_type].to_s.downcase : attr_details[:member_type]
|
18
|
+
create_fault_model_complex_element_type(pre,attr_primitive, attribute, true )
|
19
|
+
else
|
20
|
+
create_fault_model_complex_element_type(pre,attr_details[:primitive], attribute, false )
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module WashoutBuilderMethodArgumentsHelper
|
2
|
+
|
3
|
+
def create_method_argument_element( pre, param, mlen)
|
4
|
+
spacer = " "
|
5
|
+
complex_class = param.get_complex_class_name
|
6
|
+
use_spacer = mlen > 1 ? true : false
|
7
|
+
if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
|
8
|
+
pre << "#{use_spacer ? spacer: ''}<span class='blue'>#{param.type}</span> <span class='bold'>#{param.name}</span>"
|
9
|
+
else
|
10
|
+
unless complex_class.nil?
|
11
|
+
argument_content = param.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
|
12
|
+
pre << "#{use_spacer ? spacer: ''}<a href='##{complex_class}'><span class='lightBlue'>#{argument_content}</span></a> <span class='bold'>#{param.name}</span>"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_argument_element_spacer(xml, j, mlen )
|
18
|
+
if j< (mlen-1)
|
19
|
+
xml.span ", "
|
20
|
+
end
|
21
|
+
if mlen > 1
|
22
|
+
xml.br
|
23
|
+
end
|
24
|
+
if (j+1) == mlen
|
25
|
+
xml.span("class" => "bold") {|y| y << ")" }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
def create_html_public_method_arguments(xml, pre, input)
|
32
|
+
mlen = input.size
|
33
|
+
xml.br if mlen > 1
|
34
|
+
if mlen > 0
|
35
|
+
input.each_with_index do |element, index|
|
36
|
+
create_method_argument_element( pre, element, mlen)
|
37
|
+
create_argument_element_spacer(xml, index, mlen )
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module WashoutBuilderMethodListHelper
|
2
|
+
|
3
|
+
def create_element_exceptions_list_html(p)
|
4
|
+
xml.li("class" => "pre"){ |y| y<< "<a href='##{p.to_s}'><span class='lightBlue'> #{p.to_s}</span></a>" }
|
5
|
+
end
|
6
|
+
|
7
|
+
def create_parameters_element_list_html(xml, param)
|
8
|
+
xml.li("class" => "pre") { |pre|
|
9
|
+
if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
|
10
|
+
pre << "<span class='blue'>#{param.type}</span> <span class='bold'>#{param.name}</span>"
|
11
|
+
else
|
12
|
+
create_element_type_html(pre, param)
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_return_complex_type_list_html(xml, complex_class, builder_out)
|
18
|
+
return_content = builder_out[0].multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
|
19
|
+
xml.span("class" => "pre") { xml.a("href" => "##{complex_class}") { |xml| xml.span("class" => "lightBlue") { |y| y<<"#{return_content}" } } }
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def create_return_type_list_html(xml, output)
|
24
|
+
unless output.nil?
|
25
|
+
complex_class = output[0].get_complex_class_name
|
26
|
+
if WashoutBuilder::Type::BASIC_TYPES.include?(output[0].type)
|
27
|
+
xml.span("class" => "pre") { |xml| xml.span("class" => "blue") { |sp| sp << "#{output[0].type}" } }
|
28
|
+
else
|
29
|
+
create_return_complex_type_html(xml, complex_class, output) unless complex_class.nil?
|
30
|
+
end
|
31
|
+
else
|
32
|
+
xml.span("class" => "pre") { |sp| sp << "void" }
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module WashoutBuilderMethodReturnTypeHelper
|
2
|
+
|
3
|
+
def create_html_public_method_return_type(xml,pre, output)
|
4
|
+
if !output.nil?
|
5
|
+
complex_class = output[0].get_complex_class_name
|
6
|
+
if WashoutBuilder::Type::BASIC_TYPES.include?(output[0].type)
|
7
|
+
xml.span("class" => "blue") { |y| y<< "#{output[0].type}" }
|
8
|
+
else
|
9
|
+
complex_return_type = output[0].multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
|
10
|
+
pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_return_type}</span></a>" unless complex_class.nil?
|
11
|
+
end
|
12
|
+
else
|
13
|
+
pre << "void"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
unless object.blank?
|
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>" } " }
|
5
|
+
|
6
|
+
|
7
|
+
if object.is_a?(WashOut::Param)
|
8
|
+
xml.ul("class" => "pre") {
|
9
|
+
object.map.each do |element|
|
10
|
+
create_complex_type_element_html(xml, element)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
if object.is_a?(Class)
|
2
|
+
xml.h3 { |pre| pre << "#{object} #{ancestors.blank? ? "" : "<small>(extends <a href='##{ancestors[0].to_s.classify}'>#{ancestors[0].to_s.classify}</a>)</small>" } " }
|
3
|
+
xml.a("name" => "#{object}") {}
|
4
|
+
xml.ul("class" => "pre") {
|
5
|
+
structure.each do |attribute, attr_details|
|
6
|
+
create_html_fault_model_element_type(xml, attribute, attr_details)
|
7
|
+
end
|
8
|
+
}
|
9
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
xml.h3 "#{operation}"
|
2
|
+
xml.a("name" => "#{operation}") {}
|
3
|
+
|
4
|
+
xml.p("class" => "pre"){ |pre|
|
5
|
+
create_html_public_method_return_type(xml,pre, output)
|
6
|
+
xml.span("class" => "bold") {|y| y << "#{operation} (" }
|
7
|
+
create_html_public_method_arguments(xml, pre, input)
|
8
|
+
}
|
9
|
+
xml.p "#{description}" unless description.blank?
|
10
|
+
|
11
|
+
|
12
|
+
xml.p "Parameters:"
|
13
|
+
xml.ul {
|
14
|
+
input.each do |element|
|
15
|
+
create_parameters_element_list_html(xml,element)
|
16
|
+
end
|
17
|
+
}
|
18
|
+
|
19
|
+
xml.p "Return value:"
|
20
|
+
xml.ul {
|
21
|
+
xml.li {
|
22
|
+
|
23
|
+
create_return_type_list_html(xml,output)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
operation_exceptions = @document.operation_exceptions(operation)
|
29
|
+
unless operation_exceptions.blank?
|
30
|
+
xml.p "Exceptions:"
|
31
|
+
xml.ul {
|
32
|
+
operation_exceptions.each do |p|
|
33
|
+
create_element_exceptions_list_html(p)
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
@@ -41,7 +41,7 @@ xml.html( "xmlns" => "http://www.w3.org/1999/xhtml" ) {
|
|
41
41
|
xml.span( "class" => "pre") {
|
42
42
|
xml.a( "href" => "#{@document.namespace}") { |y| y << "#{@document.namespace}" }
|
43
43
|
};}
|
44
|
-
|
44
|
+
xml.p ""
|
45
45
|
unless @document.service_description.blank?
|
46
46
|
xml.p "#{@document.service_description}"
|
47
47
|
end
|
@@ -87,18 +87,25 @@ xml.html( "xmlns" => "http://www.w3.org/1999/xhtml" ) {
|
|
87
87
|
|
88
88
|
unless @complex_types.blank?
|
89
89
|
xml.h2 "Complex types:"
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
create_html_fault_types_details(xml, @fault_complex_types)
|
90
|
+
@complex_types.each { |hash|
|
91
|
+
xml << render(:partial => "wash_with_html/complex_type", :locals => { :object => hash[:obj], :class_name => hash[:class], :ancestors => hash[:ancestors]})
|
92
|
+
}
|
94
93
|
end
|
95
94
|
unless @fault_types.blank?
|
96
95
|
xml.h2 "Fault types:"
|
97
|
-
|
96
|
+
@fault_types.each { |hash|
|
97
|
+
xml << render(:partial => "wash_with_html/fault_type", :locals => { :object => hash[:fault], :structure => hash[:structure], :ancestors => hash[:ancestors]})
|
98
|
+
}
|
98
99
|
end
|
99
100
|
unless @methods.blank?
|
100
101
|
xml.h2 "Public methods:"
|
101
|
-
|
102
|
+
@map = @document.sorted_operations
|
103
|
+
unless @map.blank?
|
104
|
+
@map.each { |operation, formats|
|
105
|
+
xml << render(:partial => "wash_with_html/public_method", :locals => { :operation=> operation, :input => formats[:in], :output => formats[:out] , :exceptions => formats[:raises], :description => formats[:description]})
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
102
109
|
end
|
103
110
|
|
104
111
|
if @complex_types.blank? && @fault_types.blank? && @methods.blank?
|
@@ -12,7 +12,7 @@ module WashoutBuilder
|
|
12
12
|
bool_the_same = false
|
13
13
|
ancestors = fault_ancestors
|
14
14
|
if ancestors.blank?
|
15
|
-
defined << fault_ancestor_hash(
|
15
|
+
defined << fault_ancestor_hash(get_fault_model_structure, [])
|
16
16
|
else
|
17
17
|
defined << fault_ancestor_hash(fault_without_inheritable_elements(ancestors), ancestors)
|
18
18
|
ancestors[0].get_fault_class_ancestors( defined)
|
@@ -22,7 +22,7 @@ module WashoutBuilder
|
|
22
22
|
|
23
23
|
|
24
24
|
def fault_without_inheritable_elements(ancestors)
|
25
|
-
remove_fault_type_inheritable_elements( ancestors[0].
|
25
|
+
remove_fault_type_inheritable_elements( ancestors[0].get_fault_model_structure.keys)
|
26
26
|
end
|
27
27
|
|
28
28
|
def fault_ancestors
|
@@ -34,33 +34,44 @@ module WashoutBuilder
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def remove_fault_type_inheritable_elements( keys)
|
37
|
-
|
37
|
+
get_fault_model_structure.delete_if{|key,value| keys.include?(key) }
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
def check_valid_fault_method?(method)
|
41
|
+
method != :== && method != :! &&
|
42
|
+
( self.instance_methods.include?(:"#{method}=") ||
|
43
|
+
self.instance_methods.include?(:"#{method}")
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
41
47
|
|
42
|
-
def
|
43
|
-
attrs =
|
44
|
-
|
45
|
-
method
|
46
|
-
self.instance_methods.include?(:"#{method}=")
|
48
|
+
def get_fault_attributes
|
49
|
+
attrs = []
|
50
|
+
attrs = self.instance_methods(nil).collect do |method|
|
51
|
+
method.to_s if check_valid_fault_method?(method)
|
47
52
|
end
|
53
|
+
attrs = attrs.delete_if {|method| method.end_with?("=") && attrs.include?(method.gsub("=",'')) }
|
48
54
|
attrs.concat(["message", "backtrace"])
|
49
55
|
end
|
50
56
|
|
57
|
+
def get_fault_type_method(method_name)
|
58
|
+
case method_name.to_s.downcase
|
59
|
+
when "code"
|
60
|
+
"integer"
|
61
|
+
when "message", "backtrace"
|
62
|
+
"string"
|
63
|
+
else
|
64
|
+
"string"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
51
68
|
|
52
|
-
def
|
69
|
+
def get_fault_model_structure
|
53
70
|
h = {}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
when "message", "backtrace"
|
59
|
-
"string"
|
60
|
-
else
|
61
|
-
"string"
|
62
|
-
end
|
63
|
-
h["#{method_name}"]= {
|
71
|
+
get_fault_attributes.each do |method_name|
|
72
|
+
method_name = method_name.to_s.end_with?("=") ? method_name.to_s.gsub("=", '') : method_name
|
73
|
+
primitive_type = get_fault_type_method(method_name)
|
74
|
+
h["#{method_name}"]= {
|
64
75
|
:primitive => "#{primitive_type}",
|
65
76
|
:member_type => nil
|
66
77
|
}
|
@@ -39,6 +39,19 @@ module WashoutBuilder
|
|
39
39
|
soap_actions.map { |operation, formats| operation }
|
40
40
|
end
|
41
41
|
|
42
|
+
def sorted_operations
|
43
|
+
soap_actions.sort_by { |operation, formats| operation.downcase }.uniq unless soap_actions.blank?
|
44
|
+
end
|
45
|
+
|
46
|
+
def operation_exceptions(operation_name)
|
47
|
+
hash_object = soap_actions.detect {|operation, formats| operation.to_s.downcase == operation_name.to_s.downcase}
|
48
|
+
unless hash_object.blank?
|
49
|
+
faults = hash_object[1][:raises]
|
50
|
+
faults = faults.is_a?(Array) ? faults : [faults]
|
51
|
+
faults.select { |x| WashoutBuilder::Type.valid_fault_class?(x) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
42
55
|
def sort_complex_types(types, type)
|
43
56
|
types.sort_by { |hash| hash[type.to_sym].to_s.downcase }.uniq {|hash| hash[type.to_sym] } unless types.blank?
|
44
57
|
end
|
@@ -1,18 +1,19 @@
|
|
1
1
|
#encoding:utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
class SOAPError < WashOut::Dispatcher::SOAPError
|
5
|
-
|
6
|
-
end
|
7
4
|
|
8
5
|
describe WashoutBuilder::Document::ExceptionModel do
|
9
6
|
|
10
|
-
let(:subject) { SOAPError}
|
7
|
+
let(:subject) { WashOut::Dispatcher::SOAPError}
|
11
8
|
|
12
9
|
|
13
10
|
|
14
11
|
it "gets the strcuture" do
|
15
|
-
subject.
|
12
|
+
subject.get_fault_model_structure.should eq({"code"=>{:primitive=>"integer", :member_type=>nil}, "message"=>{:primitive=>"string", :member_type=>nil}, "backtrace"=>{:primitive=>"string", :member_type=>nil}})
|
13
|
+
end
|
14
|
+
|
15
|
+
it "gets the strcuture" do
|
16
|
+
subject.get_fault_attributes.should eq(["code","message", "backtrace"])
|
16
17
|
end
|
17
18
|
#
|
18
19
|
# it "gets the member type for arrays" do
|
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.13.
|
4
|
+
version: 0.13.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
@@ -48,7 +48,14 @@ files:
|
|
48
48
|
- README.rdoc
|
49
49
|
- Rakefile
|
50
50
|
- app/controllers/washout_builder/washout_builder_controller.rb
|
51
|
-
- app/helpers/
|
51
|
+
- app/helpers/washout_builder_complex_type_helper.rb
|
52
|
+
- app/helpers/washout_builder_fault_type_helper.rb
|
53
|
+
- app/helpers/washout_builder_method_arguments_helper.rb
|
54
|
+
- app/helpers/washout_builder_method_list_helper.rb
|
55
|
+
- app/helpers/washout_builder_method_return_type_helper.rb
|
56
|
+
- app/views/wash_with_html/_complex_type.builder
|
57
|
+
- app/views/wash_with_html/_fault_type.builder
|
58
|
+
- app/views/wash_with_html/_public_method.builder
|
52
59
|
- app/views/wash_with_html/all_services.builder
|
53
60
|
- app/views/wash_with_html/doc.builder
|
54
61
|
- config/routes.rb
|
@@ -63,7 +70,7 @@ files:
|
|
63
70
|
- lib/washout_builder/type.rb
|
64
71
|
- lib/washout_builder/version.rb
|
65
72
|
- spec/app/controllers/washout_builder_controller_spec.rb
|
66
|
-
- spec/app/helpers/
|
73
|
+
- spec/app/helpers/washout_builder_complex_type_helper_spec.rb
|
67
74
|
- spec/app/integration/washout_builder_all_services_spec.rb
|
68
75
|
- spec/app/integration/washout_builder_service_spec.rb
|
69
76
|
- spec/dummy/Rakefile
|
@@ -126,7 +133,7 @@ specification_version: 4
|
|
126
133
|
summary: WashOut Soap Service HTML-Documentation generator (extends WashOut https://github.com/inossidabile/wash_out/)
|
127
134
|
test_files:
|
128
135
|
- spec/app/controllers/washout_builder_controller_spec.rb
|
129
|
-
- spec/app/helpers/
|
136
|
+
- spec/app/helpers/washout_builder_complex_type_helper_spec.rb
|
130
137
|
- spec/app/integration/washout_builder_all_services_spec.rb
|
131
138
|
- spec/app/integration/washout_builder_service_spec.rb
|
132
139
|
- spec/dummy/Rakefile
|
@@ -1,245 +0,0 @@
|
|
1
|
-
module WashoutBuilderHelper
|
2
|
-
|
3
|
-
def create_html_complex_types(xml, types)
|
4
|
-
types.each { |hash| create_complex_type_html(xml, hash[:obj], hash[:class], hash[:ancestors]) }
|
5
|
-
end
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def create_element_type_html(pre, complex_class, element)
|
10
|
-
unless complex_class.nil?
|
11
|
-
if element.multiplied == false
|
12
|
-
pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a> <span class='bold'>#{element.name}</span>"
|
13
|
-
else
|
14
|
-
pre << "<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a> <span class='bold'>#{element.name}</span>"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def create_class_type_html(xml, class_name, ancestors)
|
21
|
-
xml.h3 { |pre| pre << "#{class_name} #{ancestors.blank? ? "" : "<small>(extends <a href='##{ancestors[0].to_s.classify}'>#{ancestors[0].to_s.classify}</a>)</small>" } " }
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
def create_complex_type_element_html(xml, element)
|
26
|
-
element.type = "string" if element.type == "text"
|
27
|
-
element.type = "integer" if element.type == "int"
|
28
|
-
xml.li { |pre|
|
29
|
-
if WashoutBuilder::Type::BASIC_TYPES.include?(element.type)
|
30
|
-
pre << "<span class='blue'>#{element.type}</span> <span class='bold'>#{element.name}</span>"
|
31
|
-
else
|
32
|
-
complex_class = element.get_complex_class_name
|
33
|
-
create_element_type_html(pre, complex_class, element)
|
34
|
-
end
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def create_complex_type_html(xml, param, class_name, ancestors)
|
40
|
-
unless param.blank?
|
41
|
-
xml.a( "name" => "#{class_name}") { }
|
42
|
-
|
43
|
-
create_class_type_html(xml, class_name, ancestors)
|
44
|
-
if param.is_a?(WashOut::Param)
|
45
|
-
xml.ul("class" => "pre") {
|
46
|
-
param.map.each do |element|
|
47
|
-
create_complex_type_element_html(xml, element)
|
48
|
-
end
|
49
|
-
}
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_html_fault_types_details(xml, fault_types)
|
55
|
-
unless fault_types.blank?
|
56
|
-
|
57
|
-
fault_types.each { |hash|
|
58
|
-
create_html_virtus_model_type(xml, hash[:fault],hash[:structure], hash[:ancestors])
|
59
|
-
}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def create_virtus_model_complex_element_type(pre, attr_primitive, attribute, array)
|
64
|
-
attribute_primitive = array == true ? "Array of #{attr_primitive}" : "#{attr_primitive}"
|
65
|
-
pre << "<a href='##{attr_primitive}'><span class='lightBlue'> #{attribute_primitive}</span></a> <span class='bold'>#{attribute}</span>"
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
def create_html_virtus_model_element_type(xml, attribute, attr_details)
|
70
|
-
xml.li { |pre|
|
71
|
-
if WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase) || attr_details[:primitive] == "nilclass"
|
72
|
-
pre << "<span class='blue'>#{attr_details[:primitive].to_s.downcase == "nilclass" ? "string" : attr_details[:primitive].to_s.downcase }</span> <span class='bold'>#{attribute}</span>"
|
73
|
-
|
74
|
-
else
|
75
|
-
if attr_details[:primitive].to_s.downcase == "array"
|
76
|
-
|
77
|
-
attr_primitive = WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:member_type].to_s.downcase) ? attr_details[:member_type].to_s.downcase : attr_details[:member_type]
|
78
|
-
create_virtus_model_complex_element_type(pre,attr_primitive, attribute, true )
|
79
|
-
else
|
80
|
-
create_virtus_model_complex_element_type(pre,attr_details[:primitive], attribute, false )
|
81
|
-
end
|
82
|
-
end
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
def create_html_virtus_model_type(xml, param, fault_structure, ancestors)
|
88
|
-
if param.is_a?(Class)
|
89
|
-
create_class_type_html(xml, param, ancestors)
|
90
|
-
xml.a("name" => "#{param}") {}
|
91
|
-
xml.ul("class" => "pre") {
|
92
|
-
fault_structure.each do |attribute, attr_details|
|
93
|
-
create_html_virtus_model_element_type(xml, attribute, attr_details)
|
94
|
-
end
|
95
|
-
}
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def create_html_public_methods(xml, map)
|
100
|
-
unless map.blank?
|
101
|
-
map =map.sort_by { |operation, formats| operation.downcase }.uniq
|
102
|
-
map.each { |operation, formats| create_html_public_method(xml, operation, formats) }
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
def create_return_complex_type_html(xml, complex_class, builder_out)
|
108
|
-
return_content = builder_out[0].multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
|
109
|
-
xml.span("class" => "pre") { xml.a("href" => "##{complex_class}") { |xml| xml.span("class" => "lightBlue") { |y| y<<"#{return_content}" } } }
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
|
-
def create_return_type_html(xml, formats)
|
114
|
-
xml.p "Return value:"
|
115
|
-
xml.ul {
|
116
|
-
xml.li {
|
117
|
-
unless formats[:builder_out].nil?
|
118
|
-
complex_class = formats[:builder_out][0].get_complex_class_name
|
119
|
-
if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:builder_out][0].type)
|
120
|
-
xml.span("class" => "pre") { |xml| xml.span("class" => "blue") { |sp| sp << "#{formats[:builder_out][0].type}" } }
|
121
|
-
else
|
122
|
-
create_return_complex_type_html(xml, complex_class, formats[:builder_out]) unless complex_class.nil?
|
123
|
-
end
|
124
|
-
else
|
125
|
-
xml.span("class" => "pre") { |sp| sp << "void" }
|
126
|
-
end
|
127
|
-
|
128
|
-
}
|
129
|
-
}
|
130
|
-
end
|
131
|
-
|
132
|
-
|
133
|
-
def create_parameters_html(xml, formats)
|
134
|
-
xml.p "Parameters:"
|
135
|
-
xml.ul {
|
136
|
-
j=0
|
137
|
-
mlen = formats[:builder_in].size
|
138
|
-
while j<mlen
|
139
|
-
param = formats[:builder_in][j]
|
140
|
-
complex_class = param.get_complex_class_name
|
141
|
-
xml.li("class" => "pre") { |pre|
|
142
|
-
if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
|
143
|
-
pre << "<span class='blue'>#{param.type}</span> <span class='bold'>#{param.name}</span>"
|
144
|
-
else
|
145
|
-
create_element_type_html(pre, complex_class, param)
|
146
|
-
end
|
147
|
-
}
|
148
|
-
j+=1
|
149
|
-
end
|
150
|
-
|
151
|
-
}
|
152
|
-
end
|
153
|
-
|
154
|
-
def create_exceptions_list_html(xml, formats)
|
155
|
-
unless formats[:raises].blank?
|
156
|
-
faults = formats[:raises]
|
157
|
-
faults = [formats[:raises]] if !faults.is_a?(Array)
|
158
|
-
|
159
|
-
faults = faults.select { |x| WashoutBuilder::Type.valid_fault_class?(x) }
|
160
|
-
unless faults.blank?
|
161
|
-
xml.p "Exceptions:"
|
162
|
-
xml.ul {
|
163
|
-
faults.each do |p|
|
164
|
-
xml.li("class" => "pre"){ |y| y<< "<a href='##{p.to_s}'><span class='lightBlue'> #{p.to_s}</span></a>" }
|
165
|
-
end
|
166
|
-
}
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
|
172
|
-
def create_html_public_method_return_type(xml,pre, formats)
|
173
|
-
unless formats[:builder_out].nil?
|
174
|
-
complex_class = formats[:builder_out][0].get_complex_class_name
|
175
|
-
if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:builder_out][0].type)
|
176
|
-
xml.span("class" => "blue") { |y| y<< "#{formats[:builder_out][0].type}" }
|
177
|
-
else
|
178
|
-
unless complex_class.nil?
|
179
|
-
if formats[:builder_out][0].multiplied == false
|
180
|
-
pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a>"
|
181
|
-
else
|
182
|
-
pre << "<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a>"
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
else
|
187
|
-
pre << "void"
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
def create_html_public_method_arguments_complex_type(pre, spacer, use_spacer, complex_class, param)
|
192
|
-
argument_content = param.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
|
193
|
-
pre << "#{use_spacer ? spacer: ''}<a href='##{complex_class}'><span class='lightBlue'>#{argument_content}</span></a> <span class='bold'>#{param.name}</span>"
|
194
|
-
end
|
195
|
-
|
196
|
-
def create_html_public_method_arguments(xml, pre, operation, formats)
|
197
|
-
mlen = formats[:builder_in].size
|
198
|
-
xml.br if mlen > 1
|
199
|
-
spacer = " "
|
200
|
-
if mlen > 0
|
201
|
-
j=0
|
202
|
-
while j<mlen
|
203
|
-
param = formats[:builder_in][j]
|
204
|
-
complex_class = param.get_complex_class_name
|
205
|
-
use_spacer = mlen > 1 ? true : false
|
206
|
-
if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
|
207
|
-
pre << "#{use_spacer ? spacer: ''}<span class='blue'>#{param.type}</span> <span class='bold'>#{param.name}</span>"
|
208
|
-
else
|
209
|
-
unless complex_class.nil?
|
210
|
-
create_html_public_method_arguments_complex_type(pre, spacer, use_spacer, complex_class, param)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
if j< (mlen-1)
|
214
|
-
xml.span ", "
|
215
|
-
end
|
216
|
-
if mlen > 1
|
217
|
-
xml.br
|
218
|
-
end
|
219
|
-
if (j+1) == mlen
|
220
|
-
xml.span("class" => "bold") {|y| y << ")" }
|
221
|
-
end
|
222
|
-
j+=1
|
223
|
-
end
|
224
|
-
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
|
229
|
-
def create_html_public_method(xml, operation, formats)
|
230
|
-
# raise YAML::dump(formats[:builder_in])
|
231
|
-
xml.h3 "#{operation}"
|
232
|
-
xml.a("name" => "#{operation}") {}
|
233
|
-
|
234
|
-
xml.p("class" => "pre"){ |pre|
|
235
|
-
create_html_public_method_return_type(xml,pre, formats)
|
236
|
-
xml.span("class" => "bold") {|y| y << "#{operation} (" }
|
237
|
-
create_html_public_method_arguments(xml, pre, operation, formats)
|
238
|
-
}
|
239
|
-
xml.p "#{formats[:description]}" if !formats[:description].blank?
|
240
|
-
create_parameters_html(xml, formats)
|
241
|
-
create_return_type_html(xml, formats)
|
242
|
-
create_exceptions_list_html(xml, formats)
|
243
|
-
end
|
244
|
-
|
245
|
-
end
|