rtm 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data/README +38 -3
  2. data/lib/rtm.rb +25 -47
  3. data/lib/rtm/axes.rb +7 -4
  4. data/lib/rtm/axes/association.rb +1 -1
  5. data/lib/rtm/axes/associations.rb +1 -1
  6. data/lib/rtm/axes/characteristic.rb +1 -1
  7. data/lib/rtm/axes/characteristics.rb +1 -1
  8. data/lib/rtm/axes/topic.rb +3 -3
  9. data/lib/rtm/axes/topics.rb +3 -3
  10. data/lib/rtm/engine.rb +48 -5
  11. data/lib/rtm/extensions.rb +58 -8
  12. data/lib/rtm/io.rb +2 -1
  13. data/lib/rtm/io/tmapix_from.rb +155 -0
  14. data/lib/rtm/io/tmapix_to.rb +223 -0
  15. data/lib/rtm/io/to_hash.rb +79 -41
  16. data/lib/rtm/io/to_jtm.rb +1 -1
  17. data/lib/rtm/io/to_rdf.rb +20 -5
  18. data/lib/rtm/io/to_string.rb +13 -2
  19. data/lib/rtm/io/to_yaml.rb +39 -11
  20. data/lib/rtm/navigation.rb +1 -15
  21. data/lib/rtm/navigation/association/players.rb +1 -1
  22. data/lib/rtm/navigation/name/characteristics.rb +1 -1
  23. data/lib/rtm/navigation/occurrence/characteristics.rb +1 -1
  24. data/lib/rtm/navigation/topic/characteristics.rb +1 -1
  25. data/lib/rtm/navigation/topic/players.rb +1 -1
  26. data/lib/rtm/navigation/topic/supertypes.rb +21 -17
  27. data/lib/rtm/navigation/topic/traverse.rb +1 -1
  28. data/lib/rtm/navigation/topic/types.rb +6 -4
  29. data/lib/rtm/psi.rb +6 -0
  30. data/lib/rtm/sugar.rb +42 -29
  31. data/lib/rtm/sugar/association/hash_access.rb +3 -3
  32. data/lib/rtm/sugar/occurrence/dynamic_value.rb +39 -56
  33. data/lib/rtm/sugar/occurrence/external.rb +53 -0
  34. data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
  35. data/lib/rtm/sugar/role/counterparts.rb +12 -6
  36. data/lib/rtm/sugar/topic/best_name.rb +74 -0
  37. data/lib/rtm/sugar/topic/characteristics.rb +10 -10
  38. data/lib/rtm/sugar/topic/counterparts.rb +131 -119
  39. data/lib/rtm/sugar/topic/scoped.rb +102 -53
  40. data/lib/rtm/sugar/topic/topic_ref.rb +63 -12
  41. data/lib/rtm/sugar/topic/typed.rb +50 -2
  42. data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
  43. data/lib/rtm/sugar/topic_map/themes.rb +53 -0
  44. data/lib/rtm/sugar/typed/types.rb +1 -1
  45. data/lib/rtm/validation.rb +2 -2
  46. data/lib/rtm/version.rb +18 -6
  47. data/spec/rtm/axes/string_spec.rb +7 -7
  48. data/spec/rtm/axes/strings_spec.rb +10 -10
  49. data/spec/rtm/io/tmapix_from_spec.rb +76 -0
  50. data/spec/rtm/io/tmapix_to_spec.rb +159 -0
  51. data/spec/rtm/io/to_hash_spec.rb +90 -0
  52. data/spec/rtm/io/to_rdf_spec.rb +37 -0
  53. data/spec/rtm/io/to_string_spec.rb +122 -0
  54. data/spec/rtm/io/to_yaml_spec.rb +89 -0
  55. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +156 -1
  56. data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
  57. data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
  58. data/spec/rtm/sugar/role/counterparts_spec.rb +174 -172
  59. data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
  60. data/spec/rtm/sugar/topic/characteristics_spec.rb +20 -5
  61. data/spec/rtm/sugar/topic/counterparts_spec.rb +41 -1
  62. data/spec/rtm/sugar/topic/hash_access_spec.rb +1 -1
  63. data/spec/rtm/sugar/topic/scoped_spec.rb +178 -114
  64. data/spec/rtm/sugar/topic/topic_ref_spec.rb +10 -10
  65. data/spec/rtm/sugar/topic/typed_spec.rb +196 -134
  66. data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
  67. data/spec/rtm/sugar/typed/types_spec.rb +1 -1
  68. data/spec/rtm/tmapi/core/association_spec.rb +2 -2
  69. data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
  70. data/spec/rtm/tmapi/core/name_spec.rb +186 -1
  71. data/spec/rtm/tmapi/core/occurrence_spec.rb +24 -67
  72. data/spec/rtm/tmapi/core/reifiable_spec.rb +2 -2
  73. data/spec/rtm/tmapi/core/scoped_spec.rb +40 -2
  74. data/spec/rtm/tmapi/core/topic_map_spec.rb +98 -30
  75. data/spec/rtm/tmapi/core/topic_spec.rb +558 -82
  76. data/spec/rtm/tmapi/core/variant_spec.rb +3 -3
  77. data/spec/rtm_spec.rb +0 -1
  78. data/spec/spec_helper.rb +7 -2
  79. data/test/javalibs/junit-4.5.jar +0 -0
  80. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  81. data/test/tmapi_tests.rb +25 -0
  82. metadata +66 -11
  83. data/lib/rtm/io/ontopia_io.rb +0 -25
  84. data/lib/rtm/io/tmapix.rb +0 -234
  85. data/lib/rtm/sugar/occurrence/externalize.rb +0 -31
  86. data/spec/rtm/io/tmapix_spec.rb +0 -85
  87. data/test/base_unit_test.rb +0 -161
  88. data/test/base_unit_test_tmapi.rb +0 -165
