rtm 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/DISCLAIMER +10 -33
- data/LICENSE +201 -0
- data/README +3 -3
- data/lib/rtm.rb +148 -74
- data/lib/rtm/axes.rb +295 -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 +58 -0
- data/lib/rtm/extensions.rb +11 -1
- 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 +18 -0
- data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
- data/lib/rtm/io/ontopia_io.rb +25 -0
- data/lib/rtm/io/tmapix.rb +234 -0
- data/lib/rtm/io/to_hash.rb +116 -0
- data/lib/rtm/io/to_jtm.rb +53 -103
- data/lib/rtm/io/to_rdf.rb +30 -0
- data/lib/rtm/io/to_string.rb +8 -6
- 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 +29 -98
- data/lib/rtm/navigation.rb +37 -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 +162 -0
- data/lib/rtm/navigation/topic/traverse.rb +51 -0
- data/lib/rtm/navigation/topic/types.rb +107 -0
- data/lib/rtm/psi.rb +33 -2
- data/lib/rtm/sugar.rb +34 -0
- data/lib/rtm/sugar/association/hash_access.rb +46 -0
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +75 -0
- data/lib/rtm/{pimp_my_api.rb → sugar/occurrence/externalize.rb} +3 -0
- data/lib/rtm/sugar/role/counterparts.rb +133 -46
- data/lib/rtm/sugar/topic/characteristics.rb +126 -12
- data/lib/rtm/sugar/topic/counterparts.rb +130 -7
- data/lib/rtm/sugar/topic/hash_access.rb +140 -30
- data/lib/rtm/sugar/topic/scoped.rb +65 -0
- data/lib/rtm/sugar/topic/topic_ref.rb +35 -0
- data/lib/rtm/sugar/topic/typed.rb +159 -0
- data/lib/rtm/sugar/typed/types.rb +38 -0
- data/lib/rtm/validation.rb +8 -5
- data/lib/rtm/version.rb +18 -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_spec.rb +85 -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 +16 -0
- data/spec/rtm/sugar/role/counterparts_spec.rb +191 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +318 -0
- data/spec/rtm/sugar/topic/counterparts_spec.rb +184 -0
- data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
- data/spec/rtm/sugar/topic/scoped_spec.rb +131 -0
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
- data/spec/rtm/sugar/topic/typed_spec.rb +155 -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/name_spec.rb +85 -0
- data/spec/rtm/tmapi/core/occurrence_spec.rb +96 -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 +403 -0
- data/spec/rtm/tmapi/core/topic_map_spec.rb +648 -0
- data/spec/rtm/tmapi/core/topic_spec.rb +992 -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 +94 -0
- data/spec/spec_helper.rb +23 -0
- data/test/base_unit_test.rb +161 -0
- data/test/{base_test.rb → base_unit_test_tmapi.rb} +46 -43
- metadata +122 -66
- 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/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
|
@@ -0,0 +1,16 @@
|
|
|
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::Occurrence::DynamicValue
|
|
7
|
+
describe self do
|
|
8
|
+
before(:each) do
|
|
9
|
+
@tm = get_used_tm_sys_tm
|
|
10
|
+
end
|
|
11
|
+
after(:each) do
|
|
12
|
+
@tm.close
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,191 @@
|
|
|
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 Role
|
|
8
|
+
module Counterparts
|
|
9
|
+
describe self do
|
|
10
|
+
before(:each) do
|
|
11
|
+
@tm = get_used_tm_sys_tm
|
|
12
|
+
@t1,@t2,@t3,@t4,@t5 = @tm.get!(["t1","t2","t3","t4","t5"])
|
|
13
|
+
@t_a1,@t_a2,@t_a3 = @tm.get!(["t_a1","t_a2","t_a3"])
|
|
14
|
+
@t_r1,@t_r2,@t_r3,@t_r4,@t_r5 = @tm.get!(["t_r1","t_r2","t_r3","t_r4","t_r5"])
|
|
15
|
+
@a1 = @tm.create_association(@t_a1)
|
|
16
|
+
@a2 = @tm.create_association(@t_a2)
|
|
17
|
+
@a3 = @tm.create_association(@t_a1)
|
|
18
|
+
@a4 = @tm.create_association(@t_a3)
|
|
19
|
+
@a5 = @tm.create_association(@t_a1)
|
|
20
|
+
@r1 = @a1.create_role(@t_r1, @t1)
|
|
21
|
+
@r2 = @a1.create_role(@t_r2, @t2)
|
|
22
|
+
@r3 = @a1.create_role(@t_r1, @t4)
|
|
23
|
+
@r4 = @a2.create_role(@t_r1, @t1)
|
|
24
|
+
@r5 = @a2.create_role(@t_r3, @t3)
|
|
25
|
+
@r6 = @a3.create_role(@t_r4, @t1)
|
|
26
|
+
@r7 = @a3.create_role(@t_r5, @t5)
|
|
27
|
+
@r8 = @a4.create_role(@t_r4, @t4)
|
|
28
|
+
@r9 = @a4.create_role(@t_r5, @t4)
|
|
29
|
+
@r10= @a5.create_role(@t_r2, @t5)
|
|
30
|
+
end
|
|
31
|
+
after(:each) do
|
|
32
|
+
@tm.close
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "#counterparts" do
|
|
36
|
+
it "should give back all counterparts (roles) if no otype is given" do
|
|
37
|
+
@r1.should have(2).counterparts
|
|
38
|
+
@r1.counterparts.should include @r2, @r3
|
|
39
|
+
@r8.should have(1).counterparts
|
|
40
|
+
@r8.counterparts.should include @r9
|
|
41
|
+
end
|
|
42
|
+
it "should give back some counterparts (roles) if otype is given" do
|
|
43
|
+
@r1.counterparts(:otype=>@t_r1).size.should == 1
|
|
44
|
+
@r1.counterparts(:otype=>@t_r1).should include @r3
|
|
45
|
+
@r6.counterparts(:otype=>@t_r1).should be_empty
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
describe "#counterplayers" do
|
|
49
|
+
it "should give back all counterplayers (topics) if no otype is given" do
|
|
50
|
+
@r1.should have(2).counterplayers
|
|
51
|
+
@r1.counterplayers.should include @t2, @t4
|
|
52
|
+
@r8.should have(1).counterplayers
|
|
53
|
+
@r8.counterplayers.should include @t4
|
|
54
|
+
end
|
|
55
|
+
it "should give back some counterplayers (topics) if otype is given " do
|
|
56
|
+
@r1.counterplayers(:otype=>@t_r1).size.should == 1
|
|
57
|
+
@r1.counterplayers(:otype=>@t_r1).should include @t4
|
|
58
|
+
@r4.counterplayers(:otype=>@t_r2).size.should == 0
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
describe "#counterpart" do
|
|
62
|
+
it "should give back the counterpart Role if the parent association is binary" do
|
|
63
|
+
@r4.counterpart.should == @r5
|
|
64
|
+
@r5.counterpart.should == @r4
|
|
65
|
+
end
|
|
66
|
+
it "should raise an error if the üparent association includes more than 2 roles" do
|
|
67
|
+
lambda {@r2.counterpart}.should raise_error
|
|
68
|
+
end
|
|
69
|
+
it "should give back nil if the parent association is unary" do
|
|
70
|
+
@r10.counterpart.should be_nil
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
describe "#counterplayer" do
|
|
74
|
+
it "should give back the counterplayer Topic if the parent association is binary" do
|
|
75
|
+
@r6.counterplayer.should == @t5
|
|
76
|
+
@r5.counterplayer.should == @t1
|
|
77
|
+
end
|
|
78
|
+
it "should raise an error if the parent association includes more than 2 roles" do
|
|
79
|
+
lambda {@r2.counterplayer}.should raise_error
|
|
80
|
+
end
|
|
81
|
+
it "should give back nil if the parent association is unary" do
|
|
82
|
+
@r10.counterplayer.should be_nil
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe self do
|
|
88
|
+
before(:each) do
|
|
89
|
+
@tm = get_used_tm_sys_tm
|
|
90
|
+
t1,t2,t3,t4,t5,t6,t7,t8 = @tm.get!(["t1","t2","t3","t4","t5","t6","t7","t8"])
|
|
91
|
+
t_a1,t_a2 = @tm.get!(["t_a1","t_a2"])
|
|
92
|
+
@t_r1,@t_r2,@t_r3,@t_r4,@t_r5,@t_r6 = @tm.get!(["t_r1","t_r2","t_r3","t_r4","t_r5","t_r6"])
|
|
93
|
+
a1 = @tm.create_association(t_a1)
|
|
94
|
+
a2 = @tm.create_association(t_a1)
|
|
95
|
+
a3 = @tm.create_association(t_a1)
|
|
96
|
+
a4 = @tm.create_association(t_a1)
|
|
97
|
+
a5 = @tm.create_association(t_a1)
|
|
98
|
+
a6 = @tm.create_association(t_a2)
|
|
99
|
+
@r1 = a1.create_role(@t_r1, t1)
|
|
100
|
+
@r2 = a1.create_role(@t_r3, t2)
|
|
101
|
+
@r4 = a2.create_role(@t_r1, t1)
|
|
102
|
+
@r5 = a2.create_role(@t_r3, t3)
|
|
103
|
+
@r6 = a3.create_role(@t_r1, t1)
|
|
104
|
+
@r7 = a3.create_role(@t_r5, t5)
|
|
105
|
+
@r3 = a4.create_role(@t_r1, t1)
|
|
106
|
+
@r8 = a4.create_role(@t_r3, t4)
|
|
107
|
+
@r9 = a4.create_role(@t_r6, t6)
|
|
108
|
+
@r10 = a5.create_role(@t_r4, t1)
|
|
109
|
+
@r11 = a5.create_role(@t_r3, t7)
|
|
110
|
+
@r12 = a6.create_role(@t_r4,t1)
|
|
111
|
+
@r13 = a6.create_role(@t_r2,t8)
|
|
112
|
+
end
|
|
113
|
+
after(:each) do
|
|
114
|
+
@tm.close
|
|
115
|
+
end
|
|
116
|
+
describe "#peers" do
|
|
117
|
+
it "should give back roles of other associations (with same size and atype) that have the same rtype and otype" do
|
|
118
|
+
@r5.peers.size.should == 1
|
|
119
|
+
@r5.peers.should include @r2
|
|
120
|
+
@r5.peers(:arity => :stuff, :otype => :stuff, :atype => :stuff, :rtyoe => :stuff).should == @r5.peers
|
|
121
|
+
end
|
|
122
|
+
it "should give back roles of other associations (with any size but same atype) that have the same rtype and otype" do
|
|
123
|
+
@r5.peers(:arity => :loose).size.should == 2
|
|
124
|
+
@r5.peers(:arity => :loose).should include @r2
|
|
125
|
+
@r5.peers(:arity => :loose).should include @r8
|
|
126
|
+
end
|
|
127
|
+
it "should give back roles of other associations (with same size and atype) that have the same otype but not rtype" do
|
|
128
|
+
@r5.peers(:rtype => :loose).size.should == 2
|
|
129
|
+
@r5.peers(:rtype => :loose).should include @r2,@r7
|
|
130
|
+
end
|
|
131
|
+
it "should give back roles of other associations (with any size but same atype) that have the same otype but not rtype" do
|
|
132
|
+
@r5.peers(:arity => :loose, :rtype => :loose).size.should == 4
|
|
133
|
+
@r5.peers(:arity => :loose, :rtype => :loose).should include @r2,@r7,@r8,@r9
|
|
134
|
+
end
|
|
135
|
+
it "should give back roles of other associations (with same size and atype) that have any otype but same rtype" do
|
|
136
|
+
@r5.peers(:otype => :loose).size.should == 2
|
|
137
|
+
@r5.peers(:otype => :loose).should include @r2,@r11
|
|
138
|
+
end
|
|
139
|
+
it "should give back roles of other associations (with same size but any atype) that have any otype and rtype" do
|
|
140
|
+
@r5.peers(:atype => :loose, :otype => :loose, :rtype => :loose).size == 4
|
|
141
|
+
@r5.peers(:atype => :loose, :otype => :loose, :rtype => :loose).should include @r7,@r13,@r2,@r11
|
|
142
|
+
end
|
|
143
|
+
it "should raise an error if argument is not a Hash" do
|
|
144
|
+
lambda{@r5.peers("something")}.should raise_error
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
describe self do
|
|
150
|
+
before(:each) do
|
|
151
|
+
@tm = get_used_tm_sys_tm
|
|
152
|
+
@dad1 = @tm.get!("dad1")
|
|
153
|
+
@dad2 = @tm.get!("dad2")
|
|
154
|
+
@mom1 = @tm.get!("mom1")
|
|
155
|
+
@mom2 = @tm.fet!("mom2")
|
|
156
|
+
@kid1 = @tm.get!("kid1")
|
|
157
|
+
@kid2 = @tm.get!("kid2")
|
|
158
|
+
@kid3 = @tm.get!("kid3")
|
|
159
|
+
@kid4 = @tm.get!("kid4")
|
|
160
|
+
@pk = @tm.get!("parent_kid")
|
|
161
|
+
@mr = @tm.get!("mom_role")
|
|
162
|
+
@dr = @tm.get!("dad_role")
|
|
163
|
+
@kr = @tm.get!("kid_role")
|
|
164
|
+
@assoc1 = @tm.create_association(@pk)
|
|
165
|
+
@r_a1_k1 = @assoc1.create_role(@kr,@kid1)
|
|
166
|
+
@r_a1_m1 = @assoc1.create_role(@mr,@mom1)
|
|
167
|
+
@r_a1_d1 = @assoc1.create_role(@dr,@dad1)
|
|
168
|
+
@assoc2 = @tm.create_association(@pk)
|
|
169
|
+
@r_a2_k2 = @assoc2.create_role(@kr,@kid2)
|
|
170
|
+
@r_a2_m1 = @assoc2.create_role(@mr,@mom1)
|
|
171
|
+
@r_a2_d1 = @assoc2.create_role(@dr,@dad1)
|
|
172
|
+
@assoc3 = @tm.create_association(@pk)
|
|
173
|
+
@r_a3_k3 = @assoc3.create_role(@kr,@kid3)
|
|
174
|
+
@r_a3_m2 = @assoc3.create_role(@mr,@mom2)
|
|
175
|
+
@r_a3_d1 = @assoc3.create_role(@dr,@dad1)
|
|
176
|
+
@assoc4 = @tm.create_association(@pk)
|
|
177
|
+
@r_a4_k4 = @assoc4.create_role(@kr,@kid4)
|
|
178
|
+
@r_a4_m1 = @assoc4.create_role(@mr,@mom1)
|
|
179
|
+
@r_a4_d2 = @assoc4.create_role(@dr,@dad2)
|
|
180
|
+
end
|
|
181
|
+
after(:each) do
|
|
182
|
+
@tm.close
|
|
183
|
+
end
|
|
184
|
+
describe "#peers the second time" do
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
@@ -0,0 +1,318 @@
|
|
|
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::Topic::Characteristics
|
|
7
|
+
describe self do
|
|
8
|
+
before(:each) do
|
|
9
|
+
@tm = get_used_tm_sys_tm
|
|
10
|
+
end
|
|
11
|
+
after(:each) do
|
|
12
|
+
@tm.close
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "#internal_occurrences" do
|
|
16
|
+
before(:each) do
|
|
17
|
+
@uni_leipzig = @tm.get!("Uni_LE")
|
|
18
|
+
@occ1 = @uni_leipzig.create_occurrence("Alter","600")
|
|
19
|
+
@occ2 = @uni_leipzig.create_occurrence("Heimat","Sachsen")
|
|
20
|
+
@occ3 = @uni_leipzig.create_occurrence("Webseite",@tm.create_locator("http://www.uni-leipzig.de"))
|
|
21
|
+
end
|
|
22
|
+
it "should give back all occurrences that are not of Datatype AnyURI" do
|
|
23
|
+
@uni_leipzig.internal_occurrences.size.should == 2
|
|
24
|
+
@uni_leipzig.internal_occurrences.should include(@occ1)
|
|
25
|
+
@uni_leipzig.internal_occurrences.should include(@occ2)
|
|
26
|
+
end
|
|
27
|
+
end #of describe "#internal_occurrences" do
|
|
28
|
+
|
|
29
|
+
describe "#external_occurrences" do
|
|
30
|
+
before(:each) do
|
|
31
|
+
@uni_leipzig = @tm.get!("Uni_LE")
|
|
32
|
+
@occ1 = @uni_leipzig.create_occurrence("Alter","600")
|
|
33
|
+
@occ2 = @uni_leipzig.create_occurrence("Heimat","Sachsen")
|
|
34
|
+
@occ3 = @uni_leipzig.create_occurrence("Webseite",@tm.create_locator("http://www.uni-leipzig.de"))
|
|
35
|
+
end
|
|
36
|
+
it "should give back all occurrences that are of Datatype AnyURI" do
|
|
37
|
+
@uni_leipzig.external_occurrences.size.should == 1
|
|
38
|
+
@uni_leipzig.external_occurrences.should include(@occ3)
|
|
39
|
+
end
|
|
40
|
+
end #of describe "#external_occurrences"
|
|
41
|
+
|
|
42
|
+
describe "#names_by" do
|
|
43
|
+
before(:each) do
|
|
44
|
+
@topic = @tm.get!("Hans")
|
|
45
|
+
@name1 = @topic.create_name("first_name","Hans-Peter")
|
|
46
|
+
@name2 = @topic.create_name("last_name","Mueller")
|
|
47
|
+
@name3 = @topic.create_name("Hans",["mum"])
|
|
48
|
+
@name4 = @topic.create_name("full_name","Hans-Peter Mueller",["official"])
|
|
49
|
+
@name5 = @topic.create_name("Hansi",["endearment","mum"])
|
|
50
|
+
end
|
|
51
|
+
it "should give back all names if no argument is given" do
|
|
52
|
+
@topic.should have(5).names_by
|
|
53
|
+
@topic.names_by.should include @name1, @name2, @name3, @name4, @name5
|
|
54
|
+
end
|
|
55
|
+
it "should give back all names if all values in the argument hash equal :any" do
|
|
56
|
+
@topic.names_by(:type => :any, :value => :any, :scope => :any).size.should == 5
|
|
57
|
+
@topic.names_by(:type => :any, :value => :any, :scope => :any).should include @name1, @name2, @name3, @name4, @name5
|
|
58
|
+
end
|
|
59
|
+
it "should give back some names if a type is given (identifier is a String)" do
|
|
60
|
+
@topic.names_by(:type => "first_name").size.should == 1
|
|
61
|
+
@topic.names_by(:type => "first_name").should include @name1
|
|
62
|
+
@topic.names_by(:type => ["first_name"]).should == @topic.names_by(:type => "first_name")
|
|
63
|
+
end
|
|
64
|
+
it "should give back some names if a type is given (identifier == :default)" do
|
|
65
|
+
@topic.names_by(:type => :default).size.should == 2
|
|
66
|
+
@topic.names_by(:type => :default).should include @name3, @name5
|
|
67
|
+
@topic.names_by(:type => [:default]).should == @topic.names_by(:type => :default)
|
|
68
|
+
end
|
|
69
|
+
it "should give back some names if a type is given (identifier is a Locator)" do
|
|
70
|
+
locator = @tm.create_locator("full_name")
|
|
71
|
+
locator.should be_a_kind_of RTM::Locator
|
|
72
|
+
@topic.names_by(:type => locator).size.should == 1
|
|
73
|
+
@topic.names_by(:type => locator).should include @name4
|
|
74
|
+
@topic.names_by(:type => [locator]).should == @topic.names_by(:type => locator)
|
|
75
|
+
end
|
|
76
|
+
it "should give back some names if a type is given (identifier is a Topic)" do
|
|
77
|
+
topic = @tm.get("last_name")
|
|
78
|
+
topic.should be_a_kind_of RTM::Topic
|
|
79
|
+
@topic.names_by(:type => topic).size.should == 1
|
|
80
|
+
@topic.names_by(:type => topic).should include @name2
|
|
81
|
+
@topic.names_by(:type => [topic]).should == @topic.names_by(:type => topic)
|
|
82
|
+
end
|
|
83
|
+
it "should give back some names if several types are given (identifier is an Array)" do
|
|
84
|
+
string = "first_name"
|
|
85
|
+
locator = @tm.create_locator("full_name")
|
|
86
|
+
topic = @tm.get("last_name")
|
|
87
|
+
symbol = :default
|
|
88
|
+
@topic.names_by(:type => [string,symbol,locator,topic]).size.should == 5
|
|
89
|
+
@topic.names_by(:type => [string,symbol,locator,topic]).should include @name1, @name2, @name3, @name4, @name5
|
|
90
|
+
end
|
|
91
|
+
it "should give back no names if a type is given but not a type of a name" do
|
|
92
|
+
@tm.get!("existing_dummy")
|
|
93
|
+
@topic.names_by(:type => "dummy").should be_empty
|
|
94
|
+
@topic.names_by(:type => "existing_dummy").should be_empty
|
|
95
|
+
@topic.names_by(:type => @tm.create_locator("dummy")).should be_empty
|
|
96
|
+
@topic.names_by(:type => @tm.create_locator("existing_dummy")).should be_empty
|
|
97
|
+
@topic.names_by(:type => @tm.get("dummy")).should be_empty
|
|
98
|
+
@topic.names_by(:type => @tm.get("existing_dummy")).should be_empty
|
|
99
|
+
end
|
|
100
|
+
it "should give back some names if several types are given but some are not types of names" do
|
|
101
|
+
@topic.names_by(:type => ["dummy",:default,"first_name"]).size.should == 3
|
|
102
|
+
@topic.names_by(:type => ["dummy",:default,"first_name"]).should include @name1, @name3, @name5
|
|
103
|
+
end
|
|
104
|
+
it "should not give back a name several times if several equals types are given" do
|
|
105
|
+
@topic.names_by(:type => ["first_name","first_name"]).should == @topic.names_by(:type => "first_name")
|
|
106
|
+
end
|
|
107
|
+
it "should give back some names if a value is given" do
|
|
108
|
+
@topic.names_by(:value => "Hansi").size.should == 1
|
|
109
|
+
@topic.names_by(:value => "Hansi").should include @name5
|
|
110
|
+
@topic.names_by(:value => ["Hansi"]).should == @topic.names_by(:value => "Hansi")
|
|
111
|
+
end
|
|
112
|
+
it "should give back some names if several values are given" do
|
|
113
|
+
@topic.names_by(:value => ["Mueller","Hans-Peter"]).size.should == 2
|
|
114
|
+
@topic.names_by(:value => ["Mueller","Hans-Peter"]).should include @name1, @name2
|
|
115
|
+
end
|
|
116
|
+
it "should give back no names if a value is given which is not a value of a name" do
|
|
117
|
+
@topic.names_by(:value => "dummy").should be_empty
|
|
118
|
+
end
|
|
119
|
+
it "should give back some names if values are given but if not all are values of names" do
|
|
120
|
+
@topic.names_by(:value => ["Hans","dummy"]).size.should == 1
|
|
121
|
+
@topic.names_by(:value => ["Hans","dummy"]).should include @name3
|
|
122
|
+
end
|
|
123
|
+
it "should not give back a name several times if several equal values are given" do
|
|
124
|
+
@topic.names_by(:value => ["Hans","Hans"]).should == @topic.names_by(:value => "Hans")
|
|
125
|
+
end
|
|
126
|
+
it "should give back no names if a value is given which is not a String" do
|
|
127
|
+
@topic.names_by(:value => 1).should be_empty
|
|
128
|
+
@topic.names_by(:value => [1]).should be_empty
|
|
129
|
+
end
|
|
130
|
+
it "should give back some names if a scope is given (one theme, String)" do
|
|
131
|
+
@topic.names_by(:scope => "mum").size.should == 2
|
|
132
|
+
@topic.names_by(:scope => "mum").should include @name3, @name5
|
|
133
|
+
end
|
|
134
|
+
it "should give back some names if a scope is given (one theme, Locator)" do
|
|
135
|
+
locator = @tm.create_locator("official")
|
|
136
|
+
@topic.names_by(:scope => locator).size.should == 1
|
|
137
|
+
@topic.names_by(:scope => locator).should include @name4
|
|
138
|
+
end
|
|
139
|
+
it "should give back some names if a scope is given (one theme, Topic)" do
|
|
140
|
+
topic = @tm.get("endearment")
|
|
141
|
+
@topic.names_by(:scope => topic).size.should == 1
|
|
142
|
+
@topic.names_by(:scope => topic).should include @name5
|
|
143
|
+
end
|
|
144
|
+
it "should give back some names if a scope is given (several themes)" do
|
|
145
|
+
string = "mum"
|
|
146
|
+
locator = @tm.create_locator("official")
|
|
147
|
+
topic = @tm.get("endearment")
|
|
148
|
+
@topic.names_by(:scope => [string,locator,topic]).size.should == 3
|
|
149
|
+
@topic.names_by(:scope => [string,locator,topic]).should include @name3, @name4, @name5
|
|
150
|
+
end
|
|
151
|
+
it "should give back no names if a scope is given which is not a scope of a name" do
|
|
152
|
+
@topic.names_by(:scope => "dummy").should be_empty
|
|
153
|
+
end
|
|
154
|
+
it "should give back some names if a scope is given (several themes) but if not all are in the scope of names" do
|
|
155
|
+
@topic.names_by(:scope => ["mum","dummy"]).size.should == 2
|
|
156
|
+
@topic.names_by(:scope => ["mum","dummy"]).should include @name3, @name5
|
|
157
|
+
end
|
|
158
|
+
it "should give back no names if a scope is given which is not a String, Locator or Topic" do
|
|
159
|
+
lambda{topic.names_by(:scope => 1)}.should raise_error
|
|
160
|
+
lambda{@topic.names_by(:scope => [1])}.should raise_error
|
|
161
|
+
end
|
|
162
|
+
it "should not give back a name several times if several equal themes are given" do
|
|
163
|
+
@topic.names_by(:scope => ["official","official"]).should == @topic.names_by(:scope => "official")
|
|
164
|
+
end
|
|
165
|
+
it "should give back name in the unconstrained scope if scope equals :ucs"
|
|
166
|
+
it "should not create Topics" do
|
|
167
|
+
@tm.get("dummy1").should be_nil
|
|
168
|
+
@tm.get("dummy2").should be_nil
|
|
169
|
+
@tm.get("dummy3").should be_nil
|
|
170
|
+
@topic.names_by(:type => "dummy1", :value => "dummy2", :scope => "dummy3").should be_empty
|
|
171
|
+
@tm.get("dummy1").should be_nil
|
|
172
|
+
@tm.get("dummy2").should be_nil
|
|
173
|
+
@tm.get("dummy3").should be_nil
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
describe "#occurrences_by" do
|
|
178
|
+
before(:each) do
|
|
179
|
+
@topic = @tm.get!("Hans")
|
|
180
|
+
@occ1 = @topic.create_occurrence("birthyear","1980")
|
|
181
|
+
@occ2 = @topic.create_occurrence("favourite_colour","blue")
|
|
182
|
+
@occ3 = @topic.create_occurrence("age","29",:scope => ["2009"])
|
|
183
|
+
@occ4 = @topic.create_occurrence("hair_colour","blue",:scope => ["2009","halloween"])
|
|
184
|
+
@occ5 = @topic.create_occurrence("age","20",:datatype => RTM::PSI[:Integer],:scope => ["2000"])
|
|
185
|
+
end
|
|
186
|
+
it "should give back all occurrences if no argument is given" do
|
|
187
|
+
@topic.should have(5).occurrences_by
|
|
188
|
+
@topic.occurrences_by.should include @occ1, @occ2, @occ3, @occ4, @occ5
|
|
189
|
+
end
|
|
190
|
+
it "should give back all occurrences if all values in the argument hash equal :any" do
|
|
191
|
+
@topic.occurrences_by(:type => :any, :value => :any, :scope => :any, :datatype => :any).size.should == 5
|
|
192
|
+
@topic.occurrences_by(:type => :any, :value => :any, :scope => :any, :datatype => :any).should include @occ1, @occ2, @occ3, @occ4, @occ5
|
|
193
|
+
end
|
|
194
|
+
it "should give back some occurrences if a type is given (identifier is a String)" do
|
|
195
|
+
@topic.occurrences_by(:type => "birthyear").size.should == 1
|
|
196
|
+
@topic.occurrences_by(:type => "birthyear").should include @occ1
|
|
197
|
+
end
|
|
198
|
+
it "should give back some occurrences if a type is given (identifier is a Locator)" do
|
|
199
|
+
locator = @tm.create_locator("age")
|
|
200
|
+
locator.should be_a_kind_of RTM::Locator
|
|
201
|
+
@topic.occurrences_by(:type => locator).size.should == 2
|
|
202
|
+
@topic.occurrences_by(:type => locator).should include @occ3, @occ5
|
|
203
|
+
end
|
|
204
|
+
it "should give back some occurrences if a type is given (identifier is a Topic)" do
|
|
205
|
+
topic = @tm.get("hair_colour")
|
|
206
|
+
topic.should be_a_kind_of RTM::Topic
|
|
207
|
+
@topic.occurrences_by(:type => topic).size.should == 1
|
|
208
|
+
@topic.occurrences_by(:type => topic).should include @occ4
|
|
209
|
+
end
|
|
210
|
+
it "should give back some occurrences if several types are given (identifier is an Array)" do
|
|
211
|
+
string = "birthyear"
|
|
212
|
+
locator = @tm.create_locator("age")
|
|
213
|
+
topic = @tm.get("hair_colour")
|
|
214
|
+
@topic.occurrences_by(:type => [string,locator,topic]).size.should == 4
|
|
215
|
+
@topic.occurrences_by(:type => [string,locator,topic]).should include @occ1, @occ3, @occ4, @occ5
|
|
216
|
+
end
|
|
217
|
+
it "should give back no occurrences if a type is given which is not a type of an occurrence" do
|
|
218
|
+
@tm.get!("existing_dummy")
|
|
219
|
+
@topic.occurrences_by(:type => "dummy").should be_empty
|
|
220
|
+
@topic.occurrences_by(:type => "existing_dummy").should be_empty
|
|
221
|
+
@topic.occurrences_by(:type => @tm.create_locator("dummy")).should be_empty
|
|
222
|
+
@topic.occurrences_by(:type => @tm.create_locator("existing_dummy")).should be_empty
|
|
223
|
+
@topic.occurrences_by(:type => @tm.get("dummy")).should be_empty
|
|
224
|
+
@topic.occurrences_by(:type => @tm.get("existing_dummy")).should be_empty
|
|
225
|
+
end
|
|
226
|
+
it "should give back some occurrences if several types are given but some are not types of occurrences" do
|
|
227
|
+
@topic.occurrences_by(:type => ["dummy","age"]).size.should == 2
|
|
228
|
+
@topic.occurrences_by(:type => ["dummy","age"]).should include @occ3, @occ5
|
|
229
|
+
end
|
|
230
|
+
it "should not give back an occurrence several times if several equal types are given" do
|
|
231
|
+
@topic.occurrences_by(:type => ["birthyear","birthyear"]).should == @topic.occurrences_by(:type => "birthyear")
|
|
232
|
+
end
|
|
233
|
+
it "should give back some occurrences if a value is given" do
|
|
234
|
+
@topic.occurrences_by(:value => "1980").size.should == 1
|
|
235
|
+
@topic.occurrences_by(:value => "1980").should include @occ1
|
|
236
|
+
@topic.occurrences_by(:value => "29").size.should == 1
|
|
237
|
+
@topic.occurrences_by(:value => "29").should include @occ3
|
|
238
|
+
end
|
|
239
|
+
it "should give back some occurrences if several values are given" do
|
|
240
|
+
@topic.occurrences_by(:value => ["blue","20"]).size.should == 3
|
|
241
|
+
@topic.occurrences_by(:value => ["blue","20"]).should include @occ2, @occ4, @occ5
|
|
242
|
+
end
|
|
243
|
+
it "should give back no occurrences if a value is given which is not a value of an occurrence" do
|
|
244
|
+
@topic.occurrences_by(:value => "dummy").should be_empty
|
|
245
|
+
end
|
|
246
|
+
it "should give back some occurrences if several values are given but some are not values of occurrences" do
|
|
247
|
+
@topic.occurrences_by(:value => ["blue","dummy","29"]).size.should == 3
|
|
248
|
+
@topic.occurrences_by(:value => ["blue","dummy","29"]).should include @occ2, @occ3, @occ4
|
|
249
|
+
end
|
|
250
|
+
it "should not give back an occurrence several times if several equal values are given" do
|
|
251
|
+
@topic.occurrences_by(:value => ["20","20"]).should == @topic.occurrences_by(:value => "20")
|
|
252
|
+
end
|
|
253
|
+
it "should give back no names if a value is given which is not a String" do
|
|
254
|
+
@topic.occurrences_by(:value => 20).should be_empty
|
|
255
|
+
@topic.occurrences_by(:value => [20]).should be_empty
|
|
256
|
+
end
|
|
257
|
+
it "should give back some occurrences if a scope is given (one theme, String)" do
|
|
258
|
+
@topic.occurrences_by(:scope => "2009").size.should == 2
|
|
259
|
+
@topic.occurrences_by(:scope => "2009").should include @occ3, @occ4
|
|
260
|
+
end
|
|
261
|
+
it "should give back some occurrences if a scope is given (one theme, Locator)" do
|
|
262
|
+
locator = @tm.create_locator("2000")
|
|
263
|
+
@topic.occurrences_by(:scope => locator).size.should == 1
|
|
264
|
+
@topic.occurrences_by(:scope => locator).should include @occ5
|
|
265
|
+
end
|
|
266
|
+
it "should give back some occurrences if a scope is given (one theme, Topic)" do
|
|
267
|
+
topic = @tm.get("halloween")
|
|
268
|
+
@topic.occurrences_by(:scope => topic).size.should == 1
|
|
269
|
+
@topic.occurrences_by(:scope => topic).should include @occ4
|
|
270
|
+
end
|
|
271
|
+
it "should give back some occurrences if a scope is given (several themes)" do
|
|
272
|
+
string = "2000"
|
|
273
|
+
locator = @tm.create_locator("2009")
|
|
274
|
+
topic = @tm.get("halloween")
|
|
275
|
+
@topic.occurrences_by(:scope => [string,locator,topic]).size.should == 3
|
|
276
|
+
@topic.occurrences_by(:scope => [string,locator,topic]).should include @occ3, @occ4, @occ5
|
|
277
|
+
end
|
|
278
|
+
it "should give back no occurrences if a scope is given which is not a scope of an occurrence" do
|
|
279
|
+
@topic.occurrences_by(:scope => "dummy").should be_empty
|
|
280
|
+
end
|
|
281
|
+
it "should give back some occurrences if a scope is given (several themes) but if not all are in the scope of occurrences" do
|
|
282
|
+
@topic.occurrences_by(:scope => ["2000","dummy"]).size.should == 1
|
|
283
|
+
@topic.occurrences_by(:scope => ["2000","dummy"]).should include @occ5
|
|
284
|
+
end
|
|
285
|
+
it "should give back no occurrences if a scope is given which is not a String, Locator or Topic" do
|
|
286
|
+
lambda{topic.occurrences_by(:scope => 1)}.should raise_error
|
|
287
|
+
lambda{@topic.occurrences_by(:scope => [1])}.should raise_error
|
|
288
|
+
end
|
|
289
|
+
it "should not give back an occurrence several times if several equal themes are given" do
|
|
290
|
+
@topic.occurrences_by(:scope => ["2009","2009"]).should == @topic.occurrences_by(:scope => "2009")
|
|
291
|
+
end
|
|
292
|
+
it "should give back occurrences in the unconstrained scope if scope equals :ucs"
|
|
293
|
+
it "should test datatype"
|
|
294
|
+
it "should not create Topics" do
|
|
295
|
+
@tm.get("dummy1").should be_nil
|
|
296
|
+
@tm.get("dummy2").should be_nil
|
|
297
|
+
@tm.get("dummy3").should be_nil
|
|
298
|
+
@tm.get("dummy4").should be_nil
|
|
299
|
+
@topic.occurrences_by(:type => "dummy1", :value => "dummy2", :datatype => "dummy3", :scope => "dummy4").should be_empty
|
|
300
|
+
@tm.get("dummy1").should be_nil
|
|
301
|
+
@tm.get("dummy2").should be_nil
|
|
302
|
+
@tm.get("dummy3").should be_nil
|
|
303
|
+
@tm.get("dummy4").should be_nil
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
# describe "#characteristics_by" do
|
|
308
|
+
# before(:each) do
|
|
309
|
+
#
|
|
310
|
+
# end
|
|
311
|
+
# it "should be testend .." do
|
|
312
|
+
#
|
|
313
|
+
# end
|
|
314
|
+
# end
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
end # of describe self
|
|
318
|
+
end # of module
|