voruby 1.1.1 → 2.0.0

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 (257) hide show
  1. data/Rakefile.rb +107 -224
  2. data/lib/misc.rb +1 -0
  3. data/lib/misc/misc.rb +60 -0
  4. data/lib/misc/propertyfile.rb +31 -0
  5. data/lib/symphony.rb +1 -0
  6. data/lib/symphony/symphony.rb +247 -0
  7. data/lib/voruby.rb +186 -0
  8. data/lib/voruby/active_votable/active_votable.rb +468 -347
  9. data/lib/voruby/adql/1.0/adql.rb +2418 -0
  10. data/lib/voruby/adql/support.rb +2 -0
  11. data/lib/voruby/misc.rb +351 -0
  12. data/lib/voruby/misc/connection_monitor.rb +97 -0
  13. data/lib/voruby/misc/libxml_ext.rb +121 -0
  14. data/lib/voruby/misc/rexml_ext.rb +223 -0
  15. data/lib/voruby/resolver/resolver.rb +12 -0
  16. data/lib/voruby/resolver/sesame.rb +299 -0
  17. data/lib/voruby/sky_query/sky_query.rb +192 -0
  18. data/lib/voruby/stc/1.10/coords.rb +2272 -0
  19. data/lib/voruby/stc/1.10/region.rb +892 -0
  20. data/lib/voruby/stc/1.10/stc.rb +3271 -0
  21. data/lib/voruby/stc/1.30/stc.rb +8666 -0
  22. data/lib/voruby/stc/support.rb +2 -0
  23. data/lib/voruby/ucd/ucd.rb +173 -0
  24. data/lib/voruby/voevent/1.1/voevent.rb +1124 -0
  25. data/lib/voruby/voevent/support.rb +5 -0
  26. data/lib/voruby/votable/1.0/votable.rb +1807 -0
  27. data/lib/voruby/votable/1.1/votable.rb +2100 -0
  28. data/lib/voruby/votable/votable.rb +305 -0
  29. data/lib/voruby/wesix/wesix.rb +491 -0
  30. data/lib/voruby/xlink/1.2/xlink.rb +21 -0
  31. data/test/voruby/active_votable/complex.vot +60 -0
  32. data/test/voruby/active_votable/error.vot +6 -0
  33. data/test/voruby/active_votable/large.vot +130040 -0
  34. data/test/voruby/active_votable/simple1.vot +38 -0
  35. data/test/voruby/active_votable/simple2.vot +38 -0
  36. data/test/voruby/active_votable/test.rb +193 -0
  37. data/test/voruby/adql/1.0/adql-alias.sql +1 -0
  38. data/test/voruby/adql/1.0/adql-alias.xml +26 -0
  39. data/test/voruby/adql/1.0/adql-avg.sql +1 -0
  40. data/test/voruby/adql/1.0/adql-avg.xml +31 -0
  41. data/test/voruby/adql/1.0/adql-circle.sql +1 -0
  42. data/test/voruby/adql/1.0/adql-circle.xml +46 -0
  43. data/test/voruby/adql/1.0/adql-expr.sql +1 -0
  44. data/test/voruby/adql/1.0/adql-expr.xml +34 -0
  45. data/test/voruby/adql/1.0/adql-function.sql +1 -0
  46. data/test/voruby/adql/1.0/adql-function.xml +41 -0
  47. data/test/voruby/adql/1.0/adql-group.sql +1 -0
  48. data/test/voruby/adql/1.0/adql-group.xml +51 -0
  49. data/test/voruby/adql/1.0/adql-having.sql +1 -0
  50. data/test/voruby/adql/1.0/adql-having.xml +25 -0
  51. data/test/voruby/adql/1.0/adql-like.sql +1 -0
  52. data/test/voruby/adql/1.0/adql-like.xml +17 -0
  53. data/test/voruby/adql/1.0/adql-order.sql +1 -0
  54. data/test/voruby/adql/1.0/adql-order.xml +37 -0
  55. data/test/voruby/adql/1.0/adql-simple.sql +1 -0
  56. data/test/voruby/adql/1.0/adql-simple.xml +12 -0
  57. data/test/voruby/adql/1.0/adql-top.sql +1 -0
  58. data/test/voruby/adql/1.0/adql-top.xml +33 -0
  59. data/test/voruby/adql/1.0/test.rb +2220 -0
  60. data/test/voruby/misc/test.rb +32 -0
  61. data/test/voruby/resolver/sesame/test.rb +56 -0
  62. data/test/voruby/sky_query/test.rb +107 -0
  63. data/test/voruby/stc/1.10/coords_test.rb +3704 -0
  64. data/test/voruby/stc/1.10/region_test.rb +993 -0
  65. data/test/voruby/stc/1.10/stc-catalog-entry-location.xml +112 -0
  66. data/test/voruby/stc/1.10/stc-obs-data-location.xml +126 -0
  67. data/test/voruby/stc/1.10/stc-region-circle.xml +5 -0
  68. data/test/voruby/stc/1.10/stc-region-convex.xml +11 -0
  69. data/test/voruby/stc/1.10/stc-region-convexhull.xml +5 -0
  70. data/test/voruby/stc/1.10/stc-region-ellipse.xml +7 -0
  71. data/test/voruby/stc/1.10/stc-region-intersection.xml +25 -0
  72. data/test/voruby/stc/1.10/stc-region-negation.xml +7 -0
  73. data/test/voruby/stc/1.10/stc-region-polygon.xml +13 -0
  74. data/test/voruby/stc/1.10/stc-region-sector.xml +6 -0
  75. data/test/voruby/stc/1.10/stc-region-union.xml +25 -0
  76. data/test/voruby/stc/1.10/stc-resource-profile.xml +60 -0
  77. data/test/voruby/stc/1.10/stc-search-location.xml +54 -0
  78. data/test/voruby/stc/1.10/stc_test.rb +4626 -0
  79. data/test/voruby/stc/1.30/stc-catalog-entry-location.xml +210 -0
  80. data/test/voruby/stc/1.30/stc-obs-data-location-arecibo.xml +353 -0
  81. data/test/voruby/stc/1.30/stc-obs-data-location-fits.xml +250 -0
  82. data/test/voruby/stc/1.30/stc-obs-data-location-xlink.xml +63 -0
  83. data/test/voruby/stc/1.30/stc-obs-data-location.xml +216 -0
  84. data/test/voruby/stc/1.30/stc-resource-profile-unusual-ref-pos.xml +39 -0
  85. data/test/voruby/stc/1.30/stc-resource-profile.xml +129 -0
  86. data/test/voruby/stc/1.30/stc-search-location-arecibo.xml +86 -0
  87. data/test/voruby/stc/1.30/stc-search-location.xml +101 -0
  88. data/test/voruby/stc/1.30/test.rb +6274 -0
  89. data/test/voruby/ucd/test.rb +48 -0
  90. data/test/voruby/voevent/1.1/test.rb +812 -0
  91. data/test/{voevent/voevent_v1_1.xml → voruby/voevent/1.1/voevent.xml} +2 -2
  92. data/test/voruby/voregistry/0.3/test.rb +137 -0
  93. data/test/voruby/votable/1.0/test.rb +714 -0
  94. data/test/voruby/votable/1.0/votable.basic.xml +660 -0
  95. data/test/voruby/votable/1.0/votable.html +86 -0
  96. data/test/voruby/votable/1.0/votable.ns.xml +56 -0
  97. data/test/voruby/votable/1.1/test.rb +785 -0
  98. data/test/voruby/votable/1.1/votable.basic.xml +38 -0
  99. data/test/voruby/votable/1.1/votable.html +86 -0
  100. data/test/voruby/votable/1.1/votable.ns.xml +56 -0
  101. data/test/voruby/votable/test.rb +15 -0
  102. data/test/voruby/wesix/test.rb +268 -0
  103. data/test/voruby/wesix/testr.fits +28 -0
  104. metadata +234 -247
  105. data/REQUIREMENTS +0 -6
  106. data/lib/voruby/active_votable/loader.rb +0 -5
  107. data/lib/voruby/adql/adql.rb +0 -2787
  108. data/lib/voruby/adql/ext.rb +0 -14
  109. data/lib/voruby/adql/loader.rb +0 -6
  110. data/lib/voruby/adql/operations.rb +0 -54
  111. data/lib/voruby/adql/parser.rb +0 -160
  112. data/lib/voruby/adql/transforms.rb +0 -573
  113. data/lib/voruby/ext.rb +0 -17
  114. data/lib/voruby/loader.rb +0 -4
  115. data/lib/voruby/misc/propertyfile.rb +0 -36
  116. data/lib/voruby/plastic/applications.rb +0 -174
  117. data/lib/voruby/plastic/constants.rb +0 -30
  118. data/lib/voruby/plastic/loader.rb +0 -10
  119. data/lib/voruby/plastic/plastic.rb +0 -1
  120. data/lib/voruby/resources/conesearch/conesearch.rb +0 -9
  121. data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +0 -55
  122. data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +0 -50
  123. data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +0 -72
  124. data/lib/voruby/resources/conesearch/loader.rb +0 -4
  125. data/lib/voruby/resources/loader.rb +0 -50
  126. data/lib/voruby/resources/nodes.rb +0 -190
  127. data/lib/voruby/resources/openskynode/loader.rb +0 -4
  128. data/lib/voruby/resources/openskynode/openskynode.rb +0 -9
  129. data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +0 -54
  130. data/lib/voruby/resources/sia/loader.rb +0 -5
  131. data/lib/voruby/resources/sia/sia.rb +0 -9
  132. data/lib/voruby/resources/sia/sia_v0_6.rb +0 -90
  133. data/lib/voruby/resources/sia/sia_v0_7.rb +0 -89
  134. data/lib/voruby/resources/sia/sia_v1_0.rb +0 -122
  135. data/lib/voruby/resources/stsci.rb +0 -59
  136. data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +0 -195
  137. data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +0 -158
  138. data/lib/voruby/resources/vodataservice/loader.rb +0 -5
  139. data/lib/voruby/resources/vodataservice/vodataservice.rb +0 -9
  140. data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +0 -189
  141. data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +0 -163
  142. data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +0 -221
  143. data/lib/voruby/resources/voregistry/loader.rb +0 -4
  144. data/lib/voruby/resources/voregistry/voregistry.rb +0 -9
  145. data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +0 -40
  146. data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +0 -30
  147. data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +0 -86
  148. data/lib/voruby/resources/voresource/loader.rb +0 -17
  149. data/lib/voruby/resources/voresource/voresource.rb +0 -9
  150. data/lib/voruby/resources/voresource/voresource_v0_10.rb +0 -327
  151. data/lib/voruby/resources/voresource/voresource_v0_9.rb +0 -405
  152. data/lib/voruby/resources/voresource/voresource_v1_0.rb +0 -230
  153. data/lib/voruby/services/ext.rb +0 -11
  154. data/lib/voruby/services/gestalt/footprint.rb +0 -95
  155. data/lib/voruby/services/gestalt/wcs_fixer.rb +0 -105
  156. data/lib/voruby/services/gestalt/wesix.rb +0 -155
  157. data/lib/voruby/services/loader.rb +0 -7
  158. data/lib/voruby/services/registry/registry.rb +0 -53
  159. data/lib/voruby/services/resolver/resolver.rb +0 -35
  160. data/lib/voruby/services/schema/schema.rb +0 -644
  161. data/lib/voruby/sesame/loader.rb +0 -6
  162. data/lib/voruby/sesame/sesame_v1_0.rb +0 -64
  163. data/lib/voruby/simple/loader.rb +0 -6
  164. data/lib/voruby/simple/parameters.rb +0 -196
  165. data/lib/voruby/simple/sap.rb +0 -446
  166. data/lib/voruby/spacetime/loader.rb +0 -3
  167. data/lib/voruby/spacetime/spacetime.rb +0 -607
  168. data/lib/voruby/stc/coords_v1_20.rb +0 -900
  169. data/lib/voruby/stc/loader.rb +0 -55
  170. data/lib/voruby/stc/region_v1_20.rb +0 -274
  171. data/lib/voruby/stc/stc_v1_20.rb +0 -1196
  172. data/lib/voruby/util.rb +0 -27
  173. data/lib/voruby/voevent/loader.rb +0 -7
  174. data/lib/voruby/voevent/voevent_v1_0.rb +0 -213
  175. data/lib/voruby/voevent/voevent_v1_1.rb +0 -196
  176. data/lib/voruby/votables/chandra.rb +0 -373
  177. data/lib/voruby/votables/data.rb +0 -179
  178. data/lib/voruby/votables/galex.rb +0 -377
  179. data/lib/voruby/votables/int.rb +0 -354
  180. data/lib/voruby/votables/libxml_parser.rb +0 -411
  181. data/lib/voruby/votables/libxml_votable.rb +0 -67
  182. data/lib/voruby/votables/loader.rb +0 -10
  183. data/lib/voruby/votables/meta.rb +0 -763
  184. data/lib/voruby/votables/misc.rb +0 -51
  185. data/lib/voruby/votables/nsa.rb +0 -410
  186. data/lib/voruby/votables/rexml_parser.rb +0 -408
  187. data/lib/voruby/votables/rexml_votable.rb +0 -67
  188. data/lib/voruby/votables/sdss.rb +0 -356
  189. data/lib/voruby/votables/transforms.rb +0 -388
  190. data/lib/voruby/votables/tree.rb +0 -45
  191. data/lib/voruby/votables/types.rb +0 -391
  192. data/lib/voruby/votables/votable.rb +0 -687
  193. data/test/active_votable/database.yml +0 -6
  194. data/test/active_votable/test.vot +0 -168492
  195. data/test/active_votable/unittest.rb +0 -41
  196. data/test/adql/test1.adql +0 -49
  197. data/test/adql/test2.adql +0 -51
  198. data/test/adql/test3.adql +0 -81
  199. data/test/adql/test4.adql +0 -53
  200. data/test/adql/test5.adql +0 -55
  201. data/test/adql/test6.adql +0 -18
  202. data/test/adql/test7.adql +0 -48
  203. data/test/adql/unittest.rb +0 -1672
  204. data/test/plastic/test.rb +0 -44
  205. data/test/plastic/test.vot +0 -5385
  206. data/test/plastic/unittest.rb +0 -66
  207. data/test/resources/conesearch/conesearch_v0_3.xml +0 -31
  208. data/test/resources/conesearch/conesearch_v1_0.xml +0 -86
  209. data/test/resources/conesearch/unittest_v0_3.rb +0 -22
  210. data/test/resources/conesearch/unittest_v1_0.rb +0 -24
  211. data/test/resources/openskynode/open_sky_node_v0_1.xml +0 -32
  212. data/test/resources/openskynode/unittest_v0_1.rb +0 -31
  213. data/test/resources/sia/simple_image_access_v0_7.xml +0 -36
  214. data/test/resources/sia/simple_image_access_v1_0.xml +0 -122
  215. data/test/resources/sia/unittest_v0_7.rb +0 -24
  216. data/test/resources/sia/unittest_v1_0.rb +0 -29
  217. data/test/resources/stsci.xml +0 -336
  218. data/test/resources/unittest_stsci.rb +0 -25
  219. data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +0 -128
  220. data/test/resources/vodataservice/data_collection_resource_v0_5.xml +0 -54
  221. data/test/resources/vodataservice/data_collection_resource_v1_0.xml +0 -117
  222. data/test/resources/vodataservice/data_service_resource_v1_0.xml +0 -115
  223. data/test/resources/vodataservice/sky_service_resource_v0_10.xml +0 -45
  224. data/test/resources/vodataservice/table_service_resource_v1_0.xml +0 -122
  225. data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +0 -60
  226. data/test/resources/vodataservice/unittest_v0_5.rb +0 -126
  227. data/test/resources/vodataservice/unittest_v1_0.rb +0 -151
  228. data/test/resources/voregistry/authority_resource_v0_3.xml +0 -20
  229. data/test/resources/voregistry/authority_resource_v1_0.xml +0 -82
  230. data/test/resources/voregistry/registry_service_v0_3.xml +0 -20
  231. data/test/resources/voregistry/registry_service_v1_0.xml +0 -107
  232. data/test/resources/voregistry/unittest_v0_3.rb +0 -31
  233. data/test/resources/voregistry/unittest_v1_0.rb +0 -34
  234. data/test/resources/voresource/organisation_resource_v1_0.xml +0 -90
  235. data/test/resources/voresource/resource_organisation_v0_10.xml +0 -22
  236. data/test/resources/voresource/resource_service_v0_10.xml +0 -19
  237. data/test/resources/voresource/resource_v0_10.xml +0 -19
  238. data/test/resources/voresource/resource_v1_0.xml +0 -79
  239. data/test/resources/voresource/service_resource_v1_0.xml +0 -91
  240. data/test/resources/voresource/unittest_v0_10.rb +0 -61
  241. data/test/resources/voresource/unittest_v0_9.rb +0 -4
  242. data/test/resources/voresource/unittest_v1_0.rb +0 -190
  243. data/test/services/gestalt/unittest.rb +0 -74
  244. data/test/services/registry/unittest.rb +0 -34
  245. data/test/services/resolver/unittest.rb +0 -38
  246. data/test/simple/unittest.rb +0 -46
  247. data/test/spacetime/unittest.rb +0 -39
  248. data/test/stc/catalog_entry_location_v1_20.xml +0 -112
  249. data/test/stc/obs_data_location_v1_20.xml +0 -108
  250. data/test/stc/search_location_v1_20.xml +0 -54
  251. data/test/stc/stc_resource_profile_v1_20.xml +0 -60
  252. data/test/stc/unittest_v1_20.rb +0 -620
  253. data/test/voevent/unittest_v1_0.rb +0 -79
  254. data/test/voevent/unittest_v1_1.rb +0 -70
  255. data/test/voevent/voevent_v1_0.xml +0 -96
  256. data/test/votables/test.vot +0 -366
  257. data/test/votables/unittest.rb +0 -54