@@ -3,7 +3,7 @@
3
3
 
4
4
  require File.dirname(__FILE__) + '/../../../spec_helper'
5
5
 
6
- module Sugar::Topic::Counterparts
6
+ module RTM::Sugar::Topic::Counterparts
7
7
  describe self do
8
8
  before(:each) do
9
9
  @tm = get_used_tm_sys_tm
@@ -180,5 +180,45 @@ module Sugar::Topic::Counterparts
180
180
  end
181
181
  end
182
182
 
183
+ describe self do
184
+ describe "unary associations" do
185
+ before(:each) do
186
+ @tm = get_used_tm_sys_tm
187
+ @player = @tm.get!("player")
188
+ end
189
+ after(:each) do
190
+ @tm.close
191
+ end
192
+ describe "#counterparts" do
193
+ it "should handle unary associations" do
194
+ @tm.create_association("assoc_type", "roletype" => "player")
195
+ @player.counterparts.should be_empty
196
+ @player.counterparts(:atype => "1", :rtype => "2", :otype => "3").should be_empty
197
+ end
198
+ end
199
+ describe "#counterplayers" do
200
+ it "should handle unary associations" do
201
+ @tm.create_association("assoc_type", "roletype" => "player")
202
+ @player.counterplayers.should be_empty
203
+ @player.counterplayers(:atype => "1", :rtype => "2", :otype => "3").should be_empty
204
+ end
205
+ end
206
+ describe "#peers" do
207
+ it "should handle unary associations" do
208
+ @tm.create_association("assoc_type", "roletype" => "player")
209
+ @player.peers.should be_empty
210
+ @player.peers("1").should be_empty
211
+ end
212
+ end
213
+ describe "#associations_played" do
214
+ it "should handle unary associations" do
215
+ assoc = @tm.create_association("assoc_type", "roletype" => "player")
216
+ @player.associations_played.size.should == 1
217
+ @player.associations_played.should include(assoc)
218
+ end
219
+ end
220
+ end
221
+ end
222
+
183
223
  end
184
224
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  require File.dirname(__FILE__) + '/../../../spec_helper'
5
5
 
6
- module Sugar::Topic::HashAccess
6
+ module RTM::Sugar::Topic::HashAccess
7
7
 
8
8
  describe self do
9
9
  before(:each) do
@@ -3,129 +3,193 @@
3
3
 
4
4
  require File.dirname(__FILE__) + '/../../../spec_helper'
5
5
 
6
- module Sugar
7
- module Topic
8
- module Scoped
9
- describe self do
10
- before(:all) do
11
- @tm = get_used_tm_sys_tm
12
- @theme0 = @tm.get!("negative")
13
- @theme1 = @tm.get!("german")
14
- @theme2 = @tm.get!("english")
15
- @theme3 = @tm.get!("2009")
16
- @theme4 = @tm.get!("sorbian")
17
- @test_theme = @tm.get!("dummy")
18
- @leipzig = @tm.get!("leipzig")
19
- @germany = @tm.get!("germany")
20
- @name1 = @leipzig.create_name("Leipzig",[@theme1,@theme2])
21
- @name2 = @germany.create_name("Germany",[@theme2,@test_theme])
22
- @name3 = @germany.create_name("Deutschland",[@theme1])
23
- @name4 = @leipzig.create_name("Leipzisch")
24
- @name5 = @leipzig.create_name("Lipsk",[@theme4])
25
- @occ1 = @leipzig.create_occurrence("inhabitants","500000", :scope => [@theme3])
26
- @occ2 = @germany.create_occurrence("states","16", :scope => [@test_theme])
27
- @occ3 = @leipzig.create_occurrence("state","Sachsen")
28
- @tm.create_association("assoc_dummy")
29
- @assoc = @tm.create_association("contained", [@test_theme])
30
- @role1 = @assoc.create_role("containee",@leipzig)
31
- @role2 = @assoc.create_role("container",@germany)
32
- @variant = @name1.create_variant("LE",[@test_theme])
33
- end
34
- after(:all) do
35
- @tm.close
36
- end
6
+ module RTM::Sugar::Topic
7
+ module Scoped
8
+ describe self do
9
+ before(:all) do
10
+ @tm = get_used_tm_sys_tm
11
+ @theme0 = @tm.get!("negative")
12
+ @theme1 = @tm.get!("german")
13
+ @theme2 = @tm.get!("english")
14
+ @theme3 = @tm.get!("2009")
15
+ @theme4 = @tm.get!("sorbian")
16
+ @test_theme = @tm.get!("dummy")
17
+ @leipzig = @tm.get!("leipzig")
18
+ @germany = @tm.get!("germany")
19
+ @name1 = @leipzig.create_name("Leipzig",[@theme1,@theme2])
20
+ @name2 = @germany.create_name("Germany",[@theme2,@test_theme])
21
+ @name3 = @germany.create_name("Deutschland",[@theme1])
22
+ @name4 = @leipzig.create_name("Leipzisch")
23
+ @name5 = @leipzig.create_name("Lipsk",[@theme4])
24
+ @occ1 = @leipzig.create_occurrence("inhabitants","500000", :scope => [@theme3])
25
+ @occ2 = @germany.create_occurrence("states","16", :scope => [@test_theme])
26
+ @occ3 = @leipzig.create_occurrence("state","Sachsen")
27
+ @tm.create_association("assoc_dummy")
28
+ @assoc = @tm.create_association("contained", [@test_theme])
29
+ @role1 = @assoc.create_role("containee",@leipzig)
30
+ @role2 = @assoc.create_role("container",@germany)
31
+ @variant = @name1.create_variant("LE",[@test_theme])
32
+ end
33
+ after(:all) do
34
+ @tm.close
35
+ end
37
36
 
