voruby 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,388 @@
1
+ module VORuby
2
+ module VOTables
3
+ module VOTable
4
+ class VOTable
5
+ def self.from_soap_obj(mvot)
6
+ VOTable.new(
7
+ VOTable::_find_attr_value(mvot.__xmlattr, 'ID'),
8
+ VOTable::_find_attr_value(mvot.__xmlattr, 'version'),
9
+ (mvot.respond_to?(:dESCRIPTION))? Meta::Description.from_soap_obj(mvot.dESCRIPTION): nil,
10
+ (mvot.respond_to?(:dEFINITIONS))? Meta::Definitions.from_soap_obj(mvot.dEFINITIONS): nil,
11
+ (mvot.respond_to?(:cOOSYS))? Meta::CooSys.from_soap_obj(mvot.cOOSYS): [],
12
+ (mvot.respond_to?(:pARAM))? Meta::Param.from_soap_obj(mvot.pARAM): [],
13
+ (mvot.respond_to?(:iNFO))? Meta::Info.from_soap_obj(mvot.iNFO): [],
14
+ (mvot.respond_to?(:rESOURCE))? Meta::Resource.from_soap_obj(mvot.rESOURCE): []
15
+ )
16
+ end
17
+ end
18
+
19
+ module Meta
20
+
21
+ class Definitions
22
+ def self.from_soap_obj(mdef)
23
+ Definitions.new(
24
+ (mdef.respond_to?(:cOOSYS))? VOTable._coosys_from_soap_obj(mdef.cOOSYS): nil,
25
+ (mdef.respond_to?(:pARAM))? VOTable._params_from_soap_obj(mdef.pARAM): nil
26
+ )
27
+ end
28
+ end
29
+
30
+ class Description
31
+ def self.from_soap_obj(mdesc)
32
+ Description.new(mdesc)
33
+ end
34
+ end
35
+
36
+ class CooSys
37
+ def self.from_soap_obj(mcoosystems)
38
+ mcoosystems = [mcoosystems] if !mcoosystems.respond_to(:each)
39
+
40
+ coosys = []
41
+ mcoosystems.each do |mcoosys|
42
+ equinox_txt = VOTable::_find_attr_value(mcoosys.__xmlattr, 'equinox')
43
+ epoch_txt = VOTable::_find_attr_value(mcoosys.__xmlattr, 'epoch')
44
+ system_txt = VOTable::_find_attr_value(mcoosys.__xmlattr, 'system') || 'eq_FK5'
45
+
46
+ coosys.push(CooSys.new(
47
+ VOTable::_find_attr_value(mcoosys.__xmlattr, 'ID'),
48
+ (equinox_txt == nil)? nil: Type::AstroYear.new(equinox_txt),
49
+ (epoch_txt == nil)? nil: Type::AstroYear.new(epoch_txt),
50
+ Type::CoordSystemType.new(system_txt)
51
+ ))
52
+ end
53
+
54
+ coosys
55
+ end
56
+ end
57
+
58
+ class Param
59
+ def self.from_soap_obj(mparams)
60
+ mparams = [mparams] if !mparams.respond_to?(:each)
61
+
62
+ params = []
63
+ mparams.each do |mparam|
64
+ datatype_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'datatype')
65
+ ucd_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'ucd')
66
+ precision_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'precision')
67
+ width_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'width')
68
+ arraysize_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'arraysize')
69
+
70
+ params.push(Param.new(
71
+ VOTable::_find_attr_value(mparam.__xmlattr, 'name'),
72
+ (datatype_txt == nil)? nil: Type::DataType.new(datatype_txt),
73
+ VOTable::_find_attr_value(mparam.__xmlattr, 'value'),
74
+ (ucd_txt == nil)? nil: Type::UCDType.new(ucd_txt),
75
+ VOTable::_find_attr_value(mparam.__xmlattr, 'unit'),
76
+ (mparam.respond_to?(:dESCRIPTION))? _description_from_soap_obj(mparam.dESCRIPTION): nil,
77
+ (mparam.respond_to?(:vALUES))? _values_from_soap_obj(mparam.vALUES): nil,
78
+ (mparam.respond_to?(:lINK))? _links_from_soap_obj(mapram.lINK): nil,
79
+ VOTable::_find_attr_value(mparam.__xmlattr, 'ID'),
80
+ (precision_txt == nil)? nil: Type::PrecisionType.new(precision_txt.to_i),
81
+ VOTable::_find_attr_value(mparam.__xmlattr, 'utype'),
82
+ (width_txt == nil)? nil: Type::PositiveInteger.new(width_txt.to_i),
83
+ VOTable::_find_attr_value(mparam.__xmlattr, 'ref'),
84
+ (arraysize_txt == nil)? nil: Type::ArrayDef.new(arraysize_txt)
85
+ ))
86
+ end
87
+
88
+ params
89
+ end
90
+ end
91
+
92
+ class Info
93
+ def self.from_soap_obj(minfo)
94
+ info = []
95
+ info.push(Info.new(
96
+ VOTable::_find_attr_value(minfo.__xmlattr, 'name'),
97
+ VOTable::_find_attr_value(minfo.__xmlattr, 'value'),
98
+ VOTable::_find_attr_value(minfo.__xmlattr, 'ID'),
99
+ minfo.__xmlele # text
100
+ ))
101
+
102
+ info
103
+ end
104
+ end
105
+
106
+ class Resource
107
+ def self.from_soap_obj(mresources)
108
+ mresources = [mresources] if !mresources.respond_to?(:each)
109
+
110
+ resources = []
111
+ mresources.each do |mres|
112
+ type_txt = VOTable::_find_attr_value(mres.__xmlattr, 'type') || 'results'
113
+
114
+ resources.push(Resource.new(
115
+ VOTable::_find_attr_value(mres.__xmlattr, 'name'),
116
+ VOTable::_find_attr_value(mres.__xmlattr, 'ID'),
117
+ VOTable::_find_attr_value(mres.__xmlattr, 'utype'),
118
+ Type::ResourceType.new(type_txt),
119
+ (mres.respond_to?(:dESCRIPTION))? Description.from_soap_obj(mres.dESCRIPTION): nil,
120
+ (mres.respond_to?(:iNFO))? Info.from_soap_obj(mres.iNFO): [],
121
+ (mres.respond_to?(:cOOSYS))? CooSys.from_soap_obj(mres.cOOSYS): [],
122
+ (mres.respond_to?(:pARAM))? Param.from_soap_obj(mres.pARAM): [],
123
+ (mres.respond_to?(:lINK))? Link.from_soap_obj(mres.lINK): [],
124
+ Table.from_soap_obj(mres.tABLE),
125
+ (mres.respond_to?(:rESOURCE))? Resource.from_soap_obj(mres.rESOURCE): []
126
+ ))
127
+ end
128
+
129
+ resources
130
+ end
131
+ end
132
+
133
+ class Table
134
+ def self.from_soap_obj(mtables)
135
+ mtables = [mtables] if !mtables.respond_to?(:each)
136
+
137
+ tables = []
138
+ mtables.each do |mtable|
139
+ ucd_txt = VOTable::_find_attr_value(mtable.__xmlattr, 'ucd')
140
+ nrows_txt = VOTable::_find_attr_value(mtable.__xmlattr, 'nrows')
141
+
142
+ tables.push(Table.new(
143
+ VOTable::_find_attr_value(mtable.__xmlattr, 'name'),
144
+ VOTable::_find_attr_value(mtable.__xmlattr, 'ID'),
145
+ (ucd_txt == nil)? nil: Type::UCDType.new(ucd_txt),
146
+ VOTable::_find_attr_value(mtable.__xmlattr, 'utype'),
147
+ VOTable::_find_attr_value(mtable.__xmlattr, 'ref'),
148
+ (nrows_txt == nil)? nil: Type::NonNegativeInteger.new(nrows_txt.to_i),
149
+ (mtable.respond_to?(:dESCRIPTION))? Description.from_soap_obj(mtable.dESCRIPTION): nil,
150
+ (mtable.respond_to?(:fIELD))? Field.from_soap_obj(mtable.fIELD): [],
151
+ (mtable.respond_to?(:pARAM))? Param.from_soap_obj(mtable.pARAM): [],
152
+ (mtable.respond_to?(:gROUP))? Group.from_soap_obj(mtable.gROUP): [],
153
+ (mtable.respond_to?(:lINK))? Link.from_soap_obj(mtable.lINK): [],
154
+ (mtable.respond_to?(:dATA))? Data::Data.from_soap_obj(mtable.dATA): nil
155
+ ))
156
+ end
157
+
158
+ tables
159
+ end
160
+ end
161
+
162
+ class Group
163
+ def self.from_soap_obj(mgroups)
164
+ mgroups = [mgroups] if !mgroups.respond_to?(:each)
165
+
166
+ groups = []
167
+ mgroups.each do |mgroup|
168
+ ucd_txt = OTable::VOTable::_find_attr_value(mgroup.__xmlattr, 'ucd')
169
+
170
+ groups.push(Group.new(
171
+ VOTable::_find_attr_value(mgroup.__xmlattr, 'name'),
172
+ (ucd_txt == nil)? nil: Type::UCDType.new(ucd_txt),
173
+ (mgroup.respond_to?(:dESCRIPTION))? Description.from_soap_obj(mgroup.dESCRIPTION): nil,
174
+ (mgroup.respond_to?(:fIELDref))? FieldRef.from_soap_obj(mgroup.fIELDref): [],
175
+ (mgroup.respond_to?(:pARAMref))? ParamRef.from_soap_obj(mgroup.pARAMref): [],
176
+ (mgroup.respond_to?(:pARAM))? Param.from_soap_obj(mgroup.pARAM): [],
177
+ (mgroup.respond_to?(:gROUP))? Group.from_soap_obj(mgroup.gROUP): [],
178
+ VOTable::_find_attr_value(mgroup.__xmlattr, 'ID'),
179
+ VOTable::_find_attr_value(mgroup.__xmlattr, 'ref'),
180
+ VOTable::_find_attr_value(mgroup.__xmlattr, 'utype')
181
+ ))
182
+ end
183
+
184
+ groups
185
+ end
186
+ end
187
+
188
+ class FieldRef
189
+ def self.from_soap_obj(mfieldrefs)
190
+ mfieldrefs = [mfieldrefs] if !mfieldrefs.respond_to?(:each)
191
+
192
+ fieldrefs = []
193
+ mfieldrefs.each do |mfieldref|
194
+ fieldrefs.push(FieldRef.new(
195
+ VOTable::_find_attr_value(mfieldref.__xmlattr, 'ref')
196
+ ))
197
+ end
198
+
199
+ fieldrefs
200
+ end
201
+ end
202
+
203
+ class ParamRef
204
+ def self.from_soap_obj(mparamrefs)
205
+ mparamrefs = [mparamrefs] if !mparamrefs.respond_to?(:each)
206
+
207
+ paramrefs = []
208
+ mparamrefs.each do |mparamref|
209
+ paramrefs.push(ParamRef.new(
210
+ VOTABLE::VOTable::_find_attr_value(mparamref.__xmlattr, 'ref')
211
+ ))
212
+ end
213
+
214
+ paramrefs
215
+ end
216
+ end
217
+
218
+ class Field
219
+ def self.from_soap_obj(mfields)
220
+ mfields = [mfields] if !mfields.respond_to?(:each)
221
+
222
+ fields = []
223
+ mfields.each do |mfield|
224
+ datatype_txt = VOTable::_find_attr_value(mfield.__xmlattr, 'datatype')
225
+ ucd_txt = VOTable::_find_attr_value(mfield.__xmlattr, 'ucd')
226
+ precision_txt = VOTable::_find_attr_value(mfield.__xmlattr, 'precision')
227
+ width_txt = VOTable::_find_attr_value(mfield.__xmlattr, 'width')
228
+ arraysize_txt = VOTable::_find_attr_value(mfield.__xmlattr, 'arraysize')
229
+ type_txt = VOTable::_find_attr_value(mfield.__xmlattr, 'type')
230
+
231
+ fields.push(Field.new(
232
+ VOTable::_find_attr_value(mfield.__xmlattr, 'name'),
233
+ (datatype_txt == nil)? nil: Type::DataType.new(datatype_txt),
234
+ (ucd_txt == nil)? nil: Type::UCDType.new(ucd_txt),
235
+ VOTable::_find_attr_value(mfield.__xmlattr, 'unit'),
236
+ (mfield.respond_to?(:dESCRIPTION))? Description.from_soap_obj(mfield.dESCRIPTION): nil,
237
+ (mfield.respond_to?(:vALUES))? Values.from_soap_obj(mfield.vALUES): nil,
238
+ (mfield.respond_to?(:lINK))? Link.from_soap_obj(mfield.lINK): [],
239
+ VOTable::_find_attr_value(mfield.__xmlattr, 'ID'),
240
+ (precision_txt == nil)? nil: Type::PrecisionType.new(precision_txt),
241
+ VOTable::_find_attr_value(mfield.__xmlattr, 'utype'),
242
+ (width_txt == nil)? nil: Type::PositiveInteger.new(width_txt.to_i),
243
+ VOTable::_find_attr_value(mfield.__xmlattr, 'ref'),
244
+ (arraysize_txt == nil)? nil: Type::ArrayDef.new(arraysize_txt),
245
+ (type_txt == nil)? nil: Type::FieldType.new(type_txt)
246
+ ))
247
+ end
248
+
249
+ fields
250
+ end
251
+ end
252
+
253
+ class Link
254
+ def self.from_soap_obj(mlinks)
255
+ mlinks = [mlinks] if !mlinks.respond_to?(:each)
256
+
257
+ links = []
258
+ mlinks.each do |mlink|
259
+ href_txt = VOTable::_find_attr_value(mlink.__xmlattr, 'href')
260
+ action_txt = VOTable::_find_attr_value(mlink.__xmlattr, 'action')
261
+ content_role_txt = VOTable::_find_attr_value(mlink.__xmlattr, 'content-role')
262
+
263
+ links.push(Link.new(
264
+ (href_txt == nil)? nil: VOTABLE::Type::AnyURI.new(href_txt),
265
+ VOTable::_find_attr_value(mlink.__xmlattr, 'value'),
266
+ VOTable::_find_attr_value(mlink.__xmlattr, 'title'),
267
+ (action_txt == nil)? nil: VOTABLE::Type::AnyURI.new(action_txt),
268
+ VOTable::_find_attr_value(mlink.__xmlattr, 'ID'),
269
+ VOTable::_find_attr_value(mlink.__xmlattr, 'content-type'),
270
+ (content_role_txt == nil)? nil: Type::ContentRole.new(content_role_txt),
271
+ VOTable::_find_attr_value(mlink.__xmlattr, 'ghref')
272
+ ))
273
+ end
274
+
275
+ links
276
+ end
277
+ end
278
+
279
+ class Values
280
+ def self.from_soap_obj(mvalues)
281
+ type_txt = VOTable::_find_attr_value(mvalues.__xmlattr, 'type') || 'legal'
282
+
283
+ Values.new(
284
+ (mvalues.respond_to?(:mIN))? Min.from_soap_obj(mvalues.mIN): nil,
285
+ (mvalues.respond_to?(:mAX))? Max.from_soap_obj(mvalues.mAX): nil,
286
+ (mvalues.respond_to?(:oPTIONS))? Option.from_soap_obj(mvalues.oPTIONS): [],
287
+ VOTable::_find_attr_value(mvalues.__xmlattr, 'ID'),
288
+ (type_txt == nil)? nil: Type::ValuesType.new(type_txt),
289
+ VOTable::_find_attr_value(mvalues.__xmlattr, 'null'),
290
+ VOTable::_find_attr_value(mvalues.__xmlattr, 'ref')
291
+ )
292
+ end
293
+ end
294
+
295
+ class Option
296
+ def self.from_soap_obj(moptions)
297
+ options = []
298
+ moptions.each do |moption|
299
+ options.push(Option.new(
300
+ VOTable::_find_attr_value(mvalues.__xmlattr, 'value'),
301
+ VOTable::_find_attr_value(mvalues.__xmlattr, 'name'),
302
+ (moption.respond_to?(:oPTION))? Option.from_soap_obj(moption.oPTION): []
303
+ ))
304
+ end
305
+
306
+ options
307
+ end
308
+ end
309
+
310
+ class Min
311
+ def self.from_soap_obj(mmin)
312
+ inclusive_txt = VOTable::_find_attr_value(mmin.__xmlattr, 'inclusive') || 'yes'
313
+
314
+ Min.new(
315
+ VOTable::_find_attr_value(mmin.__xmlattr, 'value'),
316
+ Type::YesNo.new(inclusive_txt)
317
+ )
318
+ end
319
+ end
320
+
321
+ class Max
322
+ def self.from_soap_obj(mmax)
323
+ inclusive_txt = VOTable::_find_attr_value(mmax.__xmlattr, 'inclusive') || 'yes'
324
+
325
+ Max.new(
326
+ VOTable::_find_attr_value(mmax.__xmlattr, 'value'),
327
+ Type::YesNo.new(inclusive_txt)
328
+ )
329
+ end
330
+ end
331
+
332
+ end
333
+
334
+ module Data
335
+
336
+ class Data
337
+ def self.from_soap_obj(mdata)
338
+ # Note that strictly one can also have a FITS or BINARY stream here
339
+ Data.new(
340
+ (mdata.respond_to?(:tABLEDATA))? TableData.from_soap_obj(mdata.tABLEDATA): nil
341
+ )
342
+ end
343
+ end
344
+
345
+ class TableData
346
+ def self.from_soap_obj(mtbldata)
347
+ TableData.new(
348
+ (mtbldata.respond_to?(:tR))? TR.from_soap_obj(mtbldata.tR): []
349
+ )
350
+ end
351
+ end
352
+
353
+ class TR
354
+ def self.from_soap_obj(mtrs)
355
+ mtrs = [mtrs] if !mtrs.respond_to?(:each)
356
+
357
+ trs = []
358
+ mtrs.each do |tr|
359
+ trs.push(
360
+ (tr.respond_to?(:tD))? TR.new(TD.from_soap_obj(tr.tD)): []
361
+ )
362
+ end
363
+
364
+ trs
365
+ end
366
+ end
367
+
368
+ class TD
369
+ def self.from_soap_obj(mtds)
370
+ mtds = [mtds] if !mtds.respond_to?(:each)
371
+
372
+ tds = []
373
+ mtds.each do |td|
374
+ tds.push(TD.new(
375
+ td,
376
+ (td.respond_to?(:__xmlattr))? VOTable::_find_attr_value(td.__xmlattr, 'encoding'): Type::EncodingType.new('none')
377
+ ))
378
+ end
379
+
380
+ tds
381
+ end
382
+ end
383
+
384
+ end
385
+ end
386
+
387
+ end
388
+ end
@@ -0,0 +1,45 @@
1
+ module VORuby
2
+ module VOTables
3
+ module VOTable
4
+
5
+ # A VOTable parsed from a file using a DOM-like implementation of
6
+ # an XML parser. For example:
7
+ # tree_votable = VOTable::TreeParsedVOTable.new('my_votable.xml', 'rexml')
8
+ # real_votable = tree_votable.votable # Get the VOTable
9
+ # As you can see, TreeParsedVOTable is basically a wrapper for
10
+ # VOTable.
11
+ class TreeParsedVOTable
12
+ attr_reader :path, :votable, :lib
13
+
14
+ # [_path_:]
15
+ # The path to a valid VOTable XML file.
16
+ # [_lib_:]
17
+ # The underlying library used to parse the XML. Current options are
18
+ # 'rexml' and 'libxml'. Rexml is Ruby's all-native XML parsing solution
19
+ # and is therefore shipped with every ruby release. It's very convenient
20
+ # but slow on large files. Ruby also has available[http://rubyforge.org/projects/xml-tools/]
21
+ # to it libxml2 bindings which can be installed separately. This is the
22
+ # recommended configuration for production systems as it is *much* faster.
23
+ def initialize(path, lib='rexml')
24
+ @path = path
25
+ @lib = lib
26
+
27
+ @votable = nil
28
+ if lib == 'libxml' # For a faster alternative, use libxml2
29
+ require 'voruby/votables/libxml_votable'
30
+ @votable = LibxmlParsedVOTable.new(@path)
31
+ else # By default, we'll use Ruby's built-in native XML parser
32
+ require 'voruby/votables/rexml_votable'
33
+ @votable = RexmlParsedVOTable.new(@path)
34
+ end
35
+ end
36
+
37
+ # Convert the TreeParsedVOTable to a string representation.
38
+ def to_s
39
+ "{lib=#{@lib};#{@votable}}"
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+ end