Class: WsdlMapper::DomGeneration::SchemaGenerator
- Inherits:
-
Generation::Base
- Object
- Generation::Base
- WsdlMapper::DomGeneration::SchemaGenerator
- Includes:
- Generation
- Defined in:
- lib/wsdl_mapper/dom_generation/schema_generator.rb
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) class_generator
readonly
Returns the value of attribute class_generator.
-
- (Object) context
readonly
Returns the value of attribute context.
-
- (Object) ctr_generator
readonly
Returns the value of attribute ctr_generator.
-
- (Object) enum_generator
readonly
Returns the value of attribute enum_generator.
-
- (Object) module_generator
readonly
Returns the value of attribute module_generator.
-
- (Object) namer
readonly
Returns the value of attribute namer.
-
- (Object) type_mapping
readonly
Returns the value of attribute type_mapping.
-
- (Object) value_defaults_generator
readonly
Returns the value of attribute value_defaults_generator.
-
- (Object) value_generator
readonly
Returns the value of attribute value_generator.
-
- (Object) wrapping_type_generator
readonly
Returns the value of attribute wrapping_type_generator.
Instance Method Summary (collapse)
- - (Object) generate(schema)
- - (Object) generate_complex_types(schema, result)
- - (Object) generate_enumerations(schema, result)
- - (Object) generate_restrictions(schema, result)
- - (Object) get_formatter(io)
- - (Object) get_ruby_type_name(type)
-
- (SchemaGenerator) initialize(context, skip_modules: false, formatter_factory: DefaultFormatter, namer: WsdlMapper::Naming::DefaultNamer.new, class_generator_factory: DefaultClassGenerator, module_generator_factory: DefaultModuleGenerator, ctr_generator_factory: NullCtrGenerator, enum_generator_factory: DefaultEnumGenerator, value_defaults_generator_factory: DefaultValueDefaultsGenerator, wrapping_type_generator_factory: DefaultWrappingTypeGenerator, type_mapping: WsdlMapper::TypeMapping::DEFAULT, value_generator: DefaultValueGenerator.new)
constructor
A new instance of SchemaGenerator.
Methods inherited from Generation::Base
#append_file_for, #file, #file_for, #generate_name, #get_module_names, #get_type_name, #type_file_for
Constructor Details
- (SchemaGenerator) initialize(context, skip_modules: false, formatter_factory: DefaultFormatter, namer: WsdlMapper::Naming::DefaultNamer.new, class_generator_factory: DefaultClassGenerator, module_generator_factory: DefaultModuleGenerator, ctr_generator_factory: NullCtrGenerator, enum_generator_factory: DefaultEnumGenerator, value_defaults_generator_factory: DefaultValueDefaultsGenerator, wrapping_type_generator_factory: DefaultWrappingTypeGenerator, type_mapping: WsdlMapper::TypeMapping::DEFAULT, value_generator: DefaultValueGenerator.new)
Returns a new instance of SchemaGenerator
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 29 def initialize(context, skip_modules: false, formatter_factory: DefaultFormatter, namer: WsdlMapper::Naming::DefaultNamer.new, class_generator_factory: DefaultClassGenerator, module_generator_factory: DefaultModuleGenerator, ctr_generator_factory: NullCtrGenerator, enum_generator_factory: DefaultEnumGenerator, value_defaults_generator_factory: DefaultValueDefaultsGenerator, wrapping_type_generator_factory: DefaultWrappingTypeGenerator, type_mapping: WsdlMapper::TypeMapping::DEFAULT, value_generator: DefaultValueGenerator.new) super(context) @formatter_factory = formatter_factory @namer = namer @class_generator = class_generator_factory.new self @module_generator = module_generator_factory.new self @ctr_generator = ctr_generator_factory.new self @enum_generator = enum_generator_factory.new self @value_defaults_generator = value_defaults_generator_factory.new self @wrapping_type_generator = wrapping_type_generator_factory.new self @type_mapping = type_mapping @value_generator = value_generator @skip_modules = skip_modules end |
Instance Attribute Details
- (Object) class_generator (readonly)
Returns the value of attribute class_generator
27 28 29 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 27 def class_generator @class_generator end |
- (Object) context (readonly)
Returns the value of attribute context
25 26 27 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 25 def context @context end |
- (Object) ctr_generator (readonly)
Returns the value of attribute ctr_generator
27 28 29 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 27 def ctr_generator @ctr_generator end |
- (Object) enum_generator (readonly)
Returns the value of attribute enum_generator
27 28 29 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 27 def enum_generator @enum_generator end |
- (Object) module_generator (readonly)
Returns the value of attribute module_generator
27 28 29 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 27 def module_generator @module_generator end |
- (Object) namer (readonly)
Returns the value of attribute namer
25 26 27 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 25 def namer @namer end |
- (Object) type_mapping (readonly)
Returns the value of attribute type_mapping
27 28 29 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 27 def type_mapping @type_mapping end |
- (Object) value_defaults_generator (readonly)
Returns the value of attribute value_defaults_generator
27 28 29 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 27 def value_defaults_generator @value_defaults_generator end |
- (Object) value_generator (readonly)
Returns the value of attribute value_generator
27 28 29 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 27 def value_generator @value_generator end |
- (Object) wrapping_type_generator (readonly)
Returns the value of attribute wrapping_type_generator
27 28 29 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 27 def wrapping_type_generator @wrapping_type_generator end |
Instance Method Details
- (Object) generate(schema)
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 57 def generate(schema) result = Result.new schema: schema generate_complex_types schema, result generate_enumerations schema, result generate_restrictions schema, result unless @skip_modules result.module_tree.each do |module_node| @module_generator.generate module_node, result end end result end |
- (Object) generate_complex_types(schema, result)
119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 119 def generate_complex_types(schema, result) complex_types = schema.each_type.select(&WsdlMapper::Dom::ComplexType).to_a types_to_generate = complex_types.map do |type| name = namer.get_type_name get_type_name(type) TypeToGenerate.new type, name end types_to_generate.each do |ttg| @class_generator.generate ttg, result end end |
- (Object) generate_enumerations(schema, result)
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 105 def generate_enumerations(schema, result) enum_types = schema.each_type.select(&WsdlMapper::Dom::SimpleType).select(&:enumeration?).to_a types_to_generate = enum_types.map do |type| name = namer.get_type_name get_type_name(type) TypeToGenerate.new type, name end types_to_generate.each do |ttg| @enum_generator.generate ttg, result end end |
- (Object) generate_restrictions(schema, result)
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 91 def generate_restrictions(schema, result) types = schema.each_type.select(&WsdlMapper::Dom::SimpleType).reject(&:enumeration?).to_a types_to_generate = types.map do |type| name = namer.get_type_name get_type_name(type) TypeToGenerate.new type, name end types_to_generate.each do |ttg| @wrapping_type_generator.generate ttg, result end end |
- (Object) get_formatter(io)
73 74 75 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 73 def get_formatter(io) @formatter_factory.new io end |
- (Object) get_ruby_type_name(type)
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/wsdl_mapper/dom_generation/schema_generator.rb', line 77 def get_ruby_type_name(type) if type.name.nil? type = get_type_name type end if WsdlMapper::Dom::BuiltinType.builtin? type.name type_mapping.ruby_type type.name elsif WsdlMapper::Dom::SoapEncodingType.builtin? type.name '::Array' else namer.get_type_name(type).name end end |