38
- describe "#scoped" do
39
- it "should give back all constructs which have this Topic in their scope" do
40
- @theme1.scoped.size.should == 3
41
- @theme1.scoped.should include(@name1)
42
- @theme1.scoped.should include(@name3)
43
- @theme1.scoped.should include(@variant)
44
- @theme2.scoped.size.should == 3
45
- @theme2.scoped.should include(@name1)
46
- @theme2.scoped.should include(@name2)
47
- @theme2.scoped.should include(@variant)
48
- @theme3.scoped.size.should == 1
49
- @theme3.scoped.should include(@occ1)
50
- @theme4.scoped.size.should == 1
51
- @theme4.scoped.should include(@name5)
52
- @test_theme.scoped.size.should == 4
53
- @test_theme.scoped.should include(@name2)
54
- @test_theme.scoped.should include(@occ2)
55
- @test_theme.scoped.should include(@assoc)
56
- @test_theme.scoped.should include(@variant)
57
- end
58
- it "should give back an empty Array if there are no Constructs which have this Topic in their scope" do
59
- @theme0.scoped.should be_empty
60
- end
37
+ describe "#scoped" do
38
+ it "should give back all constructs which have this Topic in their scope" do
39
+ @theme1.scoped.size.should == 3
40
+ @theme1.scoped.should include(@name1)
41
+ @theme1.scoped.should include(@name3)
42
+ @theme1.scoped.should include(@variant)
43
+ @theme2.scoped.size.should == 3
44
+ @theme2.scoped.should include(@name1)
45
+ @theme2.scoped.should include(@name2)
46
+ @theme2.scoped.should include(@variant)
47
+ @theme3.scoped.size.should == 1
48
+ @theme3.scoped.should include(@occ1)
49
+ @theme4.scoped.size.should == 1
50
+ @theme4.scoped.should include(@name5)
51
+ @test_theme.scoped.size.should == 4
52
+ @test_theme.scoped.should include(@name2)
53
+ @test_theme.scoped.should include(@occ2)
54
+ @test_theme.scoped.should include(@assoc)
55
+ @test_theme.scoped.should include(@variant)
61
56
  end
62
-
63
- describe "#scoped_associations" do
64
- it "should give back all Associations which have this Topic in their scope" do
65
- @theme1.scoped_associations.should be_empty
66
- @theme2.scoped_associations.should be_empty
67
- @theme3.scoped_associations.should be_empty
68
- @theme4.scoped_associations.should be_empty
69
- @test_theme.scoped_associations.size.should == 1
70
- @test_theme.scoped_associations.should include(@assoc)
71
- end
72
- it "should give back an empty Array if there are no Associations which have this Topic in their scope" do
73
- @theme0.scoped_associations.should be_empty
74
- end
57
+ it "should give back an empty Array if there are no Constructs which have this Topic in their scope" do
58
+ @theme0.scoped.should be_empty
75
59
  end
60
+ end
76
61
 
77
- describe "#scoped_names" do
78
- it "should give back all Names which have this Topic in their scope" do
79
- @theme1.scoped_names.size.should == 2
80
- @theme1.scoped_names.should include(@name1)
81
- @theme1.scoped_names.should include(@name3)
82
- @theme2.scoped_names.size.should == 2
83
- @theme2.scoped_names.should include(@name1)
84
- @theme2.scoped_names.should include(@name2)
85
- @theme3.scoped_names.should be_empty
86
- @theme4.scoped_names.size.should == 1
87
- @theme4.scoped_names.should include(@name5)
88
- @test_theme.scoped_names.size.should == 1
89
- @test_theme.scoped_names.should include(@name2)
90
- end
91
- it "should give back an empty Array if there are no Names which have this Topic in their scope" do
92
- @theme0.scoped_names.should be_empty
93
- end
62
+ describe "#scoped_associations" do
63
+ it "should give back all Associations which have this Topic in their scope" do
64
+ @theme1.scoped_associations.should be_empty
65
+ @theme2.scoped_associations.should be_empty
66
+ @theme3.scoped_associations.should be_empty
67
+ @theme4.scoped_associations.should be_empty
68
+ @test_theme.scoped_associations.size.should == 1
69
+ @test_theme.scoped_associations.should include(@assoc)
70
+ end
71
+ it "should give back an empty Array if there are no Associations which have this Topic in their scope" do
72
+ @theme0.scoped_associations.should be_empty
94
73
  end
