Skip to content

Commit

Permalink
Merge branch 'release/v0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Dec 3, 2013
2 parents 763e15b + 6719100 commit 3d209ab
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
58 changes: 53 additions & 5 deletions app/helpers/washout_builder_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,58 @@ def get_complex_class_name(p, defined = [])
return complex_class
end


def get_param_structure(param)
param.map.inject({}) {|h,element| h[element.name] = element.type;h }
end


def remove_type_inheritable_elements(param, keys)
param.map.delete_if{|element| keys.include?(element.name) }
end


def same_structure_as_ancestor?(param, ancestor)
param_structure = get_param_structure(param)
ancestor_structure = get_param_structure(ancestor)
if param_structure.keys == ancestor_structure.keys
return true
else
remove_type_inheritable_elements(param, ancestor_structure.keys)
return false
end
end




def get_class_ancestors(param,class_name, defined)
bool_the_same = false
param_class = class_name.is_a?(Class) ? class_name : class_name.constantize
ancestors = param_class.ancestors - param_class.included_modules
ancestors.delete_if{ |x| x.to_s.downcase == class_name.to_s.downcase || x.to_s == "ActiveRecord::Base" || x.to_s == "Object" || x.to_s =="BasicObject" || x.to_s == "WashOut::Type" }
unless ancestors.blank?
ancestor_class = ancestors[0]
ancestor_structure = {ancestor_class.to_s.downcase => ancestor_class.columns_hash.inject({}) {|h, (k,v)| h["#{k}"]="#{v.type}".to_sym; h } }
ancestor_object = WashoutBuilder::Param.parse_def(@soap_config,ancestor_structure)[0]
bool_the_same = same_structure_as_ancestor?(param, ancestor_object)
unless bool_the_same
top_ancestors = get_class_ancestors(ancestor_class, defined)
defined << {:class =>ancestor_class.to_s, :obj =>ancestor_object , :ancestors => top_ancestors }
end
end
ancestors unless bool_the_same
end


def get_nested_complex_types(param, defined)
defined = [] if defined.blank?
complex_class = get_complex_class_name(param, defined)
defined << {:class =>complex_class, :obj => param} unless complex_class.nil?
if param.classified?
defined << {:class =>complex_class, :obj => param, :ancestors => get_class_ancestors(param, complex_class, defined)} unless complex_class.nil?
else
defined << {:class =>complex_class, :obj => param} unless complex_class.nil?
end
if param.is_complex?
c_names = []
param.map.each do |obj|
Expand Down Expand Up @@ -57,21 +104,22 @@ def get_soap_action_names(map)

def create_html_complex_types(xml, types)
types.each do |hash|
create_complex_type_html(xml, hash[:obj], hash[:class])
create_complex_type_html(xml, hash[:obj], hash[:class], hash[:ancestors])
end
end



def create_complex_type_html(xml, param, class_name)
def create_complex_type_html(xml, param, class_name, ancestors)
unless param.blank?
xml.a( "name" => "#{class_name}") { }
xml.h3 "#{class_name}"
xml.h3 { |pre| pre << "#{class_name} #{ancestors.blank? ? "" : "(extends <a href='##{ancestors[0].to_s.classify}'> #{ancestors[0].to_s.classify} )</a>" } " }

if param.is_a?(WashoutBuilder::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)
Expand Down
1 change: 1 addition & 0 deletions lib/washout_builder/dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def _generate_doc
@name = controller_path.gsub('/', '_')
@service = self.class.name.underscore.gsub("_controller", "").camelize
@endpoint = @namespace.gsub("/wsdl", "/action")
@soap_config = soap_config

render :template => "wash_with_html/doc", :layout => false,
:content_type => 'text/html'
Expand Down
2 changes: 1 addition & 1 deletion lib/washout_builder/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module WashoutBuilder
VERSION = "0.4.4"
VERSION = "0.5.0"
end

0 comments on commit 3d209ab

Please sign in to comment.