Class: ResoTransport::MetadataParser
- Inherits:
-
Object
- Object
- ResoTransport::MetadataParser
- Includes:
- REXML::StreamListener
- Defined in:
- lib/reso_transport/metadata_parser.rb
Instance Attribute Summary collapse
-
#entity_sets ⇒ Object
readonly
Returns the value of attribute entity_sets.
-
#enumerations ⇒ Object
readonly
Returns the value of attribute enumerations.
-
#schemas ⇒ Object
readonly
Returns the value of attribute schemas.
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize ⇒ MetadataParser
constructor
A new instance of MetadataParser.
- #parse(doc) ⇒ Object
- #tag_end(name) ⇒ Object
-
#tag_start(name, args) ⇒ Object
Schema -> EnumType -> Members -> Annotation EntityType -> Key Properties -> enumerations.
Constructor Details
#initialize ⇒ MetadataParser
Returns a new instance of MetadataParser.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/reso_transport/metadata_parser.rb', line 7 def initialize @schemas = [] @entity_sets = [] @entity_types = [] @enumerations = [] @current_entity_type = nil @current_complex_type = nil @current_enum_type = nil @current_member = nil end |
Instance Attribute Details
#entity_sets ⇒ Object (readonly)
Returns the value of attribute entity_sets.
5 6 7 |
# File 'lib/reso_transport/metadata_parser.rb', line 5 def entity_sets @entity_sets end |
#enumerations ⇒ Object (readonly)
Returns the value of attribute enumerations.
5 6 7 |
# File 'lib/reso_transport/metadata_parser.rb', line 5 def enumerations @enumerations end |
#schemas ⇒ Object (readonly)
Returns the value of attribute schemas.
5 6 7 |
# File 'lib/reso_transport/metadata_parser.rb', line 5 def schemas @schemas end |
Instance Method Details
#finalize ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/reso_transport/metadata_parser.rb', line 25 def finalize schemas.each do |s| s.entity_types.each do |et| et.properties.each do |p| p.finalize_type(self) end et..each do |p| p.finalize_type(self) end end s.complex_types.each do |et| et.properties.each do |p| p.finalize_type(self) end end end end |
#parse(doc) ⇒ Object
19 20 21 22 23 |
# File 'lib/reso_transport/metadata_parser.rb', line 19 def parse(doc) REXML::Document.parse_stream(doc, self) finalize return self end |
#tag_end(name) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/reso_transport/metadata_parser.rb', line 86 def tag_end(name) case name when "EntityType" @current_entity_type.schema = @schemas.last.namespace @schemas.last.entity_types << @current_entity_type when "ComplexType" @current_complex_type.schema = @schemas.last.namespace @schemas.last.complex_types << @current_complex_type when "EnumType" @enumerations << @current_enum_type @current_enum_type = nil when "Member" @current_enum_type.members << @current_member @current_member = nil end end |
#tag_start(name, args) ⇒ Object
Schema ->
EnumType ->
Members ->
Annotation
EntityType ->
Key
Properties ->
enumerations
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/reso_transport/metadata_parser.rb', line 55 def tag_start(name, args) case name when "Schema" @schemas << ResoTransport::Schema.from_stream(args) when "EntitySet" @entity_sets << ResoTransport::EntitySet.from_stream(args) when "EntityType" @current_entity_type = ResoTransport::EntityType.from_stream(args) when "ComplexType" @current_complex_type = ResoTransport::EntityType.from_stream(args) when "PropertyRef" @current_entity_type.primary_key = args['Name'] when "Property" @current_entity_type.properties << ResoTransport::Property.from_stream(args.merge(schema: @schemas.last)) if @current_entity_type @current_complex_type.properties << ResoTransport::Property.from_stream(args.merge(schema: @schemas.last)) if @current_complex_type when "NavigationProperty" @current_entity_type. << ResoTransport::Property.from_stream(args) when "EnumType" @current_enum_type = ResoTransport::Enum.from_stream(args.merge(schema: @schemas.last)) when "Member" @current_member = ResoTransport::Member.from_stream(args) when "Annotation" if @current_enum_type && @current_member @current_member.annotation = args['String'] end end rescue => e puts e.inspect puts "Error processing Tag: #{[name, args].inspect}" end |