74
+ end
95
75
 
96
- describe "#scoped_occurrences" do
97
- it "should give back all Occurrences which have this Topic in their scope" do
98
- @theme1.scoped_occurrences.should be_empty
99
- @theme2.scoped_occurrences.should be_empty
100
- @theme3.scoped_occurrences.size.should == 1
101
- @theme3.scoped_occurrences.should include(@occ1)
102
- @theme4.scoped_occurrences.should be_empty
103
- @test_theme.scoped_occurrences.size.should == 1
104
- @test_theme.scoped_occurrences.should include(@occ2)
105
- end
106
- it "should give back an empty Array if there are no Occurrences which have this Topic in their scope" do
107
- @theme0.scoped_occurrences.should be_empty
108
- end
76
+ describe "#scoped_names" do
77
+ it "should give back all Names which have this Topic in their scope" do
78
+ @theme1.scoped_names.size.should == 2
79
+ @theme1.scoped_names.should include(@name1)
80
+ @theme1.scoped_names.should include(@name3)
81
+ @theme2.scoped_names.size.should == 2
82
+ @theme2.scoped_names.should include(@name1)
83
+ @theme2.scoped_names.should include(@name2)
84
+ @theme3.scoped_names.should be_empty
85
+ @theme4.scoped_names.size.should == 1
86
+ @theme4.scoped_names.should include(@name5)
87
+ @test_theme.scoped_names.size.should == 1
88
+ @test_theme.scoped_names.should include(@name2)
109
89
  end
90
+ it "should give back an empty Array if there are no Names which have this Topic in their scope" do
91
+ @theme0.scoped_names.should be_empty
92
+ end
93
+ end
110
94
 
111
- describe "#scoped_variants" do
112
- it "should give back all Variants which have this Topic in their scope" do
113
- @theme1.scoped_variants.size.should == 1
114
- @theme1.scoped_variants.should include(@variant)
115
- @theme2.scoped_variants.size.should == 1
116
- @theme2.scoped_variants.should include(@variant)
117
- @theme3.scoped_variants.should be_empty
118
- @theme4.scoped_variants.should be_empty
119
- @test_theme.scoped_variants.size.should == 1
120
- @test_theme.scoped_variants.should include(@variant)
121
- end
122
- it "should give back an empty Array if there are no Variants which have this Topic in their scope" do
123
- @theme0.scoped_variants.should be_empty
124
- end
95
+ describe "#scoped_occurrences" do
96
+ it "should give back all Occurrences which have this Topic in their scope" do
97
+ @theme1.scoped_occurrences.should be_empty
98
+ @theme2.scoped_occurrences.should be_empty
99
+ @theme3.scoped_occurrences.size.should == 1
100
+ @theme3.scoped_occurrences.should include(@occ1)
101
+ @theme4.scoped_occurrences.should be_empty
102
+ @test_theme.scoped_occurrences.size.should == 1
103
+ @test_theme.scoped_occurrences.should include(@occ2)
104
+ end
105
+ it "should give back an empty Array if there are no Occurrences which have this Topic in their scope" do
106
+ @theme0.scoped_occurrences.should be_empty
125
107
  end
108
+ end
126
109
 
