rtm 0.1.6 → 0.2

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 (163) hide show
  1. data/DISCLAIMER +10 -33
  2. data/LICENSE +201 -0
  3. data/README +32 -3
  4. data/lib/rtm.rb +126 -74
  5. data/lib/rtm/axes.rb +298 -0
  6. data/lib/rtm/axes/association.rb +76 -0
  7. data/lib/rtm/axes/associations.rb +96 -0
  8. data/lib/rtm/axes/assocs_names_occs.rb +56 -0
  9. data/lib/rtm/axes/characteristic.rb +68 -0
  10. data/lib/rtm/axes/characteristics.rb +93 -0
  11. data/lib/rtm/axes/string.rb +76 -0
  12. data/lib/rtm/axes/strings.rb +87 -0
  13. data/lib/rtm/axes/topic.rb +233 -0
  14. data/lib/rtm/axes/topics.rb +280 -0
  15. data/lib/rtm/{backward_compatibility.rb → deprecated/index_property_set.rb} +3 -0
  16. data/lib/rtm/engine.rb +101 -0
  17. data/lib/rtm/extensions.rb +65 -5
  18. data/lib/rtm/{locator_helpers.rb → helpers/locator.rb} +15 -4
  19. data/lib/rtm/{helpers.rb → helpers/no_output.rb} +3 -0
  20. data/lib/rtm/helpers/uri.rb +13 -0
  21. data/lib/rtm/io.rb +19 -0
  22. data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
  23. data/lib/rtm/io/tmapix_from.rb +155 -0
  24. data/lib/rtm/io/tmapix_to.rb +223 -0
  25. data/lib/rtm/io/to_hash.rb +154 -0
  26. data/lib/rtm/io/to_jtm.rb +53 -103
  27. data/lib/rtm/io/to_rdf.rb +45 -0
  28. data/lib/rtm/io/to_string.rb +21 -8
  29. data/lib/rtm/io/to_xtm1.rb +6 -4
  30. data/lib/rtm/io/to_xtm2.rb +10 -8
  31. data/lib/rtm/io/to_yaml.rb +59 -100
  32. data/lib/rtm/navigation.rb +23 -0
  33. data/lib/rtm/navigation/association/players.rb +25 -0
  34. data/lib/rtm/navigation/name/atomify.rb +19 -0
  35. data/lib/rtm/navigation/name/characteristics.rb +33 -0
  36. data/lib/rtm/navigation/occurrence/atomify.rb +19 -0
  37. data/lib/rtm/navigation/occurrence/characteristics.rb +33 -0
  38. data/lib/rtm/navigation/topic/characteristics.rb +33 -0
  39. data/lib/rtm/navigation/topic/indicators.rb +31 -0
  40. data/lib/rtm/navigation/topic/items.rb +31 -0
  41. data/lib/rtm/navigation/topic/locators.rb +31 -0
  42. data/lib/rtm/navigation/topic/players.rb +27 -0
  43. data/lib/rtm/navigation/topic/supertypes.rb +166 -0
  44. data/lib/rtm/navigation/topic/traverse.rb +51 -0
  45. data/lib/rtm/navigation/topic/types.rb +109 -0
  46. data/lib/rtm/psi.rb +39 -2
  47. data/lib/rtm/sugar.rb +47 -0
  48. data/lib/rtm/sugar/association/hash_access.rb +46 -0
  49. data/lib/rtm/sugar/occurrence/dynamic_value.rb +58 -0
  50. data/lib/rtm/sugar/occurrence/external.rb +53 -0
  51. data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
  52. data/lib/rtm/sugar/role/counterparts.rb +139 -46
  53. data/lib/rtm/sugar/topic/best_name.rb +74 -0
  54. data/lib/rtm/sugar/topic/characteristics.rb +126 -12
  55. data/lib/rtm/sugar/topic/counterparts.rb +145 -10
  56. data/lib/rtm/sugar/topic/hash_access.rb +140 -30
  57. data/lib/rtm/sugar/topic/scoped.rb +114 -0
  58. data/lib/rtm/sugar/topic/topic_ref.rb +86 -0
  59. data/lib/rtm/sugar/topic/typed.rb +207 -0
  60. data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
  61. data/lib/rtm/sugar/topic_map/themes.rb +53 -0
  62. data/lib/rtm/sugar/typed/types.rb +38 -0
  63. data/lib/rtm/validation.rb +7 -4
  64. data/lib/rtm/version.rb +30 -0
  65. data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
  66. data/spec/rtm/axes/association_spec.rb +88 -0
  67. data/spec/rtm/axes/associations_spec.rb +60 -0
  68. data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
  69. data/spec/rtm/axes/characteristic_spec.rb +90 -0
  70. data/spec/rtm/axes/characteristics_spec.rb +85 -0
  71. data/spec/rtm/axes/string_spec.rb +145 -0
  72. data/spec/rtm/axes/strings_spec.rb +168 -0
  73. data/spec/rtm/axes/topic_spec.rb +124 -0
  74. data/spec/rtm/axes/topics_spec.rb +103 -0
  75. data/spec/rtm/base_spec.rb +32 -0
  76. data/spec/rtm/io/tmapix_from_spec.rb +76 -0
  77. data/spec/rtm/io/tmapix_to_spec.rb +159 -0
  78. data/spec/rtm/io/to_hash_spec.rb +90 -0
  79. data/spec/rtm/io/to_rdf_spec.rb +37 -0
  80. data/spec/rtm/io/to_string_spec.rb +122 -0
  81. data/spec/rtm/io/to_yaml_spec.rb +89 -0
  82. data/spec/rtm/navigation/association/players_spec.rb +58 -0
  83. data/spec/rtm/navigation/association_spec.rb +52 -0
  84. data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
  85. data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
  86. data/spec/rtm/navigation/name_spec.rb +52 -0
  87. data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
  88. data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
  89. data/spec/rtm/navigation/occurrence_spec.rb +52 -0
  90. data/spec/rtm/navigation/string_spec.rb +51 -0
  91. data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
  92. data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
  93. data/spec/rtm/navigation/topic/items_spec.rb +44 -0
  94. data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
  95. data/spec/rtm/navigation/topic/players_spec.rb +48 -0
  96. data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
  97. data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
  98. data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
  99. data/spec/rtm/navigation/topic/types_spec.rb +195 -0
  100. data/spec/rtm/navigation/topic_spec.rb +153 -0
  101. data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
  102. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +171 -0
  103. data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
  104. data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
  105. data/spec/rtm/sugar/role/counterparts_spec.rb +193 -0
  106. data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
  107. data/spec/rtm/sugar/topic/characteristics_spec.rb +333 -0
  108. data/spec/rtm/sugar/topic/counterparts_spec.rb +224 -0
  109. data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
  110. data/spec/rtm/sugar/topic/scoped_spec.rb +195 -0
  111. data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
  112. data/spec/rtm/sugar/topic/typed_spec.rb +217 -0
  113. data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
  114. data/spec/rtm/sugar/typed/types_spec.rb +24 -0
  115. data/spec/rtm/tmapi/core/association_spec.rb +169 -0
  116. data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
  117. data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
  118. data/spec/rtm/tmapi/core/name_spec.rb +270 -0
  119. data/spec/rtm/tmapi/core/occurrence_spec.rb +53 -0
  120. data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
  121. data/spec/rtm/tmapi/core/role_spec.rb +73 -0
  122. data/spec/rtm/tmapi/core/scoped_spec.rb +441 -0
  123. data/spec/rtm/tmapi/core/topic_map_spec.rb +716 -0
  124. data/spec/rtm/tmapi/core/topic_spec.rb +1468 -0
  125. data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
  126. data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
  127. data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
  128. data/spec/rtm/tmapi_spec.rb +44 -0
  129. data/spec/rtm/utils/sparql_spec.rb +26 -0
  130. data/spec/rtm_spec.rb +93 -0
  131. data/spec/spec_helper.rb +28 -0
  132. data/test/javalibs/junit-4.5.jar +0 -0
  133. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  134. data/test/tmapi_tests.rb +25 -0
  135. metadata +169 -65
  136. data/COPYRIGHT +0 -4
  137. data/lib/Rakefile.rb +0 -42
  138. data/lib/activetopicmaps.rb +0 -278
  139. data/lib/rtm/backend/active_record.rb +0 -58
  140. data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
  141. data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
  142. data/lib/rtm/backend/active_record/locators.rb +0 -55
  143. data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
  144. data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
  145. data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
  146. data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
  147. data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
  148. data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
  149. data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
  150. data/lib/rtm/backend/active_record/tmdm.rb +0 -298
  151. data/lib/rtm/backend/active_record/topic.rb +0 -87
  152. data/lib/rtm/backend/active_record/topic_map.rb +0 -314
  153. data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
  154. data/lib/rtm/base.rb +0 -92
  155. data/lib/rtm/connect.rb +0 -92
  156. data/lib/rtm/core_ext.rb +0 -6
  157. data/lib/rtm/io/from_xtm2.rb +0 -263
  158. data/lib/rtm/merging/merging.rb +0 -307
  159. data/lib/rtm/pimp_my_api.rb +0 -28
  160. data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
  161. data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
  162. data/lib/run_main_project.rb +0 -16
  163. data/test/base_test.rb +0 -162
