voruby 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +339 -0
- data/REQUIREMENTS +4 -0
- data/Rakefile.rb +296 -0
- data/lib/voruby/adql/adql.rb +2735 -0
- data/lib/voruby/adql/ext.rb +15 -0
- data/lib/voruby/adql/loader.rb +5 -0
- data/lib/voruby/adql/operations.rb +54 -0
- data/lib/voruby/adql/parser.rb +160 -0
- data/lib/voruby/adql/transforms.rb +573 -0
- data/lib/voruby/ext.rb +17 -0
- data/lib/voruby/loader.rb +4 -0
- data/lib/voruby/misc/propertyfile.rb +36 -0
- data/lib/voruby/plastic/applications.rb +174 -0
- data/lib/voruby/plastic/constants.rb +30 -0
- data/lib/voruby/plastic/loader.rb +10 -0
- data/lib/voruby/plastic/plastic.rb +1 -0
- data/lib/voruby/resources/conesearch/conesearch.rb +9 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +55 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +50 -0
- data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +72 -0
- data/lib/voruby/resources/conesearch/loader.rb +4 -0
- data/lib/voruby/resources/loader.rb +50 -0
- data/lib/voruby/resources/nodes.rb +190 -0
- data/lib/voruby/resources/openskynode/loader.rb +4 -0
- data/lib/voruby/resources/openskynode/openskynode.rb +9 -0
- data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +54 -0
- data/lib/voruby/resources/sia/loader.rb +5 -0
- data/lib/voruby/resources/sia/sia.rb +9 -0
- data/lib/voruby/resources/sia/sia_v0_6.rb +90 -0
- data/lib/voruby/resources/sia/sia_v0_7.rb +89 -0
- data/lib/voruby/resources/sia/sia_v1_0.rb +122 -0
- data/lib/voruby/resources/stsci.rb +59 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +195 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +158 -0
- data/lib/voruby/resources/vodataservice/loader.rb +5 -0
- data/lib/voruby/resources/vodataservice/vodataservice.rb +9 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +189 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +163 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +221 -0
- data/lib/voruby/resources/voregistry/loader.rb +4 -0
- data/lib/voruby/resources/voregistry/voregistry.rb +9 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +40 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +30 -0
- data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +86 -0
- data/lib/voruby/resources/voresource/loader.rb +17 -0
- data/lib/voruby/resources/voresource/voresource.rb +9 -0
- data/lib/voruby/resources/voresource/voresource_v0_10.rb +322 -0
- data/lib/voruby/resources/voresource/voresource_v0_9.rb +405 -0
- data/lib/voruby/resources/voresource/voresource_v1_0.rb +230 -0
- data/lib/voruby/services/ext.rb +11 -0
- data/lib/voruby/services/gestalt/footprint.rb +95 -0
- data/lib/voruby/services/gestalt/wcs_fixer.rb +105 -0
- data/lib/voruby/services/gestalt/wesix.rb +155 -0
- data/lib/voruby/services/loader.rb +7 -0
- data/lib/voruby/services/registry/registry.rb +53 -0
- data/lib/voruby/services/resolver/resolver.rb +35 -0
- data/lib/voruby/sesame/loader.rb +6 -0
- data/lib/voruby/sesame/sesame_v1_0.rb +64 -0
- data/lib/voruby/simple/loader.rb +6 -0
- data/lib/voruby/simple/parameters.rb +196 -0
- data/lib/voruby/simple/sap.rb +446 -0
- data/lib/voruby/spacetime/loader.rb +3 -0
- data/lib/voruby/spacetime/spacetime.rb +607 -0
- data/lib/voruby/stc/coords_v1_20.rb +900 -0
- data/lib/voruby/stc/loader.rb +55 -0
- data/lib/voruby/stc/region_v1_20.rb +274 -0
- data/lib/voruby/stc/stc_v1_20.rb +1196 -0
- data/lib/voruby/util.rb +27 -0
- data/lib/voruby/voevent/loader.rb +7 -0
- data/lib/voruby/voevent/voevent_v1_0.rb +213 -0
- data/lib/voruby/voevent/voevent_v1_1.rb +196 -0
- data/lib/voruby/votables/chandra.rb +410 -0
- data/lib/voruby/votables/cnoc.rb +393 -0
- data/lib/voruby/votables/data.rb +179 -0
- data/lib/voruby/votables/galex.rb +390 -0
- data/lib/voruby/votables/hst.rb +391 -0
- data/lib/voruby/votables/int.rb +391 -0
- data/lib/voruby/votables/libxml_parser.rb +411 -0
- data/lib/voruby/votables/libxml_votable.rb +67 -0
- data/lib/voruby/votables/loader.rb +10 -0
- data/lib/voruby/votables/meta.rb +763 -0
- data/lib/voruby/votables/misc.rb +51 -0
- data/lib/voruby/votables/nsa.rb +393 -0
- data/lib/voruby/votables/nsar3.rb +410 -0
- data/lib/voruby/votables/rexml_parser.rb +408 -0
- data/lib/voruby/votables/rexml_votable.rb +67 -0
- data/lib/voruby/votables/sdss.rb +393 -0
- data/lib/voruby/votables/transforms.rb +388 -0
- data/lib/voruby/votables/tree.rb +45 -0
- data/lib/voruby/votables/types.rb +391 -0
- data/lib/voruby/votables/votable.rb +630 -0
- data/lib/voruby/votables/xmm.rb +394 -0
- data/test/adql/test1.adql +49 -0
- data/test/adql/test2.adql +51 -0
- data/test/adql/test3.adql +81 -0
- data/test/adql/test4.adql +53 -0
- data/test/adql/test5.adql +55 -0
- data/test/adql/test6.adql +18 -0
- data/test/adql/test7.adql +48 -0
- data/test/adql/unittest.rb +1672 -0
- data/test/plastic/test.rb +44 -0
- data/test/plastic/test.vot +5385 -0
- data/test/plastic/unittest.rb +66 -0
- data/test/resources/conesearch/conesearch_v0_3.xml +31 -0
- data/test/resources/conesearch/conesearch_v1_0.xml +86 -0
- data/test/resources/conesearch/unittest_v0_3.rb +22 -0
- data/test/resources/conesearch/unittest_v1_0.rb +24 -0
- data/test/resources/openskynode/open_sky_node_v0_1.xml +32 -0
- data/test/resources/openskynode/unittest_v0_1.rb +31 -0
- data/test/resources/sia/simple_image_access_v0_7.xml +36 -0
- data/test/resources/sia/simple_image_access_v1_0.xml +122 -0
- data/test/resources/sia/unittest_v0_7.rb +24 -0
- data/test/resources/sia/unittest_v1_0.rb +29 -0
- data/test/resources/stsci.xml +336 -0
- data/test/resources/unittest_stsci.rb +25 -0
- data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +128 -0
- data/test/resources/vodataservice/data_collection_resource_v0_5.xml +54 -0
- data/test/resources/vodataservice/data_collection_resource_v1_0.xml +117 -0
- data/test/resources/vodataservice/data_service_resource_v1_0.xml +115 -0
- data/test/resources/vodataservice/sky_service_resource_v0_10.xml +45 -0
- data/test/resources/vodataservice/table_service_resource_v1_0.xml +122 -0
- data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +60 -0
- data/test/resources/vodataservice/unittest_v0_5.rb +126 -0
- data/test/resources/vodataservice/unittest_v1_0.rb +151 -0
- data/test/resources/voregistry/authority_resource_v0_3.xml +20 -0
- data/test/resources/voregistry/authority_resource_v1_0.xml +82 -0
- data/test/resources/voregistry/registry_service_v0_3.xml +20 -0
- data/test/resources/voregistry/registry_service_v1_0.xml +107 -0
- data/test/resources/voregistry/unittest_v0_3.rb +31 -0
- data/test/resources/voregistry/unittest_v1_0.rb +34 -0
- data/test/resources/voresource/organisation_resource_v1_0.xml +90 -0
- data/test/resources/voresource/resource_organisation_v0_10.xml +22 -0
- data/test/resources/voresource/resource_service_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v1_0.xml +79 -0
- data/test/resources/voresource/service_resource_v1_0.xml +91 -0
- data/test/resources/voresource/unittest_v0_10.rb +61 -0
- data/test/resources/voresource/unittest_v0_9.rb +4 -0
- data/test/resources/voresource/unittest_v1_0.rb +190 -0
- data/test/services/gestalt/unittest.rb +74 -0
- data/test/services/registry/unittest.rb +34 -0
- data/test/services/resolver/unittest.rb +38 -0
- data/test/simple/unittest.rb +46 -0
- data/test/spacetime/unittest.rb +39 -0
- data/test/stc/catalog_entry_location_v1_20.xml +112 -0
- data/test/stc/obs_data_location_v1_20.xml +108 -0
- data/test/stc/search_location_v1_20.xml +54 -0
- data/test/stc/stc_resource_profile_v1_20.xml +60 -0
- data/test/stc/unittest_v1_20.rb +620 -0
- data/test/voevent/unittest_v1_0.rb +79 -0
- data/test/voevent/unittest_v1_1.rb +70 -0
- data/test/voevent/voevent_v1_0.xml +96 -0
- data/test/voevent/voevent_v1_1.xml +76 -0
- data/test/votables/test.vot +366 -0
- data/test/votables/unittest.rb +54 -0
- metadata +256 -0
@@ -0,0 +1,408 @@
|
|
1
|
+
module VORuby
|
2
|
+
module VOTables
|
3
|
+
module VOTable
|
4
|
+
require 'rexml/document'
|
5
|
+
|
6
|
+
module Meta
|
7
|
+
|
8
|
+
class Description
|
9
|
+
def self.from_xml(node)
|
10
|
+
return Meta::Description.new(node.text)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Definitions
|
15
|
+
def self.from_xml(node)
|
16
|
+
systems = []
|
17
|
+
node.elements.each('COOSYS'){ |sysNode|
|
18
|
+
systems.push(Meta::CooSys.from_xml(sysNode))
|
19
|
+
}
|
20
|
+
|
21
|
+
params = []
|
22
|
+
node.elements.each('PARAM'){ |paramNode|
|
23
|
+
params.push(Meta::Param.from_xml(paramNode))
|
24
|
+
}
|
25
|
+
|
26
|
+
return self.new(systems, params)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class CooSys
|
31
|
+
def self.from_xml(node)
|
32
|
+
id = node.attributes['ID']
|
33
|
+
equinox = Type::AstroYear.new(node.attributes['equinox']) if node.attributes['equinox']
|
34
|
+
epoch = Type::AstroYear.new(node.attributes['epoch']) if node.attributes['epoch']
|
35
|
+
system = Type::CoordSystemType.new(node.attributes['system']) if node.attributes['system']
|
36
|
+
|
37
|
+
return self.new(id, equinox, epoch, system)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Link
|
42
|
+
def self.from_xml(node)
|
43
|
+
id = node.attributes['ID']
|
44
|
+
content_role =
|
45
|
+
Type::ContentRole.new(node.attributes['content-role']) if node.attributes['content-role']
|
46
|
+
content_type = node.attributes['content-type']
|
47
|
+
title = node.attributes['title']
|
48
|
+
value = node.attributes['value']
|
49
|
+
href = Type::AnyURI.new(node.attributes['href']) if node.attributes['href']
|
50
|
+
gref = node.attributes['gref']
|
51
|
+
action = Type::AnyURI.new(node.attributes['action']) if node.attributes['action']
|
52
|
+
|
53
|
+
return self.new(href, value, title, action, id, content_type, content_role, gref)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Values
|
58
|
+
def self.from_xml(node)
|
59
|
+
# Attributes
|
60
|
+
id = node.attributes['ID'] if node.attributes['ID']
|
61
|
+
type = Type::ValuesType.new(node.attributes['type']) if node.attributes['type']
|
62
|
+
null = node.attributes['null'] if node.attributes['null']
|
63
|
+
ref = node.attributes['ref'] if node.attributes['ref']
|
64
|
+
|
65
|
+
# Elements
|
66
|
+
min = Meta::Min.from_xml(node.elements.to_a('MIN').first) if node.elements['MIN']
|
67
|
+
max = Meta::Max.from_xml(node.elements.to_a('MAX').first) if node.elements['MAX']
|
68
|
+
options = []
|
69
|
+
node.elements.each('OPTION'){ |optNode|
|
70
|
+
options.push(Meta::Option.from_xml(optNode))
|
71
|
+
}
|
72
|
+
|
73
|
+
return self.new(min, max, options, id, type, null, ref)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class FieldRef
|
78
|
+
def self.from_xml(node)
|
79
|
+
ref = node.attributes['ref'] if node.attributes['ref']
|
80
|
+
|
81
|
+
return self.new(ref)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class ParamRef
|
86
|
+
def self.from_xml(node)
|
87
|
+
ref = node.attributes['ref'] if node.attributes['ref']
|
88
|
+
|
89
|
+
return self.new(ref)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class Group
|
94
|
+
def self.from_xml(node)
|
95
|
+
# Attributes
|
96
|
+
id = node.attributes['ID'] if node.attributes['ID']
|
97
|
+
name = node.attributes['name'] if node.attributes['name']
|
98
|
+
ref = node.attributes['ref'] if node.attributes['ref']
|
99
|
+
ucd = Type::UCDType.new(node.attributes['ucd']) if node.attributes['ucd']
|
100
|
+
utype = node.attributes['utype'] if node.attributes['utype']
|
101
|
+
|
102
|
+
# Elements
|
103
|
+
description =
|
104
|
+
Meta::Description.from_xml(node.elements.to_a('DESCRIPTION').first) if node.elements['DESCRIPTION']
|
105
|
+
|
106
|
+
fieldrefs = []
|
107
|
+
node.elements.each('FIELDref'){ |fref|
|
108
|
+
fieldrefs.push(Meta::FieldRef.from_xml(fref))
|
109
|
+
}
|
110
|
+
|
111
|
+
paramrefs = []
|
112
|
+
node.elements.each('PARAMref'){ |pref|
|
113
|
+
paramrefs.push(Meta::ParamRef.from_xml(pref))
|
114
|
+
}
|
115
|
+
|
116
|
+
params = []
|
117
|
+
node.elements.each('PARAM'){ |param|
|
118
|
+
params.push(Meta::Param.from_xml(param))
|
119
|
+
}
|
120
|
+
|
121
|
+
groups = []
|
122
|
+
node.elements.each('GROUP'){ |group|
|
123
|
+
groups.push(Meta::Group.from_xml(group))
|
124
|
+
}
|
125
|
+
|
126
|
+
return self.new(name, ucd, description, fieldrefs, paramrefs, params, groups,
|
127
|
+
id, ref, utype)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class Param
|
132
|
+
def self.from_xml(node)
|
133
|
+
# Attributes
|
134
|
+
id = node.attributes['ID'] if node.attributes['ID']
|
135
|
+
unit = node.attributes['unit'] if node.attributes['unit']
|
136
|
+
datatype = Type::DataType.new(node.attributes['datatype']) if node.attributes['datatype']
|
137
|
+
precision = Type::PrecisionType.new(node.attributes['precision']) if node.attributes['precision']
|
138
|
+
width = Type::PositiveInteger.new(node.attributes['width'].to_i) if node.attributes['width']
|
139
|
+
ref = node.attributes['ref'] if node.attributes['ref']
|
140
|
+
name = node.attributes['name'] if node.attributes['name']
|
141
|
+
ucd = Type::UCDType.new(node.attributes['ucd']) if node.attributes['ucd']
|
142
|
+
utype = node.attributes['utype'] if node.attributes['utype']
|
143
|
+
value = node.attributes['value'] if node.attributes['value']
|
144
|
+
arraysize = Type::ArrayDef.new(node.attributes['arraysize']) if node.attributes['arraysize']
|
145
|
+
|
146
|
+
# Elements
|
147
|
+
description =
|
148
|
+
Meta::Description.from_xml(node.elements.to_a('DESCRIPTION').first) if node.elements['DESCRIPTION']
|
149
|
+
values = Meta::Values.from_xml(node.elements.to_a('VALUES').first) if node.elements['VALUES']
|
150
|
+
links = []
|
151
|
+
node.elements.each('LINK'){ |linkNode|
|
152
|
+
links.push(Meta::Link.from_xml(linkNode))
|
153
|
+
}
|
154
|
+
|
155
|
+
return self.new(name, datatype, value, ucd, unit, description, values, links,
|
156
|
+
id, precision, utype, width, ref, arraysize)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class Field
|
161
|
+
def self.from_xml(node)
|
162
|
+
# Attributes
|
163
|
+
id = node.attributes['ID'] if node.attributes['ID']
|
164
|
+
unit = node.attributes['unit'] if node.attributes['unit']
|
165
|
+
datatype = Type::DataType.new(node.attributes['datatype']) if node.attributes['datatype']
|
166
|
+
precision = Type::PrecisionType.new(node.attributes['precision']) if node.attributes['precision']
|
167
|
+
width = Type::PositiveInteger.new(node.attributes['width'].to_i) if node.attributes['width']
|
168
|
+
ref = node.attributes['ref'] if node.attributes['ref']
|
169
|
+
name = node.attributes['name'] if node.attributes['name']
|
170
|
+
ucd = Type::UCDType.new(node.attributes['ucd']) if node.attributes['ucd']
|
171
|
+
arraysize = Type::ArrayDef.new(node.attributes['arraysize']) if node.attributes['arraysize']
|
172
|
+
type = Type::FieldType.new(node.attributes['type']) if node.attributes['type']
|
173
|
+
utype = node.attributes['utype'] if node.attributes['utype']
|
174
|
+
|
175
|
+
# Elements
|
176
|
+
description =
|
177
|
+
Meta::Description.from_xml(node.elements.to_a('DESCRIPTION').first) if node.elements['DESCRIPTION']
|
178
|
+
values = Meta::Values.from_xml(node.elements.to_a('VALUES').first) if node.elements['VALUES']
|
179
|
+
links = []
|
180
|
+
node.elements.each('LINK'){ |link|
|
181
|
+
links.push(Meta::Link.from_xml(link))
|
182
|
+
}
|
183
|
+
|
184
|
+
return self.new(name, datatype, ucd, unit, description, values,
|
185
|
+
links, id, precision, utype, width, ref, arraysize, type)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
class Info
|
190
|
+
def self.from_xml(node)
|
191
|
+
id = node.attributes['ID']
|
192
|
+
name = node.attributes['name']
|
193
|
+
value = node.attributes['value']
|
194
|
+
text = node.text
|
195
|
+
|
196
|
+
return self.new(name, value, id, text)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
class Table
|
201
|
+
def self.from_xml(node)
|
202
|
+
# Attributes
|
203
|
+
id = node.attributes['ID'] if node.attributes['ID']
|
204
|
+
name = node.attributes['name'] if node.attributes['name']
|
205
|
+
ref = node.attributes['ref'] if node.attributes['ref']
|
206
|
+
ucd = Type::UCDType.new(node.attributes['ucd']) if node.attributes['ucd']
|
207
|
+
utype = node.attributes['utype'] if node.attributes['utype']
|
208
|
+
nrows = Type::NonNegativeInteger.new(node.attributes['nrows'].to_i) if node.attributes['nrows']
|
209
|
+
|
210
|
+
# Elements
|
211
|
+
description =
|
212
|
+
Meta::Description.from_xml(node.elements.to_a('DESCRIPTION').first) if node.elements['DESCRIPTION']
|
213
|
+
|
214
|
+
fields = []
|
215
|
+
node.elements.each('FIELD'){ |fieldNode|
|
216
|
+
fields.push(Meta::Field.from_xml(fieldNode))
|
217
|
+
}
|
218
|
+
|
219
|
+
params = []
|
220
|
+
node.elements.each('PARAM'){ |paramNode|
|
221
|
+
params.push(Meta::Param.from_xml(paramNode))
|
222
|
+
}
|
223
|
+
|
224
|
+
groups = []
|
225
|
+
node.elements.each('GROUP'){ |groupNode|
|
226
|
+
params.push(Meta::Group.from_xml(groupNode))
|
227
|
+
}
|
228
|
+
|
229
|
+
links = []
|
230
|
+
node.elements.each('LINK'){ |linkNode|
|
231
|
+
params.push(Meta::Link.from_xml(linkNode))
|
232
|
+
}
|
233
|
+
|
234
|
+
data = Data::Data.from_xml(node.elements.to_a('DATA').first) if node.elements['DATA']
|
235
|
+
|
236
|
+
return self.new(name, id, ucd, utype, ref, nrows, description,
|
237
|
+
fields, params, groups, links, data)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
class Resource
|
242
|
+
def self.from_xml(node)
|
243
|
+
# Attributes
|
244
|
+
name = node.attributes['name'] if node.attributes['name']
|
245
|
+
id = node.attributes['ID'] if node.attributes['ID']
|
246
|
+
utype = node.attributes['utype'] if node.attributes['utype']
|
247
|
+
type = Type::ResourceType.new(node.attributes['type']) if node.attributes['type']
|
248
|
+
|
249
|
+
# Elements
|
250
|
+
description =
|
251
|
+
Meta::Description.from_xml(node.elements.to_a('DESCRIPTION').first) if node.elements['DESCRIPTION']
|
252
|
+
|
253
|
+
info = []
|
254
|
+
node.elements.each('INFO'){ |infoNode|
|
255
|
+
info.push(Meta::Info.from_xml(infoNode))
|
256
|
+
}
|
257
|
+
|
258
|
+
systems = []
|
259
|
+
node.elements.each('COOSYS'){ |sysNode|
|
260
|
+
systems.push(Meta::CooSys.from_xml(sysNode))
|
261
|
+
}
|
262
|
+
|
263
|
+
params = []
|
264
|
+
node.elements.each('PARAM'){ |paramNode|
|
265
|
+
params.push(Meta::Param.from_xml(paramNode))
|
266
|
+
}
|
267
|
+
|
268
|
+
resources = []
|
269
|
+
node.elements.each('RESOURCE'){ |resNode|
|
270
|
+
resources.push(Meta::Resource.from_xml(resNode))
|
271
|
+
}
|
272
|
+
|
273
|
+
links = []
|
274
|
+
node.elements.each('LINK'){ |linkNode|
|
275
|
+
links.push(Meta::Link.from_xml(linkNode))
|
276
|
+
}
|
277
|
+
|
278
|
+
tables = []
|
279
|
+
node.elements.each('TABLE'){ |tblNode|
|
280
|
+
tables.push(Meta::Table.from_xml(tblNode))
|
281
|
+
}
|
282
|
+
|
283
|
+
return self.new(name, id, utype, type, description,
|
284
|
+
info, systems, params, links, tables, resources)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
class Option
|
289
|
+
def self.from_xml(node)
|
290
|
+
value = node.attributes['value'] if node.attributes['value']
|
291
|
+
name = node.attributes['name'] if node.attributes['name']
|
292
|
+
|
293
|
+
options = []
|
294
|
+
node.elements.each('OPTION'){ |optNode|
|
295
|
+
options.push(Meta::Option.from_xml(optNode))
|
296
|
+
}
|
297
|
+
|
298
|
+
return self.new(value, name, options)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
class Max
|
303
|
+
def self.from_xml(node)
|
304
|
+
value = node.attributes['node'] if node.attributes['node']
|
305
|
+
inclusive = Type::YesNo.new(node.attributes['inclusive']) if node.attributes['inclusive']
|
306
|
+
|
307
|
+
return self.new(value, inclusive)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
class Min
|
312
|
+
def self.from_xml(node)
|
313
|
+
value = node.attributes['node'] if node.attributes['node']
|
314
|
+
inclusive = Type::YesNo.new(node.attributes['inclusive']) if node.attributes['inclusive']
|
315
|
+
|
316
|
+
return self.new(value, inclusive)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
end
|
321
|
+
|
322
|
+
module Data
|
323
|
+
|
324
|
+
class Stream
|
325
|
+
def self.from_xml(node)
|
326
|
+
href = Type::AnyURI.new(node.attributes['href']) if node.attributes['href']
|
327
|
+
expires = DateTime.parse(node.attributes['expires']) if node.attributes['expires']
|
328
|
+
rights = node.attributes['rights']
|
329
|
+
type = Type::StreamType.new(node.attributes['type']) if node.attributes['type']
|
330
|
+
actuate = Type::Actuate.new(node.attributes['actuate']) if node.attributes['actuate']
|
331
|
+
encoding = Type::EncodingType.new(node.attributes['encoding']) if node.attributes['encoding']
|
332
|
+
|
333
|
+
return self.new(href, expires, rights, type, actuate, encoding)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
class BinaryStream
|
338
|
+
def self.from_xml(node)
|
339
|
+
stream = Stream.from_xml(node.elements.each('STREAM').first)
|
340
|
+
|
341
|
+
return self.new(stream)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
class FITSStream
|
346
|
+
def self.from_xml(node)
|
347
|
+
stream = Stream.from_xml(node.elements.each('STREAM').first)
|
348
|
+
extnum = Type::PositiveInteger.new(node.attributes['extnum'].to_i) if node.attributes['extnum']
|
349
|
+
|
350
|
+
return self.new(stream, extnum)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
class TD
|
355
|
+
def self.from_xml(node)
|
356
|
+
value = node.text
|
357
|
+
encoding = Type::EncodingType.new(node.attributes['encoding']) if node.attributes['encoding']
|
358
|
+
|
359
|
+
return self.new(value, encoding)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
class TR
|
364
|
+
def self.from_xml(node)
|
365
|
+
tds = []
|
366
|
+
node.elements.each('TD'){ |tdNode|
|
367
|
+
tds.push(TD.from_xml(tdNode))
|
368
|
+
}
|
369
|
+
|
370
|
+
return self.new(tds)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
class TableData
|
375
|
+
def self.from_xml(node)
|
376
|
+
trs = []
|
377
|
+
node.elements.each('TR'){ |trNode|
|
378
|
+
trs.push(TR.from_xml(trNode))
|
379
|
+
}
|
380
|
+
|
381
|
+
return self.new(trs)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
class Data
|
386
|
+
def self.from_xml(node)
|
387
|
+
format = nil
|
388
|
+
node.elements.each('FITS'){ |fnode|
|
389
|
+
format = FITSStream.from_xml(fnode)
|
390
|
+
}
|
391
|
+
|
392
|
+
node.elements.each('BINARY'){ |bnode|
|
393
|
+
format = BinaryStream.from_xml(bode)
|
394
|
+
}
|
395
|
+
|
396
|
+
node.elements.each('TABLEDATA'){ |tnode|
|
397
|
+
format = TableData.from_xml(tnode)
|
398
|
+
}
|
399
|
+
|
400
|
+
return self.new(format)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
end
|
408
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module VORuby
|
2
|
+
module VOTables
|
3
|
+
|
4
|
+
module VOTable
|
5
|
+
require 'voruby/votables/votable'
|
6
|
+
require 'voruby/votables/rexml_parser'
|
7
|
+
|
8
|
+
# A wrapper around VOTable::VOTable that uses ruby's built in rexml library
|
9
|
+
# to parse XML. Typically one would use VOTABLE::TreeParsedVOTable
|
10
|
+
# rather than using this class directly.
|
11
|
+
# rexml_votable = VOTable::RexmlParsedVOTable('my_votable.xml')
|
12
|
+
# votable = rexml_votable.votable
|
13
|
+
class RexmlParsedVOTable
|
14
|
+
attr_reader :path, :votable
|
15
|
+
|
16
|
+
# [_path_:]
|
17
|
+
# The path to the VOTable XML file to parse.
|
18
|
+
def initialize(path)
|
19
|
+
@path = path
|
20
|
+
file = File.new(path)
|
21
|
+
|
22
|
+
doc = REXML::Document.new(file)
|
23
|
+
root = doc.root # Root document
|
24
|
+
|
25
|
+
# Attributes
|
26
|
+
id = root.attributes['ID'] if root.attributes['ID']
|
27
|
+
version = root.attributes['version'] if root.attributes['version']
|
28
|
+
|
29
|
+
# Elements
|
30
|
+
description =
|
31
|
+
Meta::Description.from_xml(root.elements.to_a('DESCRIPTION').first) if root.elements['DESCRIPTION']
|
32
|
+
definition =
|
33
|
+
Meta::Definitions.from_xml(root.elements.to_a('DEFINITIONS').first) if root.elements['DEFINITIONS']
|
34
|
+
|
35
|
+
coosys = []
|
36
|
+
root.elements.each('COOSYS'){ |sys|
|
37
|
+
coosys.push(Meta::CooSys.from_xml(sys))
|
38
|
+
}
|
39
|
+
|
40
|
+
params = []
|
41
|
+
root.elements.each('PARAM'){ |param|
|
42
|
+
params.push(Meta::Param.from_xml(param))
|
43
|
+
}
|
44
|
+
|
45
|
+
info = []
|
46
|
+
root.elements.each('INFO'){ |inf|
|
47
|
+
info.push(Meta::Info.from_xml(inf))
|
48
|
+
}
|
49
|
+
|
50
|
+
resources = []
|
51
|
+
root.elements.each('RESOURCE'){ |res|
|
52
|
+
resources.push(Meta::Resource.from_xml(res))
|
53
|
+
}
|
54
|
+
|
55
|
+
@votable = VOTable.new(id, version, description, definition, coosys, params, info, resources)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Convert a RexmlParsedVOTable into a string representation.
|
59
|
+
def to_s
|
60
|
+
"{file=#{@path};votable=#{@votable}}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|