127
- end #of describe self
128
-
129
- end
110
+ describe "#scoped_variants" do
111
+ it "should give back all Variants which have this Topic in their scope" do
112
+ @theme1.scoped_variants.size.should == 1
113
+ @theme1.scoped_variants.should include(@variant)
114
+ @theme2.scoped_variants.size.should == 1
115
+ @theme2.scoped_variants.should include(@variant)
116
+ @theme3.scoped_variants.should be_empty
117
+ @theme4.scoped_variants.should be_empty
118
+ @test_theme.scoped_variants.size.should == 1
119
+ @test_theme.scoped_variants.should include(@variant)
120
+ end
121
+ it "should give back an empty Array if there are no Variants which have this Topic in their scope" do
122
+ @theme0.scoped_variants.should be_empty
123
+ end
124
+ end
125
+
126
+ describe "#used_as_theme?" do
127
+ it "should give back true if this topic is used as theme in a scope" do
128
+ @theme1.used_as_theme?.should be_true
129
+ @theme2.used_as_theme?.should be_true
130
+ @theme3.used_as_theme?.should be_true
131
+ @theme4.used_as_theme?.should be_true
132
+ @test_theme.used_as_theme?.should be_true
133
+ end
134
+ it "should give back false if this topic is not used as theme in a scope" do
135
+ @theme0.used_as_theme?.should be_false
136
+ end
137
+ end
138
+
139
+ describe "#used_as_association_theme?" do
140
+ it "should give back true if this topic is used as theme in a scope of an association" do
141
+ @test_theme.used_as_association_theme?.should be_true
142
+ end
143
+ it "should give back false if this topic is not used as theme in a scope of an association" do
144
+ @theme0.used_as_association_theme?.should be_false
145
+ @theme1.used_as_association_theme?.should be_false
146
+ @theme2.used_as_association_theme?.should be_false
147
+ @theme3.used_as_association_theme?.should be_false
148
+ @theme4.used_as_association_theme?.should be_false
149
+ end
150
+ end
151
+
152
+ describe "#used_as_name_theme?" do
153
+ it "should give back true if this topic is used as theme in a scope of a name" do
154
+ @test_theme.used_as_name_theme?.should be_true
155
+ @theme1.used_as_name_theme?.should be_true
156
+ @theme2.used_as_name_theme?.should be_true
157
+ @theme4.used_as_name_theme?.should be_true
158
+ end
159
+ it "should give back false if this topic is not used as theme in a scope of a name" do
160
+ @theme0.used_as_name_theme?.should be_false
161
+ @theme3.used_as_name_theme?.should be_false
162
+
163
+ end
164
+ end
165
+
166
+ describe "#used_as_occurrence_theme?" do
167
+ it "should give back true if this topic is used as theme in a scope of an occurrence" do
168
+ @test_theme.used_as_occurrence_theme?.should be_true
169
+ @theme3.used_as_occurrence_theme?.should be_true
170
+ end
171
+ it "should give back false if this topic is not used as theme in a scope of an occurrence" do
172
+ @theme0.used_as_occurrence_theme?.should be_false
173
+ @theme1.used_as_occurrence_theme?.should be_false
174
+ @theme2.used_as_occurrence_theme?.should be_false
175
+ @theme4.used_as_occurrence_theme?.should be_false
176
+ end
177
+ end
178
+
179
+ describe "#used_as_variant_theme?" do
180
+ it "should give back true if this topic is used as theme in a scope of a variant" do
181
+ @test_theme.used_as_variant_theme?.should be_true
182
+ @theme1.used_as_variant_theme?.should be_true
183
+ @theme2.used_as_variant_theme?.should be_true
184
+ end
185
+ it "should give back false if this topic is not used as theme in a scope of a variant" do
186
+ @theme0.used_as_variant_theme?.should be_false
187
+ @theme3.used_as_variant_theme?.should be_false
188
+ @theme4.used_as_variant_theme?.should be_false
189
+ end
190
+ end
191
+
192
+ end #of describe self
130
193
  end
131
194
  end
195
+
@@ -14,28 +14,28 @@ module Sugar
14
14
  after(:each) do
15
15
  @tm.close
16
16
  end
17
- describe "#topic_references" do
17
+ describe "#references" do
18
18
  it "should not give back an empty Array" do
19
- @topic.topic_references.should_not be_empty
19
+ @topic.references.should_not be_empty
20
20
  end
21
21
  it "should give back an item identifier that starts with a ^" do
22
22
  pending if implementation_for_spec == :ontopia
23
- @topic.topic_references.first[0].should == ?^
24
- @topic.topic_references.should include("^http://www.topicmapslab.de/uni_leipzig")
23
+ @topic.references.first[0].should == ?^
24
+ @topic.references.should include("^http://www.topicmapslab.de/uni_leipzig")
25
25
  end
26
26
  it "should give back subject locators also" do
27
27
  pending if implementation_for_spec == :ontopia
28
28
  @topic.addSubjectLocator(@tm.create_locator("uni_leipzig"))
29
- @topic.topic_references.size.should == 2
30
- @topic.topic_references.should include("^http://www.topicmapslab.de/uni_leipzig")
31
- @topic.topic_references.should include("=http://www.topicmapslab.de/uni_leipzig")
29
+ @topic.references.size.should == 2
30
+ @topic.references.should include("^http://www.topicmapslab.de/uni_leipzig")
31
+ @topic.references.should include("=http://www.topicmapslab.de/uni_leipzig")
32
32
  end
33
33
  it "should give back subject identifiers also" do
34
34
  pending if implementation_for_spec == :ontopia
35
35
  @topic.add_subject_identifier(@tm.create_locator("uni_leipzig"))
36
- @topic.topic_references.size.should == 2
37
- @topic.topic_references.should include("^http://www.topicmapslab.de/uni_leipzig")
38
- @topic.topic_references.should include("http://www.topicmapslab.de/uni_leipzig")
36
+ @topic.references.size.should == 2
37
+ @topic.references.should include("^http://www.topicmapslab.de/uni_leipzig")
38
+ @topic.references.should include("http://www.topicmapslab.de/uni_leipzig")
39
39
  end
40
40
  end #of describe "#identifiers"
41
41
  end #of describe self
@@ -3,153 +3,215 @@
3
3
 
4
4
  require File.dirname(__FILE__) + '/../../../spec_helper'
5
5
 
