voruby 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. data/Rakefile.rb +107 -224
  2. data/lib/misc.rb +1 -0
  3. data/lib/misc/misc.rb +60 -0
  4. data/lib/misc/propertyfile.rb +31 -0
  5. data/lib/symphony.rb +1 -0
  6. data/lib/symphony/symphony.rb +247 -0
  7. data/lib/voruby.rb +186 -0
  8. data/lib/voruby/active_votable/active_votable.rb +468 -347
  9. data/lib/voruby/adql/1.0/adql.rb +2418 -0
  10. data/lib/voruby/adql/support.rb +2 -0
  11. data/lib/voruby/misc.rb +351 -0
  12. data/lib/voruby/misc/connection_monitor.rb +97 -0
  13. data/lib/voruby/misc/libxml_ext.rb +121 -0
  14. data/lib/voruby/misc/rexml_ext.rb +223 -0
  15. data/lib/voruby/resolver/resolver.rb +12 -0
  16. data/lib/voruby/resolver/sesame.rb +299 -0
  17. data/lib/voruby/sky_query/sky_query.rb +192 -0
  18. data/lib/voruby/stc/1.10/coords.rb +2272 -0
  19. data/lib/voruby/stc/1.10/region.rb +892 -0
  20. data/lib/voruby/stc/1.10/stc.rb +3271 -0
  21. data/lib/voruby/stc/1.30/stc.rb +8666 -0
  22. data/lib/voruby/stc/support.rb +2 -0
  23. data/lib/voruby/ucd/ucd.rb +173 -0
  24. data/lib/voruby/voevent/1.1/voevent.rb +1124 -0
  25. data/lib/voruby/voevent/support.rb +5 -0
  26. data/lib/voruby/votable/1.0/votable.rb +1807 -0
  27. data/lib/voruby/votable/1.1/votable.rb +2100 -0
  28. data/lib/voruby/votable/votable.rb +305 -0
  29. data/lib/voruby/wesix/wesix.rb +491 -0
  30. data/lib/voruby/xlink/1.2/xlink.rb +21 -0
  31. data/test/voruby/active_votable/complex.vot +60 -0
  32. data/test/voruby/active_votable/error.vot +6 -0
  33. data/test/voruby/active_votable/large.vot +130040 -0
  34. data/test/voruby/active_votable/simple1.vot +38 -0
  35. data/test/voruby/active_votable/simple2.vot +38 -0
  36. data/test/voruby/active_votable/test.rb +193 -0
  37. data/test/voruby/adql/1.0/adql-alias.sql +1 -0
  38. data/test/voruby/adql/1.0/adql-alias.xml +26 -0
  39. data/test/voruby/adql/1.0/adql-avg.sql +1 -0
  40. data/test/voruby/adql/1.0/adql-avg.xml +31 -0
  41. data/test/voruby/adql/1.0/adql-circle.sql +1 -0
  42. data/test/voruby/adql/1.0/adql-circle.xml +46 -0
  43. data/test/voruby/adql/1.0/adql-expr.sql +1 -0
  44. data/test/voruby/adql/1.0/adql-expr.xml +34 -0
  45. data/test/voruby/adql/1.0/adql-function.sql +1 -0
  46. data/test/voruby/adql/1.0/adql-function.xml +41 -0
  47. data/test/voruby/adql/1.0/adql-group.sql +1 -0
  48. data/test/voruby/adql/1.0/adql-group.xml +51 -0
  49. data/test/voruby/adql/1.0/adql-having.sql +1 -0
  50. data/test/voruby/adql/1.0/adql-having.xml +25 -0
  51. data/test/voruby/adql/1.0/adql-like.sql +1 -0
  52. data/test/voruby/adql/1.0/adql-like.xml +17 -0
  53. data/test/voruby/adql/1.0/adql-order.sql +1 -0
  54. data/test/voruby/adql/1.0/adql-order.xml +37 -0
  55. data/test/voruby/adql/1.0/adql-simple.sql +1 -0
  56. data/test/voruby/adql/1.0/adql-simple.xml +12 -0
  57. data/test/voruby/adql/1.0/adql-top.sql +1 -0
  58. data/test/voruby/adql/1.0/adql-top.xml +33 -0
  59. data/test/voruby/adql/1.0/test.rb +2220 -0
  60. data/test/voruby/misc/test.rb +32 -0
  61. data/test/voruby/resolver/sesame/test.rb +56 -0
  62. data/test/voruby/sky_query/test.rb +107 -0
  63. data/test/voruby/stc/1.10/coords_test.rb +3704 -0
  64. data/test/voruby/stc/1.10/region_test.rb +993 -0
  65. data/test/voruby/stc/1.10/stc-catalog-entry-location.xml +112 -0
  66. data/test/voruby/stc/1.10/stc-obs-data-location.xml +126 -0
  67. data/test/voruby/stc/1.10/stc-region-circle.xml +5 -0
  68. data/test/voruby/stc/1.10/stc-region-convex.xml +11 -0
  69. data/test/voruby/stc/1.10/stc-region-convexhull.xml +5 -0
  70. data/test/voruby/stc/1.10/stc-region-ellipse.xml +7 -0
  71. data/test/voruby/stc/1.10/stc-region-intersection.xml +25 -0
  72. data/test/voruby/stc/1.10/stc-region-negation.xml +7 -0
  73. data/test/voruby/stc/1.10/stc-region-polygon.xml +13 -0
  74. data/test/voruby/stc/1.10/stc-region-sector.xml +6 -0
  75. data/test/voruby/stc/1.10/stc-region-union.xml +25 -0
  76. data/test/voruby/stc/1.10/stc-resource-profile.xml +60 -0
  77. data/test/voruby/stc/1.10/stc-search-location.xml +54 -0
  78. data/test/voruby/stc/1.10/stc_test.rb +4626 -0
  79. data/test/voruby/stc/1.30/stc-catalog-entry-location.xml +210 -0
  80. data/test/voruby/stc/1.30/stc-obs-data-location-arecibo.xml +353 -0
  81. data/test/voruby/stc/1.30/stc-obs-data-location-fits.xml +250 -0
  82. data/test/voruby/stc/1.30/stc-obs-data-location-xlink.xml +63 -0
  83. data/test/voruby/stc/1.30/stc-obs-data-location.xml +216 -0
  84. data/test/voruby/stc/1.30/stc-resource-profile-unusual-ref-pos.xml +39 -0
  85. data/test/voruby/stc/1.30/stc-resource-profile.xml +129 -0
  86. data/test/voruby/stc/1.30/stc-search-location-arecibo.xml +86 -0
  87. data/test/voruby/stc/1.30/stc-search-location.xml +101 -0
  88. data/test/voruby/stc/1.30/test.rb +6274 -0
  89. data/test/voruby/ucd/test.rb +48 -0
  90. data/test/voruby/voevent/1.1/test.rb +812 -0
  91. data/test/{voevent/voevent_v1_1.xml → voruby/voevent/1.1/voevent.xml} +2 -2
  92. data/test/voruby/voregistry/0.3/test.rb +137 -0
  93. data/test/voruby/votable/1.0/test.rb +714 -0
  94. data/test/voruby/votable/1.0/votable.basic.xml +660 -0
  95. data/test/voruby/votable/1.0/votable.html +86 -0
  96. data/test/voruby/votable/1.0/votable.ns.xml +56 -0
  97. data/test/voruby/votable/1.1/test.rb +785 -0
  98. data/test/voruby/votable/1.1/votable.basic.xml +38 -0
  99. data/test/voruby/votable/1.1/votable.html +86 -0
  100. data/test/voruby/votable/1.1/votable.ns.xml +56 -0
  101. data/test/voruby/votable/test.rb +15 -0
  102. data/test/voruby/wesix/test.rb +268 -0
  103. data/test/voruby/wesix/testr.fits +28 -0
  104. metadata +234 -247
  105. data/REQUIREMENTS +0 -6
  106. data/lib/voruby/active_votable/loader.rb +0 -5
  107. data/lib/voruby/adql/adql.rb +0 -2787
  108. data/lib/voruby/adql/ext.rb +0 -14
  109. data/lib/voruby/adql/loader.rb +0 -6
  110. data/lib/voruby/adql/operations.rb +0 -54
  111. data/lib/voruby/adql/parser.rb +0 -160
  112. data/lib/voruby/adql/transforms.rb +0 -573
  113. data/lib/voruby/ext.rb +0 -17
  114. data/lib/voruby/loader.rb +0 -4
  115. data/lib/voruby/misc/propertyfile.rb +0 -36
  116. data/lib/voruby/plastic/applications.rb +0 -174
  117. data/lib/voruby/plastic/constants.rb +0 -30
  118. data/lib/voruby/plastic/loader.rb +0 -10
  119. data/lib/voruby/plastic/plastic.rb +0 -1
  120. data/lib/voruby/resources/conesearch/conesearch.rb +0 -9
  121. data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +0 -55
  122. data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +0 -50
  123. data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +0 -72
  124. data/lib/voruby/resources/conesearch/loader.rb +0 -4
  125. data/lib/voruby/resources/loader.rb +0 -50
  126. data/lib/voruby/resources/nodes.rb +0 -190
  127. data/lib/voruby/resources/openskynode/loader.rb +0 -4
  128. data/lib/voruby/resources/openskynode/openskynode.rb +0 -9
  129. data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +0 -54
  130. data/lib/voruby/resources/sia/loader.rb +0 -5
  131. data/lib/voruby/resources/sia/sia.rb +0 -9
  132. data/lib/voruby/resources/sia/sia_v0_6.rb +0 -90
  133. data/lib/voruby/resources/sia/sia_v0_7.rb +0 -89
  134. data/lib/voruby/resources/sia/sia_v1_0.rb +0 -122
  135. data/lib/voruby/resources/stsci.rb +0 -59
  136. data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +0 -195
  137. data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +0 -158
  138. data/lib/voruby/resources/vodataservice/loader.rb +0 -5
  139. data/lib/voruby/resources/vodataservice/vodataservice.rb +0 -9
  140. data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +0 -189
  141. data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +0 -163
  142. data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +0 -221
  143. data/lib/voruby/resources/voregistry/loader.rb +0 -4
  144. data/lib/voruby/resources/voregistry/voregistry.rb +0 -9
  145. data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +0 -40
  146. data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +0 -30
  147. data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +0 -86
  148. data/lib/voruby/resources/voresource/loader.rb +0 -17
  149. data/lib/voruby/resources/voresource/voresource.rb +0 -9
  150. data/lib/voruby/resources/voresource/voresource_v0_10.rb +0 -327
  151. data/lib/voruby/resources/voresource/voresource_v0_9.rb +0 -405
  152. data/lib/voruby/resources/voresource/voresource_v1_0.rb +0 -230
  153. data/lib/voruby/services/ext.rb +0 -11
  154. data/lib/voruby/services/gestalt/footprint.rb +0 -95
  155. data/lib/voruby/services/gestalt/wcs_fixer.rb +0 -105
  156. data/lib/voruby/services/gestalt/wesix.rb +0 -155
  157. data/lib/voruby/services/loader.rb +0 -7
  158. data/lib/voruby/services/registry/registry.rb +0 -53
  159. data/lib/voruby/services/resolver/resolver.rb +0 -35
  160. data/lib/voruby/services/schema/schema.rb +0 -644
  161. data/lib/voruby/sesame/loader.rb +0 -6
  162. data/lib/voruby/sesame/sesame_v1_0.rb +0 -64
  163. data/lib/voruby/simple/loader.rb +0 -6
  164. data/lib/voruby/simple/parameters.rb +0 -196
  165. data/lib/voruby/simple/sap.rb +0 -446
  166. data/lib/voruby/spacetime/loader.rb +0 -3
  167. data/lib/voruby/spacetime/spacetime.rb +0 -607
  168. data/lib/voruby/stc/coords_v1_20.rb +0 -900
  169. data/lib/voruby/stc/loader.rb +0 -55
  170. data/lib/voruby/stc/region_v1_20.rb +0 -274
  171. data/lib/voruby/stc/stc_v1_20.rb +0 -1196
  172. data/lib/voruby/util.rb +0 -27
  173. data/lib/voruby/voevent/loader.rb +0 -7
  174. data/lib/voruby/voevent/voevent_v1_0.rb +0 -213
  175. data/lib/voruby/voevent/voevent_v1_1.rb +0 -196
  176. data/lib/voruby/votables/chandra.rb +0 -373
  177. data/lib/voruby/votables/data.rb +0 -179
  178. data/lib/voruby/votables/galex.rb +0 -377
  179. data/lib/voruby/votables/int.rb +0 -354
  180. data/lib/voruby/votables/libxml_parser.rb +0 -411
  181. data/lib/voruby/votables/libxml_votable.rb +0 -67
  182. data/lib/voruby/votables/loader.rb +0 -10
  183. data/lib/voruby/votables/meta.rb +0 -763
  184. data/lib/voruby/votables/misc.rb +0 -51
  185. data/lib/voruby/votables/nsa.rb +0 -410
  186. data/lib/voruby/votables/rexml_parser.rb +0 -408
  187. data/lib/voruby/votables/rexml_votable.rb +0 -67
  188. data/lib/voruby/votables/sdss.rb +0 -356
  189. data/lib/voruby/votables/transforms.rb +0 -388
  190. data/lib/voruby/votables/tree.rb +0 -45
  191. data/lib/voruby/votables/types.rb +0 -391
  192. data/lib/voruby/votables/votable.rb +0 -687
  193. data/test/active_votable/database.yml +0 -6
  194. data/test/active_votable/test.vot +0 -168492
  195. data/test/active_votable/unittest.rb +0 -41
  196. data/test/adql/test1.adql +0 -49
  197. data/test/adql/test2.adql +0 -51
  198. data/test/adql/test3.adql +0 -81
  199. data/test/adql/test4.adql +0 -53
  200. data/test/adql/test5.adql +0 -55
  201. data/test/adql/test6.adql +0 -18
  202. data/test/adql/test7.adql +0 -48
  203. data/test/adql/unittest.rb +0 -1672
  204. data/test/plastic/test.rb +0 -44
  205. data/test/plastic/test.vot +0 -5385
  206. data/test/plastic/unittest.rb +0 -66
  207. data/test/resources/conesearch/conesearch_v0_3.xml +0 -31
  208. data/test/resources/conesearch/conesearch_v1_0.xml +0 -86
  209. data/test/resources/conesearch/unittest_v0_3.rb +0 -22
  210. data/test/resources/conesearch/unittest_v1_0.rb +0 -24
  211. data/test/resources/openskynode/open_sky_node_v0_1.xml +0 -32
  212. data/test/resources/openskynode/unittest_v0_1.rb +0 -31
  213. data/test/resources/sia/simple_image_access_v0_7.xml +0 -36
  214. data/test/resources/sia/simple_image_access_v1_0.xml +0 -122
  215. data/test/resources/sia/unittest_v0_7.rb +0 -24
  216. data/test/resources/sia/unittest_v1_0.rb +0 -29
  217. data/test/resources/stsci.xml +0 -336
  218. data/test/resources/unittest_stsci.rb +0 -25
  219. data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +0 -128
  220. data/test/resources/vodataservice/data_collection_resource_v0_5.xml +0 -54
  221. data/test/resources/vodataservice/data_collection_resource_v1_0.xml +0 -117
  222. data/test/resources/vodataservice/data_service_resource_v1_0.xml +0 -115
  223. data/test/resources/vodataservice/sky_service_resource_v0_10.xml +0 -45
  224. data/test/resources/vodataservice/table_service_resource_v1_0.xml +0 -122
  225. data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +0 -60
  226. data/test/resources/vodataservice/unittest_v0_5.rb +0 -126
  227. data/test/resources/vodataservice/unittest_v1_0.rb +0 -151
  228. data/test/resources/voregistry/authority_resource_v0_3.xml +0 -20
  229. data/test/resources/voregistry/authority_resource_v1_0.xml +0 -82
  230. data/test/resources/voregistry/registry_service_v0_3.xml +0 -20
  231. data/test/resources/voregistry/registry_service_v1_0.xml +0 -107
  232. data/test/resources/voregistry/unittest_v0_3.rb +0 -31
  233. data/test/resources/voregistry/unittest_v1_0.rb +0 -34
  234. data/test/resources/voresource/organisation_resource_v1_0.xml +0 -90
  235. data/test/resources/voresource/resource_organisation_v0_10.xml +0 -22
  236. data/test/resources/voresource/resource_service_v0_10.xml +0 -19
  237. data/test/resources/voresource/resource_v0_10.xml +0 -19
  238. data/test/resources/voresource/resource_v1_0.xml +0 -79
  239. data/test/resources/voresource/service_resource_v1_0.xml +0 -91
  240. data/test/resources/voresource/unittest_v0_10.rb +0 -61
  241. data/test/resources/voresource/unittest_v0_9.rb +0 -4
  242. data/test/resources/voresource/unittest_v1_0.rb +0 -190
  243. data/test/services/gestalt/unittest.rb +0 -74
  244. data/test/services/registry/unittest.rb +0 -34
  245. data/test/services/resolver/unittest.rb +0 -38
  246. data/test/simple/unittest.rb +0 -46
  247. data/test/spacetime/unittest.rb +0 -39
  248. data/test/stc/catalog_entry_location_v1_20.xml +0 -112
  249. data/test/stc/obs_data_location_v1_20.xml +0 -108
  250. data/test/stc/search_location_v1_20.xml +0 -54
  251. data/test/stc/stc_resource_profile_v1_20.xml +0 -60
  252. data/test/stc/unittest_v1_20.rb +0 -620
  253. data/test/voevent/unittest_v1_0.rb +0 -79
  254. data/test/voevent/unittest_v1_1.rb +0 -70
  255. data/test/voevent/voevent_v1_0.xml +0 -96
  256. data/test/votables/test.vot +0 -366
  257. data/test/votables/unittest.rb +0 -54
@@ -1,408 +0,0 @@
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
@@ -1,67 +0,0 @@
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