module WashoutBuilderHelper
def create_html_complex_types(xml, types)
types.each { |hash| create_complex_type_html(xml, hash[:obj], hash[:class], hash[:ancestors]) }
end
def create_complex_type_html(xml, param, class_name, ancestors)
unless param.blank?
xml.a( "name" => "#{class_name}") { }
xml.h3 { |pre| pre << "#{class_name} #{ancestors.blank? ? "" : "(extends #{ancestors[0].to_s.classify})" } " }
if param.is_a?(WashOut::Param)
xml.ul("class" => "pre") {
param.map.each do |element|
element.type = "string" if element.type == "text"
# raise YAML::dump(element) if class_name.include?("ype") and element.name == "members"
xml.li { |pre|
if WashoutBuilder::Type::BASIC_TYPES.include?(element.type)
element.type = "integer" if element.type == "int"
pre << "#{element.type} #{element.name}"
else
complex_class = element.get_complex_class_name
unless complex_class.nil?
if element.multiplied == false
pre << "#{complex_class} #{element.name}"
else
pre << "Array of #{complex_class} #{element.name}"
end
end
end
}
end
}
end
end
end
def create_html_fault_types_details(xml, fault_types)
unless fault_types.blank?
fault_types.each { |hash|
create_html_virtus_model_type(xml, hash[:fault],hash[:structure], hash[:ancestors])
}
end
end
def create_html_virtus_model_type(xml, param, fault_structure, ancestors)
if param.is_a?(Class)
xml.h3 { |pre| pre << "#{param} #{ancestors.blank? ? "" : "(extends #{ancestors[0].to_s.classify})" } " }
xml.a("name" => "#{param}") {}
xml.ul("class" => "pre") {
fault_structure.each do |attribute, attr_details|
xml.li { |pre|
if WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase) || attr_details[:primitive] == "nilclass"
pre << "#{attr_details[:primitive].to_s.downcase == "nilclass" ? "string" : attr_details[:primitive].to_s.downcase } #{attribute}"
else
if attr_details[:primitive].to_s.downcase == "array"
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]
pre << "Array of #{attr_primitive} #{attribute}"
else
pre << "#{attr_details[:primitive]} #{attribute}"
end
end
}
end
}
end
end
def create_html_public_methods(xml, map)
unless map.blank?
map =map.sort_by { |operation, formats| operation.downcase }.uniq
map.each { |operation, formats| create_html_public_method(xml, operation, formats) }
end
end
def create_html_public_method(xml, operation, formats)
# raise YAML::dump(formats[:in])
xml.h3 "#{operation}"
xml.a("name" => "#{operation}") {}
xml.p("class" => "pre"){ |pre|
unless formats[:out].nil?
complex_class = formats[:out][0].get_complex_class_name
if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:out][0].type)
xml.span("class" => "blue") { |y| y<< "#{formats[:out][0].type}" }
else
unless complex_class.nil?
if formats[:out][0].multiplied == false
pre << "#{complex_class}"
else
pre << "Array of #{complex_class}"
end
end
end
else
pre << "void"
end
xml.span("class" => "bold") {|y| y << "#{operation} (" }
mlen = formats[:in].size
xml.br if mlen > 1
spacer = " "
if mlen > 0
j=0
while j 1 ? true : false
if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
pre << "#{use_spacer ? spacer: ''}#{param.type} #{param.name}"
else
unless complex_class.nil?
if param.multiplied == false
pre << "#{use_spacer ? spacer: ''}#{complex_class} #{param.name}"
else
pre << "#{use_spacer ? spacer: ''}Array of #{complex_class} #{param.name}"
end
end
end
if j< (mlen-1)
xml.span ", "
end
if mlen > 1
xml.br
end
if (j+1) == mlen
xml.span("class" => "bold") {|y| y << ")" }
end
j+=1
end
end
}
xml.p "#{formats[:description]}" if !formats[:description].blank?
xml.p "Parameters:"
xml.ul {
j=0
mlen = formats[:in].size
while j "pre") { |pre|
if WashoutBuilder::Type::BASIC_TYPES.include?(param.type)
pre << "#{param.type} #{param.name}"
else
unless complex_class.nil?
if param.multiplied == false
pre << "#{complex_class} #{param.name}"
else
pre << "Array of #{complex_class} #{param.name}"
end
end
end
}
j+=1
end
}
xml.p "Return value:"
xml.ul {
xml.li {
if !formats[:out].nil?
if WashoutBuilder::Type::BASIC_TYPES.include?(formats[:out][0].type)
xml.span("class" => "pre") { |xml| xml.span("class" => "blue") { |sp| sp << "#{formats[:out][0].type}" } }
else
xml.span("class" => "pre") { xml.a("href" => "##{formats[:out][0].type}") { |xml| xml.span("class" => "lightBlue") { |y| y<<"#{formats[:out][0].type}" } } }
end
else
xml.span("class" => "pre") { |sp| sp << "void" }
end
}
}
unless formats[:raises].blank?
faults = formats[:raises]
faults = [formats[:raises]] if !faults.is_a?(Array)
faults = faults.select { |x| x.is_a?(Class) && x.ancestors.include?(WashOut::SOAPError) }
unless faults.blank?
xml.p "Exceptions:"
xml.ul {
faults.each do |p|
xml.li("class" => "pre"){ |y| y<< " #{p.to_s}" }
end
}
end
end
end
end