6
- module Sugar
7
- module Topic
8
- module Typed
9
- describe self do
10
- before(:each) do
11
- @tm = get_used_tm_sys_tm
12
- @type0 = @tm.get!("negative")
13
- @default_name_type = @tm.get!(RTM::PSI[:name_type])
14
- @dummy_type = @tm.get!("dummy_type")
15
- @container = @tm.get!("container")
16
- @containee = @tm.get!("containee")
17
- @contained = @tm.get!("contained")
18
- @leipzig = @tm.get!("leipzig")
19
- @germany = @tm.get!("germany")
20
- @dummy = @tm.get!("dummy")
21
- @name1 = @leipzig.create_name(@dummy_type, "Leipzig")
22
- @name2 = @germany.create_name("Germany")
23
- @name3 = @germany.create_name("Deutschland")
24
- @name4 = @leipzig.create_name("Leipzisch")
25
- @name5 = @leipzig.create_name("Lipsk")
26
- @occ1 = @leipzig.create_occurrence("inhabitants","500000")
27
- @occ2 = @germany.create_occurrence("states","16")
28
- @occ3 = @leipzig.create_occurrence("state","Sachsen")
29
- @occ2 = @germany.create_occurrence(@dummy_type,"0")
30
- @assoc1 = @tm.create_association(@dummy_type,["assoc_dummy"])
31
- @assoc2 = @tm.create_association(@contained)
32
- @role1 = @assoc2.create_role(@containee,@leipzig)
33
- @role2 = @assoc2.create_role(@container,@germany)
34
- @dummy_role = @assoc1.create_role(@dummy_type,@dummy)
35
- end
36
- after(:each) do
37
- @tm.close
38
- end
6
+ module RTM::Sugar::Topic
7
+ module Typed
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ @type0 = @tm.get!("negative")
12
+ @default_name_type = @tm.get!(RTM::PSI[:name_type])
13
+ @dummy_type = @tm.get!("dummy_type")
14
+ @container = @tm.get!("container")
15
+ @containee = @tm.get!("containee")
16
+ @contained = @tm.get!("contained")
17
+ @leipzig = @tm.get!("leipzig")
18
+ @germany = @tm.get!("germany")
19
+ @dummy = @tm.get!("dummy")
20
+ @name1 = @leipzig.create_name(@dummy_type, "Leipzig")
21
+ @name2 = @germany.create_name("Germany")
22
+ @name3 = @germany.create_name("Deutschland")
23
+ @name4 = @leipzig.create_name("Leipzisch")
24
+ @name5 = @leipzig.create_name("Lipsk")
25
+ @occ1 = @leipzig.create_occurrence("inhabitants","500000")
26
+ @occ2 = @germany.create_occurrence("states","16")
27
+ @occ3 = @leipzig.create_occurrence("state","Sachsen")
28
+ @occ2 = @germany.create_occurrence(@dummy_type,"0")
29
+ @assoc1 = @tm.create_association(@dummy_type,["assoc_dummy"])
30
+ @assoc2 = @tm.create_association(@contained)
31
+ @role1 = @assoc2.create_role(@containee,@leipzig)
32
+ @role2 = @assoc2.create_role(@container,@germany)
33
+ @dummy_role = @assoc1.create_role(@dummy_type,@dummy)
34
+ end
35
+ after(:each) do
36
+ @tm.close
37
+ end
39
38
 
40
- describe "#typed" do
41
- it "should give back all constructs which have this Topic as type" do
42
- @default_name_type.typed.size.should == 4
43
- @default_name_type.typed.should include(@name2)
44
- @default_name_type.typed.should include(@name3)
45
- @default_name_type.typed.should include(@name4)
46
- @default_name_type.typed.should include(@name5)
47
- @container.typed.size.should == 1
48
- @container.typed.should include(@role2)
49
- @containee.typed.size.should == 1
50
- @containee.typed.should include(@role1)
51
- @contained.typed.size.should == 1
52
- @contained.typed.should include(@assoc2)
53
- @dummy_type.typed.size.should == 4
54
- @dummy_type.typed.should include(@name1)
55
- @dummy_type.typed.should include(@occ2)
56
- @dummy_type.typed.should include(@assoc1)
57
- @dummy_type.typed.should include(@dummy_role)
58
- end
59
- it "should give back an empty Array if there are no Constructs which have this Topic as type" do
60
- @type0.typed.should be_empty
61
- end
39
+ describe "#typed" do
40
+ it "should give back all constructs which have this Topic as type" do
41
+ @default_name_type.typed.size.should == 4
42
+ @default_name_type.typed.should include(@name2)
43
+ @default_name_type.typed.should include(@name3)
44
+ @default_name_type.typed.should include(@name4)
45
+ @default_name_type.typed.should include(@name5)
46
+ @container.typed.size.should == 1
47
+ @container.typed.should include(@role2)
48
+ @containee.typed.size.should == 1
49
+ @containee.typed.should include(@role1)
50
+ @contained.typed.size.should == 1
51
+ @contained.typed.should include(@assoc2)
52
+ @dummy_type.typed.size.should == 4
53
+ @dummy_type.typed.should include(@name1)
54
+ @dummy_type.typed.should include(@occ2)
55
+ @dummy_type.typed.should include(@assoc1)
56
+ @dummy_type.typed.should include(@dummy_role)
62
57
  end
58
+ it "should give back an empty Array if there are no Constructs which have this Topic as type" do
59
+ @type0.typed.should be_empty
60
+ end
61
+ end
63
62
 
