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,174 @@
1
+ require 'voruby/plastic/loader'
2
+
3
+ module VORuby
4
+ module Plastic
5
+ module Application
6
+
7
+ class Base
8
+ attr_reader :name, :description, :icon_url, :ivorn, :plastic_version, :config, :hub_id, :app_id
9
+
10
+ def initialize(name=nil, description=nil, icon_url=nil, ivorn=nil, plastic_version=0.5)
11
+ initialize_config()
12
+
13
+ @hub = ::XMLRPC::Client.new_from_uri(@config['plastic.xmlrpc.url'])
14
+
15
+ @name = name
16
+ @hub_id = URI.parse(call('plastic.hub.getHubId'))
17
+
18
+ @description = description
19
+ @icon_url = icon_url
20
+ @ivorn = ivorn
21
+ @plastic_version = plastic_version
22
+ end
23
+
24
+ def initialize_config
25
+ begin
26
+ @config = Misc::PropertyFile::SimpleReader.new("#{ENV['HOME']}/.plastic")
27
+ rescue Errno::ENOENT => e
28
+ puts "Unable to find .plastic file. Is a PLASTIC hub running? #{e}"
29
+ end
30
+
31
+ raise 'Unable to determine value of XMLRPC URL' if !@config['plastic.xmlrpc.url']
32
+ @config['plastic.xmlrpc.url'].gsub!(/\\:/, ':')
33
+ end
34
+
35
+ def register
36
+ @app_id = call('plastic.hub.registerNoCallBack', self.name)
37
+ end
38
+
39
+ def get_registered_ids
40
+ call('plastic.hub.getRegisteredIds').collect{ |uri| URI.parse(uri) }
41
+ end
42
+
43
+ def get_understood_messages(app_id)
44
+ call('plastic.hub.getUnderstoodMessages', app_id.to_s).collect{ |uri| URI.parse(uri) }
45
+ end
46
+
47
+ def get_message_registered_ids(msg)
48
+ call('plastic.hub.getMessageRegisteredIds', msg.to_s).collect{ |uri| URI.parse(uri) }
49
+ end
50
+
51
+ def get_name(app_id)
52
+ name = call('plastic.hub.getName', app_id.to_s)
53
+ (name != '')? name: nil
54
+ end
55
+
56
+ def unregister
57
+ call('plastic.hub.unregister', self.app_id.to_s) if self.app_id
58
+ end
59
+
60
+ def request(msg, *args)
61
+ responses = {}
62
+ call('plastic.hub.request', self.app_id.to_s, msg.to_s, args).each do |app_id, response|
63
+ responses[URI.parse(app_id)] = response
64
+ end
65
+
66
+ responses
67
+ end
68
+
69
+ def request_to_subset(msg, args, *recipients)
70
+ responses = {}
71
+ call('plastic.hub.requestToSubset', self.app_id.to_s, msg.to_s, args,
72
+ recipients.collect{ |id| id.to_s }).each do |app_id, response|
73
+ responses[URI.parse(app_id)] = response
74
+ end
75
+
76
+ responses
77
+ end
78
+
79
+ def request_asynch(msg, *args)
80
+ call_async('plastic.hub.requestAsynch', self.app_id.to_s, msg.to_s, args)
81
+ end
82
+
83
+ def request_to_subset_asynch(msg, args, recipients)
84
+ call_async('plastic.hub.requestToSubsetAsynch', self.app_id.to_s, msg.to_s, args, recipients.collect{ |id| id.to_s })
85
+ end
86
+
87
+ def call(method_name, *args)
88
+ begin
89
+ @hub.call(method_name, *args)
90
+ rescue ::XMLRPC::FaultException => e
91
+ puts "XMLRPC Error while calling #{method_name} (#{e.faultCode}): #{e.faultString}"
92
+ end
93
+ end
94
+
95
+ def call_async(method_name, *args)
96
+ begin
97
+ @hub.call_async(method_name, *args)
98
+ rescue ::XMLRPC::FaultException => e
99
+ puts "XMLRPC Error while calling #{method_name} (#{e.faultCode}): #{e.faultString}"
100
+ end
101
+ end
102
+
103
+ private :initialize_config, :call, :call_async
104
+ end
105
+
106
+ class Full < Base
107
+ attr_reader :supported_messages, :call_back_url, :xmlrpc_server, :http_server
108
+
109
+ def initialize(supported_messages={}, port=8080, mount_point='/RPC2',
110
+ name=nil, description=nil, icon_url=nil, ivorn=nil, plastic_version=0.5)
111
+ super(name, description, icon_url, ivorn, plastic_version)
112
+
113
+ initialize_core_messages()
114
+ @supported_messages = @core_messages.merge(supported_messages)
115
+
116
+ initialize_xmlrpc_server(port, mount_point)
117
+ end
118
+
119
+ def initialize_core_messages
120
+ @core_messages = {
121
+ Messages::TEST_ECHO => Proc.new{ |sender_id, args| args[0] },
122
+ Messages::INFO_GET_IVORN => Proc.new{ |sender_id, args| self.ivorn.to_s },
123
+ Messages::INFO_GET_NAME => Proc.new{ |sender_id, args| self.name },
124
+ Messages::INFO_GET_VERSION => Proc.new{ |sender_id, args| self.plastic_version.to_s },
125
+ Messages::INFO_GET_ICON_URL => Proc.new{ |sender_id, args| self.icon_url.to_s },
126
+ Messages::INFO_GET_DESCRIPTION => Proc.new{ |sender_id, args| self.description },
127
+ Messages::HUB_EVENT_APPLICATION_REGISTERED => Proc.new{ |sender_id, args| '' },
128
+ Messages::HUB_EVENT_APPLICATION_UNREGISTERED => Proc.new{ |sender_id, args| '' },
129
+ Messages::HUB_EVENT_HUB_STOPPING => Proc.new{ |sender_id, args| '' }
130
+ }
131
+ end
132
+
133
+ def initialize_xmlrpc_server(port=8080, mount_point='/RPC2')
134
+ @xmlrpc_server = ::XMLRPC::WEBrickServlet.new
135
+ @xmlrpc_server.set_default_handler do |action, *args|
136
+ sending_app_id = URI.parse(args[0])
137
+ msg = URI.parse(args[1])
138
+ msg_args = args[2..-1]
139
+
140
+ return false if !self.supported_messages.has_key?(msg) or action != 'perform'
141
+ self.supported_messages[msg].call(sending_app_id, msg_args)
142
+ end
143
+
144
+ @http_server = ::WEBrick::HTTPServer.new(:Port => port)
145
+ @http_server.mount(mount_point, @xmlrpc_server)
146
+ trap('INT'){ @http_server.shutdown }
147
+
148
+ @call_back_url = URI::Generic.new('http', nil, @http_server.config[:ServerName], @http_server.config[:Port],
149
+ nil, mount_point,
150
+ nil, nil, nil, false)
151
+
152
+ @server_thread = Thread.new { @http_server.start }
153
+ end
154
+
155
+ def register
156
+ @app_id = call('plastic.hub.registerXMLRPC', self.name,
157
+ self.supported_messages.keys.collect{ |msg| msg.to_s }, self.call_back_url.to_s)
158
+ end
159
+
160
+ def wait_for_requests
161
+ @server_thread.join
162
+ end
163
+
164
+ def shutdown
165
+ self.unregister
166
+ self.http_server.shutdown
167
+ end
168
+
169
+ private :initialize_core_messages, :initialize_xmlrpc_server
170
+ end
171
+
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,30 @@
1
+ module VORuby
2
+ module Plastic
3
+ module Messages
4
+ PREFIX = 'ivo://votech.org'
5
+
6
+ # Core messages
7
+ TEST_ECHO = URI.parse("#{PREFIX}/test/echo")
8
+ INFO_GET_IVORN = URI.parse("#{PREFIX}/info/getIVORN")
9
+ INFO_GET_NAME = URI.parse("#{PREFIX}/info/getName")
10
+ INFO_GET_VERSION = URI.parse("#{PREFIX}/info/getVersion")
11
+ INFO_GET_ICON_URL = URI.parse("#{PREFIX}/info/getIconURL")
12
+ INFO_GET_DESCRIPTION = URI.parse("#{PREFIX}/info/getDescription")
13
+ HUB_EVENT_APPLICATION_REGISTERED = URI.parse("#{PREFIX}/hub/event/ApplicationRegistered")
14
+ HUB_EVENT_APPLICATION_UNREGISTERED = URI.parse("#{PREFIX}/hub/event/ApplicationUnregistered")
15
+ HUB_EVENT_HUB_STOPPING = URI.parse("#{PREFIX}/hub/event/HubStopping")
16
+ CORE_MESSAGES = [TEST_ECHO,
17
+ INFO_GET_IVORN, INFO_GET_NAME, INFO_GET_VERSION, INFO_GET_ICON_URL, INFO_GET_DESCRIPTION,
18
+ HUB_EVENT_APPLICATION_REGISTERED, HUB_EVENT_APPLICATION_UNREGISTERED, HUB_EVENT_HUB_STOPPING]
19
+
20
+ # Agreed messages
21
+ VOTABLE_LOAD = URI.parse("#{PREFIX}/votable/load")
22
+ VOTABLE_LOAD_FROM_URL = URI.parse("#{PREFIX}/votable/loadFromURL")
23
+ VOTABLE_SHOW_OBJECTS = URI.parse("#{PREFIX}/votable/showObjects")
24
+
25
+ # Image related messages
26
+ FITS_IMAGE_LOAD_FROM_URL = URI.parse("#{PREFIX}/fits/image/loadFromURL")
27
+ SKY_POINTS_AT_COORDS = URI.parse("#{PREFIX}/sky/pointsAtCoords")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ require 'uri'
2
+ require 'xmlrpc/client'
3
+ require 'xmlrpc/server'
4
+ require 'webrick'
5
+
6
+ #require 'rubygems'
7
+ #require 'propertyfile'
8
+
9
+ require 'voruby/misc/propertyfile'
10
+ require 'voruby/plastic/constants'
@@ -0,0 +1 @@
1
+ require 'voruby/plastic/applications'
@@ -0,0 +1,9 @@
1
+ require 'voruby/resources/conesearch/conesearch_v1_0'
2
+
3
+ module VORuby
4
+ module Resources
5
+ module ConeSearch
6
+ #include ConeSearch::V1_0
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,55 @@
1
+ require 'voruby/resources/conesearch/loader'
2
+
3
+ require 'voruby/resources/voresource/voresource_v0_9'
4
+ require 'voruby/resources/vodataservice/vodataservice_v0_4'
5
+
6
+ include VORuby::Resources::VOResource::V0_9
7
+ include VORuby::Resources::VODataService::V0_4
8
+
9
+ module VORuby
10
+ module Resources
11
+ module ConeSearch
12
+ module V0_2
13
+
14
+ # Forward declarations
15
+ class ConeSearchType < CapabilityType; end
16
+ class ConeSearch < ConeSearchType; end
17
+ class MaxRecords; end
18
+ class MaxSR; end
19
+ class Verbosity; end
20
+
21
+ # The capabilities of a Cone Search implementation. It includes
22
+ # the listing of the columns that appear in image query
23
+ # output VOTable and Cone Search-specific metadata.
24
+ class ConeSearch; end
25
+ class ConeSearchType
26
+ object_node :max_sr, 'MaxSR', :class => MaxSR, :optional => false
27
+ object_node :max_records, 'MaxRecords', :class => MaxRecords, :optional => false
28
+ object_node :verbosity, 'Verbosity', :class => Verbosity, :optional => false
29
+ end
30
+
31
+ # The largest number of records that the service will return.
32
+ class MaxRecords
33
+ include XML::Mapping
34
+
35
+ numeric_node :value, '', :optional => false
36
+ end
37
+
38
+ # The largest search radius, in degrees, that will be accepted by the service without returning an error condition.
39
+ class MaxSR
40
+ include XML::Mapping
41
+
42
+ numeric_node :value, '', :optional => false
43
+ end
44
+
45
+ # True if the service supports the VERB keyword; false, otherwise.
46
+ class Verbosity
47
+ include XML::Mapping
48
+
49
+ boolean_node :value, '', 'true', 'false', :optional => false
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,50 @@
1
+ require 'voruby/resources/conesearch/loader'
2
+
3
+ require 'voruby/resources/voresource/voresource_v0_10'
4
+ require 'voruby/resources/vodataservice/vodataservice_v0_5'
5
+
6
+ include VORuby::Resources::VOResource::V0_10
7
+ include VORuby::Resources::VODataService::V0_5
8
+
9
+ module VORuby
10
+ module Resources
11
+ module ConeSearch
12
+ module V0_3
13
+
14
+ # Forward declarations
15
+ class ConeSearch < TabularSkyService; end
16
+ class CSCapRestriction < Capability; end
17
+ class ConeSearchCapability < CSCapRestriction; end
18
+
19
+ # A standard service that returns catalog entries with a
20
+ # position falling within a cone on the sky (given by a position
21
+ # and a radius).
22
+ class ConeSearch
23
+ # a description of how this particular ConeSearch service behaves
24
+ object_node :capability, 'capability', :class => ConeSearchCapability, :optional => false
25
+ end
26
+
27
+ # An abstract capability that sets the standardURL to the ConeSearch standard definition.
28
+ class CSCapRestriction
29
+ object_node :standard_id, '@standardID', :class => IdentifierURI, :optional => true
30
+ object_node :standard_url, '@standardURL', :class => AnyURI, :optional => true,
31
+ :default_value => 'http://www.us-vo.org/metadata/conesearch.html'
32
+ end
33
+
34
+ # The capabilities of a Cone Search implementation. It includes
35
+ # the listing of the columns that appear in image query
36
+ # output VOTable and Cone Search-specific metadata.
37
+ class ConeSearchCapability
38
+ # the largest search radius, in degrees, that will be accepted by the service without returning an error condition
39
+ numeric_node :max_sr, 'maxSR', :optional => false
40
+ # the largest number of records that the service will return
41
+ numeric_node :max_records, 'maxRecords', :optional => false
42
+
43
+ # true if the service supports the VERB keyword; false, otherwise
44
+ boolean_node :verbosity, 'verbosity', 'true', 'false', :optional => false
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,72 @@
1
+ require 'voruby/resources/conesearch/loader'
2
+
3
+ require 'voruby/resources/voresource/voresource_v1_0'
4
+ require 'voruby/resources/vodataservice/vodataservice_v1_0'
5
+
6
+ include VORuby::Resources::VOResource::V1_0
7
+ include VORuby::Resources::VODataService::V1_0
8
+
9
+ module VORuby
10
+ module Resources
11
+ module ConeSearch
12
+ module V1_0
13
+
14
+ # Forward declarations
15
+ class CSCapRestriction < Capability; end
16
+ class ConeSearch < CSCapRestriction; end
17
+ class Query; end
18
+
19
+ # An abstract capability that fixes the standardID to the IVOA ID for the ConeSearch standard.
20
+ class CSCapRestriction
21
+ text_node :description, 'description', :optional => true
22
+
23
+ object_node :standard_id, '@standardID', :class => IdentifierURI, :optional => false,
24
+ :default_value => 'ivo://ivoa.net/std/ConeSearch'
25
+
26
+ array_node :validation_levels, 'validationLevel', :class => Validation, :optional => true, :default_value => []
27
+ array_node :interfaces, 'interface', :unmarshaller => $InterfaceUnmarshaller, :optional => true, :default_value => []
28
+ end
29
+
30
+ # The capabilities of a Cone Search implementation. It includes
31
+ # the listing of the columns that appear in image query
32
+ # output VOTable and Cone Search-specific metadata.
33
+ class ConeSearch
34
+ # the largest search radius, in degrees, that will be
35
+ # accepted by the service without returning an error
36
+ # condition
37
+ numeric_node :max_sr, 'maxSR', :optional => false
38
+ # the largest number of records that the service will return
39
+ numeric_node :max_records, 'maxRecords', :optional => false
40
+
41
+ # true if the service supports the VERB keyword; false, otherwise
42
+ boolean_node :verbosity, 'verbosity', 'true', 'false', :optional => false
43
+
44
+ # a query that will result in at least on matched record that can be used to test the service
45
+ object_node :test_query, 'testQuery', :class => Query
46
+ end
47
+
48
+ # A query to be sent to the service.
49
+ class Query
50
+ include XML::Mapping
51
+
52
+ # the right ascension of the search cone's center in decimal degree
53
+ numeric_node :ra, 'ra', :optional => false
54
+ # the declination of the search cone's center in decimal degrees
55
+ numeric_node :dec, 'dec', :optional => false
56
+ # the radius of the search cone in decimal degrees
57
+ numeric_node :sr, 'sr', :optional => false
58
+ # the verbosity level to use where 1 means the bare minimum set of columns and 3 means the full set of
59
+ # available columns.
60
+ numeric_node :verb, 'verb', :optional => true
61
+
62
+ # the catalog to query
63
+ text_node :catalog, 'catalog', :optional => true
64
+ # any extra (non-standard) parameters that must be provided (apart from what is part of base URL given
65
+ # by the accessURL element).
66
+ text_node :extras, 'extras', :optional => true
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'xml/mapping'
3
+
4
+ require 'voruby/loader'
@@ -0,0 +1,50 @@
1
+ require 'voruby/loader'
2
+
3
+ module VORuby
4
+ module Resources
5
+ NAMESPACE_MODULE_MAP =
6
+ {
7
+ 'http://www.ivoa.net/xml/VOResource/v0.10' => 'VORuby::Resources::VOResource::V_10',
8
+ 'http://www.ivoa.net/xml/VOResource/v0.9' => 'VORuby::Resources::VOResource::V0_9',
9
+ 'http://www.ivoa.net/xml/VOResource/v1.0' => 'VORuby::Resources::VOResource::V1_0',
10
+ 'http://www.ivoa.net/xml/VODataService/v0.4' => 'VORuby::Resources::VODataService',
11
+ 'http://www.ivoa.net/xml/VODataService/v0.5' => 'VORuby::Resources::VODataService::V0_5',
12
+ 'http://www.ivoa.net/xml/VODataService/v1.0' => 'VORuby::Resources::VODataService::V1_0',
13
+ 'http://www.ivoa.net/xml/OpenSkyNode/v0.1' => 'VORuby::OpenSkyNode',
14
+ 'http://www.ivoa.net/xml/VORegistry/v0.2' => 'VORuby::Resources::VORegistry::V0_2',
15
+ 'http://www.ivoa.net/xml/VORegistry/v0.3' => 'VORuby::Resources::VORegistry::V0_3',
16
+ 'http://www.ivoa.net/xml/VORegistry/v1.0' => 'VORuby::Resources::VORegistry::V1_0',
17
+ 'http://www.ivoa.net/xml/SIA/v0.6' => 'VORuby::Resources::SIA::V0_6',
18
+ 'http://www.ivoa.net/xml/SIA/v0.7' => 'VORuby::Resources::SIA::V0_7',
19
+ 'http://www.ivoa.net/xml/SIA/v1.0' => 'VORuby::Resources::SIA::V1_0',
20
+ 'http://www.ivoa.net/xml/ConeSearch/v0.2' => 'VORuby::Resources::ConeSearch::V0_2',
21
+ 'http://www.ivoa.net/xml/ConeSearch/v0.3' => 'VORuby::Resources::ConeSearch::V0_3',
22
+ 'http://www.ivoa.net/xml/ConeSearch/v1.0' => 'VORuby::Resources::ConeSearch::V1_0'
23
+ }
24
+
25
+ # Dynamically dispatches a request to a class using the determined XML
26
+ # namespace.
27
+ def self.namespace_dispatcher(default_module, default_type, default_class)
28
+ return Proc.new{ |xml|
29
+ the_module = type = nil
30
+ if xml.attributes['type']
31
+ ns_prefix, type = xml.attributes['type'].split(':')
32
+ type = ns_prefix if !type
33
+
34
+ the_module = NAMESPACE_MODULE_MAP[xml.namespace(ns_prefix)]
35
+ the_module = default_module if !the_module
36
+ else
37
+ the_module = default_module
38
+ type = default_type
39
+ end
40
+
41
+ # The name of the appropriate class corresponds to the type.
42
+ begin
43
+ eval("#{the_module}::#{type}.load_from_xml(xml)") # Would like to get rid of this eval somehow...
44
+ rescue NameError
45
+ default_class.load_from_xml(xml)
46
+ end
47
+ }
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,190 @@
1
+ require 'xml/mapping'
2
+ require 'date'
3
+ require 'time'
4
+
5
+ module VORuby
6
+ module VOResource
7
+ module Mapping
8
+
9
+ class DateTimeNode < XML::Mapping::SingleAttributeNode
10
+ def initialize_impl(path)
11
+ @path = XML::XXPath.new(path)
12
+ end
13
+
14
+ def extract_attr_value(xml)
15
+ txt = default_when_xpath_err{ @path.first(xml).text }
16
+ DateTime.parse(txt)
17
+ end
18
+
19
+ def set_attr_value(xml, value)
20
+ raise RuntimeError, "Not a date/time: #{value}" unless Time === value
21
+ @path.first(xml, :ensure_created => true).text = value.to_s
22
+ end
23
+ end
24
+
25
+ class JulianDateTimeNode < DateTimeNode
26
+ def extract_attr_value(xml)
27
+ txt = default_when_xpath_err{ @path.first(xml).text }
28
+ DateTime.jd(txt.to_i)
29
+ end
30
+ end
31
+
32
+ class UtcTimestampNode < DateTimeNode
33
+ def set_attr_value(xml, value)
34
+ raise RuntimeError, "Not a date/time: #{value}" unless Time === value
35
+ @path.first(xml, :ensure_created => true).text = value.to_s
36
+ end
37
+ end
38
+
39
+ class UtcDateTimeNode < DateTimeNode
40
+ def set_attr_value(xml, value)
41
+ raise RuntimeError, "Not a date/time: #{value}" unless Time === value
42
+ @path.first(xml, :ensure_created => true).text = value.getutc.xmlschema
43
+ end
44
+ end
45
+
46
+ module Misc
47
+ def raise_error(value)
48
+ raise RuntimeError, "Not a valid choice: #{value}. Choose one of: #{@options[:choices].join(', ')}"
49
+ end
50
+ end
51
+
52
+ class TextEnumerationNode < XML::Mapping::TextNode
53
+ include Misc
54
+
55
+ def extract_attr_value(xml)
56
+ txt = default_when_xpath_err{ @path.first(xml).text }
57
+ self.raise_error("#{txt} in #{xml.parent}") if !@options[:choices].include?(txt)
58
+
59
+ return txt
60
+ end
61
+
62
+ def set_attr_value(xml, value)
63
+ self.raise_error(value) unless @options[:choices].include?(value)
64
+ @path.first(xml, :ensure_created => true).text = value.to_s
65
+ end
66
+ end
67
+
68
+ class NumericEnumerationNode < XML::Mapping::NumericNode
69
+ include Misc
70
+
71
+ def extract_attr_value(xml)
72
+ txt = default_when_xpath_err{ @path.first(xml).text }
73
+
74
+ num = nil
75
+ begin
76
+ num = Integer(txt)
77
+ rescue ArgumentError
78
+ num = Float(txt)
79
+ end
80
+
81
+ self.raise_error(txt) if !@options[:choices].include?(num)
82
+
83
+ return num
84
+ end
85
+
86
+ def set_attr_value(xml, value)
87
+ raise RuntimeError, "Not an integer: #{value}" unless Numeric === value
88
+ self.raise_error(value) unless @options[:choices].include?(value)
89
+ @path.first(xml,:ensure_created=>true).text = value.to_s
90
+ end
91
+ end
92
+
93
+ # This is a copy of ObjectNode, but using REXML's full XPath
94
+ # implementation (i.e. not pre-compiling expressions). It's
95
+ # potentially slower but necessary for some schema.
96
+ class FullObjectNode < XML::Mapping::SubObjectBaseNode
97
+ # Initializer. _path_ (a string denoting an XPath expression) is
98
+ # the location of the subtree.
99
+ def initialize_impl(path)
100
+ super
101
+ @path_str = path
102
+ end
103
+
104
+ def extract_attr_value(xml) # :nodoc:
105
+ paths = []
106
+ @path_str.split(/\s*\|\s*/).each{ |path|
107
+ paths << path
108
+ xml.prefixes.each{ |prefix|
109
+ paths << "#{prefix}:#{path}"
110
+ }
111
+ }
112
+ xpath = paths.join('|')
113
+
114
+ result = default_when_xpath_err{REXML::XPath.first(xml, xpath)}
115
+ result ? @options[:unmarshaller].call(result): nil
116
+ end
117
+
118
+ def set_attr_value(xml, value) # :nodoc:
119
+ @options[:marshaller].call(@path.first(xml,:ensure_created=>true), value)
120
+ end
121
+ end
122
+
123
+ class FullArrayNode < XML::Mapping::SubObjectBaseNode
124
+ # Initializer, delegates to do_initialize. Called with keyword
125
+ # arguments and either 1 or 2 paths; the hindmost path argument
126
+ # passed is delegated to _per_arrelement_path_; the preceding
127
+ # path argument (if present, "" by default) is delegated to
128
+ # _base_path_.
129
+ def initialize_impl(path,path2=nil)
130
+ super
131
+ if path2
132
+ do_initialize(path,path2)
133
+ else
134
+ do_initialize("",path)
135
+ end
136
+ end
137
+
138
+ # "Real" initializer.
139
+ def do_initialize(base_path, per_arrelement_path)
140
+ @base_path = base_path
141
+ @per_arrelement_path = per_arrelement_path
142
+ end
143
+
144
+ def extract_attr_value(xml) # :nodoc:
145
+ paths = []
146
+ @per_arrelement_path.split(/\s*\|\s*/).each{ |path|
147
+ paths << path
148
+ xml.prefixes.each{ |prefix|
149
+ paths << "#{prefix}:#{path}"
150
+ }
151
+ }
152
+ xpath = @base_path + '(' + paths.join('|') + ')'
153
+
154
+ result = []
155
+ default_when_xpath_err{REXML::XPath.match(xml, xpath)}.each do |elt|
156
+ result << @options[:unmarshaller].call(elt)
157
+ end
158
+
159
+ result
160
+ end
161
+
162
+ def set_attr_value(xml, value) # :nodoc:
163
+ base_elt = @base_path.first(xml,:ensure_created=>true)
164
+ value.each do |arr_elt|
165
+ @options[:marshaller].call(@per_arrelement_path.create_new(base_elt), arr_elt)
166
+ end
167
+ end
168
+ end
169
+
170
+ class TextFloatArrayNode < XML::Mapping::TextNode
171
+ def extract_attr_value(xml)
172
+ txt = default_when_xpath_err{ @path.first(xml).text }
173
+
174
+ nums = []
175
+ txt.split(/\s+/).each do |str|
176
+ nums << str.to_f
177
+ end
178
+
179
+ return nums
180
+ end
181
+
182
+ def set_attr_value(xml, value)
183
+ raise RuntimeError, "Not an array: #{value}" unless Array === value
184
+ @path.first(xml, :ensure_created=>true).text = value.join(' ')
185
+ end
186
+ end
187
+
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'xml/mapping'
3
+
4
+ require 'voruby/loader'
@@ -0,0 +1,9 @@
1
+ require 'voruby/resources/openskynode/openskynode_v0_1'
2
+
3
+ module VORuby
4
+ module Resources
5
+ module OpenSkyNode
6
+ #include OpenSkyNode::V0_1
7
+ end
8
+ end
9
+ end