@@ -0,0 +1,32 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../spec_helper'
5
+
6
+
7
+ describe "RTM" do
8
+ describe "#create" do
9
+ it "should give back an instance of RTM::TopicMap" do
10
+ # RTM.connect
11
+ # @tm = RTM.create("test:test")
12
+ # @tm.should be_a_kind_of RTM::TopicMap
13
+ # @tm.close
14
+ end
15
+ end
16
+ describe "#[]" do
17
+ it "should allow to see the existing TM's and 2 access them" do
18
+ # RTM.connect
19
+ # RTM[].should be_empty
20
+ # @tm = RTM.create("test:test")
21
+ # @tm_2 = RTM.create("test:test_2")
22
+ # RTM["test:test_2"].include?(@tm_2).should be_true
23
+ # RTM["test:test_2"].length.should == 1
24
+ # RTM["test:test","test:test_2"].length.should == 2
25
+ # RTM[].length.should == 2
26
+ # @tm.close
27
+ # @tm_2.close
28
+ end
29
+ end
30
+
31
+ end
32
+
@@ -0,0 +1,76 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../spec_helper'
5
+
6
+ module RTM::IO::TmapiXFrom::TopicMap
7
+
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ end
12
+ after(:each) do
13
+ @tm.close
14
+ end
15
+
16
+ describe "#from_ltm" do
17
+ it "import into an empty topic map" do
18
+ @tm.from_ltm(File.dirname(__FILE__) + "/../../resources/toyTM.ltm")
19
+ end
20
+ end
21
+
22
+ describe "#from_ctm" do
23
+ it "import into an empty topic map" do
24
+ @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
25
+ end
26
+ end
27
+
28
+ describe "#from_jtm" do
29
+ it "import into an empty topic map" do
30
+ #@tm.from_jtm(File.dirname(__FILE__) + "/../../resources/toyTM.jtm")
31
+ end
32
+ end
33
+
34
+ describe "#from_tmxml" do
35
+ it "import into an empty topic map" do
36
+ #@tm.from_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM.tmxml")
37
+ end
38
+ end
39
+
40
+ describe "#from_xtm10" do
41
+ it "import into an empty topic map" do
42
+ #@tm.from_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_xtm10.xtm")
43
+ end
44
+ it "should provide an alias for from_xtm1" do
45
+ @tm.method(:from_xtm1).should == @tm.method(:from_xtm10)
46
+ end
47
+ end
48
+
49
+ describe "#from_xtm20" do
50
+ it "import into an empty topic map" do
51
+ @tm.from_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM.xtm")
52
+ end
53
+ it "should provide an alias for from_xtm2" do
54
+ @tm.method(:from_xtm2).should == @tm.method(:from_xtm20)
55
+ end
56
+ end
57
+
58
+ describe "#from_xtm" do
59
+ it "import into an empty topic map from xtm v2.0" do
60
+ @tm.from_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM.xtm")
61
+ end
62
+ it "import into an empty topic map from xtm v1.0" do
63
+ #@tm.from_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_xtm10.xtm")
64
+ end
65
+ end
66
+
67
+ describe "#from_n3" do
68
+ it "should be tested"
69
+ end
70
+
71
+ describe "#from_rdfxml" do
72
+ it "should be tested"
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,159 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../spec_helper'
5
+
6
+ module RTM::IO::TmapiXTo::TopicMap
7
+
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ end
12
+ after(:each) do
13
+ @tm.close
14
+ end
15
+
16
+ describe "#to_xtm20" do
17
+ before(:each) do
18
+ @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
19
+ end
20
+ it "should serialize a topic map to String" do
21
+ @tm.to_xtm20.should be_a_kind_of String
22
+ end
23
+ it "should serialize a topic map to a file" do
24
+ @tm.to_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm20").should be_true
25
+ end
26
+ it "should serialize a topic map to a file given a base iri" do
27
+ @tm.to_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm20", "http://www.example.org/testtm").should be_true
28
+ end
29
+ it "should serialize a topic map to a java.io.Stream" do
30
+ @tm.to_xtm20(java.io.ByteArrayOutputStream.new).should be_true
31
+ end
32
+ it "should be the case that the xtm20 writer does not respond to :setProperty" do
33
+ org.tmapix.io.XTM20TopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
34
+ end
35
+ it "should provide an alias for to_xtm" do
36
+ @tm.method(:to_xtm).should == @tm.method(:to_xtm20)
37
+ end
38
+ it "should provide an alias for to_xtm2" do
39
+ @tm.method(:to_xtm2).should == @tm.method(:to_xtm20)
40
+ end
41
+ end
42
+
43
+ describe "#to_xtm10" do
44
+ before(:each) do
45
+ @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
46
+ end
47
+ it "should serialize a topic map to String" do
48
+ @tm.to_xtm10.should be_a_kind_of String
49
+ end
50
+ it "should serialize a topic map to a file" do
51
+ @tm.to_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm10").should be_true
52
+ end
53
+ it "should serialize a topic map to a file given a base iri" do
54
+ @tm.to_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm10", "http://www.example.org/testtm").should be_true
55
+ end
56
+ it "should serialize a topic map to a java.io.Stream" do
57
+ @tm.to_xtm10(java.io.ByteArrayOutputStream.new).should be_true
58
+ end
59
+ it "should be the case that the xtm10 writer does not respond to :setProperty" do
60
+ org.tmapix.io.XTM10TopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
61
+ end
62
+ it "should provide an alias for to_xtm1" do
63
+ @tm.method(:to_xtm1).should == @tm.method(:to_xtm10)
64
+ end
65
+ end
66
+
67
+ describe "#to_jtm" do
68
+ before(:each) do
69
+ @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
70
+ end
71
+ it "should serialize a topic map to String" do
72
+ @tm.to_jtm.should be_a_kind_of String
73
+ end
74
+ it "should serialize a topic map to a file" do
75
+ @tm.to_jtm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.jtm").should be_true
76
+ end
77
+ it "should serialize a topic map to a file given a base iri" do
78
+ @tm.to_jtm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.jtm", "http://www.example.org/testtm").should be_true
79
+ end
80
+ it "should serialize a topic map to a java.io.Stream" do
81
+ @tm.to_jtm(java.io.ByteArrayOutputStream.new).should be_true
82
+ end
83
+ it "should be the case that the xtm10 writer does not respond to :setProperty" do
84
+ org.tmapix.io.JTMTopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
85
+ end
86
+ it "should provide an alias fpr to_json" do
87
+ @tm.method(:to_json).should == @tm.method(:to_jtm)
88
+ end
89
+ end
90
+
91
+ describe "#to_ltm" do
92
+ before(:each) do
93
+ @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
94
+ end
95
+ it "should serialize a topic map to String" do
96
+ @tm.to_ltm.should be_a_kind_of String
97
+ end
98
+ it "should serialize a topic map to a file" do
99
+ @tm.to_ltm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ltm").should be_true
100
+ end
101
+ it "should serialize a topic map to a file given a base iri" do
102
+ @tm.to_ltm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ltm", "http://www.example.org/testtm").should be_true
103
+ end
104
+ it "should serialize a topic map to a java.io.Stream" do
105
+ @tm.to_ltm(java.io.ByteArrayOutputStream.new).should be_true
106
+ end
107
+ it "should be the case that the xtm10 writer does not respond to :setProperty" do
108
+ org.tmapix.io.LTMTopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
109
+ end
110
+ end
111
+
112
+ describe "#to_tmxml" do
113
+ before(:each) do
114
+ @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
115
+ end
116
+ it "should serialize a topic map to String" do
117
+ @tm.to_tmxml.should be_a_kind_of String
118
+ end
119
+ it "should serialize a topic map to a file" do
120
+ @tm.to_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.tmxml").should be_true
121
+ end
122
+ it "should serialize a topic map to a file given a base iri" do
123
+ @tm.to_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.tmxml", "http://www.example.org/testtm").should be_true
124
+ end
125
+ it "should serialize a topic map to a java.io.Stream" do
126
+ @tm.to_tmxml(java.io.ByteArrayOutputStream.new).should be_true
127
+ end
128
+ it "should be the case that the xtm10 writer does not respond to :setProperty" do
129
+ org.tmapix.io.TMXMLTopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
130
+ end
131
+ end
132
+
133
+ describe "#to_ctm" do
134
+ before(:each) do
135
+ @tm.from_xtm(File.dirname(__FILE__) + "/../../resources/toyTM.xtm")
136
+ end
137
+ it "should serialize a topic map to String" do
138
+ @tm.to_ctm.should be_a_kind_of String
139
+ end
140
+ it "should serialize a topic map to a file" do
141
+ @tm.to_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm").should be_true
142
+ end
143
+ it "should serialize a topic map to a file given a base iri" do
144
+ @tm.to_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm", "http://www.example.org/testtm").should be_true
145
+ end
146
+ it "should serialize a topic map to a java.io.Stream" do
147
+ @tm.to_ctm(java.io.ByteArrayOutputStream.new).should be_true
148
+ end
149
+ it "should be the case that the xtm10 writer does respond to :setProperty" do
150
+ de.topicmapslab.ctm.writer.core.CTMTopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should respond_to(:setProperty)
151
+ end
152
+ it "should read it afterwards" do
153
+ emptyTM = get_used_tm_sys.create("http://blub.org/")
154
+ emptyTM.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm")
155
+ end
156
+ end
157
+
158
+ end
159
+ end
@@ -0,0 +1,90 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../spec_helper'
5
+
6
+ module RTM::IO::ToHash
7
+
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ @tm.reifier!
12
+ @topic = @tm.get!("a:b")
13
+ @name = @topic.create_name("name type", "name value", ["theme1", "theme2"])
14
+ @name.reifier!
15
+ @var = @name.create_variant(1234, RTM::PSI[:String], ["theme5"])
16
+ @var.reifier!
17
+ @occ = @topic.create_occurrence("occ type", "occ value", :datatype => RTM::PSI[:IRI], :scope => ["theme3", "theme4"])
18
+ @occ.reifier!
19
+ @assoc = @tm.create_association("assoc type", ["theme6", "theme7"])
20
+ @assoc.reifier!
21
+ @role = @assoc.create_role("role type", "role player")
22
+ @role.reifier!
23
+ @locator = @tm.create_locator("http://www.example.org/test this locator")
24
+ end
25
+ after(:each) do
26
+ @output.should be_a_kind_of Hash
27
+ @tm.close
28
+ end
29
+
30
+ describe "#to_hash" do
31
+ describe "for TopicMap" do
32
+ before(:each) do
33
+ @tm.should be_a_kind_of RTM::TopicMap
34
+ end
35
+ it "should give back a Hash" do
36
+ @output = @tm.to_hash
37
+ end
38
+ end
39
+ describe "for Topic" do
40
+ before(:each) do
41
+ @topic.should be_a_kind_of RTM::Topic
42
+ end
43
+ it "should give back a Hash" do
44
+ @output = @topic.to_hash
45
+ end
46
+ end
47
+ describe "for Association" do
48
+ before(:each) do
49
+ @assoc.should be_a_kind_of RTM::Association
50
+ end
51
+ it "should give back a Hash" do
52
+ @output = @assoc.to_hash
53
+ end
54
+ end
55
+ describe "for Role" do
56
+ before(:each) do
57
+ @role.should be_a_kind_of RTM::Role
58
+ end
59
+ it "should give back a Hash" do
60
+ @output = @role.to_hash
61
+ end
62
+ end
63
+ describe "for Name" do
64
+ before(:each) do
65
+ @name.should be_a_kind_of RTM::Name
66
+ end
67
+ it "should give back a Hash" do
68
+ @output = @name.to_hash
69
+ end
70
+ end
71
+ describe "for Occurrence" do
72
+ before(:each) do
73
+ @occ.should be_a_kind_of RTM::Occurrence
74
+ end
75
+ it "should give back a Hash" do
76
+ @output = @occ.to_hash
77
+ end
78
+ end
79
+ describe "for Variant" do
80
+ before(:each) do
81
+ @var.should be_a_kind_of RTM::Variant
82
+ end
83
+ it "should give back a Hash" do
84
+ @output = @var.to_hash
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ end
@@ -0,0 +1,37 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../spec_helper'
5
+
6
+ module RTM::IO::ToRDF::TopicMap
7
+
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
12
+ end
13
+ after(:each) do
14
+ @tm.close
15
+ end
16
+
17
+ describe "#to_rdf" do
18
+ it "should be callable on an Ontopia topic map" do
19
+ if implementation_for_spec == :ontopia
20
+ lambda{@tm.to_rdf}.should_not raise_error
21
+ @tm.to_rdf.should be_a_kind_of String
22
+ else
23
+ lambda{@tm.to_rdf}.should raise_error
24
+ end
25
+ end
26
+ end
27
+
28
+ describe "#to_rdf_ontopia" do
29
+ it "should be callable on an Ontopia topic map" do
30
+ if implementation_for_spec == :ontopia
31
+ @tm.to_rdf_ontopia.should be_a_kind_of String
32
+ end
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,122 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../spec_helper'
5
+
6
+ module RTM::IO::ToString
7
+
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ @tm.reifier!
12
+ @topic = @tm.get!("a:b")
13
+ @name = @topic.create_name("name type", "name value", ["theme1", "theme2"])
14
+ @name.reifier!
15
+ @var = @name.create_variant(1234, RTM::PSI[:String], ["theme5"])
16
+ @var.reifier!
17
+ @occ = @topic.create_occurrence("occ type", "occ value", :datatype => RTM::PSI[:IRI], :scope => ["theme3", "theme4"])
18
+ @occ.reifier!
19
+ @assoc = @tm.create_association("assoc type", ["theme6", "theme7"])
20
+ @assoc.reifier!
21
+ @role = @assoc.create_role("role type", "role player")
22
+ @role.reifier!
23
+ @locator = @tm.create_locator("http://www.example.org/test this locator")
24
+ end
25
+ after(:each) do
26
+ @output.should be_a_kind_of String
27
+ @tm.close
28
+ end
29
+
30
+ describe "#to_s" do
31
+ describe "for TopicMap" do
32
+ before(:each) do
33
+ @tm.should be_a_kind_of RTM::TopicMap
34
+ end
35
+ it "should give back a String using the short version" do
36
+ @output = @tm.to_s(:short)
37
+ end
38
+ it "should give back a String using the long version" do
39
+ @output = @tm.to_s(:long)
40
+ end
41
+ end
42
+ describe "for Topic" do
43
+ before(:each) do
44
+ @topic.should be_a_kind_of RTM::Topic
45
+ end
46
+ it "should give back a String using the short version" do
47
+ @output = @topic.to_s(:short)
48
+ end
49
+ it "should give back a String using the long version" do
50
+ @output = @topic.to_s(:long)
51
+ end
52
+ end
53
+ describe "for Association" do
54
+ before(:each) do
55
+ @assoc.should be_a_kind_of RTM::Association
56
+ end
57
+ it "should give back a String using the short version" do
58
+ @output = @assoc.to_s(:short)
59
+ end
60
+ it "should give back a String using the long version" do
61
+ @output = @assoc.to_s(:long)
62
+ end
63
+ end
64
+ describe "for Role" do
65
+ before(:each) do
66
+ @role.should be_a_kind_of RTM::Role
67
+ end
68
+ it "should give back a String using the short version" do
69
+ @output = @role.to_s(:short)
70
+ end
71
+ it "should give back a String using the long version" do
72
+ @output = @role.to_s(:long)
73
+ end
74
+ end
75
+ describe "for Name" do
76
+ before(:each) do
77
+ @name.should be_a_kind_of RTM::Name
78
+ end
79
+ it "should give back a String using the short version" do
80
+ @output = @name.to_s(:short)
81
+ end
82
+ it "should give back a String using the long version" do
83
+ @output = @name.to_s(:long)
84
+ end
85
+ end
86
+ describe "for Occurrence" do
87
+ before(:each) do
88
+ @occ.should be_a_kind_of RTM::Occurrence
89
+ end
90
+ it "should give back a String using the short version" do
91
+ @output = @occ.to_s(:short)
92
+ end
93
+ it "should give back a String using the long version" do
94
+ @output = @occ.to_s(:long)
95
+ end
96
+ end
97
+ describe "for Variant" do
98
+ before(:each) do
99
+ @var.should be_a_kind_of RTM::Variant
100
+ end
101
+ it "should give back a String using the short version" do
102
+ @output = @var.to_s(:short)
103
+ end
104
+ it "should give back a String using the short version" do
105
+ @output = @var.to_s(:long)
106
+ end
107
+ end
108
+ describe "for Locator" do
109
+ before(:each) do
110
+ @locator.should be_a_kind_of RTM::Locator
111
+ end
112
+ it "should give back a String using the short version" do
113
+ @output = @locator.to_s(:short)
114
+ end
115
+ it "should give back a String using the long version" do
116
+ @output = @locator.to_s(:long)
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ end