5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rober/reader.rb', line 5
def self.read(path)
doc = Nokogiri::XML(file_read(path))
entities = []
doc.xpath('/ERD/ENTITY').each do |it|
entity = Rober::Entity.new
entity.logical_name = it[:"L-NAME"]
entity.physical_name = it[:"P-NAME"]
entity. = it[:"COMMENT"]
it.xpath('ATTR').each do |attr|
attribute = Rober::Attribute.new
attribute.logical_name = attr[:"L-NAME"]
attribute.physical_name = attr[:"P-NAME"]
attribute.datatype = attr[:"DATATYPE"]
attribute.length = attr[:"LENGTH"]
attribute.scale = attr[:"SCALE"]
attribute.null = attr[:"NULL"]
attribute.def = attr[:"DEF"]
attribute.pk = attr[:"PK"]
entity.add(attribute)
end
entities << entity
end
{entities: entities}
end
|