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,391 @@
1
+ require 'uri'
2
+
3
+ module VORuby
4
+ module VOTables
5
+ module VOTable
6
+
7
+ # Types of input that go into a VOTable. Typically these enforce restrictions
8
+ # on string input formats and what not.
9
+ module Type
10
+
11
+ # A class that represents a vanilla-flavoured string.
12
+ class AnyText
13
+ attr_reader :value
14
+
15
+ # [_txt_:]
16
+ # The text of the string.
17
+ def initialize(txt=nil)
18
+ @value = txt
19
+ end
20
+
21
+ def to_s
22
+ "{#{@value}}"
23
+ end
24
+ end
25
+
26
+ # A class representing a valid astronomical year.
27
+ class AstroYear
28
+ attr_reader :value
29
+ @@pattern = '^[JB]?[0-9]+([.][0-9]*)?$'
30
+
31
+ # [_txt_:]
32
+ # An astronomical year. The allowed pattern is:
33
+ # [JB]?[0-9]+([.][0-9]*)?$
34
+ # i.e. 2001, J2001, B2001, 2001.2 etc.
35
+ def initialize(txt=nil)
36
+ if txt and txt.match(@@pattern)
37
+ @value = txt
38
+ else
39
+ raise "Astro year '#{txt}' does not match #{@@pattern}"
40
+ end
41
+ end
42
+
43
+ def to_s
44
+ "{#{@value}}"
45
+ end
46
+ end
47
+
48
+ # A class representing a UCD, including UCD1+.
49
+ class UCDType
50
+ attr_reader :value
51
+ @@pattern = '^[A-Za-z0-9_.:;\-]*$'
52
+
53
+ # [_txt_:]
54
+ # A UCD. The allowed pattern is:
55
+ # ^[A-Za-z0-9_.:;\-]*$
56
+ # i.e. phot.mag;em.opt.V, PHOT_JHN_V etc.
57
+ def initialize(txt=nil)
58
+ if txt and txt.match(@@pattern)
59
+ @value = txt
60
+ else
61
+ raise "UCD type '#{txt}' does not match #{@@pattern}"
62
+ end
63
+ end
64
+
65
+ def to_s
66
+ "{#{@value}}"
67
+ end
68
+ end
69
+
70
+ # A class representing a definition of an array size.
71
+ class ArrayDef
72
+ attr_reader :value
73
+ @@pattern = '^([0-9]+x)*[0-9]*[*]?(s\W)?$'
74
+
75
+ # [_txt_:]
76
+ # The text of the array size definition. The allowed pattern is:
77
+ # ^([0-9]+x)*[0-9]*[*]?(s\W)?$
78
+ # i.e. *, 64x64x10*, etc.
79
+ def initialize(txt=nil)
80
+ if txt and txt.match(@@pattern)
81
+ @value = txt
82
+ else
83
+ raise "Array definition '#{txt}' does not match #{@@pattern}"
84
+ end
85
+ end
86
+
87
+ def to_s
88
+ "{#{@value}}"
89
+ end
90
+ end
91
+
92
+ # A class representing the encoding method of a document.
93
+ class EncodingType
94
+ attr_reader :value
95
+ @@types = ['gzip', 'base64', 'dynamic', 'none']
96
+
97
+ # [_txt_:]
98
+ # The encoding type. Choices: gzip, base64, dynamic, none.
99
+ def initialize(txt=nil)
100
+ txt = 'none' if !txt
101
+ if @@types.include?(txt)
102
+ @value = txt
103
+ else
104
+ raise "Encoding type '#{txt}' is not valid. Use one of: " +
105
+ @@types.join(', ')
106
+ end
107
+ end
108
+
109
+ def to_s
110
+ "{#{@value}}"
111
+ end
112
+ end
113
+
114
+ # A class representing a datatype.
115
+ class DataType
116
+ attr_reader :value
117
+ @@types = ['boolean', 'bit', 'unsignedByte', 'short', 'int',
118
+ 'long', 'char', 'unicodeChar', 'float', 'double',
119
+ 'floatComplex', 'doubleComplex']
120
+
121
+ # [_txt_:]
122
+ # The datatype. Choices: boolean, bit, unsignedByte, short, int
123
+ # long, char, unicodeChar, float, double, floatComplex, doubleComplex.
124
+ def initialize(txt=nil)
125
+ if txt and @@types.include?(txt)
126
+ @value = txt
127
+ else
128
+ raise "Data type '#{txt}' is not valid. Use one of: " +
129
+ @@types.join(', ')
130
+ end
131
+ end
132
+
133
+ def to_s
134
+ "{#{@value}}"
135
+ end
136
+ end
137
+
138
+ # A class representing a precision type.
139
+ class PrecisionType
140
+ attr_reader :value
141
+ @@pattern = '^[EF]?[1-9][0-9]*$'
142
+
143
+ # [_txt_:]
144
+ # The precision type. The allowed pattern is:
145
+ # ^[EF]?[1-9][0-9]*$
146
+ # i.e. F3, 5 etc.
147
+ def initialize(txt=nil)
148
+ if txt and txt.match(@@pattern)
149
+ @value = txt
150
+ else
151
+ raise "Precision type '#{txt}' does not match #{@@pattern}"
152
+ end
153
+ end
154
+
155
+ def to_s
156
+ "{#{@value}}"
157
+ end
158
+ end
159
+
160
+ # A class representing 'yes' or 'no'.
161
+ class YesNo
162
+ attr_reader :value
163
+
164
+ # [_txt_:]
165
+ # A text string with the value 'yes' or 'no'.
166
+ def initialize(txt=nil)
167
+ if txt and (txt.downcase == 'yes' or txt.downcase == 'no')
168
+ @value = txt.downcase
169
+ else
170
+ raise "YesNo '#{txt}' is not valid. Use one of: yes, no"
171
+ end
172
+ end
173
+
174
+ def to_s
175
+ "{#{@value}}"
176
+ end
177
+ end
178
+
179
+ # A class representing the type of coordinate system.
180
+ class CoordSystemType
181
+ attr_reader :value
182
+ @@systems = ['eq_FK4', 'eq_FK5', 'ICRS', 'ecl_FK4', 'ecl_FK5',
183
+ 'galactic', 'supergalactic', 'xy', 'barycentric',
184
+ 'geo_app']
185
+
186
+ # [_txt_:]
187
+ # The coordinate system type. Choices: eq_FK4, ICRS, ecl_FK4,
188
+ # ecl_FK5, galactic, supergalactic, xy, barycentric, geo_app.
189
+ def initialize(txt='eq_FK5')
190
+ if txt and @@systems.include?(txt)
191
+ @value = txt
192
+ else
193
+ raise "Coordinate system type '#{txt}' is not valid. Use one of: " +
194
+ @@systems.join(', ')
195
+ end
196
+ end
197
+
198
+ def to_s
199
+ "{#{@value}}"
200
+ end
201
+ end
202
+
203
+ # A class representing a valid URI.
204
+ class AnyURI
205
+ attr_reader :value
206
+
207
+ # [_txt_:]
208
+ # A string representing a _valid_ URI (e.g. one that Ruby's URI.parse
209
+ # method recognizes.
210
+ def initialize(txt=nil)
211
+ begin
212
+ @value = URI.parse(URI.escape(txt))
213
+ rescue
214
+ raise "URI '#{txt}' is not valid: #{$!}"
215
+ end
216
+ end
217
+
218
+ def to_s
219
+ "{#{@value.to_s}}"
220
+ end
221
+ end
222
+
223
+ # A class representing the content role of a document.
224
+ class ContentRole
225
+ attr_reader :value
226
+ @@roles = ['query', 'hints', 'doc', 'location']
227
+
228
+ # [_txt_:]
229
+ # The content role. Choices: query, hints, doc, location.
230
+ def initialize(txt=nil)
231
+ if txt and @@roles.include?(txt)
232
+ @value = txt
233
+ else
234
+ raise "Content role '#{txt}' is not valid. Use one of: " +
235
+ @@roles.join(', ')
236
+ end
237
+ end
238
+
239
+ def to_s
240
+ "{#{@value}}"
241
+ end
242
+ end
243
+
244
+ # A class representing a type of stream.
245
+ class StreamType
246
+ attr_reader :value
247
+ @@types = ['locator', 'other']
248
+
249
+ # [_txt_:]
250
+ # The stream type. Choices: locator, other.
251
+ def initialize(txt=nil)
252
+ if txt and @@types.include?(txt)
253
+ @value = txt
254
+ else
255
+ raise "Stream type '#{txt}' is not valid. Use one of: " +
256
+ @@types.join(', ')
257
+ end
258
+ end
259
+
260
+ def to_s
261
+ "{#{@value}}"
262
+ end
263
+ end
264
+
265
+ # A class representing an actuator event.
266
+ class Actuate
267
+ attr_reader :value
268
+ @@events = ['onLoad', 'onRequest', 'other', 'none']
269
+
270
+ # [_txt_:]
271
+ # The event. Choices: onLoad, onRequest, other, none.
272
+ def initialize(txt=nil)
273
+ if txt and @@events.include?(txt)
274
+ @value = txt
275
+ else
276
+ raise "Actuate event '#{txt}' is not valid: " +
277
+ @@events.join(', ')
278
+ end
279
+ end
280
+
281
+ def to_s
282
+ "{#{@value}}"
283
+ end
284
+ end
285
+
286
+ # A class representing a positive integer.
287
+ class PositiveInteger
288
+ attr_reader :value
289
+
290
+ # [_num_:]
291
+ # An integer > 0.
292
+ def initialize(num=nil)
293
+ if num and num > 0
294
+ @value = num
295
+ else
296
+ raise "Positive integer #{num} must be > 0"
297
+ end
298
+ end
299
+
300
+ def to_s
301
+ "{#{@value.to_s}}"
302
+ end
303
+ end
304
+
305
+ # A class representing 0 or a positive integer.
306
+ class NonNegativeInteger
307
+ attr_reader :value
308
+
309
+ # [_num_:]
310
+ # An integer >= 0.
311
+ def initialize(num=nil)
312
+ if num and num >= 0
313
+ @value = num
314
+ else
315
+ raise "Non-negative integer #{num} must be >= 0"
316
+ end
317
+ end
318
+
319
+ def to_s
320
+ "{#{@value.to_s}}"
321
+ end
322
+ end
323
+
324
+ # A class representing a values type.
325
+ class ValuesType
326
+ attr_reader :value
327
+ @@types = ['legal', 'actual']
328
+
329
+ # [_txt_:]
330
+ # The type of values. Choices: legal, actual.
331
+ def initialize(txt=nil)
332
+ if txt and @@types.include?(txt)
333
+ @value = txt
334
+ else
335
+ raise "Values type '#{txt}' is not valid. Use one of: " +
336
+ @@types.join(', ')
337
+ end
338
+ end
339
+
340
+ def to_s
341
+ "{#{@value}}"
342
+ end
343
+ end
344
+
345
+ # A class representing a resource type.
346
+ class ResourceType
347
+ attr_reader :value
348
+ @@types = ['results', 'meta']
349
+
350
+ # [_txt_:]
351
+ # The type of resource. Choices: results, meta.
352
+ def initialize(txt=nil)
353
+ if txt and @@types.include?(txt)
354
+ @value = txt
355
+ else
356
+ raise "Resource type '#{txt}' is not valid. Use one of: " +
357
+ @@types.join(', ')
358
+ end
359
+ end
360
+
361
+ def to_s
362
+ "{#{@value}}"
363
+ end
364
+ end
365
+
366
+ # A class representing a field type.
367
+ class FieldType
368
+ attr_reader :value
369
+ @@types = ['hidden', 'no_query', 'trigger', 'location']
370
+
371
+ # [_txt_:]
372
+ # The field type. Choices: hidden, no_query, trigger, location.
373
+ def initialize(txt=nil)
374
+ if txt and @@types.include?(txt)
375
+ @value = txt
376
+ else
377
+ raise "Field type '#{txt}' is not valid. Use one of: " +
378
+ @@types.join(', ')
379
+ end
380
+ end
381
+
382
+ def to_s
383
+ "{#{@value}}"
384
+ end
385
+ end
386
+
387
+ end
388
+ end
389
+
390
+ end
391
+ end