64
- describe "#typed_associations" do
65
- it "should give back all Associations which have this Topic as type" do
66
- @default_name_type.typed_associations.should be_empty
67
- @container.typed_associations.should be_empty
68
- @containee.typed_associations.should be_empty
69
- @contained.typed_associations.size.should == 1
70
- @contained.typed_associations.should include(@assoc2)
71
- @dummy_type.typed_associations.size.should == 1
72
- @dummy_type.typed_associations.should include(@assoc1)
73
- end
74
- it "should give back an empty Array if there are no Associations which have this Topic as type" do
75
- @type0.typed_associations.should be_empty
76
- end
63
+ describe "#typed_associations" do
64
+ it "should give back all Associations which have this Topic as type" do
65
+ @default_name_type.typed_associations.should be_empty
66
+ @container.typed_associations.should be_empty
67
+ @containee.typed_associations.should be_empty
68
+ @contained.typed_associations.size.should == 1
69
+ @contained.typed_associations.should include(@assoc2)
70
+ @dummy_type.typed_associations.size.should == 1
71
+ @dummy_type.typed_associations.should include(@assoc1)
72
+ end
73
+ it "should give back an empty Array if there are no Associations which have this Topic as type" do
74
+ @type0.typed_associations.should be_empty
77
75
  end
76
+ end
78
77
 
79
- describe "#typed_names" do
80
- it "should give back all Names which have this Topic as type" do
81
- @default_name_type.typed_names.size.should == 4
82
- @default_name_type.typed_names.should include(@name2)
83
- @default_name_type.typed_names.should include(@name3)
84
- @default_name_type.typed_names.should include(@name4)
85
- @default_name_type.typed_names.should include(@name5)
86
- @container.typed_names.should be_empty
87
- @containee.typed_names.should be_empty
88
- @contained.typed_names.should be_empty
89
- @dummy_type.typed_names.size.should == 1
90
- @dummy_type.typed_names.should include(@name1)
91
- end
92
- it "should give back an empty Array if there are no Names which have this Topic as type" do
93
- @type0.typed_names.should be_empty
94
- end
78
+ describe "#typed_names" do
79
+ it "should give back all Names which have this Topic as type" do
80
+ @default_name_type.typed_names.size.should == 4
81
+ @default_name_type.typed_names.should include(@name2)
82
+ @default_name_type.typed_names.should include(@name3)
83
+ @default_name_type.typed_names.should include(@name4)
84
+ @default_name_type.typed_names.should include(@name5)
85
+ @container.typed_names.should be_empty
86
+ @containee.typed_names.should be_empty
87
+ @contained.typed_names.should be_empty
88
+ @dummy_type.typed_names.size.should == 1
89
+ @dummy_type.typed_names.should include(@name1)
95
90
  end
91
+ it "should give back an empty Array if there are no Names which have this Topic as type" do
92
+ @type0.typed_names.should be_empty
93
+ end
94
+ end
96
95
 
97
- describe "#typed_occurrences" do
98
- it "should give back all Occurrences which have this Topic as type" do
99
- @default_name_type.typed_occurrences.should be_empty
100
- @container.typed_occurrences.should be_empty
101
- @containee.typed_occurrences.should be_empty
102
- @contained.typed_occurrences.should be_empty
103
- @dummy_type.typed_occurrences.size.should == 1
104
- @dummy_type.typed_occurrences.should include(@occ2)
105
- end
106
- it "should give back an empty Array if there are no Occurrences which have this Topic as type" do
107
- @type0.typed_occurrences.should be_empty
108
- end
96
+ describe "#typed_occurrences" do
97
+ it "should give back all Occurrences which have this Topic as type" do
98
+ @default_name_type.typed_occurrences.should be_empty
99
+ @container.typed_occurrences.should be_empty
100
+ @containee.typed_occurrences.should be_empty
101
+ @contained.typed_occurrences.should be_empty
102
+ @dummy_type.typed_occurrences.size.should == 1
103
+ @dummy_type.typed_occurrences.should include(@occ2)
104
+ end
105
+ it "should give back an empty Array if there are no Occurrences which have this Topic as type" do
106
+ @type0.typed_occurrences.should be_empty
109
107
  end
108
+ end
110
109
 
111
- describe "#typed_roles" do
112
- it "should give back all Roles which have this Topic as type" do
113
- @default_name_type.typed_roles.should be_empty
114
- @container.typed_roles.size.should == 1
115
- @container.typed_roles.should include(@role2)
116
- @containee.typed_roles.size.should == 1
117
- @containee.typed_roles.should include(@role1)
118
- @contained.typed_roles.should be_empty
119
- @dummy_type.typed_roles.size.should == 1
120
- @dummy_type.typed_roles.should include(@dummy_role)
121
- end
122
- it "should give back an empty Array if there are no Roles which have this Topic as type" do
123
- @type0.typed_roles.should be_empty
124
- end
110
+ describe "#typed_roles" do
111
+ it "should give back all Roles which have this Topic as type" do
112
+ @default_name_type.typed_roles.should be_empty
113
+ @container.typed_roles.size.should == 1
114
+ @container.typed_roles.should include(@role2)
115
+ @containee.typed_roles.size.should == 1
116
+ @containee.typed_roles.should include(@role1)
117
+ @contained.typed_roles.should be_empty
118
+ @dummy_type.typed_roles.size.should == 1
119
+ @dummy_type.typed_roles.should include(@dummy_role)
125
120
  end
