joerivandervelde-molgenis-gem 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/molgenis_model.rb +2 -2
- data/lib/molgenis_parser.rb +17 -6
- metadata +2 -3
data/lib/molgenis_model.rb
CHANGED
@@ -39,7 +39,7 @@ module MOLGENIS # :nodoc:
|
|
39
39
|
|
40
40
|
#Definition of an Entity in MOLGENIS model
|
41
41
|
class EntityModel
|
42
|
-
attr_accessor :name
|
42
|
+
attr_accessor :name,:label, :fields, :abstract,:implements,:extends,:module_name,:color,:description
|
43
43
|
|
44
44
|
# Creates an empty entity
|
45
45
|
def initialize
|
@@ -50,6 +50,6 @@ module MOLGENIS # :nodoc:
|
|
50
50
|
end
|
51
51
|
|
52
52
|
class FieldModel
|
53
|
-
attr_accessor :name,:type,:system,:xref_entity,:xref_field
|
53
|
+
attr_accessor :name,:label,:type,:system,:xref_entity,:xref_field,:description
|
54
54
|
end
|
55
55
|
end
|
data/lib/molgenis_parser.rb
CHANGED
@@ -9,12 +9,13 @@ module MOLGENIS
|
|
9
9
|
# foo = ... # stuff to initialize foo here
|
10
10
|
# bar = MOLGENIS_MODEL:Parser.new.parse(foo)
|
11
11
|
def parse(molgenis_src)
|
12
|
+
puts "tests"
|
12
13
|
case molgenis_src.class.to_s
|
13
14
|
when /^string$/i
|
14
|
-
document = LibXML::XML::Parser.string(molgenis_src).parse
|
15
|
+
document = LibXML::XML::Parser.string(molgenis_src,:encoding => LibXML::XML::Encoding::UTF_8).parse
|
15
16
|
when /^stringio|file$/i
|
16
17
|
molgenis_src.rewind
|
17
|
-
document = LibXML::XML::Parser.string(molgenis_src.read).parse
|
18
|
+
document = LibXML::XML::Parser.string(molgenis_src.read,:encoding => LibXML::XML::Encoding::UTF_8).parse
|
18
19
|
else
|
19
20
|
raise "Error parsing file."
|
20
21
|
end
|
@@ -44,7 +45,7 @@ module MOLGENIS
|
|
44
45
|
parse_entities(element.find("entity"),model, color)
|
45
46
|
|
46
47
|
element.find("module").each { |module_xml|
|
47
|
-
|
48
|
+
|
48
49
|
module_obj = ModuleModel.new
|
49
50
|
module_attributes = module_xml.attributes
|
50
51
|
module_obj.name = module_attributes["name"]
|
@@ -56,28 +57,38 @@ module MOLGENIS
|
|
56
57
|
|
57
58
|
model.modules << module_obj
|
58
59
|
}
|
59
|
-
|
60
|
+
|
60
61
|
return model
|
61
62
|
end
|
62
63
|
|
63
64
|
def parse_entities(entities,module_obj,colorno)
|
64
|
-
|
65
|
+
if entities
|
65
66
|
entities.each do |entity_xml|
|
66
67
|
entity = EntityModel.new
|
67
68
|
entity.module_name = module_obj.name
|
68
69
|
entity_attributes = entity_xml.attributes
|
69
70
|
entity.name = entity_attributes["name"]
|
70
71
|
entity.color = colorno
|
72
|
+
|
73
|
+
entity.description =""
|
74
|
+
entity_xml.find("description").each { |desc|
|
75
|
+
desc.children.each { |el|
|
76
|
+
entity.description = entity.description + el.to_s
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
71
80
|
entity_attributes["implements"].split(",").each { |interface|
|
72
81
|
entity.implements << interface
|
73
82
|
} if !entity_attributes["implements"].nil?
|
74
83
|
entity.extends = entity_attributes["extends"]
|
75
|
-
|
84
|
+
|
76
85
|
entity_xml.find("field").each do |field_xml|
|
77
86
|
field = FieldModel.new
|
78
87
|
field_attributes = field_xml.attributes
|
79
88
|
field.name = field_attributes["name"]
|
80
89
|
field.type = field_attributes["type"]
|
90
|
+
field.label = field_attributes["label"]
|
91
|
+
field.description = field_attributes["description"]
|
81
92
|
if(field_attributes["xref_field"])
|
82
93
|
split = field_attributes["xref_field"].split(".")
|
83
94
|
if(split.size == 2)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joerivandervelde-molgenis-gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Morris Swertz
|
@@ -59,7 +59,6 @@ files:
|
|
59
59
|
- LICENCE
|
60
60
|
has_rdoc: true
|
61
61
|
homepage: http://gbic.target.rug.nl/trac/molgenis
|
62
|
-
licenses:
|
63
62
|
post_install_message:
|
64
63
|
rdoc_options:
|
65
64
|
- -N
|
@@ -82,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
81
|
requirements: []
|
83
82
|
|
84
83
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.2.0
|
86
85
|
signing_key:
|
87
86
|
specification_version: 1
|
88
87
|
summary: A Ruby implementation of the interaction of MOLGENIS datamodels (XML).
|