voruby 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +339 -0
- data/REQUIREMENTS +4 -0
- data/Rakefile.rb +296 -0
- data/lib/voruby/adql/adql.rb +2735 -0
- data/lib/voruby/adql/ext.rb +15 -0
- data/lib/voruby/adql/loader.rb +5 -0
- data/lib/voruby/adql/operations.rb +54 -0
- data/lib/voruby/adql/parser.rb +160 -0
- data/lib/voruby/adql/transforms.rb +573 -0
- data/lib/voruby/ext.rb +17 -0
- data/lib/voruby/loader.rb +4 -0
- data/lib/voruby/misc/propertyfile.rb +36 -0
- data/lib/voruby/plastic/applications.rb +174 -0
- data/lib/voruby/plastic/constants.rb +30 -0
- data/lib/voruby/plastic/loader.rb +10 -0
- data/lib/voruby/plastic/plastic.rb +1 -0
- data/lib/voruby/resources/conesearch/conesearch.rb +9 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +55 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +50 -0
- data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +72 -0
- data/lib/voruby/resources/conesearch/loader.rb +4 -0
- data/lib/voruby/resources/loader.rb +50 -0
- data/lib/voruby/resources/nodes.rb +190 -0
- data/lib/voruby/resources/openskynode/loader.rb +4 -0
- data/lib/voruby/resources/openskynode/openskynode.rb +9 -0
- data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +54 -0
- data/lib/voruby/resources/sia/loader.rb +5 -0
- data/lib/voruby/resources/sia/sia.rb +9 -0
- data/lib/voruby/resources/sia/sia_v0_6.rb +90 -0
- data/lib/voruby/resources/sia/sia_v0_7.rb +89 -0
- data/lib/voruby/resources/sia/sia_v1_0.rb +122 -0
- data/lib/voruby/resources/stsci.rb +59 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +195 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +158 -0
- data/lib/voruby/resources/vodataservice/loader.rb +5 -0
- data/lib/voruby/resources/vodataservice/vodataservice.rb +9 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +189 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +163 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +221 -0
- data/lib/voruby/resources/voregistry/loader.rb +4 -0
- data/lib/voruby/resources/voregistry/voregistry.rb +9 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +40 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +30 -0
- data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +86 -0
- data/lib/voruby/resources/voresource/loader.rb +17 -0
- data/lib/voruby/resources/voresource/voresource.rb +9 -0
- data/lib/voruby/resources/voresource/voresource_v0_10.rb +322 -0
- data/lib/voruby/resources/voresource/voresource_v0_9.rb +405 -0
- data/lib/voruby/resources/voresource/voresource_v1_0.rb +230 -0
- data/lib/voruby/services/ext.rb +11 -0
- data/lib/voruby/services/gestalt/footprint.rb +95 -0
- data/lib/voruby/services/gestalt/wcs_fixer.rb +105 -0
- data/lib/voruby/services/gestalt/wesix.rb +155 -0
- data/lib/voruby/services/loader.rb +7 -0
- data/lib/voruby/services/registry/registry.rb +53 -0
- data/lib/voruby/services/resolver/resolver.rb +35 -0
- data/lib/voruby/sesame/loader.rb +6 -0
- data/lib/voruby/sesame/sesame_v1_0.rb +64 -0
- data/lib/voruby/simple/loader.rb +6 -0
- data/lib/voruby/simple/parameters.rb +196 -0
- data/lib/voruby/simple/sap.rb +446 -0
- data/lib/voruby/spacetime/loader.rb +3 -0
- data/lib/voruby/spacetime/spacetime.rb +607 -0
- data/lib/voruby/stc/coords_v1_20.rb +900 -0
- data/lib/voruby/stc/loader.rb +55 -0
- data/lib/voruby/stc/region_v1_20.rb +274 -0
- data/lib/voruby/stc/stc_v1_20.rb +1196 -0
- data/lib/voruby/util.rb +27 -0
- data/lib/voruby/voevent/loader.rb +7 -0
- data/lib/voruby/voevent/voevent_v1_0.rb +213 -0
- data/lib/voruby/voevent/voevent_v1_1.rb +196 -0
- data/lib/voruby/votables/chandra.rb +410 -0
- data/lib/voruby/votables/cnoc.rb +393 -0
- data/lib/voruby/votables/data.rb +179 -0
- data/lib/voruby/votables/galex.rb +390 -0
- data/lib/voruby/votables/hst.rb +391 -0
- data/lib/voruby/votables/int.rb +391 -0
- data/lib/voruby/votables/libxml_parser.rb +411 -0
- data/lib/voruby/votables/libxml_votable.rb +67 -0
- data/lib/voruby/votables/loader.rb +10 -0
- data/lib/voruby/votables/meta.rb +763 -0
- data/lib/voruby/votables/misc.rb +51 -0
- data/lib/voruby/votables/nsa.rb +393 -0
- data/lib/voruby/votables/nsar3.rb +410 -0
- data/lib/voruby/votables/rexml_parser.rb +408 -0
- data/lib/voruby/votables/rexml_votable.rb +67 -0
- data/lib/voruby/votables/sdss.rb +393 -0
- data/lib/voruby/votables/transforms.rb +388 -0
- data/lib/voruby/votables/tree.rb +45 -0
- data/lib/voruby/votables/types.rb +391 -0
- data/lib/voruby/votables/votable.rb +630 -0
- data/lib/voruby/votables/xmm.rb +394 -0
- data/test/adql/test1.adql +49 -0
- data/test/adql/test2.adql +51 -0
- data/test/adql/test3.adql +81 -0
- data/test/adql/test4.adql +53 -0
- data/test/adql/test5.adql +55 -0
- data/test/adql/test6.adql +18 -0
- data/test/adql/test7.adql +48 -0
- data/test/adql/unittest.rb +1672 -0
- data/test/plastic/test.rb +44 -0
- data/test/plastic/test.vot +5385 -0
- data/test/plastic/unittest.rb +66 -0
- data/test/resources/conesearch/conesearch_v0_3.xml +31 -0
- data/test/resources/conesearch/conesearch_v1_0.xml +86 -0
- data/test/resources/conesearch/unittest_v0_3.rb +22 -0
- data/test/resources/conesearch/unittest_v1_0.rb +24 -0
- data/test/resources/openskynode/open_sky_node_v0_1.xml +32 -0
- data/test/resources/openskynode/unittest_v0_1.rb +31 -0
- data/test/resources/sia/simple_image_access_v0_7.xml +36 -0
- data/test/resources/sia/simple_image_access_v1_0.xml +122 -0
- data/test/resources/sia/unittest_v0_7.rb +24 -0
- data/test/resources/sia/unittest_v1_0.rb +29 -0
- data/test/resources/stsci.xml +336 -0
- data/test/resources/unittest_stsci.rb +25 -0
- data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +128 -0
- data/test/resources/vodataservice/data_collection_resource_v0_5.xml +54 -0
- data/test/resources/vodataservice/data_collection_resource_v1_0.xml +117 -0
- data/test/resources/vodataservice/data_service_resource_v1_0.xml +115 -0
- data/test/resources/vodataservice/sky_service_resource_v0_10.xml +45 -0
- data/test/resources/vodataservice/table_service_resource_v1_0.xml +122 -0
- data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +60 -0
- data/test/resources/vodataservice/unittest_v0_5.rb +126 -0
- data/test/resources/vodataservice/unittest_v1_0.rb +151 -0
- data/test/resources/voregistry/authority_resource_v0_3.xml +20 -0
- data/test/resources/voregistry/authority_resource_v1_0.xml +82 -0
- data/test/resources/voregistry/registry_service_v0_3.xml +20 -0
- data/test/resources/voregistry/registry_service_v1_0.xml +107 -0
- data/test/resources/voregistry/unittest_v0_3.rb +31 -0
- data/test/resources/voregistry/unittest_v1_0.rb +34 -0
- data/test/resources/voresource/organisation_resource_v1_0.xml +90 -0
- data/test/resources/voresource/resource_organisation_v0_10.xml +22 -0
- data/test/resources/voresource/resource_service_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v1_0.xml +79 -0
- data/test/resources/voresource/service_resource_v1_0.xml +91 -0
- data/test/resources/voresource/unittest_v0_10.rb +61 -0
- data/test/resources/voresource/unittest_v0_9.rb +4 -0
- data/test/resources/voresource/unittest_v1_0.rb +190 -0
- data/test/services/gestalt/unittest.rb +74 -0
- data/test/services/registry/unittest.rb +34 -0
- data/test/services/resolver/unittest.rb +38 -0
- data/test/simple/unittest.rb +46 -0
- data/test/spacetime/unittest.rb +39 -0
- data/test/stc/catalog_entry_location_v1_20.xml +112 -0
- data/test/stc/obs_data_location_v1_20.xml +108 -0
- data/test/stc/search_location_v1_20.xml +54 -0
- data/test/stc/stc_resource_profile_v1_20.xml +60 -0
- data/test/stc/unittest_v1_20.rb +620 -0
- data/test/voevent/unittest_v1_0.rb +79 -0
- data/test/voevent/unittest_v1_1.rb +70 -0
- data/test/voevent/voevent_v1_0.xml +96 -0
- data/test/voevent/voevent_v1_1.xml +76 -0
- data/test/votables/test.vot +366 -0
- data/test/votables/unittest.rb +54 -0
- metadata +256 -0
@@ -0,0 +1,573 @@
|
|
1
|
+
require 'voruby/adql/adql'
|
2
|
+
require 'rexml/element'
|
3
|
+
|
4
|
+
module VORuby
|
5
|
+
|
6
|
+
module ADQL
|
7
|
+
class ScalarExpression
|
8
|
+
def to_adqls
|
9
|
+
self.value
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ClosedExpr
|
14
|
+
def to_adqls
|
15
|
+
"(#{self.value.to_adqls})"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class BinaryOperator
|
20
|
+
def to_adqls
|
21
|
+
self.operator
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class BinaryExpr
|
26
|
+
def to_adqls
|
27
|
+
"#{self.arg1.to_adqls} #{self.oper.to_adqls} #{self.arg2.to_adqls}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class UnaryOperator
|
32
|
+
def to_adqls
|
33
|
+
self.operator
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class UnaryExpr
|
38
|
+
def to_adqls
|
39
|
+
"#{self.oper.to_adqls}#{self.arg.to_adqls}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class ColumnReference
|
44
|
+
def to_adqls
|
45
|
+
"#{self.table}.#{self.name}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_adqlx(element_name)
|
49
|
+
"<#{element_name} Name=\"#{self.name}\" Table=\"#{self.table}\" " +
|
50
|
+
"xsi:type=\"columnReferenceType\"/>"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Atom
|
55
|
+
def to_adqls
|
56
|
+
lit_value = self.literal
|
57
|
+
if lit_value.is_a?(StringType)
|
58
|
+
"'#{lit_value.to_adqls}#{self.unit || ''}'"
|
59
|
+
else
|
60
|
+
"#{lit_value.to_adqls}#{self.unit || ''}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_adqlx(element_name)
|
65
|
+
literal_type = ''
|
66
|
+
if self.literal.is_a?(ADQL::RealType)
|
67
|
+
literal_type = 'realType'
|
68
|
+
elsif self.literal.is_a?(ADQL::IntegerType)
|
69
|
+
literal_type = 'integerType'
|
70
|
+
elsif self.literal.is_a?(ADQL::StringType)
|
71
|
+
literal_type = 'stringType'
|
72
|
+
end
|
73
|
+
|
74
|
+
atom = "<#{element_name} xsi:type=\"atomType\">\n"
|
75
|
+
atom << self.literal.to_adqlx(literal_type)
|
76
|
+
atom << "\n</#{element_name}>\n"
|
77
|
+
|
78
|
+
return atom
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class LiteralType
|
83
|
+
def to_adqls
|
84
|
+
self.value.to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_adqlx(literal_type)
|
88
|
+
"<Literal xsi:type=\"#{literal_type}\" Value=\"#{self.value.to_s}\" />"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class SelectionOption
|
93
|
+
def to_adqls
|
94
|
+
self.option.option
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class AllOrDistinct
|
99
|
+
def to_adqls
|
100
|
+
self.option
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class TrigonometricFunctionName
|
105
|
+
def to_adqls
|
106
|
+
self.value
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class TrigonometricFunction
|
111
|
+
def to_adqls
|
112
|
+
if self.allow
|
113
|
+
"#{self.name.to_adqls}(#{self.allow.to_adqls} #{self.arg.to_adqls})"
|
114
|
+
else
|
115
|
+
"#{self.name.to_adqls}(#{self.arg.to_adqls})"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
class MathFunctionName
|
121
|
+
def to_adqls
|
122
|
+
self.value
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
class MathFunction
|
127
|
+
def to_adqls
|
128
|
+
if self.allow
|
129
|
+
"#{self.name.to_adqls}(#{self.allow.to_adqls} #{self.arg.to_adqls})"
|
130
|
+
else
|
131
|
+
"#{self.name.to_adqls}(#{self.arg.to_adqls})"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class AggregateFunctionName
|
137
|
+
def to_adqls
|
138
|
+
self.value
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class AggregateFunction
|
143
|
+
def to_adqls
|
144
|
+
if self.allow
|
145
|
+
"#{self.name.to_adqls}(#{self.allow.to_adqls} #{self.arg.to_adqls})"
|
146
|
+
else
|
147
|
+
"#{self.name.to_adqls}(#{self.arg.to_adqls})"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
class AliasSelectionItem
|
153
|
+
def to_adqls
|
154
|
+
if self.as
|
155
|
+
"#{self.expression.to_adqls} AS #{self.as}"
|
156
|
+
else
|
157
|
+
self.expression.to_adqls
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
class AllSelectionItem
|
163
|
+
def to_adqls
|
164
|
+
'*'
|
165
|
+
end
|
166
|
+
|
167
|
+
def to_adqlx(element_name)
|
168
|
+
"<#{element_name} xsi:type=\"allSelectionItemType\"/>"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
class Comparison
|
173
|
+
def to_adqls
|
174
|
+
self.value
|
175
|
+
end
|
176
|
+
|
177
|
+
def to_adqlx
|
178
|
+
self.value
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
class ArchiveTable
|
183
|
+
def to_adqls
|
184
|
+
if self.alias_name
|
185
|
+
"#{self.archive}:#{self.name} #{self.alias_name}"
|
186
|
+
else
|
187
|
+
"#{self.archive}:#{self.name}"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def to_adqlx
|
192
|
+
if self.alias_name
|
193
|
+
"<Table Name=\"#{self.name}\" Archive=\"#{self.archive}\" " +
|
194
|
+
"Alias=\"#{self.alias_name}\" xsi:type=\"tableType\"/>"
|
195
|
+
else
|
196
|
+
"<Table Name=\"#{self.name}\" Archive=\"#{self.archive}\" " +
|
197
|
+
"xsi:type=\"tableType\"/>"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
class Table
|
203
|
+
def to_adqls
|
204
|
+
if self.alias_name
|
205
|
+
"#{self.name} #{self.alias_name}"
|
206
|
+
else
|
207
|
+
self.name
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
class XMatchTableAlias
|
213
|
+
def to_adqls
|
214
|
+
self.name
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
class DropTable
|
219
|
+
def to_adqls
|
220
|
+
"!#{self.name}"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
class IntersectionSearch
|
225
|
+
def to_adqls
|
226
|
+
"#{self.cond1.to_adqls} AND #{self.cond2.to_adqls}"
|
227
|
+
end
|
228
|
+
|
229
|
+
def to_adqlx
|
230
|
+
intersection_search = "<Condition xsi:type=\"intersectionSearchType\">\n"
|
231
|
+
intersection_search << self.cond1.to_adqlx
|
232
|
+
intersection_search << self.cond2.to_adqlx
|
233
|
+
intersection_search << "</Condition>\n"
|
234
|
+
return intersection_search
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
class UnionSearch
|
239
|
+
def to_adqls
|
240
|
+
"#{self.cond1.to_adqls} OR #{self.cond2.to_adqls}"
|
241
|
+
end
|
242
|
+
|
243
|
+
def to_adqlx
|
244
|
+
union_search = "<Condition xsi:type=\"unionSearchType\">\n"
|
245
|
+
union_search << self.cond1.to_adqlx
|
246
|
+
union_search << self.cond2.to_adqlx
|
247
|
+
union_search << "</Condition>\n"
|
248
|
+
return union_search
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
class XMatch
|
253
|
+
def to_adqls
|
254
|
+
tables = self.tables.collect{|x| x.to_adqls}.join(', ')
|
255
|
+
"XMATCH(#{tables}) #{nature.value} #{sigma.value}"
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
class LikePred
|
260
|
+
def to_adqls
|
261
|
+
"#{self.arg.to_adqls} LIKE #{self.pattern.to_adqls}"
|
262
|
+
end
|
263
|
+
|
264
|
+
def to_adqlx
|
265
|
+
like_pred = "<Condition xsi:type=\"likePredType\">\n"
|
266
|
+
like_pred << self.arg.to_adqlx('Arg') + "\n"
|
267
|
+
like_pred << self.pattern.to_adqlx('Pattern')
|
268
|
+
like_pred << "</Condition>\n"
|
269
|
+
|
270
|
+
return like_pred
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
class NotLikePred
|
275
|
+
def to_adqls
|
276
|
+
"#{self.arg.to_adqls} NOT LIKE #{self.pattern.to_adqls}"
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
class SubQuerySet
|
281
|
+
def to_adqls
|
282
|
+
self.selection.to_adqls
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
class ClosedSearch
|
287
|
+
def to_adqls
|
288
|
+
"(#{self.condition.to_adqls})"
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
class ComparisonPred
|
293
|
+
def to_adqls
|
294
|
+
"#{self.arg1.to_adqls} #{self.comparison.to_adqls} #{self.arg2.to_adqls}"
|
295
|
+
end
|
296
|
+
|
297
|
+
def to_adqlx
|
298
|
+
comparison_pred = "<Condition xsi:type=\"comparisonPredType\" Comparison=\"#{self.comparison.to_adqlx}\">\n"
|
299
|
+
comparison_pred << self.arg1.to_adqlx('Arg') + "\n"
|
300
|
+
comparison_pred << self.arg2.to_adqlx('Arg')
|
301
|
+
comparison_pred << "</Condition>\n"
|
302
|
+
return comparison_pred
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
class BetweenPred
|
307
|
+
def to_adqls
|
308
|
+
"#{self.arg1.to_adqls} BETWEEN #{self.arg2.to_adqls} AND #{self.arg3.to_adqls}"
|
309
|
+
end
|
310
|
+
|
311
|
+
def to_adqlx
|
312
|
+
between_pred = "<Condition xsi:type=\"betweenPredType\">\n"
|
313
|
+
between_pred << self.arg1.to_adqlx('Arg') + "\n"
|
314
|
+
between_pred << self.arg2.to_adqlx('Arg')
|
315
|
+
between_pred << self.arg3.to_adqlx('Arg')
|
316
|
+
between_pred << "</Condition>\n"
|
317
|
+
return between_pred
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
class NotBetweenPred
|
322
|
+
def to_adqls
|
323
|
+
"#{self.arg1.to_adqls} NOT BETWEEN #{self.arg2.to_adqls} AND #{self.arg3.to_adqls}"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
class Circle
|
328
|
+
def to_adqls
|
329
|
+
"#{self.shape.to_adqls} #{self.system.to_adqls} #{self.ra.to_adqls} #{self.dec.to_adqls} #{self.radius.to_adqls}"
|
330
|
+
end
|
331
|
+
|
332
|
+
def to_adqlx
|
333
|
+
circle = "xsi:type=\"reg:circleType\" unit=\"deg\">\n"
|
334
|
+
circle << "<reg:Center>#{self.ra.value} #{self.dec.value}</reg:Center>\n"
|
335
|
+
circle << "<reg:Radius>#{self.radius.value}</reg:Radius>\n"
|
336
|
+
return circle
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
class Box
|
341
|
+
def to_adqls
|
342
|
+
"#{self.shape.to_adqls} #{self.system.to_adqls} " +
|
343
|
+
"#{self.ra.to_adqls} #{self.dec.to_adqls} " +
|
344
|
+
"#{self.dra.to_adqls} #{self.ddec.to_adqls}"
|
345
|
+
end
|
346
|
+
|
347
|
+
def to_adqlx
|
348
|
+
box = "xsi:type=\"reg:boxType\">\n"
|
349
|
+
box << "<reg:Center>#{self.ra.value} #{self.dec.value}</reg:Center>\n"
|
350
|
+
box << "<reg:Size>#{self.dra.value} #{self.ddec.value}</reg:Size>\n"
|
351
|
+
return box
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
class RegionSearch
|
356
|
+
def to_adqls
|
357
|
+
"Region('#{self.shape.to_adqls}')"
|
358
|
+
end
|
359
|
+
|
360
|
+
def to_adqlx
|
361
|
+
region = "<Condition xsi:type=\"regionSearchType\" intersection=\"#{self.intersection.value}\">\n"
|
362
|
+
region << "<Region "
|
363
|
+
|
364
|
+
region << self.shape.to_adqlx
|
365
|
+
|
366
|
+
region << "</Region>\n"
|
367
|
+
region << "</Condition>\n"
|
368
|
+
return region
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
class InverseSearch
|
373
|
+
def to_adqls
|
374
|
+
"NOT #{self.condition.to_adqls}"
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
class Having
|
379
|
+
def to_adqls
|
380
|
+
"HAVING #{self.condition.to_adqls}"
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
class GroupBy
|
385
|
+
def to_adqls
|
386
|
+
cols = self.columns.collect{|x| x.to_adqls}.join(', ')
|
387
|
+
"GROUP BY #{cols}"
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
class Where
|
392
|
+
def to_adqls
|
393
|
+
"WHERE #{self.condition.to_adqls}" if self.condition
|
394
|
+
end
|
395
|
+
|
396
|
+
def to_adqlx
|
397
|
+
if self.condition
|
398
|
+
where = "<Where>\n"
|
399
|
+
where << self.condition.to_adqlx
|
400
|
+
where << "\n</Where>\n"
|
401
|
+
return where
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
class From
|
407
|
+
def to_adqls
|
408
|
+
tables = self.tables.collect{|x| x.to_adqls}.join(', ')
|
409
|
+
"FROM #{tables}"
|
410
|
+
end
|
411
|
+
|
412
|
+
def to_adqlx
|
413
|
+
from = "<From>\n"
|
414
|
+
from << self.tables.collect{|x| x.to_adqlx}.join("\n")
|
415
|
+
from << "\n</From>\n"
|
416
|
+
|
417
|
+
return from
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
class SelectionList
|
422
|
+
def to_adqls
|
423
|
+
self.items.collect{|x| x.to_adqls}.join(', ')
|
424
|
+
end
|
425
|
+
|
426
|
+
def to_adqlx
|
427
|
+
selection_list = "<SelectionList>\n"
|
428
|
+
selection_list << self.items.collect{|x| x.to_adqlx('Item')}.join("\n")
|
429
|
+
selection_list << "\n</SelectionList>\n"
|
430
|
+
|
431
|
+
return selection_list
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
class SelectionLimit
|
436
|
+
def to_adqls
|
437
|
+
"TOP #{self.top}"
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
class Into
|
442
|
+
def to_adqls
|
443
|
+
"INTO #{self.table_name}"
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
class OrderDirection
|
448
|
+
def to_adqls
|
449
|
+
self.value
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
class OrderOption
|
454
|
+
def to_adqls
|
455
|
+
self.direction.to_adqls
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
class Order
|
460
|
+
def to_adqls
|
461
|
+
if self.order
|
462
|
+
"#{self.expression.to_adqls} #{self.order.to_adqls}"
|
463
|
+
else
|
464
|
+
"#{self.expression.to_adqls}"
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
class OrderExpression
|
470
|
+
def to_adqls
|
471
|
+
items = self.items.collect{|x| x.to_adqls}.join(', ')
|
472
|
+
"ORDER BY #{items}"
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
class ConstantListSet
|
477
|
+
def to_adqls
|
478
|
+
self.items.collect{ |x|
|
479
|
+
if x.is_a?(NumberType)
|
480
|
+
x.to_adqls
|
481
|
+
else
|
482
|
+
"\"#{x.to_adqls}\""
|
483
|
+
end
|
484
|
+
}.join(', ')
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
class InclusiveSearch
|
489
|
+
def to_adqls
|
490
|
+
"#{self.expression.to_adqls} IN (#{self.set.to_adqls})"
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
class ExclusiveSearch
|
495
|
+
def to_adqls
|
496
|
+
"#{self.expression.to_adqls} NOT IN (#{self.set.to_adqls})"
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
class Select
|
501
|
+
def to_adqls
|
502
|
+
select = 'SELECT'
|
503
|
+
select << " #{self.allow.to_adqls}" if self.allow
|
504
|
+
select << " #{self.restrict.to_adqls}" if self.restrict
|
505
|
+
select << " #{self.selection_list.to_adqls}"
|
506
|
+
select << " #{self.in_to.to_adqls}" if self.in_to
|
507
|
+
select << " #{self.from.to_adqls}" if self.from
|
508
|
+
select << " #{self.where.to_adqls}" if self.where
|
509
|
+
select << " #{self.group_by.to_adqls}" if self.group_by
|
510
|
+
select << " #{self.having.to_adqls}" if self.having
|
511
|
+
select << " #{self.order_by.to_adqls}" if self.order_by
|
512
|
+
|
513
|
+
return select
|
514
|
+
end
|
515
|
+
|
516
|
+
def to_adqlx
|
517
|
+
adqlx = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
518
|
+
"<Select xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
519
|
+
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
|
520
|
+
"xmlns=\"http://www.ivoa.net/xml/ADQL/v0.9\" " +
|
521
|
+
"xmlns:reg=\"http://www.ivoa.net/xml/STC/STCregion/v1.20\">\n"
|
522
|
+
|
523
|
+
# adqlx << " #{self.allow.to_adqlx}" if self.allow
|
524
|
+
# adqlx << " #{self.restrict.to_adqlx}" if self.restrict
|
525
|
+
adqlx << " #{self.selection_list.to_adqlx}"
|
526
|
+
# adqlx << " #{self.in_to.to_adqlx}" if self.in_to
|
527
|
+
adqlx << " #{self.from.to_adqlx}" if self.from
|
528
|
+
adqlx << " #{self.where.to_adqlx}" if self.where
|
529
|
+
# adqlx << " #{self.group_by.to_adqlx}" if self.group_by
|
530
|
+
# adqlx << " #{self.having.to_adqlx}" if self.having
|
531
|
+
# adqlx << " #{self.order_by.to_adqlx}" if self.order_by
|
532
|
+
adqlx << "</Select>"
|
533
|
+
|
534
|
+
return adqlx
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
class UserDefinedFunction
|
539
|
+
def to_adqls
|
540
|
+
params = ''
|
541
|
+
if self.params and self.params.size > 0
|
542
|
+
params = self.params.collect{|x| x.to_adqls}.join(', ')
|
543
|
+
end
|
544
|
+
"#{self.name}(#{params})"
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
class JointTableQualifier
|
549
|
+
def to_adqls
|
550
|
+
self.value
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
class JoinTable
|
555
|
+
def to_adqls
|
556
|
+
"#{self.qualifier.to_adqls} #{self.tables.to_adqls} ON #{self.condition.to_adqls}"
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
560
|
+
class ArrayOfFromTable
|
561
|
+
def to_adqls
|
562
|
+
self.from_tables.collect{|x| x.to_adqls}.join(', ')
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
566
|
+
class Unit
|
567
|
+
def to_adqls
|
568
|
+
self.unit
|
569
|
+
end
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
end
|
data/lib/voruby/ext.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class Object
|
2
|
+
# The hidden singleton lurks behind everyone
|
3
|
+
def metaclass; class << self; self; end; end
|
4
|
+
def meta_eval(&blk)
|
5
|
+
metaclass.instance_eval(&blk)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Adds methods to a metaclass
|
9
|
+
def meta_def(name, &blk)
|
10
|
+
meta_eval { define_method(name, &blk) }
|
11
|
+
end
|
12
|
+
|
13
|
+
# Defines an instance method within a class
|
14
|
+
def class_def(name, &blk)
|
15
|
+
class_eval { define_method(name, &blk) }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module VORuby
|
2
|
+
module Misc
|
3
|
+
module PropertyFile
|
4
|
+
|
5
|
+
# A *very* simple property file reader.
|
6
|
+
# It can only understand files with entries
|
7
|
+
# of the property=value format--nothing fancy.
|
8
|
+
class SimpleReader
|
9
|
+
def initialize(file_name)
|
10
|
+
@file_name = file_name
|
11
|
+
load()
|
12
|
+
end
|
13
|
+
|
14
|
+
def load
|
15
|
+
@properties = {}
|
16
|
+
File.open(@file_name) do |file|
|
17
|
+
file.each do |line|
|
18
|
+
line.lstrip!
|
19
|
+
if line !~ /^\#/
|
20
|
+
key, value = line.split(/\s*=\s*/, 2)
|
21
|
+
@properties[key] = value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def [](name)
|
28
|
+
@properties[name]
|
29
|
+
end
|
30
|
+
|
31
|
+
private :load
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|