121
+ it "should give back an empty Array if there are no Roles which have this Topic as type" do
122
+ @type0.typed_roles.should be_empty
123
+ end
124
+ end
125
+
126
+ describe "#topic_is_a?" do
127
+ before(:each) do
128
+ @t1, @t2, @t3, @t4, @t5 = @tm.get!(["t1", "t2", "t3", "t4", "t5"])
129
+ @t1.add_types(@t1, @t2)
130
+ @t1.add_instance(@t3)
131
+ @t2.add_supertype(@t4)
132
+ @t4.add_supertype(@t5)
133
+ end
134
+ it "give back true, if the argument is a type of this topic" do
135
+ @t1.topic_is_a?(@t1).should be_true
136
+ @t1.topic_is_a?("t2").should be_true
137
+ end
138
+ it "should give back false, if the argument is no type of this topic" do
139
+ @t1.topic_is_a?(@t3).should be_false
140
+ end
141
+ it "should give back false, if the argument is not a topic in the topic map" do
142
+ @t1.topic_is_a?("t6").should be_false
143
+ end
144
+ it "should give back true, if the argument is a supertype of the type of this topic" do
145
+ @t1.topic_is_a?(@t4).should be_true
146
+ @t1.topic_is_a?("t5").should be_true
147
+ end
148
+ end
149
+
126
150
 
127
- describe "#topic_is_a?" do
128
- before(:each) do
129
- @t1, @t2, @t3, @t4, @t5 = @tm.get!(["t1", "t2", "t3", "t4", "t5"])
130
- @t1.add_types(@t1, @t2)
131
- @t1.add_instance(@t3)
132
- @t2.add_supertype(@t4)
133
- @t4.add_supertype(@t5)
134
- end
135
- it "give back true, if the argument is a type of this topic" do
136
- @t1.topic_is_a?(@t1).should be_true
137
- @t1.topic_is_a?("t2").should be_true
138
- end
139
- it "should give back false, if the argument is no type of this topic" do
140
- @t1.topic_is_a?(@t3).should be_false
141
- end
142
- it "should give back false, if the argument is not a topic in the topic map" do
143
- @t1.topic_is_a?("t6").should be_false
144
- end
145
- it "should give back true, if the argument is a supertype of the type of this topic" do
146
- @t1.topic_is_a?(@t4).should be_true
147
- @t1.topic_is_a?("t5").should be_true
148
- end
151
+ describe "#used_as_type?" do
152
+ it "should give back true if this topic is used as type in a scope" do
153
+ @default_name_type.used_as_type?.should be_true
154
+ @dummy_type.used_as_type?.should be_true
155
+ @contained.used_as_type?.should be_true
156
+ @tm.get("inhabitants").used_as_type?.should be_true
157
+ @tm.get("states").used_as_type?.should be_true
158
+ @tm.get("state").used_as_type?.should be_true
159
+ @containee.used_as_type?.should be_true
160
+ @container.used_as_type?.should be_true
161
+ end
162
+ it "should give back false if this topic is not used as type in a scope" do
163
+ @type0.used_as_type?.should be_false
164
+ end
165
+ end
166
+
167
+ describe "#used_as_association_type?" do
168
+ it "should give back true if this topic is used as type in a scope of an association" do
169
+ @dummy_type.used_as_association_type?.should be_true
170
+ @contained.used_as_association_type?.should be_true
171
+ end
172
+ it "should give back false if this topic is not used as type in a scope of an association" do
173
+ @default_name_type.used_as_association_type?.should be_false
174
+ @type0.used_as_association_type?.should be_false
175
+ end
176
+ end
177
+
178
+ describe "#used_as_name_type?" do
179
+ it "should give back true if this topic is used as type in a scope of a name" do
180
+ @default_name_type.used_as_name_type?.should be_true
181
+ @dummy_type.used_as_name_type?.should be_true
182
+
183
+ end
184
+ it "should give back false if this topic is not used as type in a scope of a name" do
185
+ @type0.used_as_name_type?.should be_false
186
+ end
187
+ end
188
+
189
+ describe "#used_as_occurrence_type?" do
190
+ it "should give back true if this topic is used as type in a scope of an occurrence" do
191
+ @dummy_type.used_as_occurrence_type?.should be_true
192
+ @tm.get("inhabitants").used_as_occurrence_type?.should be_true
193
+ @tm.get("states").used_as_occurrence_type?.should be_true
194
+ @tm.get("state").used_as_occurrence_type?.should be_true
195
+ end
196
+ it "should give back false if this topic is not used as type in a scope of an occurrence" do
197
+ @default_name_type.used_as_occurrence_type?.should be_false
198
+ @type0.used_as_occurrence_type?.should be_false
199
+ end
200
+ end
201
+
202
+ describe "#used_as_role_type?" do
203
+ it "should give back true if this topic is used as type in a scope of a role" do
204
+ @dummy_type.used_as_role_type?.should be_true
205
+ @containee.used_as_role_type?.should be_true
206
+ @container.used_as_role_type?.should be_true
207
+ end
208
+ it "should give back false if this topic is not used as type in a scope of a role" do
209
+ @default_name_type.used_as_role_type?.should be_false
210
+ @type0.used_as_role_type?.should be_false
149
211
  end
212
+ end
150
213
 
151
- end #of describe self
214
+ end #of describe self
152
215
 
153
- end
154
216
  end
155
217
  end