@@ -5,8 +5,8 @@
5
5
  version="1.1"
6
6
  xmlns:voe="http://www.ivoa.net/xml/VOEvent/v1.1"
7
7
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8
- xsi:schemaLocation="http://www.ivoa.net/xml/VOEvent/v1.1
9
- http://www.ivoa.net/xml/VOEvent/VOEvent-v1.1.xsd">
8
+ xmlns="http://www.ivoa.net/xml/VOEvent/v1.1"
9
+ xsi:schemaLocation="http://www.ivoa.net/xml/VOEvent/v1.1 http://www.ivoa.net/xml/VOEvent/VOEvent-v1.1.xsd">
10
10
 
11
11
  <Citations>
12
12
  <EventIVORN cite="followup">ivo://raptor.lanl/VOEvent#235649408</EventIVORN>
@@ -0,0 +1,137 @@
1
+ require 'voruby/voregistry/0.3/voregistry'
2
+ require 'test/unit'
3
+
4
+ include VORuby::VORegistry::V0_3
5
+
6
+ module VORuby
7
+ module VORegistry
8
+ module V0_3
9
+ module Test
10
+
11
+ class RegistryTest < ::Test::Unit::TestCase
12
+ def setup
13
+ @title = 'A great resource'
14
+ @identifier = IdentifierURI.new('ivo://resources.noao.edu/1123')
15
+ @curation = Curation.new(
16
+ ResourceName.new('NOAO'),
17
+ Contact.new('David Gasson'),
18
+ Creator.new('John Q. Observer'),
19
+ [ResourceName.new('WIYN'), ResourceName.new('Subaru')],
20
+ [VOResource::V0_10::Date.new('2008-01-01'), VOResource::V0_10::Date.new('2008-02-03')],
21
+ '1.0'
22
+ )
23
+ @content = Content.new(
24
+ 'My content',
25
+ URI.parse('http://www.noao.edu/'),
26
+ ['subject 1', 'subject 2'],
27
+ Source.new('1994A&AS..103..135A'),
28
+ [Type.new('Archive'), Type.new('Catalog')],
29
+ [ContentLevel.new('University'), ContentLevel.new('Research')],
30
+ [Relationship.new('related-to', [ResourceName.new('resource1'), ResourceName.new('resource2')])]
31
+ )
32
+ @interfaces = [
33
+ WebBrowser.new('http://www.noao.edu/interface1'),
34
+ WebBrowser.new('http://www.noao.edu/interface2')
35
+ ]
36
+ @managed_authorities = [
37
+ AuthorityID.new('NOAO'),
38
+ AuthorityID.new('STScI')
39
+ ]
40
+ end
41
+
42
+ def test_construction
43
+ assert_nothing_raised {
44
+ Registry.new(@title, @identifier, @curation, @content, @interfaces, @managed_authorities)
45
+ Registry.new(@title, @identifier, @curation, @content, @interfaces)
46
+ }
47
+
48
+ assert_raises TypeError do
49
+ Registry.new(@title, @identifier, @curation, @content, @interfaces, 'blah')
50
+ end
51
+ end
52
+
53
+ def test_relationships
54
+ assert_kind_of Service, Registry.new(@title, @identifier, @curation, @content, @interfaces, @managed_authorities)
55
+ end
56
+
57
+ def test_accessors
58
+ r = Registry.new(@title, @identifier, @curation, @content, @interfaces, @managed_authorities)
59
+
60
+ assert_equal @title, r.title
61
+ assert_equal @identifier, r.identifier
62
+ assert_equal @curation, r.curation
63
+ assert_equal @content, r.content
64
+ assert_equal @interfaces, r.interfaces
65
+ assert_equal @managed_authorities, r.managed_authorities
66
+ end
67
+
68
+ def test_xml
69
+ r1 = Registry.new(@title, @identifier, @curation, @content, @interfaces, @managed_authorities)
70
+ r2 = Registry.from_xml(r1.to_xml)
71
+ assert_equal r1, r2
72
+ end
73
+ end
74
+
75
+ class AuthorityTest < ::Test::Unit::TestCase
76
+ def setup
77
+ @title = 'A great resource'
78
+ @identifier = IdentifierURI.new('ivo://resources.noao.edu/1123')
79
+ @curation = Curation.new(
80
+ ResourceName.new('NOAO'),
81
+ Contact.new('David Gasson'),
82
+ Creator.new('John Q. Observer'),
83
+ [ResourceName.new('WIYN'), ResourceName.new('Subaru')],
84
+ [VOResource::V0_10::Date.new('2008-01-01'), VOResource::V0_10::Date.new('2008-02-03')],
85
+ '1.0'
86
+ )
87
+ @content = Content.new(
88
+ 'My content',
89
+ URI.parse('http://www.noao.edu/'),
90
+ ['subject 1', 'subject 2'],
91
+ Source.new('1994A&AS..103..135A'),
92
+ [Type.new('Archive'), Type.new('Catalog')],
93
+ [ContentLevel.new('University'), ContentLevel.new('Research')],
94
+ [Relationship.new('related-to', [ResourceName.new('resource1'), ResourceName.new('resource2')])]
95
+ )
96
+ @managing_orgs = [
97
+ ResourceName.new('MyResource1'),
98
+ ResourceName.new('MyResource2')
99
+ ]
100
+ end
101
+
102
+ def test_construction
103
+ assert_nothing_raised {
104
+ Authority.new(@title, @identifier, @curation, @content, @managing_orgs)
105
+ Authority.new(@title, @identifier, @curation, @content)
106
+ }
107
+
108
+ assert_raises TypeError do
109
+ Authority.new(@title, @identifier, @curation, @content, 'blah')
110
+ end
111
+ end
112
+
113
+ def test_accessors
114
+ a = Authority.new(@title, @identifier, @curation, @content, @managing_orgs)
115
+
116
+ assert_equal @title, a.title
117
+ assert_equal @identifier, a.identifier
118
+ assert_equal @curation, a.curation
119
+ assert_equal @content, a.content
120
+ assert_equal @managing_orgs, a.managing_orgs
121
+ end
122
+
123
+ def test_relationships
124
+ assert_kind_of Resource, Authority.new(@title, @identifier, @curation, @content, @managing_orgs)
125
+ end
126
+
127
+ def test_xml
128
+ a1 = Authority.new(@title, @identifier, @curation, @content, @managing_orgs)
129
+ a2 = Authority.from_xml(a1.to_xml)
130
+ assert_equal a1, a2
131
+ end
132
+ end
133
+
134
+ end
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,714 @@
1
+ require 'voruby/votable/1.0/votable'
2
+ require 'test/unit'
3
+
4
+ include VORuby::VOTable::V1_0
5
+
6
+ module VORuby
7
+ module VOTable
8
+ module V1_0
9
+ module Test
10
+
11
+ module Methods
12
+ def test_construction
13
+ obj = self.class_to_test.new(self.inputs)
14
+ outputs = self.respond_to?(:expected_outputs) ? self.expected_outputs : self.inputs
15
+
16
+ outputs.each do |name, value|
17
+ result = obj.send(name)
18
+ assert_equal result, outputs[name]
19
+ end
20
+ end
21
+
22
+ def test_accessors
23
+ obj = self.class_to_test.new
24
+ outputs = self.respond_to?(:expected_outputs) ? self.expected_outputs : self.inputs
25
+
26
+ if self.inputs.is_a?(Hash)
27
+ self.inputs.each do |name, value|
28
+ obj.send("#{name}=", value)
29
+ assert_equal obj.send(name), outputs[name]
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ class VOTableTest < ::Test::Unit::TestCase
36
+ include Methods
37
+
38
+ def class_to_test; VOTable end
39
+
40
+ def inputs
41
+ {
42
+ :version => '1.0',
43
+ :id => 'my_test_votable',
44
+ :description => Description.new,
45
+ :definitions => Definitions.new,
46
+ :infos => [Info.new],
47
+ :resources => [Resource.new]
48
+ }
49
+ end
50
+
51
+ def test_to_html
52
+ votable = VOTable.new(
53
+ :version => '1.0',
54
+ :coordinate_systems => [
55
+ Coosys.new(:id => 'J2000', :equinox => 'J2000.', :epoch => 'J2000.', :system => 'eq_FK5')
56
+ ],
57
+ :resources => [
58
+ Resource.new(
59
+ :name => 'myFavouriteGalaxies',
60
+ :tables => [
61
+ Table.new(
62
+ :name => 'results',
63
+ :description => Description.new(:text => 'Velocities and Distance estimations'),
64
+ :params => [
65
+ Param.new(
66
+ :name => 'Telescope',
67
+ :datatype => 'float',
68
+ :ucd => 'phys.size;instr.tel',
69
+ :unit => 'm',
70
+ :value => '3.6'
71
+ )
72
+ ],
73
+ :fields => [
74
+ Field.new(:name => 'RA', :id => 'col1', :ucd => 'pos.eq.ra;meta.main',
75
+ :ref => 'J2000', :datatype => 'float', :width => 6, :precision => '2', :unit => 'deg'),
76
+ Field.new(:name => 'Dec', :id => 'col2', :ucd => 'pos.eq.dec;meta.main',
77
+ :ref => 'J2000', :datatype => 'float', :width => 6, :precision => '2', :unit => 'deg'),
78
+ Field.new(:name => 'Name', :id => 'col3', :ucd => 'meta.id;meta.main',
79
+ :datatype => 'char', :arraysize => '8*'),
80
+ Field.new(:name => 'RVel', :id => 'col4', :ucd => 'src.veloc.hc', :datatype => 'int',
81
+ :width => 5, :unit => 'km/s'),
82
+ Field.new(:name => 'e_RVel', :id => 'col5', :ucd => 'stat.error;src.veloc.hc',
83
+ :datatype => 'int', :width => 3, :unit => 'km/s'),
84
+ Field.new(:name => 'R', :id => 'col6', :ucd => 'phys.distance', :datatype => 'float',
85
+ :width => 4, :precision => '1', :unit => 'Mpc',
86
+ :description => Description.new(:text => 'Distance of Galaxy, assuming H=75km/s/Mpc'))
87
+ ],
88
+ :data => Data.new(
89
+ :format => TableData.new(
90
+ :trs => [
91
+ Tr.new(:tds => [
92
+ Td.new(:text => '010.68'), Td.new(:text => '+41.27'), Td.new(:text => 'N 224'),
93
+ Td.new(:text => '-297'), Td.new(:text => '5'), Td.new(:text => '0.7')
94
+ ]),
95
+ Tr.new(:tds => [
96
+ Td.new(:text => '287.43'), Td.new(:text => '-63.85'), Td.new(:text => 'N 6744'),
97
+ Td.new(:text => '839'), Td.new(:text => '6'), Td.new(:text => '10.4')
98
+ ]),
99
+ Tr.new(:tds => [
100
+ Td.new(:text => '023.48'), Td.new(:text => '+30.66'), Td.new(:text => 'N 598'),
101
+ Td.new(:text => '-182'), Td.new(:text => '3'), Td.new(:text => '0.7')
102
+ ])
103
+ ]
104
+ )
105
+ )
106
+ )
107
+ ]
108
+ )
109
+ ]
110
+ )
111
+
112
+ assert_equal(
113
+ File.read('test/voruby/votable/1.0/votable.html').strip.gsub(/\n+\s*/, ''),
114
+ votable.to_html.strip.gsub(/\n+\s*/, '')
115
+ )
116
+ end
117
+ end
118
+
119
+ class DescriptionTest < ::Test::Unit::TestCase
120
+ include Methods
121
+
122
+ def class_to_test; Description end
123
+
124
+ def inputs; {:text => 'A description'} end
125
+ end
126
+
127
+ class DefinitionsTest < ::Test::Unit::TestCase
128
+ include Methods
129
+
130
+ def class_to_test; Definitions end
131
+
132
+ def inputs
133
+ {
134
+ :coordinate_systems => [Coosys.new],
135
+ :params => [Param.new]
136
+ }
137
+ end
138
+ end
139
+
140
+ class CoosysTest < ::Test::Unit::TestCase
141
+ include Methods
142
+
143
+ def class_to_test; Coosys end
144
+
145
+ def inputs
146
+ {:id => 'my_coosys', :equinox => 'J2000', :epoch => 'B1950', :system => 'supergalactic'}
147
+ end
148
+ end
149
+
150
+ class ParamTest < ::Test::Unit::TestCase
151
+ include Methods
152
+
153
+ def class_to_test; Param end
154
+
155
+ def inputs
156
+ {
157
+ :id => 'my_param_test',
158
+ :unit => 'm/s',
159
+ :datatype => 'float',
160
+ :arraysize => '*',
161
+ :precision => '3',
162
+ :width => 6,
163
+ :ref => 'refer_to_1',
164
+ :name => 'My param test',
165
+ :ucd => 'phys.velocity',
166
+ :value => '123.456',
167
+ :description => Description.new,
168
+ :values => Values.new,
169
+ :links => [Link.new]
170
+ }
171
+ end
172
+
173
+ def test_casting
174
+ param = Param.new(:datatype => 'float', :arraysize => '*')
175
+ param.value = [123.4, 21.5]
176
+ assert_equal [123.4, 21.5], param.value(true)
177
+ end
178
+ end
179
+
180
+ class InfoTest < ::Test::Unit::TestCase
181
+ include Methods
182
+
183
+ def class_to_test; Info end
184
+
185
+ def inputs
186
+ {:id => 'my_info', :name => 'info_lite', :value => '123'}
187
+ end
188
+ end
189
+
190
+ class ResourceTest < ::Test::Unit::TestCase
191
+ include Methods
192
+
193
+ def class_to_test; Resource end
194
+
195
+ def inputs
196
+ {
197
+ :name => 'Test Resource',
198
+ :id => 'my_test_resource',
199
+ :type => 'a_type',
200
+ :description => Description.new,
201
+ :infos => [Info.new],
202
+ :coordinate_systems => [Coosys.new],
203
+ :params => [Param.new],
204
+ :links => [Link.new],
205
+ :tables => [Table.new],
206
+ :resources => [Resource.new]
207
+ }
208
+ end
209
+ end
210
+
211
+ class LinkTest < ::Test::Unit::TestCase
212
+ include Methods
213
+
214
+ def class_to_test; Link end
215
+
216
+ def inputs
217
+ {
218
+ :id => 'my_link', :content_role => 'hints', :content_type => 'text/html',
219
+ :title => 'link title', :value => 'this is value',
220
+ :href => 'http://www.google.com/', :gref => 'a gref',
221
+ :action => 'http://www.noao.edu/actions/mine'
222
+ }
223
+ end
224
+
225
+ def expected_outputs
226
+ self.inputs.merge({
227
+ :href => URI.parse('http://www.google.com/'),
228
+ :action => URI.parse('http://www.noao.edu/actions/mine')
229
+ })
230
+ end
231
+ end
232
+
233
+ class TableTest < ::Test::Unit::TestCase
234
+ include Methods
235
+
236
+ def class_to_test; Table end
237
+
238
+ def inputs
239
+ {
240
+ :id => 'my_table',
241
+ :name => 'My Table',
242
+ :ref => 'ref1',
243
+ :description => Description.new,
244
+ :data => Data.new(),
245
+ :fields => [Field.new],
246
+ :links => [Link.new]
247
+ }
248
+ end
249
+
250
+ def test_to_html
251
+ table = Table.new(
252
+ :id => 'table1',
253
+ :description => Description.new(:text => 'A test table'),
254
+ :fields => [
255
+ Field.new(:name => 'RA', :id => 'col1', :ucd => 'pos.eq.ra;meta.main',
256
+ :ref => 'J2000', :datatype => 'float', :width => 6, :precision => '2', :unit => 'deg'),
257
+ Field.new(:name => 'Dec', :id => 'col2', :ucd => 'pos.eq.dec;meta.main',
258
+ :ref => 'J2000', :datatype => 'float', :width => 6, :precision => '2', :unit => 'deg'),
259
+ Field.new(:name => 'Name', :id => 'col3', :ucd => 'meta.id;meta.main',
260
+ :datatype => 'char', :arraysize => '8*')
261
+ ],
262
+ :data => Data.new(
263
+ :format => TableData.new(
264
+ :trs => [
265
+ Tr.new(:tds => [Td.new(:text => '123'), Td.new(:text => '456'), Td.new(:text => 'my_obj1')]),
266
+ Tr.new(:tds => [Td.new(:text => '789'), Td.new(:text => '112'), Td.new(:text => 'my_obj2')]),
267
+ Tr.new(:tds => [Td.new(:text => '145'), Td.new(:text => '178'), Td.new(:text => 'my_obj3')])
268
+ ]
269
+ )
270
+ )
271
+ )
272
+
273
+ assert_equal(
274
+ '<table id="table1">' +
275
+ '<caption>A test table</caption>' +
276
+ '<thead>' +
277
+ '<tr>' +
278
+ '<th>' +
279
+ '<div class="field" id="col1">' +
280
+ '<div class="name">RA</div>' +
281
+ '<div class="ucd">pos.eq.ra;meta.main</div>' +
282
+ '<div class="unit">deg</div>' +
283
+ '<span class="datatype">float</span>' +
284
+ '</div>' +
285
+ '</th>' +
286
+ '<th>' +
287
+ '<div class="field" id="col2">' +
288
+ '<div class="name">Dec</div>' +
289
+ '<div class="ucd">pos.eq.dec;meta.main</div>' +
290
+ '<div class="unit">deg</div>' +
291
+ '<span class="datatype">float</span>' +
292
+ '</div>' +
293
+ '</th>' +
294
+ '<th>' +
295
+ '<div class="field" id="col3">' +
296
+ '<div class="name">Name</div>' +
297
+ '<div class="ucd">meta.id;meta.main</div>' +
298
+ '<span class="datatype">char</span>' +
299
+ '<span class="arraysize">8*</span>' +
300
+ '</div>' +
301
+ '</th>' +
302
+ '</tr>' +
303
+ '</thead>' +
304
+ '<tbody>' +
305
+ '<tr>' +
306
+ '<td>123</td>' +
307
+ '<td>456</td>' +
308
+ '<td>my_obj1</td>' +
309
+ '</tr>' +
310
+ '<tr>' +
311
+ '<td>789</td>' +
312
+ '<td>112</td>' +
313
+ '<td>my_obj2</td>' +
314
+ '</tr>' +
315
+ '<tr>' +
316
+ '<td>145</td>' +
317
+ '<td>178</td>' +
318
+ '<td>my_obj3</td>' +
319
+ '</tr>' +
320
+ '</tbody>' +
321
+ '</table>',
322
+ table.to_html.strip.gsub(/\n+\s*/, '')
323
+ )
324
+ end
325
+ end
326
+
327
+ class FieldTest < ::Test::Unit::TestCase
328
+ include Methods
329
+
330
+ def class_to_test; Field end
331
+
332
+ def inputs
333
+ {
334
+ :id => 'my_field',
335
+ :unit => 'm/s',
336
+ :datatype => 'float',
337
+ :precision => '3',
338
+ :width => '6',
339
+ :precision => '3',
340
+ :ref => 'my_ref',
341
+ :name => 'Velocity',
342
+ :ucd => 'phys.velocity',
343
+ :arraysize => '*',
344
+ :type => 'a_type',
345
+ :description => Description.new,
346
+ :values => [Values.new],
347
+ :links => [Link.new]
348
+ }
349
+ end
350
+
351
+ def expected_outputs
352
+ self.inputs.merge({:width => 6})
353
+ end
354
+
355
+ def test_to_html
356
+ field = Field.new(:id => 'col1', :name => 'Name', :ucd => 'meta.id;meta.main', :datatype => 'char', :arraysize => '*')
357
+ assert_equal(
358
+ '<div class="field" id="col1">' +
359
+ '<div class="name">Name</div>' +
360
+ '<div class="ucd">meta.id;meta.main</div>' +
361
+ '<span class="datatype">char</span>' +
362
+ '<span class="arraysize">*</span>' +
363
+ '</div>',
364
+ field.to_html.strip.gsub(/\n+\s*/, '')
365
+ )
366
+ end
367
+ end
368
+
369
+ class ValuesTest < ::Test::Unit::TestCase
370
+ include Methods
371
+
372
+ def class_to_test; Values end
373
+
374
+ def inputs
375
+ {
376
+ :id => 'my_values',
377
+ :type => 'a_type',
378
+ :null => ' ',
379
+ :invalid => 'true',
380
+ :max => Max.new,
381
+ :min => Min.new,
382
+ :options => [Option.new]
383
+ }
384
+ end
385
+
386
+ def test_invalid
387
+ values = Values.new(:invalid => true)
388
+ assert_equal true, values.invalid?
389
+
390
+ values.invalid = false
391
+ assert_equal false, values.invalid?
392
+ end
393
+ end
394
+
395
+ class MinTest < ::Test::Unit::TestCase
396
+ include Methods
397
+
398
+ def class_to_test; Min end
399
+
400
+ def inputs
401
+ {:value => '10.2', :inclusive => 'no'}
402
+ end
403
+
404
+ def test_inclusive
405
+ min = Min.new(self.inputs)
406
+ assert_equal false, min.inclusive?
407
+ end
408
+
409
+ def test_alternate_inclusives
410
+ min = Min.new(:inclusive => false)
411
+ assert_equal 'no', min.inclusive
412
+ min.inclusive = true
413
+ assert_equal 'yes', min.inclusive
414
+ end
415
+ end
416
+
417
+ class MaxTest < ::Test::Unit::TestCase
418
+ include Methods
419
+
420
+ def class_to_test; Max end
421
+
422
+ def inputs
423
+ {:value => '10.2', :inclusive => 'yes'}
424
+ end
425
+
426
+ def test_inclusive
427
+ max = Max.new(self.inputs)
428
+ assert_equal true, max.inclusive?
429
+ end
430
+
431
+ def test_alternate_inclusives
432
+ max = Max.new(:inclusive => false)
433
+ assert_equal 'no', max.inclusive
434
+ max.inclusive = true
435
+ assert_equal 'yes', max.inclusive
436
+ end
437
+ end
438
+
439
+ class OptionTest < ::Test::Unit::TestCase
440
+ include Methods
441
+
442
+ def class_to_test; Option end
443
+
444
+ def inputs
445
+ {
446
+ :name => 'my_option',
447
+ :value => 'blahdeblah'
448
+ }
449
+ end
450
+ end
451
+
452
+ class DataTest < ::Test::Unit::TestCase
453
+ include Methods
454
+
455
+ def class_to_test; Data end
456
+
457
+ def inputs
458
+ {
459
+ :format => TableData.new
460
+ }
461
+ end
462
+
463
+ def test_alternative_formats
464
+ data = Data.new(:format => Binary.new)
465
+ assert_equal Binary.new, data.format
466
+
467
+ data = Data.new(:format => Fits.new)
468
+ assert_equal Fits.new, data.format
469
+ end
470
+ end
471
+
472
+ class TableDataTest < ::Test::Unit::TestCase
473
+ include Methods
474
+
475
+ def class_to_test; TableData end
476
+
477
+ def inputs; {:trs => [Tr.new]} end
478
+ end
479
+
480
+ class BinaryTest < ::Test::Unit::TestCase
481
+ include Methods
482
+
483
+ def class_to_test; Binary end
484
+
485
+ def inputs; {:stream => Stream.new()} end
486
+ end
487
+
488
+ class StreamTest < ::Test::Unit::TestCase
489
+ include Methods
490
+
491
+ def class_to_test; Stream end
492
+
493
+ def inputs
494
+ {
495
+ :type => 'other', :href => 'http://www.noao.edu/', :actuate => 'onRequest',
496
+ :encoding => 'gzip', :expires => '2007-12-05T08:45:14', :rights => 'none',
497
+ :text => 'Some text'
498
+ }
499
+ end
500
+
501
+ def expected_outputs
502
+ self.inputs.merge({
503
+ :href => URI.parse(self.inputs[:href]),
504
+ :expires => DateTime.parse(self.inputs[:expires])
505
+ })
506
+ end
507
+
508
+ def test_retrieve
509
+ stream = Stream.new(:href => 'http://www.noao.edu/index.shtml')
510
+ file = stream.retrieve
511
+ #assert_kind_of Tempfile, file
512
+ assert_match /National Optical Astronomy Observatory/, file.read
513
+
514
+ stream = Stream.new(:text => 'my text')
515
+ file = stream.retrieve
516
+ assert_kind_of StringIO, file
517
+ assert_equal 'my text', file.read
518
+ end
519
+ end
520
+
521
+ class FitsTest < ::Test::Unit::TestCase
522
+ include Methods
523
+
524
+ def class_to_test; Fits end
525
+
526
+ def inputs
527
+ {
528
+ :extnum => '2',
529
+ :stream => Stream.new
530
+ }
531
+ end
532
+
533
+ def expected_outputs
534
+ self.inputs.merge({:extnum => 2})
535
+ end
536
+
537
+ # def test_to_rfits
538
+ # fits = Fits.new(:stream => Stream.new(:href => 'http://fits.gsfc.nasa.gov/nrao_data/samples/image/swp05569slg.fits'))
539
+ # rfits = fits.to_rfits
540
+ #
541
+ # (VORuby.rfits?) ? assert_kind_of(RFits::File, rfits) : assert_kind_of(Tempfile, rfits)
542
+ # end
543
+ end
544
+
545
+ class TrTest < ::Test::Unit::TestCase
546
+ include Methods
547
+
548
+ def class_to_test; Tr end
549
+
550
+ def inputs; {:tds => [Td.new]} end
551
+
552
+ def test_to_html
553
+ tr = Tr.new(:tds => [Td.new(:text => 'hello'), Td.new(:text => 'world')])
554
+ assert_equal("<tr><td>hello</td><td>world</td></tr>", tr.to_html.strip.gsub(/\n+\s*/, ''))
555
+ end
556
+ end
557
+
558
+ class TdTest < ::Test::Unit::TestCase
559
+ include Methods
560
+
561
+ def class_to_test; Td end
562
+
563
+ def inputs
564
+ {
565
+ :ref => 'my_ref1',
566
+ :text => 'my value'
567
+ }
568
+ end
569
+
570
+ def test_casting
571
+ table = Table.new(
572
+ :fields => [
573
+ Field.new(:name => 'col1', :datatype => 'boolean'),
574
+ Field.new(:name => 'col1_2', :datatype => 'boolean', :arraysize => '*'),
575
+ Field.new(:name => 'col2', :datatype => 'bit'),
576
+ Field.new(:name => 'col2_2', :datatype => 'bit', :arraysize => '*'),
577
+ Field.new(:name => 'col3', :datatype => 'unsignedByte'),
578
+ Field.new(:name => 'col3_2', :datatype => 'unsignedByte', :arraysize => '*'),
579
+ Field.new(:name => 'col4', :datatype => 'short'),
580
+ Field.new(:name => 'col4_2', :datatype => 'short', :arraysize => '*'),
581
+ Field.new(:name => 'col5', :datatype => 'int'),
582
+ Field.new(:name => 'col5_2', :datatype => 'int', :arraysize => '*'),
583
+ Field.new(:name => 'col6', :datatype => 'long'),
584
+ Field.new(:name => 'col6_2', :datatype => 'long', :arraysize => '*'),
585
+ Field.new(:name => 'col7', :datatype => 'char'),
586
+ Field.new(:name => 'col7_2', :datatype => 'char', :arraysize => '*'),
587
+ Field.new(:name => 'col8', :datatype => 'unicodeChar'),
588
+ Field.new(:name => 'col8_2', :datatype => 'unicodeChar', :arraysize => '*'),
589
+ Field.new(:name => 'col9', :datatype => 'float'),
590
+ Field.new(:name => 'col9_2', :datatype => 'float', :arraysize => '*'),
591
+ Field.new(:name => 'col10', :datatype => 'double'),
592
+ Field.new(:name => 'col10_2', :datatype => 'double', :arraysize => '*'),
593
+ Field.new(:name => 'col11', :datatype => 'floatComplex'),
594
+ Field.new(:name => 'col11_2', :datatype => 'floatComplex', :arraysize => '*'),
595
+ Field.new(:name => 'col12', :datatype => 'doubleComplex'),
596
+ Field.new(:name => 'col12_2', :datatype => 'doubleComplex', :arraysize => '*')
597
+ ],
598
+ :data => Data.new(
599
+ :format => TableData.new(
600
+ :trs => [
601
+ Tr.new(:tds => [
602
+ Td.new(:text => 't'),
603
+ Td.new(:text => 't f 1 true false 0'),
604
+ Td.new(:text => '1'),
605
+ Td.new(:text => '1 1 0 1 1'),
606
+ Td.new(:text => 'a'),
607
+ Td.new(:text => 'a b c d'),
608
+ Td.new(:text => '34'),
609
+ Td.new(:text => '34 12 4 1'),
610
+ Td.new(:text => '100'),
611
+ Td.new(:text => '100 101 102'),
612
+ Td.new(:text => '1000'),
613
+ Td.new(:text => '1000 1001 1002'),
614
+ Td.new(:text => 'a'),
615
+ Td.new(:text => 'hello'),
616
+ Td.new(:text => 'b'),
617
+ Td.new(:text => 'world'),
618
+ Td.new(:text => '12.1'),
619
+ Td.new(:text => '1.1 2.2 3.3'),
620
+ Td.new(:text => '1000'),
621
+ Td.new(:text => '100.1, 200.2, 300.3'),
622
+ Td.new(:text => '7.2 5.5'),
623
+ Td.new(:text => '1.1 10.1 3.2 2.2 9.0 7.1')
624
+ ])
625
+ ]
626
+ )
627
+ )
628
+ )
629
+
630
+ tr = table.data.format.trs.first
631
+
632
+ # Retrieval...
633
+ assert_equal true, tr.tds[0].value
634
+ assert_equal [true, false, true, true, false, false], tr.tds[1].value
635
+ assert_equal 1, tr.tds[2].value
636
+ assert_equal [1, 1, 0, 1, 1], tr.tds[3].value
637
+ assert_equal 97, tr.tds[4].value
638
+ assert_equal [97, 98, 99, 100], tr.tds[5].value
639
+ assert_equal 34, tr.tds[6].value
640
+ assert_equal [34, 12, 4, 1], tr.tds[7].value
641
+ assert_equal 100, tr.tds[8].value
642
+ assert_equal [100, 101, 102], tr.tds[9].value
643
+ assert_equal 1000, tr.tds[10].value
644
+ assert_equal [1000, 1001, 1002], tr.tds[11].value
645
+ assert_equal 'a', tr.tds[12].value
646
+ assert_equal 'hello', tr.tds[13].value
647
+ assert_equal 'b', tr.tds[14].value
648
+ assert_equal 'world', tr.tds[15].value
649
+ assert_equal 12.1, tr.tds[16].value
650
+ assert_equal [1.1, 2.2, 3.3], tr.tds[17].value
651
+ assert_equal 1000, tr.tds[18].value
652
+ assert_equal [100.1, 200.2, 300.3], tr.tds[19].value
653
+ assert_equal Complex.new(7.2, 5.5), tr.tds[20].value
654
+ assert_equal [Complex.new(1.1, 10.1), Complex.new(3.2, 2.2), Complex.new(9.0, 7.1)], tr.tds[21].value
655
+
656
+ # Setters
657
+ tr.tds[0].value = true
658
+ assert_equal true, tr.tds[0].value
659
+ tr.tds[2].value = 1
660
+ assert_equal 1, tr.tds[2].value
661
+ tr.tds[4].value = 'a'
662
+ assert_equal 97, tr.tds[4].value
663
+ tr.tds[6].value = 1000
664
+ assert_equal 1000, tr.tds[6].value
665
+ tr.tds[8].value = 10000
666
+ assert_equal 10000, tr.tds[8].value
667
+ tr.tds[10].value = 1000000
668
+ assert_equal 1000000, tr.tds[10].value
669
+ tr.tds[12].value = 'b'
670
+ assert_equal 'b', tr.tds[12].value
671
+ tr.tds[14].value = 'B'
672
+ assert_equal 'B', tr.tds[14].value
673
+ tr.tds[16].value = 1.1
674
+ assert_equal 1.1, tr.tds[16].value
675
+ tr.tds[18].value = 10001.1
676
+ assert_equal 10001.1, tr.tds[18].value
677
+ tr.tds[20].value = Complex.new(1.1, 2.2)
678
+ assert_equal Complex.new(1.1, 2.2), tr.tds[20].value
679
+
680
+ # This should be an array...
681
+ assert_raise RuntimeError do
682
+ tr.tds[1].value = 1
683
+ end
684
+
685
+ # And this should be a scalar...
686
+ assert_raise RuntimeError do
687
+ tr.tds[0].value = [1, 0, 1, 1]
688
+ end
689
+ end
690
+
691
+ def test_to_html
692
+ td = Td.new(:text => '1 1 0 1 1')
693
+ assert_equal("<td>1 1 0 1 1</td>", td.to_html.strip.gsub(/\n+\s*/, ''))
694
+ end
695
+ end
696
+
697
+ class NSVOTableTest < ::Test::Unit::TestCase
698
+ def test_ns
699
+ votable = VOTable.new(File.open('test/voruby/votable/1.0/votable.ns.xml'))
700
+ table = votable.resources.first.tables.first
701
+
702
+ assert_equal 'ra', table.fields[-3].name
703
+ assert_equal 'double', table.fields[-3].datatype
704
+ assert_equal 10, table.fields[-3].width
705
+
706
+ assert_equal -14.0986, table.data.format.trs.first.tds[3].value
707
+ assert_equal 1.0456679, table.data.format.trs[1].tds[-2].value
708
+ end
709
+ end
710
+
711
+ end
712
+ end
713
+ end
714
+ end