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.
- data/DISCLAIMER +10 -33
- data/LICENSE +201 -0
- data/README +32 -3
- data/lib/rtm.rb +126 -74
- data/lib/rtm/axes.rb +298 -0
- data/lib/rtm/axes/association.rb +76 -0
- data/lib/rtm/axes/associations.rb +96 -0
- data/lib/rtm/axes/assocs_names_occs.rb +56 -0
- data/lib/rtm/axes/characteristic.rb +68 -0
- data/lib/rtm/axes/characteristics.rb +93 -0
- data/lib/rtm/axes/string.rb +76 -0
- data/lib/rtm/axes/strings.rb +87 -0
- data/lib/rtm/axes/topic.rb +233 -0
- data/lib/rtm/axes/topics.rb +280 -0
- data/lib/rtm/{backward_compatibility.rb → deprecated/index_property_set.rb} +3 -0
- data/lib/rtm/engine.rb +101 -0
- data/lib/rtm/extensions.rb +65 -5
- data/lib/rtm/{locator_helpers.rb → helpers/locator.rb} +15 -4
- data/lib/rtm/{helpers.rb → helpers/no_output.rb} +3 -0
- data/lib/rtm/helpers/uri.rb +13 -0
- data/lib/rtm/io.rb +19 -0
- data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
- data/lib/rtm/io/tmapix_from.rb +155 -0
- data/lib/rtm/io/tmapix_to.rb +223 -0
- data/lib/rtm/io/to_hash.rb +154 -0
- data/lib/rtm/io/to_jtm.rb +53 -103
- data/lib/rtm/io/to_rdf.rb +45 -0
- data/lib/rtm/io/to_string.rb +21 -8
- data/lib/rtm/io/to_xtm1.rb +6 -4
- data/lib/rtm/io/to_xtm2.rb +10 -8
- data/lib/rtm/io/to_yaml.rb +59 -100
- data/lib/rtm/navigation.rb +23 -0
- data/lib/rtm/navigation/association/players.rb +25 -0
- data/lib/rtm/navigation/name/atomify.rb +19 -0
- data/lib/rtm/navigation/name/characteristics.rb +33 -0
- data/lib/rtm/navigation/occurrence/atomify.rb +19 -0
- data/lib/rtm/navigation/occurrence/characteristics.rb +33 -0
- data/lib/rtm/navigation/topic/characteristics.rb +33 -0
- data/lib/rtm/navigation/topic/indicators.rb +31 -0
- data/lib/rtm/navigation/topic/items.rb +31 -0
- data/lib/rtm/navigation/topic/locators.rb +31 -0
- data/lib/rtm/navigation/topic/players.rb +27 -0
- data/lib/rtm/navigation/topic/supertypes.rb +166 -0
- data/lib/rtm/navigation/topic/traverse.rb +51 -0
- data/lib/rtm/navigation/topic/types.rb +109 -0
- data/lib/rtm/psi.rb +39 -2
- data/lib/rtm/sugar.rb +47 -0
- data/lib/rtm/sugar/association/hash_access.rb +46 -0
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +58 -0
- data/lib/rtm/sugar/occurrence/external.rb +53 -0
- data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
- data/lib/rtm/sugar/role/counterparts.rb +139 -46
- data/lib/rtm/sugar/topic/best_name.rb +74 -0
- data/lib/rtm/sugar/topic/characteristics.rb +126 -12
- data/lib/rtm/sugar/topic/counterparts.rb +145 -10
- data/lib/rtm/sugar/topic/hash_access.rb +140 -30
- data/lib/rtm/sugar/topic/scoped.rb +114 -0
- data/lib/rtm/sugar/topic/topic_ref.rb +86 -0
- data/lib/rtm/sugar/topic/typed.rb +207 -0
- data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
- data/lib/rtm/sugar/topic_map/themes.rb +53 -0
- data/lib/rtm/sugar/typed/types.rb +38 -0
- data/lib/rtm/validation.rb +7 -4
- data/lib/rtm/version.rb +30 -0
- data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
- data/spec/rtm/axes/association_spec.rb +88 -0
- data/spec/rtm/axes/associations_spec.rb +60 -0
- data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
- data/spec/rtm/axes/characteristic_spec.rb +90 -0
- data/spec/rtm/axes/characteristics_spec.rb +85 -0
- data/spec/rtm/axes/string_spec.rb +145 -0
- data/spec/rtm/axes/strings_spec.rb +168 -0
- data/spec/rtm/axes/topic_spec.rb +124 -0
- data/spec/rtm/axes/topics_spec.rb +103 -0
- data/spec/rtm/base_spec.rb +32 -0
- data/spec/rtm/io/tmapix_from_spec.rb +76 -0
- data/spec/rtm/io/tmapix_to_spec.rb +159 -0
- data/spec/rtm/io/to_hash_spec.rb +90 -0
- data/spec/rtm/io/to_rdf_spec.rb +37 -0
- data/spec/rtm/io/to_string_spec.rb +122 -0
- data/spec/rtm/io/to_yaml_spec.rb +89 -0
- data/spec/rtm/navigation/association/players_spec.rb +58 -0
- data/spec/rtm/navigation/association_spec.rb +52 -0
- data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
- data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
- data/spec/rtm/navigation/name_spec.rb +52 -0
- data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
- data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
- data/spec/rtm/navigation/occurrence_spec.rb +52 -0
- data/spec/rtm/navigation/string_spec.rb +51 -0
- data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
- data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
- data/spec/rtm/navigation/topic/items_spec.rb +44 -0
- data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
- data/spec/rtm/navigation/topic/players_spec.rb +48 -0
- data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
- data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
- data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
- data/spec/rtm/navigation/topic/types_spec.rb +195 -0
- data/spec/rtm/navigation/topic_spec.rb +153 -0
- data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
- data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +171 -0
- data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
- data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
- data/spec/rtm/sugar/role/counterparts_spec.rb +193 -0
- data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +333 -0
- data/spec/rtm/sugar/topic/counterparts_spec.rb +224 -0
- data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
- data/spec/rtm/sugar/topic/scoped_spec.rb +195 -0
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
- data/spec/rtm/sugar/topic/typed_spec.rb +217 -0
- data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
- data/spec/rtm/sugar/typed/types_spec.rb +24 -0
- data/spec/rtm/tmapi/core/association_spec.rb +169 -0
- data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
- data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
- data/spec/rtm/tmapi/core/name_spec.rb +270 -0
- data/spec/rtm/tmapi/core/occurrence_spec.rb +53 -0
- data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
- data/spec/rtm/tmapi/core/role_spec.rb +73 -0
- data/spec/rtm/tmapi/core/scoped_spec.rb +441 -0
- data/spec/rtm/tmapi/core/topic_map_spec.rb +716 -0
- data/spec/rtm/tmapi/core/topic_spec.rb +1468 -0
- data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
- data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
- data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
- data/spec/rtm/tmapi_spec.rb +44 -0
- data/spec/rtm/utils/sparql_spec.rb +26 -0
- data/spec/rtm_spec.rb +93 -0
- data/spec/spec_helper.rb +28 -0
- data/test/javalibs/junit-4.5.jar +0 -0
- data/test/javalibs/tmapi-2.0-tests.jar +0 -0
- data/test/tmapi_tests.rb +25 -0
- metadata +169 -65
- data/COPYRIGHT +0 -4
- data/lib/Rakefile.rb +0 -42
- data/lib/activetopicmaps.rb +0 -278
- data/lib/rtm/backend/active_record.rb +0 -58
- data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
- data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
- data/lib/rtm/backend/active_record/locators.rb +0 -55
- data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
- data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
- data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
- data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
- data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
- data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
- data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
- data/lib/rtm/backend/active_record/tmdm.rb +0 -298
- data/lib/rtm/backend/active_record/topic.rb +0 -87
- data/lib/rtm/backend/active_record/topic_map.rb +0 -314
- data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
- data/lib/rtm/base.rb +0 -92
- data/lib/rtm/connect.rb +0 -92
- data/lib/rtm/core_ext.rb +0 -6
- data/lib/rtm/io/from_xtm2.rb +0 -263
- data/lib/rtm/merging/merging.rb +0 -307
- data/lib/rtm/pimp_my_api.rb +0 -28
- data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
- data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
- data/lib/run_main_project.rb +0 -16
- data/test/base_test.rb +0 -162
|
@@ -0,0 +1,234 @@
|
|
|
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::Sugar::Topic::HashAccess
|
|
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
|
+
describe "#[]" do
|
|
16
|
+
before(:each) do
|
|
17
|
+
@topic1 = @tm.get!("Hans")
|
|
18
|
+
@name1 = @topic1.create_name("Hans")
|
|
19
|
+
@name2 = @topic1.create_name("first","George",["en","always"])
|
|
20
|
+
@name3 = @topic1.create_name("last","Meyer",["underground"])
|
|
21
|
+
@occ1 = @topic1.create_occurrence("Heimat","Sachsen",:scope => ["de"])
|
|
22
|
+
@occ2 = @topic1.create_occurrence("Heimat","Germany",:scope => ["de","always"])
|
|
23
|
+
@occ3 = @topic1.create_occurrence("Birthyear","1969",:scope => ["always"])
|
|
24
|
+
@occ4 = @topic1.create_occurrence("parents","none")
|
|
25
|
+
end
|
|
26
|
+
it "should give back an Occurrence of the specified type, in an Array, if the argument is a Topic" do
|
|
27
|
+
@topic1[@tm.get("Something")].size.should == 0
|
|
28
|
+
@topic1[@tm.get("Heimat")].size.should == 2
|
|
29
|
+
@topic1[@tm.get("Heimat")].should include(@occ1)
|
|
30
|
+
@topic1[@tm.get("Heimat")].should include(@occ2)
|
|
31
|
+
end
|
|
32
|
+
it "should give back an empty Array if the argument is nil" do
|
|
33
|
+
@topic1[nil].should be_empty
|
|
34
|
+
@topic1.[](nil).should be_empty
|
|
35
|
+
end
|
|
36
|
+
it "should give back all occurrences of this Topic if no argument is given" do
|
|
37
|
+
@topic1[].size.should == 4
|
|
38
|
+
@topic1[].should include(@occ1)
|
|
39
|
+
@topic1[].should include(@occ2)
|
|
40
|
+
@topic1[].should include(@occ3)
|
|
41
|
+
@topic1[].should include(@occ4)
|
|
42
|
+
end
|
|
43
|
+
it "should return an array of names with default nametype if the argument equals '-'" do
|
|
44
|
+
@topic1["-"].size.should == 1
|
|
45
|
+
@topic1["-"].should include(@name1)
|
|
46
|
+
end
|
|
47
|
+
it "should give back all names that have the given name type if argument equals '-type'" do
|
|
48
|
+
@topic1["-first"].size.should == 1
|
|
49
|
+
@topic1["-first"].should include(@name2)
|
|
50
|
+
end
|
|
51
|
+
it "should give back all names that have the given name type and scope if argument equals '-type @scope" do
|
|
52
|
+
@topic1["-last @underground"].size.should == 1
|
|
53
|
+
@topic1["-last @underground"].should include(@name3)
|
|
54
|
+
end
|
|
55
|
+
it "should give back an empty Array if argument equals '-type' or '-type @scope' or '-type @scope1 scope2' but type or scope/1/2 does not exist" do
|
|
56
|
+
@topic1["-nothing"].should be_empty
|
|
57
|
+
@topic1["-first @nothing"].should be_empty
|
|
58
|
+
@topic1["-nothing @nothing"].should be_empty
|
|
59
|
+
@topic1["-first @en nothing"].should be_empty
|
|
60
|
+
@topic1["-first @nothing en"].should be_empty
|
|
61
|
+
@topic1["-nothing @nothing nothing"].should be_empty
|
|
62
|
+
end
|
|
63
|
+
it "should give back all names that have the given name type and scope if argument equals '-type @scope1 scope2" do
|
|
64
|
+
@topic1["-first @en always"].size.should == 1
|
|
65
|
+
@topic1["-first @en always"].should include(@name2)
|
|
66
|
+
@topic1["-first @en, always"].should == @topic1["-first @en always"]
|
|
67
|
+
end
|
|
68
|
+
it "should give back all occurrences that have the given occurrence type if argument equals 'type'" do
|
|
69
|
+
@topic1["Heimat"].size.should == 2
|
|
70
|
+
@topic1["Heimat"].should include(@occ1)
|
|
71
|
+
@topic1["Heimat"].should include(@occ2)
|
|
72
|
+
end
|
|
73
|
+
it "should give back all occurrences that have the given occurrence type and scope if argument equals 'type @scope'" do
|
|
74
|
+
@topic1["Heimat @de"].size.should == 2
|
|
75
|
+
@topic1["Heimat @de"].should include(@occ1)
|
|
76
|
+
@topic1["Heimat @de"].should include(@occ2)
|
|
77
|
+
end
|
|
78
|
+
it "should give back all occurrences that have the given occurrence type and scope if argument equals 'type @scope1 scope2'" do
|
|
79
|
+
@topic1["Heimat @de always"].size.should == 1
|
|
80
|
+
@topic1["Heimat @de always"].should include(@occ2)
|
|
81
|
+
@topic1["Heimat @de, always"].should == @topic1["Heimat @de always"]
|
|
82
|
+
end
|
|
83
|
+
it "should give back an empty Array if argument equals 'type' or 'type @scope' or 'type @scope1 scope2' but type or scope/1/2 does not exist" do
|
|
84
|
+
@topic1["nothing"].should be_empty
|
|
85
|
+
@topic1["first @nothing"].should be_empty
|
|
86
|
+
@topic1["nothing @nothing"].should be_empty
|
|
87
|
+
@topic1["parents @en nothing"].should be_empty
|
|
88
|
+
@topic1["parents @nothing en"].should be_empty
|
|
89
|
+
@topic1["nothing @nothing nothing"].should be_empty
|
|
90
|
+
end
|
|
91
|
+
it "should give back all name and occurrences of this Topic if argument equals '*'" do
|
|
92
|
+
@topic1["*"].size.should == 7
|
|
93
|
+
end
|
|
94
|
+
it "should give back all name and occurrences that have the given type if argument equals '*type'" do
|
|
95
|
+
name = @topic1.create_name("dummy_type","dummy_name")
|
|
96
|
+
occ = @topic1.create_occurrence("dummy_type","dummy_occ")
|
|
97
|
+
@topic1["*dummy_type"].size.should == 2
|
|
98
|
+
@topic1["*dummy_type"].should include(name)
|
|
99
|
+
@topic1["*dummy_type"].should include(occ)
|
|
100
|
+
@topic1["*first"].size.should == 1
|
|
101
|
+
@topic1["*first"].should include(@name2)
|
|
102
|
+
@topic1["*parents"].size.should == 1
|
|
103
|
+
@topic1["*parents"].should include(@occ4)
|
|
104
|
+
end
|
|
105
|
+
it "should give back all name and occurrences that have the given type and scope if argument equals '*type @scope'" do
|
|
106
|
+
name1 = @topic1.create_name("dummy_type","dummy_name1",["theme0"])
|
|
107
|
+
name2 = @topic1.create_name("dummy_type","dummy_name2",["theme1"])
|
|
108
|
+
occ1 = @topic1.create_occurrence("dummy_type","dummy_occ1", :scope => ["theme0","theme1"])
|
|
109
|
+
occ2 = @topic1.create_occurrence("dummy_type","dummy_occ2",:scope => ["theme1"])
|
|
110
|
+
@topic1["*dummy_type @theme0"].size.should == 2
|
|
111
|
+
@topic1["*dummy_type @theme0"].should include(occ1)
|
|
112
|
+
@topic1["*dummy_type @theme0"].should include(name1)
|
|
113
|
+
@topic1["*dummy_type @theme1"].size.should == 3
|
|
114
|
+
@topic1["*dummy_type @theme1"].should include(name2)
|
|
115
|
+
@topic1["*dummy_type @theme1"].should include(occ1)
|
|
116
|
+
@topic1["*dummy_type @theme1"].should include(occ2)
|
|
117
|
+
end
|
|
118
|
+
it "should give back all name and occurrences that have the given type and scope if argument equals '*type @scope1 scope2'" do
|
|
119
|
+
name1 = @topic1.create_name("dummy_type","dummy_name1",["theme0","theme1"])
|
|
120
|
+
name2 = @topic1.create_name("dummy_type","dummy_name2",["theme1"])
|
|
121
|
+
occ1 = @topic1.create_occurrence("dummy_type","dummy_occ1",:scope => ["theme0"])
|
|
122
|
+
occ2 = @topic1.create_occurrence("dummy_type","dummy_occ2",:scope => ["theme0","theme1"])
|
|
123
|
+
@topic1["*dummy_type @theme0 theme1"].size.should == 2
|
|
124
|
+
@topic1["*dummy_type @theme0 theme1"].should include(name1)
|
|
125
|
+
@topic1["*dummy_type @theme0 theme1"].should include(occ2)
|
|
126
|
+
end
|
|
127
|
+
it "should handle spaces if argument is a String" do
|
|
128
|
+
@topic1[" - "].should == @topic1["-"]
|
|
129
|
+
@topic1[" - first "].should == @topic1["-first"]
|
|
130
|
+
@topic1[" - last @ underground"].should == @topic1["-last @underground"]
|
|
131
|
+
@topic1[" - first @ en always"].should == @topic1["-first @en always"]
|
|
132
|
+
@topic1[" - first @ en, always"].should == @topic1["-first @en, always"]
|
|
133
|
+
@topic1[" Heimat "].should == @topic1["Heimat"]
|
|
134
|
+
@topic1[" Heimat @ de "].should == @topic1["Heimat @de"]
|
|
135
|
+
@topic1[" Heimat @ de always "].should == @topic1["Heimat @de always"]
|
|
136
|
+
@topic1[" * "].should == @topic1["*"]
|
|
137
|
+
end
|
|
138
|
+
it "should give back occurrences and names whose type have item identifier" do
|
|
139
|
+
topic = @tm.get!("name_ii_test")
|
|
140
|
+
name = topic.create_name("ii:firstname_ii_test","Hans")
|
|
141
|
+
@tm.get("^firstname_ii_test").should_not be_nil
|
|
142
|
+
occ = topic.create_occurrence("ii:age_ii_test","12")
|
|
143
|
+
@tm.get("^age_ii_test").should_not be_nil
|
|
144
|
+
topic["-ii:firstname_ii_test"].size.should == 1
|
|
145
|
+
topic["-ii:firstname_ii_test"].should include name
|
|
146
|
+
topic["ii:age_ii_test"].size.should == 1
|
|
147
|
+
topic["ii:age_ii_test"].should include occ
|
|
148
|
+
topic["-firstname_ii_test"].should be_empty
|
|
149
|
+
topic["age_ii_test"].should be_empty
|
|
150
|
+
topic["*"].size.should == 2
|
|
151
|
+
end
|
|
152
|
+
it "should give back occurrences and names whose type have subject locator"
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
describe "#[]=" do
|
|
156
|
+
before(:each) do
|
|
157
|
+
@topic2 = @tm.get!("Peter")
|
|
158
|
+
end
|
|
159
|
+
it "should set a name with standard name type given '-'" do
|
|
160
|
+
@topic2["-"] = "Peter"
|
|
161
|
+
@topic2["Hausnummer"] = "1"
|
|
162
|
+
@topic2.names.size.should == 1
|
|
163
|
+
@topic2.names.first.type.should == @tm.get(RTM::PSI[:name_type])
|
|
164
|
+
@topic2.names.first.value.should == "Peter"
|
|
165
|
+
end
|
|
166
|
+
it "should set a name with standard name type and scope given '- @scope'" do
|
|
167
|
+
scope = RTM::PREFIX[:language] + "german"
|
|
168
|
+
@topic2["- @" + scope] = "Peter"
|
|
169
|
+
@topic2["Hausnummer"] = "1"
|
|
170
|
+
@topic2.names.size.should == 1
|
|
171
|
+
@topic2.names.first.type.should == @tm.get(RTM::PSI[:name_type])
|
|
172
|
+
@topic2.names.first.value.should == "Peter"
|
|
173
|
+
@topic2.names.first.scope.first.should == @tm.get(scope)
|
|
174
|
+
end
|
|
175
|
+
it "should set a name with standard name type and scope (which is a qname) given '-@qname'" do
|
|
176
|
+
@tm.add_prefix("lang",RTM::PREFIX[:language])
|
|
177
|
+
@topic2["- @lang:german"] = "Peter"
|
|
178
|
+
@topic2["Hausnummer"] = "1"
|
|
179
|
+
@topic2.names.size.should == 1
|
|
180
|
+
@topic2.names.first.type.should == @tm.get(RTM::PSI[:name_type])
|
|
181
|
+
@topic2.names.first.value.should == "Peter"
|
|
182
|
+
scope = RTM::PREFIX[:language] + "german"
|
|
183
|
+
@topic2.names.first.scope.first.should == @tm.get(scope)
|
|
184
|
+
end
|
|
185
|
+
it "should set a name and nametype type given '-nametype'" do
|
|
186
|
+
@topic2["-first"] = "Peter"
|
|
187
|
+
@topic2["Hausnummer"] = "1"
|
|
188
|
+
@topic2.names.size.should == 1
|
|
189
|
+
@topic2.names.first.type.should == @tm.get("first")
|
|
190
|
+
@topic2.names.first.value.should == "Peter"
|
|
191
|
+
end
|
|
192
|
+
it "should set an Occurrence and Occurrence type given 'occurrencetype'" do
|
|
193
|
+
@topic2["-first"] = "Peter"
|
|
194
|
+
@topic2["Hausnummer"] = "1"
|
|
195
|
+
@topic2.occurrences.size.should == 1
|
|
196
|
+
@topic2.occurrences.first.type.should == @tm.get("Hausnummer")
|
|
197
|
+
@topic2.occurrences.first.value.should == "1"
|
|
198
|
+
end
|
|
199
|
+
it "should set the Scope given [...@ scope] or [...@ scope1, scope2 scope3 ...]" do
|
|
200
|
+
@topic2["-first @deutsch"] = "Peter"
|
|
201
|
+
@topic2["Hausnummer @scope1, scope2 scope3"] = "1"
|
|
202
|
+
@topic2.names.first.type.should == @tm.get("first")
|
|
203
|
+
@topic2.names.first.value.should == "Peter"
|
|
204
|
+
@topic2.names.first.scope.first.should == @tm.get("deutsch")
|
|
205
|
+
@topic2.occurrences.first.type.should == @tm.get("Hausnummer")
|
|
206
|
+
@topic2.occurrences.first.value.should == "1"
|
|
207
|
+
@topic2.occurrences.first.scope.size.should == 3
|
|
208
|
+
@topic2.occurrences.first.scope.should include(@tm.get("scope1"))
|
|
209
|
+
@topic2.occurrences.first.scope.should include(@tm.get("scope2"))
|
|
210
|
+
@topic2.occurrences.first.scope.should include(@tm.get("scope3"))
|
|
211
|
+
end
|
|
212
|
+
it "should allow spaces before and after and between - and Nametype and @" do
|
|
213
|
+
@topic2[" - first @ scope1 scope2 scope3"] = "Peter"
|
|
214
|
+
@topic2.names.size.should == 1
|
|
215
|
+
@topic2.names.first.type.should == @tm.get("first")
|
|
216
|
+
@topic2.names.first.scope.size.should == 3
|
|
217
|
+
@topic2.names.first.scope.should include(@tm.get("scope1"))
|
|
218
|
+
@topic2.names.first.scope.should include(@tm.get("scope2"))
|
|
219
|
+
@topic2.names.first.scope.should include(@tm.get("scope3"))
|
|
220
|
+
end
|
|
221
|
+
it "should create names whose types have item identifier" do
|
|
222
|
+
@topic2["-ii:a_name"] = "Billy"
|
|
223
|
+
@tm.get("^a_name").should_not be_nil
|
|
224
|
+
@topic2.names.first.type.should == @tm.get("^a_name")
|
|
225
|
+
end
|
|
226
|
+
it "should create occurrences whose types have item identifier" do
|
|
227
|
+
@topic2["ii:an_occ"] = "42"
|
|
228
|
+
@tm.get("^an_occ").should_not be_nil
|
|
229
|
+
@topic2.occurrences.first.type.should == @tm.get("^an_occ")
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
end
|
|
@@ -0,0 +1,195 @@
|
|
|
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::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
|
|
36
|
+
|
|
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)
|
|
56
|
+
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
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
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
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
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)
|
|
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
|
|
94
|
+
|
|
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
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
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
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
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 Sugar
|
|
7
|
+
module Topic
|
|
8
|
+
module TopicRef
|
|
9
|
+
describe self do
|
|
10
|
+
before(:each) do
|
|
11
|
+
@tm = get_used_tm_sys_tm
|
|
12
|
+
@topic = @tm.get!("ii:uni_leipzig")
|
|
13
|
+
end
|
|
14
|
+
after(:each) do
|
|
15
|
+
@tm.close
|
|
16
|
+
end
|
|
17
|
+
describe "#references" do
|
|
18
|
+
it "should not give back an empty Array" do
|
|
19
|
+
@topic.references.should_not be_empty
|
|
20
|
+
end
|
|
21
|
+
it "should give back an item identifier that starts with a ^" do
|
|
22
|
+
pending if implementation_for_spec == :ontopia
|
|
23
|
+
@topic.references.first[0].should == ?^
|
|
24
|
+
@topic.references.should include("^http://www.topicmapslab.de/uni_leipzig")
|
|
25
|
+
end
|
|
26
|
+
it "should give back subject locators also" do
|
|
27
|
+
pending if implementation_for_spec == :ontopia
|
|
28
|
+
@topic.addSubjectLocator(@tm.create_locator("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
|
+
end
|
|
33
|
+
it "should give back subject identifiers also" do
|
|
34
|
+
pending if implementation_for_spec == :ontopia
|
|
35
|
+
@topic.add_subject_identifier(@tm.create_locator("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
|
+
end
|
|
40
|
+
end #of describe "#identifiers"
|
|
41
|
+
end #of describe self
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|