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