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
@@ -0,0 +1,86 @@
1
+ <div class="votable">
2
+ <div class="resource">
3
+ <h3>myFavouriteGalaxies</h3>
4
+ <table>
5
+ <caption>Velocities and Distance estimations</caption>
6
+ <thead>
7
+ <tr>
8
+ <th>
9
+ <div class="field" id="col1">
10
+ <div class="name">RA</div>
11
+ <div class="ucd">pos.eq.ra;meta.main</div>
12
+ <div class="unit">deg</div>
13
+ <span class="datatype">float</span>
14
+ </div>
15
+ </th>
16
+ <th>
17
+ <div class="field" id="col2">
18
+ <div class="name">Dec</div>
19
+ <div class="ucd">pos.eq.dec;meta.main</div>
20
+ <div class="unit">deg</div>
21
+ <span class="datatype">float</span>
22
+ </div>
23
+ </th>
24
+ <th>
25
+ <div class="field" id="col3">
26
+ <div class="name">Name</div>
27
+ <div class="ucd">meta.id;meta.main</div>
28
+ <span class="datatype">char</span>
29
+ <span class="arraysize">8*</span>
30
+ </div>
31
+ </th>
32
+ <th>
33
+ <div class="field" id="col4">
34
+ <div class="name">RVel</div>
35
+ <div class="ucd">src.veloc.hc</div>
36
+ <div class="unit">km/s</div>
37
+ <span class="datatype">int</span>
38
+ </div>
39
+ </th>
40
+ <th>
41
+ <div class="field" id="col5">
42
+ <div class="name">e_RVel</div>
43
+ <div class="ucd">stat.error;src.veloc.hc</div>
44
+ <div class="unit">km/s</div>
45
+ <span class="datatype">int</span>
46
+ </div>
47
+ </th>
48
+ <th>
49
+ <div class="field" id="col6">
50
+ <div class="name">R</div>
51
+ <div class="ucd">phys.distance</div>
52
+ <div class="unit">Mpc</div>
53
+ <span class="datatype">float</span>
54
+ </div>
55
+ </th>
56
+ </tr>
57
+ </thead>
58
+ <tbody>
59
+ <tr>
60
+ <td>010.68</td>
61
+ <td>+41.27</td>
62
+ <td>N 224</td>
63
+ <td>-297</td>
64
+ <td>5</td>
65
+ <td>0.7</td>
66
+ </tr>
67
+ <tr>
68
+ <td>287.43</td>
69
+ <td>-63.85</td>
70
+ <td>N 6744</td>
71
+ <td>839</td>
72
+ <td>6</td>
73
+ <td>10.4</td>
74
+ </tr>
75
+ <tr>
76
+ <td>023.48</td>
77
+ <td>+30.66</td>
78
+ <td>N 598</td>
79
+ <td>-182</td>
80
+ <td>3</td>
81
+ <td>0.7</td>
82
+ </tr>
83
+ </tbody>
84
+ </table>
85
+ </div>
86
+ </div>
@@ -0,0 +1,56 @@
1
+ <ns1:VOTABLE xmlns:ns1="SkyPortal.ivoa.net">
2
+ <ns2:RESOURCE xmlns:ns2="http://vizier.u-strasbg.fr/xml/VOTable-1.1.xsd">
3
+ <ns2:TABLE name="Table 1">
4
+ <ns2:FIELD datatype="double" name="NUMBER" width="10"/>
5
+ <ns2:FIELD datatype="double" name="MAG_ISO" width="10"/>
6
+ <ns2:FIELD datatype="double" name="MAGERR_ISO" width="10"/>
7
+ <ns2:FIELD datatype="double" name="MAG_ISOCOR" width="10"/>
8
+ <ns2:FIELD datatype="double" name="MAGERR_ISOCOR" width="10"/>
9
+ <ns2:FIELD datatype="double" name="MAG_APER" width="10"/>
10
+ <ns2:FIELD datatype="double" name="MAGERR_APER" width="10"/>
11
+ <ns2:FIELD datatype="double" name="MAG_AUTO" width="10"/>
12
+ <ns2:FIELD datatype="double" name="MAGERR_AUTO" width="10"/>
13
+ <ns2:FIELD datatype="double" name="MAG_BEST" width="10"/>
14
+ <ns2:FIELD datatype="double" name="MAGERR_BEST" width="10"/>
15
+ <ns2:FIELD datatype="double" name="ra" width="10"/>
16
+ <ns2:FIELD datatype="double" name="dec" width="10"/>
17
+ <ns2:FIELD datatype="double" name="FLAGS" width="10"/>
18
+ <ns2:DATA>
19
+ <ns2:TABLEDATA>
20
+ <ns2:TR>
21
+ <ns2:TD>1</ns2:TD>
22
+ <ns2:TD>-14.0836</ns2:TD>
23
+ <ns2:TD>0.0008</ns2:TD>
24
+ <ns2:TD>-14.0986</ns2:TD>
25
+ <ns2:TD>0.0008</ns2:TD>
26
+ <ns2:TD>-12.6699</ns2:TD>
27
+ <ns2:TD>0.0002</ns2:TD>
28
+ <ns2:TD>-14.1114</ns2:TD>
29
+ <ns2:TD>0.0007</ns2:TD>
30
+ <ns2:TD>-14.1114</ns2:TD>
31
+ <ns2:TD>0.0007</ns2:TD>
32
+ <ns2:TD>2.9325730</ns2:TD>
33
+ <ns2:TD>+1.0539001</ns2:TD>
34
+ <ns2:TD>2</ns2:TD>
35
+ </ns2:TR>
36
+ <ns2:TR>
37
+ <ns2:TD>2</ns2:TD>
38
+ <ns2:TD>-6.0965</ns2:TD>
39
+ <ns2:TD>0.1047</ns2:TD>
40
+ <ns2:TD>-6.8029</ns2:TD>
41
+ <ns2:TD>0.1221</ns2:TD>
42
+ <ns2:TD>-5.5913</ns2:TD>
43
+ <ns2:TD>0.1576</ns2:TD>
44
+ <ns2:TD>-7.6463</ns2:TD>
45
+ <ns2:TD>0.0858</ns2:TD>
46
+ <ns2:TD>-7.6463</ns2:TD>
47
+ <ns2:TD>0.0858</ns2:TD>
48
+ <ns2:TD>2.9335704</ns2:TD>
49
+ <ns2:TD>+1.0456679</ns2:TD>
50
+ <ns2:TD>0</ns2:TD>
51
+ </ns2:TR>
52
+ </ns2:TABLEDATA>
53
+ </ns2:DATA>
54
+ </ns2:TABLE>
55
+ </ns2:RESOURCE>
56
+ </ns1:VOTABLE>
@@ -0,0 +1,785 @@
1
+ require 'voruby/votable/1.1/votable'
2
+ require 'test/unit'
3
+
4
+ include VORuby::VOTable::V1_1
5
+
6
+ module VORuby
7
+ module VOTable
8
+ module V1_1
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.1',
43
+ :id => 'my_test_votable',
44
+ :description => Description.new,
45
+ :definitions => Definitions.new,
46
+ :coordinate_systems => [Coosys.new],
47
+ :params => [Param.new],
48
+ :infos => [Info.new],
49
+ :resources => [Resource.new]
50
+ }
51
+ end
52
+
53
+ def test_to_html
54
+ votable = VOTable.new(
55
+ :version => '1.1',
56
+ :coordinate_systems => [
57
+ Coosys.new(:id => 'J2000', :equinox => 'J2000.', :epoch => 'J2000.', :system => 'eq_FK5')
58
+ ],
59
+ :resources => [
60
+ Resource.new(
61
+ :name => 'myFavouriteGalaxies',
62
+ :tables => [
63
+ Table.new(
64
+ :name => 'results',
65
+ :description => Description.new(:text => 'Velocities and Distance estimations'),
66
+ :params => [
67
+ Param.new(
68
+ :name => 'Telescope',
69
+ :datatype => 'float',
70
+ :ucd => 'phys.size;instr.tel',
71
+ :unit => 'm',
72
+ :value => '3.6'
73
+ )
74
+ ],
75
+ :fields => [
76
+ Field.new(:name => 'RA', :id => 'col1', :ucd => 'pos.eq.ra;meta.main',
77
+ :ref => 'J2000', :datatype => 'float', :width => 6, :precision => '2', :unit => 'deg'),
78
+ Field.new(:name => 'Dec', :id => 'col2', :ucd => 'pos.eq.dec;meta.main',
79
+ :ref => 'J2000', :datatype => 'float', :width => 6, :precision => '2', :unit => 'deg'),
80
+ Field.new(:name => 'Name', :id => 'col3', :ucd => 'meta.id;meta.main',
81
+ :datatype => 'char', :arraysize => '8*'),
82
+ Field.new(:name => 'RVel', :id => 'col4', :ucd => 'src.veloc.hc', :datatype => 'int',
83
+ :width => 5, :unit => 'km/s'),
84
+ Field.new(:name => 'e_RVel', :id => 'col5', :ucd => 'stat.error;src.veloc.hc',
85
+ :datatype => 'int', :width => 3, :unit => 'km/s'),
86
+ Field.new(:name => 'R', :id => 'col6', :ucd => 'phys.distance', :datatype => 'float',
87
+ :width => 4, :precision => '1', :unit => 'Mpc',
88
+ :description => Description.new(:text => 'Distance of Galaxy, assuming H=75km/s/Mpc'))
89
+ ],
90
+ :data => Data.new(
91
+ :format => TableData.new(
92
+ :trs => [
93
+ Tr.new(:tds => [
94
+ Td.new(:text => '010.68'), Td.new(:text => '+41.27'), Td.new(:text => 'N 224'),
95
+ Td.new(:text => '-297'), Td.new(:text => '5'), Td.new(:text => '0.7')
96
+ ]),
97
+ Tr.new(:tds => [
98
+ Td.new(:text => '287.43'), Td.new(:text => '-63.85'), Td.new(:text => 'N 6744'),
99
+ Td.new(:text => '839'), Td.new(:text => '6'), Td.new(:text => '10.4')
100
+ ]),
101
+ Tr.new(:tds => [
102
+ Td.new(:text => '023.48'), Td.new(:text => '+30.66'), Td.new(:text => 'N 598'),
103
+ Td.new(:text => '-182'), Td.new(:text => '3'), Td.new(:text => '0.7')
104
+ ])
105
+ ]
106
+ )
107
+ )
108
+ )
109
+ ]
110
+ )
111
+ ]
112
+ )
113
+
114
+ assert_equal(
115
+ File.read('test/voruby/votable/1.1/votable.html').strip.gsub(/\n+\s*/, ''),
116
+ votable.to_html.strip.gsub(/\n+\s*/, '')
117
+ )
118
+ end
119
+ end
120
+
121
+ class DescriptionTest < ::Test::Unit::TestCase
122
+ include Methods
123
+
124
+ def class_to_test; Description end
125
+
126
+ def inputs; {:text => 'A description'} end
127
+ end
128
+
129
+ class DefinitionsTest < ::Test::Unit::TestCase
130
+ include Methods
131
+
132
+ def class_to_test; Definitions end
133
+
134
+ def inputs
135
+ {
136
+ :coordinate_systems => [Coosys.new],
137
+ :params => [Param.new]
138
+ }
139
+ end
140
+ end
141
+
142
+ class CoosysTest < ::Test::Unit::TestCase
143
+ include Methods
144
+
145
+ def class_to_test; Coosys end
146
+
147
+ def inputs
148
+ {:id => 'my_coosys', :equinox => 'J2000', :epoch => 'B1950', :system => 'supergalactic'}
149
+ end
150
+ end
151
+
152
+ class ParamTest < ::Test::Unit::TestCase
153
+ include Methods
154
+
155
+ def class_to_test; Param end
156
+
157
+ def inputs
158
+ {
159
+ :id => 'my_param_test',
160
+ :unit => 'm/s',
161
+ :datatype => 'float',
162
+ :arraysize => '*',
163
+ :precision => '3',
164
+ :width => 6,
165
+ :ref => 'refer_to_1',
166
+ :name => 'My param test',
167
+ :ucd => 'phys.velocity',
168
+ :utype => 'my_utype',
169
+ :value => '123.456',
170
+ :description => Description.new,
171
+ :values => Values.new,
172
+ :links => [Link.new]
173
+ }
174
+ end
175
+
176
+ def test_casting
177
+ param = Param.new(:datatype => 'float', :arraysize => '*')
178
+ param.value = [123.4, 21.5]
179
+ assert_equal [123.4, 21.5], param.value(true)
180
+ end
181
+ end
182
+
183
+ class InfoTest < ::Test::Unit::TestCase
184
+ include Methods
185
+
186
+ def class_to_test; Info end
187
+
188
+ def inputs
189
+ {:id => 'my_info', :name => 'info_lite', :value => '123'}
190
+ end
191
+ end
192
+
193
+ class ResourceTest < ::Test::Unit::TestCase
194
+ include Methods
195
+
196
+ def class_to_test; Resource end
197
+
198
+ def inputs
199
+ {
200
+ :name => 'Test Resource',
201
+ :id => 'my_test_resource',
202
+ :utype => 'a_utype',
203
+ :type => 'a_type',
204
+ :description => Description.new,
205
+ :infos => [Info.new],
206
+ :coordinate_systems => [Coosys.new],
207
+ :params => [Param.new],
208
+ :links => [Link.new],
209
+ :tables => [Table.new],
210
+ :resources => [Resource.new]
211
+ }
212
+ end
213
+ end
214
+
215
+ class LinkTest < ::Test::Unit::TestCase
216
+ include Methods
217
+
218
+ def class_to_test; Link end
219
+
220
+ def inputs
221
+ {
222
+ :id => 'my_link', :content_role => 'hints', :content_type => 'text/html',
223
+ :title => 'link title', :value => 'this is value',
224
+ :href => 'http://www.google.com/', :gref => 'a gref',
225
+ :action => 'http://www.noao.edu/actions/mine'
226
+ }
227
+ end
228
+
229
+ def expected_outputs
230
+ self.inputs.merge({
231
+ :href => URI.parse('http://www.google.com/'),
232
+ :action => URI.parse('http://www.noao.edu/actions/mine')
233
+ })
234
+ end
235
+ end
236
+
237
+ class TableTest < ::Test::Unit::TestCase
238
+ include Methods
239
+
240
+ def class_to_test; Table end
241
+
242
+ def inputs
243
+ {
244
+ :id => 'my_table',
245
+ :name => 'My Table',
246
+ :ref => 'ref1',
247
+ :ucd => 'a_ucd',
248
+ :utype => 'a_utype',
249
+ :nrows => '5',
250
+ :description => Description.new,
251
+ :data => Data.new(),
252
+ :fields => [Field.new],
253
+ :params => [Param.new],
254
+ :groups => [Group.new],
255
+ :links => [Link.new]
256
+ }
257
+ end
258
+
259
+ def expected_outputs
260
+ self.inputs.merge({:nrows => 5})
261
+ end
262
+
263
+ def test_to_html
264
+ table = Table.new(
265
+ :id => 'table1',
266
+ :description => Description.new(:text => 'A test table'),
267
+ :fields => [
268
+ Field.new(:name => 'RA', :id => 'col1', :ucd => 'pos.eq.ra;meta.main',
269
+ :ref => 'J2000', :datatype => 'float', :width => 6, :precision => '2', :unit => 'deg'),
270
+ Field.new(:name => 'Dec', :id => 'col2', :ucd => 'pos.eq.dec;meta.main',
271
+ :ref => 'J2000', :datatype => 'float', :width => 6, :precision => '2', :unit => 'deg'),
272
+ Field.new(:name => 'Name', :id => 'col3', :ucd => 'meta.id;meta.main',
273
+ :datatype => 'char', :arraysize => '8*')
274
+ ],
275
+ :data => Data.new(
276
+ :format => TableData.new(
277
+ :trs => [
278
+ Tr.new(:tds => [Td.new(:text => '123'), Td.new(:text => '456'), Td.new(:text => 'my_obj1')]),
279
+ Tr.new(:tds => [Td.new(:text => '789'), Td.new(:text => '112'), Td.new(:text => 'my_obj2')]),
280
+ Tr.new(:tds => [Td.new(:text => '145'), Td.new(:text => '178'), Td.new(:text => 'my_obj3')])
281
+ ]
282
+ )
283
+ )
284
+ )
285
+
286
+ assert_equal(
287
+ '<table id="table1">' +
288
+ '<caption>A test table</caption>' +
289
+ '<thead>' +
290
+ '<tr>' +
291
+ '<th>' +
292
+ '<div class="field" id="col1">' +
293
+ '<div class="name">RA</div>' +
294
+ '<div class="ucd">pos.eq.ra;meta.main</div>' +
295
+ '<div class="unit">deg</div>' +
296
+ '<span class="datatype">float</span>' +
297
+ '</div>' +
298
+ '</th>' +
299
+ '<th>' +
300
+ '<div class="field" id="col2">' +
301
+ '<div class="name">Dec</div>' +
302
+ '<div class="ucd">pos.eq.dec;meta.main</div>' +
303
+ '<div class="unit">deg</div>' +
304
+ '<span class="datatype">float</span>' +
305
+ '</div>' +
306
+ '</th>' +
307
+ '<th>' +
308
+ '<div class="field" id="col3">' +
309
+ '<div class="name">Name</div>' +
310
+ '<div class="ucd">meta.id;meta.main</div>' +
311
+ '<span class="datatype">char</span>' +
312
+ '<span class="arraysize">8*</span>' +
313
+ '</div>' +
314
+ '</th>' +
315
+ '</tr>' +
316
+ '</thead>' +
317
+ '<tbody>' +
318
+ '<tr>' +
319
+ '<td>123</td>' +
320
+ '<td>456</td>' +
321
+ '<td>my_obj1</td>' +
322
+ '</tr>' +
323
+ '<tr>' +
324
+ '<td>789</td>' +
325
+ '<td>112</td>' +
326
+ '<td>my_obj2</td>' +
327
+ '</tr>' +
328
+ '<tr>' +
329
+ '<td>145</td>' +
330
+ '<td>178</td>' +
331
+ '<td>my_obj3</td>' +
332
+ '</tr>' +
333
+ '</tbody>' +
334
+ '</table>',
335
+ table.to_html.strip.gsub(/\n+\s*/, '')
336
+ )
337
+ end
338
+ end
339
+
340
+ class FieldTest < ::Test::Unit::TestCase
341
+ include Methods
342
+
343
+ def class_to_test; Field end
344
+
345
+ def inputs
346
+ {
347
+ :id => 'my_field',
348
+ :unit => 'm/s',
349
+ :datatype => 'float',
350
+ :precision => '3',
351
+ :width => '6',
352
+ :precision => '3',
353
+ :ref => 'my_ref',
354
+ :name => 'Velocity',
355
+ :ucd => 'phys.velocity',
356
+ :utype => 'a_utype',
357
+ :arraysize => '*',
358
+ :type => 'a_type',
359
+ :description => Description.new,
360
+ :values => [Values.new],
361
+ :links => [Link.new]
362
+ }
363
+ end
364
+
365
+ def expected_outputs
366
+ self.inputs.merge({:width => 6})
367
+ end
368
+
369
+ def test_to_html
370
+ field = Field.new(:id => 'col1', :name => 'Name', :ucd => 'meta.id;meta.main', :datatype => 'char', :arraysize => '*')
371
+ assert_equal(
372
+ '<div class="field" id="col1">' +
373
+ '<div class="name">Name</div>' +
374
+ '<div class="ucd">meta.id;meta.main</div>' +
375
+ '<span class="datatype">char</span>' +
376
+ '<span class="arraysize">*</span>' +
377
+ '</div>',
378
+ field.to_html.strip.gsub(/\n+\s*/, '')
379
+ )
380
+ end
381
+ end
382
+
383
+ class ValuesTest < ::Test::Unit::TestCase
384
+ include Methods
385
+
386
+ def class_to_test; Values end
387
+
388
+ def inputs
389
+ {
390
+ :id => 'my_values',
391
+ :type => 'a_type',
392
+ :null => ' ',
393
+ :ref => 'values_ref',
394
+ :max => Max.new,
395
+ :min => Min.new,
396
+ :options => [Option.new]
397
+ }
398
+ end
399
+ end
400
+
401
+ class MinTest < ::Test::Unit::TestCase
402
+ include Methods
403
+
404
+ def class_to_test; Min end
405
+
406
+ def inputs
407
+ {:value => '10.2', :inclusive => 'no'}
408
+ end
409
+
410
+ def test_inclusive
411
+ min = Min.new(self.inputs)
412
+ assert_equal false, min.inclusive?
413
+ end
414
+
415
+ def test_alternate_inclusives
416
+ min = Min.new(:inclusive => false)
417
+ assert_equal 'no', min.inclusive
418
+ min.inclusive = true
419
+ assert_equal 'yes', min.inclusive
420
+ end
421
+ end
422
+
423
+ class MaxTest < ::Test::Unit::TestCase
424
+ include Methods
425
+
426
+ def class_to_test; Max end
427
+
428
+ def inputs
429
+ {:value => '10.2', :inclusive => 'yes'}
430
+ end
431
+
432
+ def test_inclusive
433
+ max = Max.new(self.inputs)
434
+ assert_equal true, max.inclusive?
435
+ end
436
+
437
+ def test_alternate_inclusives
438
+ max = Max.new(:inclusive => false)
439
+ assert_equal 'no', max.inclusive
440
+ max.inclusive = true
441
+ assert_equal 'yes', max.inclusive
442
+ end
443
+ end
444
+
445
+ class OptionTest < ::Test::Unit::TestCase
446
+ include Methods
447
+
448
+ def class_to_test; Option end
449
+
450
+ def inputs
451
+ {
452
+ :name => 'my_option',
453
+ :value => 'blahdeblah',
454
+ :options => [Option.new]
455
+ }
456
+ end
457
+ end
458
+
459
+ class GroupTest < ::Test::Unit::TestCase
460
+ include Methods
461
+
462
+ def class_to_test; Group end
463
+
464
+ def inputs
465
+ {
466
+ :id => 'my_group',
467
+ :name => 'Group1',
468
+ :ref => 'group1',
469
+ :ucd => 'a_ucd',
470
+ :utype => 'a_utype',
471
+ :description => Description.new,
472
+ :field_refs => [FieldRef.new],
473
+ :param_refs => [ParamRef.new],
474
+ :params => [Param.new],
475
+ :groups => [Group.new]
476
+ }
477
+ end
478
+ end
479
+
480
+ class FieldRefTest < ::Test::Unit::TestCase
481
+ include Methods
482
+
483
+ def class_to_test; FieldRef end
484
+
485
+ def inputs; {:ref => 'my_field_ref'} end
486
+
487
+ def test_field_retrieval
488
+ table = Table.new(
489
+ :fields => [Field.new(:id => 'col1', :name => 'my column')],
490
+ :groups => [
491
+ Group.new(
492
+ :field_refs => [FieldRef.new(:ref => 'col1')]
493
+ )
494
+ ]
495
+ )
496
+
497
+ assert_equal Field.new(:id => 'col1', :name => 'my column'), table.groups.first.field_refs.first.field
498
+ end
499
+ end
500
+
501
+ class ParamRefTest < ::Test::Unit::TestCase
502
+ include Methods
503
+
504
+ def class_to_test; ParamRef end
505
+
506
+ def inputs; {:ref => 'my_param_ref'} end
507
+
508
+ def test_param_retrieval
509
+ table = Table.new(
510
+ :params => [Param.new(:id => 'param1', :name => 'my param')],
511
+ :groups => [
512
+ Group.new(
513
+ :param_refs => [ParamRef.new(:ref => 'param1')]
514
+ )
515
+ ]
516
+ )
517
+
518
+ assert_equal Param.new(:id => 'param1', :name => 'my param'), table.groups.first.param_refs.first.param
519
+ end
520
+ end
521
+
522
+ class DataTest < ::Test::Unit::TestCase
523
+ include Methods
524
+
525
+ def class_to_test; Data end
526
+
527
+ def inputs
528
+ {
529
+ :format => TableData.new
530
+ }
531
+ end
532
+
533
+ def test_alternative_formats
534
+ data = Data.new(:format => Binary.new)
535
+ assert_equal Binary.new, data.format
536
+
537
+ data = Data.new(:format => Fits.new)
538
+ assert_equal Fits.new, data.format
539
+ end
540
+ end
541
+
542
+ class TableDataTest < ::Test::Unit::TestCase
543
+ include Methods
544
+
545
+ def class_to_test; TableData end
546
+
547
+ def inputs; {:trs => [Tr.new]} end
548
+ end
549
+
550
+ class BinaryTest < ::Test::Unit::TestCase
551
+ include Methods
552
+
553
+ def class_to_test; Binary end
554
+
555
+ def inputs; {:stream => Stream.new()} end
556
+ end
557
+
558
+ class StreamTest < ::Test::Unit::TestCase
559
+ include Methods
560
+
561
+ def class_to_test; Stream end
562
+
563
+ def inputs
564
+ {
565
+ :type => 'other', :href => 'http://www.noao.edu/', :actuate => 'onRequest',
566
+ :encoding => 'gzip', :expires => '2007-12-05T08:45:14', :rights => 'none',
567
+ :text => 'Some text'
568
+ }
569
+ end
570
+
571
+ def expected_outputs
572
+ self.inputs.merge({
573
+ :href => URI.parse(self.inputs[:href]),
574
+ :expires => DateTime.parse(self.inputs[:expires])
575
+ })
576
+ end
577
+
578
+ def test_retrieve
579
+ stream = Stream.new(:href => 'http://www.noao.edu/index.shtml')
580
+ file = stream.retrieve
581
+ #assert_kind_of Tempfile, file
582
+ assert_match /National Optical Astronomy Observatory/, file.read
583
+
584
+ stream = Stream.new(:text => 'my text')
585
+ file = stream.retrieve
586
+ assert_kind_of StringIO, file
587
+ assert_equal 'my text', file.read
588
+ end
589
+ end
590
+
591
+ class FitsTest < ::Test::Unit::TestCase
592
+ include Methods
593
+
594
+ def class_to_test; Fits end
595
+
596
+ def inputs
597
+ {
598
+ :extnum => '2',
599
+ :stream => Stream.new
600
+ }
601
+ end
602
+
603
+ def expected_outputs
604
+ self.inputs.merge({:extnum => 2})
605
+ end
606
+
607
+ # def test_to_rfits
608
+ # fits = Fits.new(:stream => Stream.new(:href => 'http://fits.gsfc.nasa.gov/nrao_data/samples/image/swp05569slg.fits'))
609
+ # rfits = fits.to_rfits
610
+ #
611
+ # (VORuby.rfits?) ? assert_kind_of(RFits::File, rfits) : assert_kind_of(Tempfile, rfits)
612
+ # end
613
+ end
614
+
615
+ class TrTest < ::Test::Unit::TestCase
616
+ include Methods
617
+
618
+ def class_to_test; Tr end
619
+
620
+ def inputs; {:tds => [Td.new]} end
621
+
622
+ def test_to_html
623
+ tr = Tr.new(:tds => [Td.new(:text => 'hello'), Td.new(:text => 'world')])
624
+ assert_equal("<tr><td>hello</td><td>world</td></tr>", tr.to_html.strip.gsub(/\n+\s*/, ''))
625
+ end
626
+ end
627
+
628
+ class TdTest < ::Test::Unit::TestCase
629
+ include Methods
630
+
631
+ def class_to_test; Td end
632
+
633
+ def inputs
634
+ {
635
+ :encoding => 'base64',
636
+ :text => 'my value'
637
+ }
638
+ end
639
+
640
+ def test_casting
641
+ table = Table.new(
642
+ :fields => [
643
+ Field.new(:name => 'col1', :datatype => 'boolean'),
644
+ Field.new(:name => 'col1_2', :datatype => 'boolean', :arraysize => '*'),
645
+ Field.new(:name => 'col2', :datatype => 'bit'),
646
+ Field.new(:name => 'col2_2', :datatype => 'bit', :arraysize => '*'),
647
+ Field.new(:name => 'col3', :datatype => 'unsignedByte'),
648
+ Field.new(:name => 'col3_2', :datatype => 'unsignedByte', :arraysize => '*'),
649
+ Field.new(:name => 'col4', :datatype => 'short'),
650
+ Field.new(:name => 'col4_2', :datatype => 'short', :arraysize => '*'),
651
+ Field.new(:name => 'col5', :datatype => 'int'),
652
+ Field.new(:name => 'col5_2', :datatype => 'int', :arraysize => '*'),
653
+ Field.new(:name => 'col6', :datatype => 'long'),
654
+ Field.new(:name => 'col6_2', :datatype => 'long', :arraysize => '*'),
655
+ Field.new(:name => 'col7', :datatype => 'char'),
656
+ Field.new(:name => 'col7_2', :datatype => 'char', :arraysize => '*'),
657
+ Field.new(:name => 'col8', :datatype => 'unicodeChar'),
658
+ Field.new(:name => 'col8_2', :datatype => 'unicodeChar', :arraysize => '*'),
659
+ Field.new(:name => 'col9', :datatype => 'float'),
660
+ Field.new(:name => 'col9_2', :datatype => 'float', :arraysize => '*'),
661
+ Field.new(:name => 'col10', :datatype => 'double'),
662
+ Field.new(:name => 'col10_2', :datatype => 'double', :arraysize => '*'),
663
+ Field.new(:name => 'col11', :datatype => 'floatComplex'),
664
+ Field.new(:name => 'col11_2', :datatype => 'floatComplex', :arraysize => '*'),
665
+ Field.new(:name => 'col12', :datatype => 'doubleComplex'),
666
+ Field.new(:name => 'col12_2', :datatype => 'doubleComplex', :arraysize => '*')
667
+ ],
668
+ :data => Data.new(
669
+ :format => TableData.new(
670
+ :trs => [
671
+ Tr.new(:tds => [
672
+ Td.new(:text => 't'),
673
+ Td.new(:text => 't f 1 true false 0'),
674
+ Td.new(:text => '1'),
675
+ Td.new(:text => '1 1 0 1 1'),
676
+ Td.new(:text => 'a'),
677
+ Td.new(:text => 'a b c d'),
678
+ Td.new(:text => '34'),
679
+ Td.new(:text => '34 12 4 1'),
680
+ Td.new(:text => '100'),
681
+ Td.new(:text => '100 101 102'),
682
+ Td.new(:text => '1000'),
683
+ Td.new(:text => '1000 1001 1002'),
684
+ Td.new(:text => 'a'),
685
+ Td.new(:text => 'hello'),
686
+ Td.new(:text => 'b'),
687
+ Td.new(:text => 'world'),
688
+ Td.new(:text => '12.1'),
689
+ Td.new(:text => '1.1 2.2 3.3'),
690
+ Td.new(:text => '1000'),
691
+ Td.new(:text => '100.1, 200.2, 300.3'),
692
+ Td.new(:text => '7.2 5.5'),
693
+ Td.new(:text => '1.1 10.1 3.2 2.2 9.0 7.1')
694
+ ])
695
+ ]
696
+ )
697
+ )
698
+ )
699
+
700
+ tr = table.data.format.trs.first
701
+
702
+ # Retrieval...
703
+ assert_equal true, tr.tds[0].value
704
+ assert_equal [true, false, true, true, false, false], tr.tds[1].value
705
+ assert_equal 1, tr.tds[2].value
706
+ assert_equal [1, 1, 0, 1, 1], tr.tds[3].value
707
+ assert_equal 97, tr.tds[4].value
708
+ assert_equal [97, 98, 99, 100], tr.tds[5].value
709
+ assert_equal 34, tr.tds[6].value
710
+ assert_equal [34, 12, 4, 1], tr.tds[7].value
711
+ assert_equal 100, tr.tds[8].value
712
+ assert_equal [100, 101, 102], tr.tds[9].value
713
+ assert_equal 1000, tr.tds[10].value
714
+ assert_equal [1000, 1001, 1002], tr.tds[11].value
715
+ assert_equal 'a', tr.tds[12].value
716
+ assert_equal 'hello', tr.tds[13].value
717
+ assert_equal 'b', tr.tds[14].value
718
+ assert_equal 'world', tr.tds[15].value
719
+ assert_equal 12.1, tr.tds[16].value
720
+ assert_equal [1.1, 2.2, 3.3], tr.tds[17].value
721
+ assert_equal 1000, tr.tds[18].value
722
+ assert_equal [100.1, 200.2, 300.3], tr.tds[19].value
723
+ assert_equal Complex.new(7.2, 5.5), tr.tds[20].value
724
+ assert_equal [Complex.new(1.1, 10.1), Complex.new(3.2, 2.2), Complex.new(9.0, 7.1)], tr.tds[21].value
725
+
726
+ # Setters
727
+ tr.tds[0].value = true
728
+ assert_equal true, tr.tds[0].value
729
+ tr.tds[2].value = 1
730
+ assert_equal 1, tr.tds[2].value
731
+ tr.tds[4].value = 'a'
732
+ assert_equal 97, tr.tds[4].value
733
+ tr.tds[6].value = 1000
734
+ assert_equal 1000, tr.tds[6].value
735
+ tr.tds[8].value = 10000
736
+ assert_equal 10000, tr.tds[8].value
737
+ tr.tds[10].value = 1000000
738
+ assert_equal 1000000, tr.tds[10].value
739
+ tr.tds[12].value = 'b'
740
+ assert_equal 'b', tr.tds[12].value
741
+ tr.tds[14].value = 'B'
742
+ assert_equal 'B', tr.tds[14].value
743
+ tr.tds[16].value = 1.1
744
+ assert_equal 1.1, tr.tds[16].value
745
+ tr.tds[18].value = 10001.1
746
+ assert_equal 10001.1, tr.tds[18].value
747
+ tr.tds[20].value = Complex.new(1.1, 2.2)
748
+ assert_equal Complex.new(1.1, 2.2), tr.tds[20].value
749
+
750
+ # This should be an array...
751
+ assert_raise RuntimeError do
752
+ tr.tds[1].value = 1
753
+ end
754
+
755
+ # And this should be a scalar...
756
+ assert_raise RuntimeError do
757
+ tr.tds[0].value = [1, 0, 1, 1]
758
+ end
759
+
760
+ end
761
+
762
+ def test_to_html
763
+ td = Td.new(:text => '1 1 0 1 1')
764
+ assert_equal("<td>1 1 0 1 1</td>", td.to_html.strip.gsub(/\n+\s*/, ''))
765
+ end
766
+ end
767
+
768
+ class NSVOTableTest < ::Test::Unit::TestCase
769
+ def test_ns
770
+ votable = VOTable.new(File.open('test/voruby/votable/1.1/votable.ns.xml'))
771
+ table = votable.resources.first.tables.first
772
+
773
+ assert_equal 'ra', table.fields[-3].name
774
+ assert_equal 'double', table.fields[-3].datatype
775
+ assert_equal 10, table.fields[-3].width
776
+
777
+ assert_equal -14.0986, table.data.format.trs.first.tds[3].value
778
+ assert_equal 1.0456679, table.data.format.trs[1].tds[-2].value
779
+ end
780
+ end
781
+
782
+ end
783
+ end
784
+ end
785
+ end