class WsdlMapper::Naming::DefaultNamer

This is the default Namer implementation. It provides the de-facto standard of organizing and naming classes in ruby:

  1. Class/Module names are CamelCase (e.g. `SomeType`)

  2. File names are under_score (e.g. `some_type.rb`)

  3. Each class in its own file

  4. (De)Serializers are put within the same module as XSD Types

Public Class Methods

new(module_path: [], content_attribute_name: 'content', soap_array_item_name: 'item') click to toggle source

Initializes a new {DefaultNamer} instance.

@param [Array<String>] module_path the root module for the generated classes, e.g. `['MyApi', 'Types']` => `MyApi::Types::SomeClass` in `my_api/types/some_class.rb` @param [String] content_attribute_name the accessor name for {file:concepts/wrapping_types.md wrapping types} (complex _type with simple content and simple types with restrictions)

Calls superclass method
# File lib/wsdl_mapper/naming/default_namer.rb, line 28
def initialize(module_path: [],
    content_attribute_name: 'content',
    soap_array_item_name: 'item')
  super module_path: module_path

  @content_attribute_name = content_attribute_name
  @soap_array_item_name = soap_array_item_name
end

Public Instance Methods

get_attribute_name(attribute) click to toggle source

@param [WsdlMapper::Dom::Attribute] attribute @return [PropertyName]

# File lib/wsdl_mapper/naming/default_namer.rb, line 99
def get_attribute_name(attribute)
  PropertyName.new get_accessor_name(attribute.name.name), get_var_name(attribute.name.name)
end
get_content_name(_type) click to toggle source

@param [WsdlMapper::Dom::ComplexType, WsdlMapper::Dom::SimpleType] _type @return [PropertyName]

# File lib/wsdl_mapper/naming/default_namer.rb, line 112
def get_content_name(_type)
  @content_name ||= PropertyName.new get_accessor_name(@content_attribute_name), get_var_name(@content_attribute_name)
end
get_d10r_element_directory_name() click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 67
def get_d10r_element_directory_name
  get_support_name 'D10rElementDirectory'
end
get_d10r_name(type) click to toggle source

@param [WsdlMapper::Dom::ComplexType, WsdlMapper::Dom::SimpleType] type @return [TypeName]

# File lib/wsdl_mapper/naming/default_namer.rb, line 85
def get_d10r_name(type)
  type_name = TypeName.new get_d10r_class_name(type), get_d10r_module_path(type), get_d10r_file_name(type), get_d10r_file_path(type)
  type_name.parent = make_parents get_d10r_module_path(type)
  type_name
end
get_d10r_type_directory_name() click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 63
def get_d10r_type_directory_name
  get_support_name 'D10rTypeDirectory'
end
get_enumeration_value_name(_type, enum_value) click to toggle source

@param [WsdlMapper::Dom::SimpleType] _type @param [WsdlMapper::Dom::EnumerationValue] enum_value @return [EnumerationValueName]

# File lib/wsdl_mapper/naming/default_namer.rb, line 106
def get_enumeration_value_name(_type, enum_value)
  EnumerationValueName.new get_constant_name(enum_value.value), get_key_name(enum_value.value)
end
get_global_d10r_name() click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 71
def get_global_d10r_name
  get_support_name 'Deserializer'
end
get_global_s8r_name() click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 59
def get_global_s8r_name
  get_support_name 'Serializer'
end
get_inline_type(element) click to toggle source

@param [WsdlMapper::Dom::Property, WsdlMapper::Dom::Element] element @return [InlineType]

# File lib/wsdl_mapper/naming/default_namer.rb, line 118
def get_inline_type(element)
  name = element.name.name + 'InlineType'
  InlineType.new WsdlMapper::Dom::Name.get(element.name.ns, name)
end
get_property_name(property) click to toggle source

@param [WsdlMapper::Dom::Property] property @return [PropertyName]

# File lib/wsdl_mapper/naming/default_namer.rb, line 93
def get_property_name(property)
  PropertyName.new get_accessor_name(property.name.name), get_var_name(property.name.name)
end
get_s8r_name(type) click to toggle source

@param [WsdlMapper::Dom::ComplexType, WsdlMapper::Dom::SimpleType] type @return [TypeName]

# File lib/wsdl_mapper/naming/default_namer.rb, line 77
def get_s8r_name(type)
  type_name = TypeName.new get_s8r_class_name(type), get_s8r_module_path(type), get_s8r_file_name(type), get_s8r_file_path(type)
  type_name.parent = make_parents get_s8r_module_path(type)
  type_name
end
get_s8r_type_directory_name() click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 55
def get_s8r_type_directory_name
  get_support_name 'S8rTypeDirectory'
end
get_soap_array_item_name(_type) click to toggle source

@param [WsdlMapper::Dom::ComplexType] _type @return [String]

# File lib/wsdl_mapper/naming/default_namer.rb, line 125
def get_soap_array_item_name(_type)
  @soap_array_item_name
end
get_support_name(name) click to toggle source

@param [String] name @return [TypeName]

# File lib/wsdl_mapper/naming/default_namer.rb, line 49
def get_support_name(name)
  type_name = TypeName.new get_support_class_name(name), get_support_module_path(name), get_support_file_name(name), get_support_file_path(name)
  type_name.parent = make_parents get_support_module_path(name)
  type_name
end
get_type_name(type) click to toggle source

Returns a _type name for the given _type (simple or complex).

@param [WsdlMapper::Dom::ComplexType, WsdlMapper::Dom::SimpleType] type @return [TypeName]

# File lib/wsdl_mapper/naming/default_namer.rb, line 41
def get_type_name(type)
  type_name = TypeName.new get_class_name(type), get_class_module_path(type), get_class_file_name(type), get_class_file_path(type)
  type_name.parent = make_parents get_class_module_path(type)
  type_name
end

Protected Instance Methods

get_class_file_name(type) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 134
def get_class_file_name(type)
  underscore(type.name.name) + '.rb'
end
get_class_file_path(type) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 144
def get_class_file_path(type)
  get_file_path get_class_module_path type
end
get_class_module_path(type) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 138
def get_class_module_path(type)
  @module_path
end
get_class_name(type) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 130
def get_class_name(type)
  camelize type.name.name
end
get_d10r_class_name(type) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 154
def get_d10r_class_name(type)
  camelize type.name.name + 'Deserializer'
end
get_d10r_file_name(type) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 150
def get_d10r_file_name(type)
  underscore(type.name.name) + '_deserializer.rb'
end
get_d10r_file_path(type)
Alias for: get_class_file_path
get_d10r_module_path(type)
get_s8r_class_name(type) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 162
def get_s8r_class_name(type)
  camelize type.name.name + 'Serializer'
end
get_s8r_file_name(type) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 158
def get_s8r_file_name(type)
  underscore(type.name.name) + '_serializer.rb'
end
get_s8r_file_path(type)
Alias for: get_class_file_path
get_s8r_module_path(type)
get_support_class_name(name) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 166
def get_support_class_name(name)
  camelize name
end
get_support_file_name(name) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 178
def get_support_file_name(name)
  get_file_name name
end
get_support_file_path(name) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 174
def get_support_file_path(name)
  get_file_path get_support_module_path name
end
get_support_module_path(_name) click to toggle source
# File lib/wsdl_mapper/naming/default_namer.rb, line 170
def get_support_module_path(_name)
  @module_path
end