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,25 @@
|
|
|
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::Construct
|
|
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 "#id" do
|
|
16
|
+
it "should return the id of the construct as String" do
|
|
17
|
+
@tm.id.should be_a_kind_of String
|
|
18
|
+
topic = @tm.get!("x")
|
|
19
|
+
topic.id.should be_a_kind_of String
|
|
20
|
+
end
|
|
21
|
+
it "should be tested further"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,236 @@
|
|
|
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::DatatypeAware
|
|
7
|
+
|
|
8
|
+
describe self do
|
|
9
|
+
before(:each) do
|
|
10
|
+
@tm = get_used_tm_sys_tm
|
|
11
|
+
end
|
|
12
|
+
after(:each) do
|
|
13
|
+
@tm.close
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#value=" do
|
|
17
|
+
before(:each) do
|
|
18
|
+
@topic = @tm.get!("House")
|
|
19
|
+
end
|
|
20
|
+
describe "for Occurrence" do
|
|
21
|
+
it "should set the datatype to xsd:anyURI if argument datatype is xsd:anyURI" do
|
|
22
|
+
occ = @topic.create_occurrence("street number", "1")
|
|
23
|
+
occ.datatype.to_external_form.should == RTM::PSI[:String]
|
|
24
|
+
occ.value = "http://www.example.org/House", RTM::PSI[:IRI]
|
|
25
|
+
occ.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
26
|
+
occ.value.should == "http://www.example.org/House"
|
|
27
|
+
end
|
|
28
|
+
it "should set the datatype to xsd:anyURI if argument datatype is xsd:anyURI and resolve the value using the base iri" do
|
|
29
|
+
occ = @topic.create_occurrence("street number", "1")
|
|
30
|
+
occ.datatype.to_external_form.should == RTM::PSI[:String]
|
|
31
|
+
occ.value = "House", RTM::PSI[:IRI]
|
|
32
|
+
occ.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
33
|
+
occ.value.should == "http://www.topicmapslab.de/House"
|
|
34
|
+
end
|
|
35
|
+
it "should set the datatype to xsd:anyURI also if it was Integer before" do
|
|
36
|
+
occ = @topic.create_occurrence("street number", "1", :datatype => RTM::PSI[:Integer])
|
|
37
|
+
occ.value.should == "1"
|
|
38
|
+
occ.datatype.reference.should == RTM::PSI[:Integer]
|
|
39
|
+
occ.value = 1, RTM::PSI[:IRI]
|
|
40
|
+
occ.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
41
|
+
occ.value.should == "http://www.topicmapslab.de/1"
|
|
42
|
+
end
|
|
43
|
+
it "should set an IRI value and the datatype to xsd:AnyURI if argument is a Locator" do
|
|
44
|
+
occ = @topic.create_occurrence("street number", "1")
|
|
45
|
+
occ.datatype.to_external_form.should == RTM::PSI[:String]
|
|
46
|
+
occ.value = @tm.create_locator("http://www.example.org/House")
|
|
47
|
+
occ.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
48
|
+
occ.value.should == "http://www.example.org/House" # since we dont know if not */ as in case of ontopia
|
|
49
|
+
end
|
|
50
|
+
it "should set a String value and the datatype to xsd:String if argument is a String" do
|
|
51
|
+
occ = @topic.create_occurrence("Webseite", @tm.create_locator("http://www.example.org/House"))
|
|
52
|
+
occ.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
53
|
+
occ.value=("1")
|
|
54
|
+
occ.datatype.to_external_form.should == RTM::PSI[:String]
|
|
55
|
+
occ.value.should == "1"
|
|
56
|
+
end
|
|
57
|
+
it "should set a Float value and the datatype to xsd:Float if arguement is a Float" do
|
|
58
|
+
occ = @topic.create_occurrence("Webseite", @tm.create_locator("http://www.example.org/House"))
|
|
59
|
+
occ.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
60
|
+
0.5.class.should == Float
|
|
61
|
+
occ.value = 0.5
|
|
62
|
+
occ.datatype.to_external_form.should == RTM::PSI[:Float]
|
|
63
|
+
occ.value.should == "0.5"
|
|
64
|
+
end
|
|
65
|
+
it "should set a Fixnum value and the datatype to xsd:long if arguement is a Fixnum" do
|
|
66
|
+
occ = @topic.create_occurrence("Webseite", @tm.create_locator("http://www.example.org/House"))
|
|
67
|
+
occ.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
68
|
+
1.class.should == Fixnum
|
|
69
|
+
occ.value = 1
|
|
70
|
+
occ.datatype.to_external_form.should == RTM::PSI[:Long]
|
|
71
|
+
occ.value.should == "1"
|
|
72
|
+
end
|
|
73
|
+
it "should set a Bignum value and the datatype to xsd:integer if arguement is a Bignum" do
|
|
74
|
+
occ = @topic.create_occurrence("Webseite", @tm.create_locator("http://www.example.org/House"))
|
|
75
|
+
occ.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
76
|
+
9999999999999999999.class.should == Bignum
|
|
77
|
+
occ.value = 9999999999999999999
|
|
78
|
+
occ.datatype.to_external_form.should == RTM::PSI[:Integer]
|
|
79
|
+
occ.value.should == "9999999999999999999"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
describe "for Variant" do
|
|
83
|
+
it "should set the datatype to xsd:anyURI if argument datatype is xsd:anyURI" do
|
|
84
|
+
var = @topic.create_name("White House").create_variant("WH", ["short form"])
|
|
85
|
+
var.datatype.reference.should == RTM::PSI[:String]
|
|
86
|
+
var.value = "http://www.example.org/WhiteHouse", RTM::PSI[:IRI]
|
|
87
|
+
var.datatype.reference.should == RTM::PSI[:IRI]
|
|
88
|
+
var.value.should == "http://www.example.org/WhiteHouse"
|
|
89
|
+
end
|
|
90
|
+
it "should set the datatype to xsd:anyURI if argument datatype is xsd:anyURI and resolve the value using the base iri" do
|
|
91
|
+
var = @topic.create_name("White House").create_variant("WH", ["short form"])
|
|
92
|
+
var.datatype.to_external_form.should == RTM::PSI[:String]
|
|
93
|
+
var.value = "White-House", RTM::PSI[:IRI]
|
|
94
|
+
var.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
95
|
+
var.value.should == "http://www.topicmapslab.de/White-House"
|
|
96
|
+
end
|
|
97
|
+
it "should set the datatype to xsd:anyURI also if it was Integer before" do
|
|
98
|
+
var = @topic.create_name("White House").create_variant("1", RTM::PSI[:Integer], ["short form"])
|
|
99
|
+
var.value.should == "1"
|
|
100
|
+
var.datatype.reference.should == RTM::PSI[:Integer]
|
|
101
|
+
var.value = 1, RTM::PSI[:IRI]
|
|
102
|
+
var.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
103
|
+
var.value.should == "http://www.topicmapslab.de/1"
|
|
104
|
+
end
|
|
105
|
+
it "should set an IRI value and the datatype to xsd:AnyURI if argument is a Locator" do
|
|
106
|
+
var = @topic.create_name("White House").create_variant("WH", ["short form"])
|
|
107
|
+
var.datatype.to_external_form.should == RTM::PSI[:String]
|
|
108
|
+
var.value = @tm.create_locator("http://www.example.org/House")
|
|
109
|
+
var.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
110
|
+
var.value.should == "http://www.example.org/House" # since we dont know if not */ as in case of ontopia
|
|
111
|
+
end
|
|
112
|
+
it "should set a String value and the datatype to xsd:String if argument is a String" do
|
|
113
|
+
var = @topic.create_name("White House").create_variant(@tm.create_locator("WH"), ["short form"])
|
|
114
|
+
var.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
115
|
+
var.value=("1")
|
|
116
|
+
var.datatype.to_external_form.should == RTM::PSI[:String]
|
|
117
|
+
var.value.should == "1"
|
|
118
|
+
end
|
|
119
|
+
it "should set a Float value and the datatype to xsd:Float if arguement is a Float" do
|
|
120
|
+
var = @topic.create_name("White House").create_variant(@tm.create_locator("WH"), ["short form"])
|
|
121
|
+
var.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
122
|
+
0.5.class.should == Float
|
|
123
|
+
var.value = 0.5
|
|
124
|
+
var.datatype.to_external_form.should == RTM::PSI[:Float]
|
|
125
|
+
var.value.should == "0.5"
|
|
126
|
+
end
|
|
127
|
+
it "should set a Fixnum value and the datatype to xsd:long if arguement is a Fixnum" do
|
|
128
|
+
var = @topic.create_name("White House").create_variant(@tm.create_locator("WH"), ["short form"])
|
|
129
|
+
var.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
130
|
+
1.class.should == Fixnum
|
|
131
|
+
var.value = 1
|
|
132
|
+
var.datatype.to_external_form.should == RTM::PSI[:Long]
|
|
133
|
+
var.value.should == "1"
|
|
134
|
+
end
|
|
135
|
+
it "should set a Bignum value and the datatype to xsd:integer if arguement is a Bignum" do
|
|
136
|
+
var = @topic.create_name("White House").create_variant(@tm.create_locator("WH"), ["short form"])
|
|
137
|
+
var.datatype.to_external_form.should == RTM::PSI[:IRI]
|
|
138
|
+
9999999999999999999.class.should == Bignum
|
|
139
|
+
var.value = 9999999999999999999
|
|
140
|
+
var.datatype.to_external_form.should == RTM::PSI[:Integer]
|
|
141
|
+
var.value.should == "9999999999999999999"
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
describe "#datatype=" do
|
|
148
|
+
before(:each) do
|
|
149
|
+
@topic = @tm.get!("House")
|
|
150
|
+
end
|
|
151
|
+
describe "for Occurrence" do
|
|
152
|
+
it "should set the datatype to xsd:anyURI even if value is a String" do
|
|
153
|
+
occ = @topic.create_occurrence("street number", "1")
|
|
154
|
+
occ.datatype.reference.should == RTM::PSI[:String]
|
|
155
|
+
occ.datatype = RTM::PSI[:IRI]
|
|
156
|
+
occ.datatype.reference.should == RTM::PSI[:IRI]
|
|
157
|
+
end
|
|
158
|
+
it "should set the datatype to xsd:String even if value is a Locator" do
|
|
159
|
+
occ = @topic.create_occurrence("wesbite", @tm.create_locator("http://www.example.org/House"))
|
|
160
|
+
occ.value.should == "http://www.example.org/House"
|
|
161
|
+
occ.datatype.reference.should == RTM::PSI[:IRI]
|
|
162
|
+
occ.datatype = RTM::PSI[:String]
|
|
163
|
+
occ.value.should == "http://www.example.org/House"
|
|
164
|
+
occ.datatype.reference.should == RTM::PSI[:String]
|
|
165
|
+
end
|
|
166
|
+
it "should set the datatype to xsd:anyURI even if value is a number" do
|
|
167
|
+
occ = @topic.create_occurrence("street number", "1", :datatype => RTM::PSI[:Integer])
|
|
168
|
+
occ.value.should == "1"
|
|
169
|
+
occ.datatype.reference.should == RTM::PSI[:Integer]
|
|
170
|
+
occ.datatype = RTM::PSI[:IRI]
|
|
171
|
+
occ.value.should == "http://www.topicmapslab.de/1"
|
|
172
|
+
occ.datatype.reference.should == RTM::PSI[:IRI]
|
|
173
|
+
end
|
|
174
|
+
it "should set the datatype to xsd:Integer even if value is a String" do
|
|
175
|
+
occ = @topic.create_occurrence("street number", "1")
|
|
176
|
+
occ.value.should == "1"
|
|
177
|
+
occ.datatype.reference.should == RTM::PSI[:String]
|
|
178
|
+
occ.datatype = RTM::PSI[:Integer]
|
|
179
|
+
occ.value.should == "1"
|
|
180
|
+
occ.datatype.reference.should == RTM::PSI[:Integer]
|
|
181
|
+
end
|
|
182
|
+
it "should raise an error if datatype is no String or Locator" do
|
|
183
|
+
occ = @topic.create_occurrence("street number", "1")
|
|
184
|
+
occ.datatype.reference.should == RTM::PSI[:String]
|
|
185
|
+
lambda{occ.datatype = 1}.should raise_error
|
|
186
|
+
# don't test for symbols
|
|
187
|
+
#lambda{occ.datatype = :test}.should raise_error
|
|
188
|
+
lambda{occ.datatype = @tm.get!(RTM::PSI[:IRI])}.should raise_error
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
describe "for Variant" do
|
|
192
|
+
it "should set the datatype to xsd:anyURI even if value is a String" do
|
|
193
|
+
var = @topic.create_name("White House").create_variant("WH", ["short form"])
|
|
194
|
+
var.value.should == "WH"
|
|
195
|
+
var.datatype.reference.should == RTM::PSI[:String]
|
|
196
|
+
var.datatype = RTM::PSI[:IRI]
|
|
197
|
+
var.datatype.reference.should == RTM::PSI[:IRI]
|
|
198
|
+
end
|
|
199
|
+
it "should set the datatype to xsd:String even if value is a Locator" do
|
|
200
|
+
var = @topic.create_name("White House").create_variant(@tm.create_locator("http://www.example.org/House"), ["short form"])
|
|
201
|
+
var.value.should == "http://www.example.org/House"
|
|
202
|
+
var.datatype.reference.should == RTM::PSI[:IRI]
|
|
203
|
+
var.datatype = RTM::PSI[:String]
|
|
204
|
+
var.value.should == "http://www.example.org/House"
|
|
205
|
+
var.datatype.reference.should == RTM::PSI[:String]
|
|
206
|
+
end
|
|
207
|
+
it "should set the datatype to xsd:anyURI even if value is a number" do
|
|
208
|
+
var = @topic.create_name("White House").create_variant("1", RTM::PSI[:Integer], ["short form"])
|
|
209
|
+
var.value.should == "1"
|
|
210
|
+
var.datatype.reference.should == RTM::PSI[:Integer]
|
|
211
|
+
var.datatype = RTM::PSI[:IRI]
|
|
212
|
+
var.value.should == "http://www.topicmapslab.de/1"
|
|
213
|
+
var.datatype.reference.should == RTM::PSI[:IRI]
|
|
214
|
+
end
|
|
215
|
+
it "should set the datatype to xsd:Integer even if value is a String" do
|
|
216
|
+
occ = @topic.create_name("White House").create_variant("1", ["short form"])
|
|
217
|
+
occ.value.should == "1"
|
|
218
|
+
occ.datatype.reference.should == RTM::PSI[:String]
|
|
219
|
+
occ.datatype = RTM::PSI[:Integer]
|
|
220
|
+
occ.value.should == "1"
|
|
221
|
+
occ.datatype.reference.should == RTM::PSI[:Integer]
|
|
222
|
+
end
|
|
223
|
+
it "should raise an error if datatype is no String or Locator" do
|
|
224
|
+
var = @topic.create_name("White House").create_variant("1", ["short form"])
|
|
225
|
+
var.datatype.reference.should == RTM::PSI[:String]
|
|
226
|
+
lambda{var.datatype = 1}.should raise_error
|
|
227
|
+
# don't test for symbols
|
|
228
|
+
#lambda{var.datatype = :test}.should raise_error
|
|
229
|
+
lambda{var.datatype = @tm.get!(RTM::PSI[:IRI])}.should raise_error
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
end
|
|
236
|
+
end
|
|
@@ -0,0 +1,270 @@
|
|
|
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::Name
|
|
7
|
+
|
|
8
|
+
describe self do
|
|
9
|
+
before(:each) do
|
|
10
|
+
@tm = get_used_tm_sys_tm
|
|
11
|
+
@topic = @tm.create_topic_by("Uni_Leipzig")
|
|
12
|
+
@testname = @topic.create_name("Universitaet Leipzig")
|
|
13
|
+
end
|
|
14
|
+
after(:each) do
|
|
15
|
+
@tm.close
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "#parent" do
|
|
19
|
+
it "should give back the Topic the Name belongs to" do
|
|
20
|
+
#puts "ancestors:"
|
|
21
|
+
#puts @testname.java_class
|
|
22
|
+
#puts @testname.class.ancestors
|
|
23
|
+
@testname.should be_a_kind_of RTM::Name
|
|
24
|
+
@testname.parent.should == @topic
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "#atomify" do
|
|
29
|
+
it "should give back the value of the Name" do
|
|
30
|
+
@testname.should be_a_kind_of RTM::Name
|
|
31
|
+
@testname.atomify.should == "Universitaet Leipzig"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "#children" do
|
|
36
|
+
it "should return all Variants defined for this Name" do
|
|
37
|
+
topic = @tm.create_topic_by("Uni_Leipzig")
|
|
38
|
+
name = topic.create_name("Universitaet Leipzig")
|
|
39
|
+
scope1 = @tm.create_topic_by("englisch")
|
|
40
|
+
scope2 = @tm.create_topic_by("umgangssprachlich")
|
|
41
|
+
variant1 = name.create_variant("University of Leipzig", [scope1])
|
|
42
|
+
variant2 = name.create_variant("Universiaet Leipzsch", [scope2])
|
|
43
|
+
#puts "ancestors:"
|
|
44
|
+
#puts variant1.java_class
|
|
45
|
+
#puts variant1.class.ancestors.inspect
|
|
46
|
+
variant1.should be_a_kind_of RTM::Variant
|
|
47
|
+
variant2.should be_a_kind_of RTM::Variant
|
|
48
|
+
name.children.size.should == 2
|
|
49
|
+
name.children.should include(variant1)
|
|
50
|
+
name.children.should include(variant2)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe "#create_variant" do
|
|
55
|
+
describe "in tmapi notation" do
|
|
56
|
+
describe "(errors)" do
|
|
57
|
+
it "should raise an error if the value's datatype is not supported" do
|
|
58
|
+
lambda{@testname.create_variant({:a => :b}, ["scope"])}.should raise_error
|
|
59
|
+
end
|
|
60
|
+
it "should not raise an error if a datatype is given, the value's datatype is not supported but the value may be converted to string" do
|
|
61
|
+
lambda{:a.to_s}.should_not raise_error
|
|
62
|
+
lambda{@testname.create_variant(:a, RTM::PSI[:String], ["scope"])}.should_not raise_error
|
|
63
|
+
end
|
|
64
|
+
it "should raise an error if no scope is given" do
|
|
65
|
+
lambda{@testname.create_variant("Uni Leipzig")}.should raise_error
|
|
66
|
+
end
|
|
67
|
+
it "should raise an error if the scope is an empty array" do
|
|
68
|
+
if implementation_for_spec == :ontopia
|
|
69
|
+
pending "ontopia" do
|
|
70
|
+
lambda{@testname.create_variant("Uni Leipzig", [])}.should raise_error
|
|
71
|
+
end
|
|
72
|
+
else
|
|
73
|
+
lambda{@testname.create_variant("Uni Leipzig", [])}.should raise_error
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
describe "given value and scope" do
|
|
78
|
+
after(:each) do
|
|
79
|
+
@var.should be_a_kind_of RTM::Variant
|
|
80
|
+
@var.scope.should_not be_empty
|
|
81
|
+
end
|
|
82
|
+
it "should create a variant with datatype xsd:string if value is a String" do
|
|
83
|
+
@var = @testname.create_variant("Uni Leipzig", ["short_form"])
|
|
84
|
+
@var.value.should == "Uni Leipzig"
|
|
85
|
+
@var.datatype.reference.should == RTM::PSI[:String]
|
|
86
|
+
@var.scope.size.should == 1
|
|
87
|
+
@var.scope.should include(@tm.get("short_form"))
|
|
88
|
+
end
|
|
89
|
+
it "should create a variant with datatype xsd:anyURI if value is a Locator" do
|
|
90
|
+
@var = @testname.create_variant(@tm.create_locator("http://example.org/testvariant"), [@tm.create_locator("short form")])
|
|
91
|
+
@var.value.should == "http://example.org/testvariant"
|
|
92
|
+
@var.datatype.reference.should == RTM::PSI[:IRI]
|
|
93
|
+
@var.scope.size.should == 1
|
|
94
|
+
@var.scope.should include(@tm.get("short form"))
|
|
95
|
+
end
|
|
96
|
+
it "should create a variant with datatype xsd:float if value is a Float" do
|
|
97
|
+
@var = @testname.create_variant(0.5, [@tm.get!("theme1"), "theme2"])
|
|
98
|
+
@var.value.should == "0.5"
|
|
99
|
+
@var.datatype.reference.should == RTM::PSI[:Float]
|
|
100
|
+
@var.scope.size.should == 2
|
|
101
|
+
@var.scope.should include(@tm.get("theme1"), @tm.get("theme2"))
|
|
102
|
+
end
|
|
103
|
+
it "should create a variant with datatype xsd:long if value is a Fixnum" do
|
|
104
|
+
@var = @testname.create_variant(5, [@tm.get!("theme1"), @tm.create_locator("theme2")])
|
|
105
|
+
@var.value.should == "5"
|
|
106
|
+
@var.datatype.reference.should == RTM::PSI[:Long]
|
|
107
|
+
@var.scope.size.should == 2
|
|
108
|
+
@var.scope.should include(@tm.get("theme1"), @tm.get("theme2"))
|
|
109
|
+
end
|
|
110
|
+
it "should create a variant with datatype xsd:integer if value is a Bignum" do
|
|
111
|
+
number = 9999999999999999999
|
|
112
|
+
number.class.should == Bignum
|
|
113
|
+
@var = @testname.create_variant(number, [@tm.get!("theme1"), "theme2"])
|
|
114
|
+
@var.value.should == number.to_s
|
|
115
|
+
@var.datatype.reference.should == RTM::PSI[:Integer]
|
|
116
|
+
@var.scope.size.should == 2
|
|
117
|
+
@var.scope.should include(@tm.get("theme1"), @tm.get("theme2"))
|
|
118
|
+
end
|
|
119
|
+
describe "given a parent name with scope" do
|
|
120
|
+
it "should create a variant" do
|
|
121
|
+
@name = @topic.create_name("University of Leipzig", ["en", "official"])
|
|
122
|
+
@name.scope.size.should == 2
|
|
123
|
+
@name.scope.should include(@tm.get("en"), @tm.get("official"))
|
|
124
|
+
@var = @name.create_variant("U o L", ["short form"])
|
|
125
|
+
@var.scope.size.should == 3
|
|
126
|
+
@var.scope.should include(@tm.get("en"), @tm.get("official"), @tm.get("short form"))
|
|
127
|
+
@var.datatype.reference.should == RTM::PSI[:String]
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
describe "given value, datatype and scope" do
|
|
132
|
+
after(:each) do
|
|
133
|
+
if @var
|
|
134
|
+
@var.should be_a_kind_of RTM::Variant
|
|
135
|
+
@var.scope.should_not be_empty
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
describe "and value is a String" do
|
|
139
|
+
after(:each) do
|
|
140
|
+
if @var
|
|
141
|
+
@var.scope.size.should == 1
|
|
142
|
+
@var.scope.should include(@tm.get("short_form"))
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
it "should create a variant if datatye is xsd:string" do
|
|
146
|
+
@var = @testname.create_variant("Uni Leipzig", RTM::PSI[:String], ["short_form"])
|
|
147
|
+
@var.value.should == "Uni Leipzig"
|
|
148
|
+
@var.datatype.reference.should == RTM::PSI[:String]
|
|
149
|
+
end
|
|
150
|
+
it "should create a variant if datatye is xsd:anyURI" do
|
|
151
|
+
@var = @testname.create_variant("Uni Leipzig", RTM::PSI[:IRI], ["short_form"])
|
|
152
|
+
@var.value.should == "http://www.topicmapslab.de/Uni Leipzig"
|
|
153
|
+
@var.datatype.reference.should == RTM::PSI[:IRI]
|
|
154
|
+
end
|
|
155
|
+
it "should create a variant if datatye is xsd:float" do
|
|
156
|
+
@var = @testname.create_variant("0.5", RTM::PSI[:Float], ["short_form"])
|
|
157
|
+
@var.value.should == "0.5"
|
|
158
|
+
@var.datatype.reference.should == RTM::PSI[:Float]
|
|
159
|
+
end
|
|
160
|
+
it "should create a variant if datatye is xsd:long" do
|
|
161
|
+
@var = @testname.create_variant("5", RTM::PSI[:Long], ["short_form"])
|
|
162
|
+
@var.value.should == "5"
|
|
163
|
+
@var.datatype.reference.should == RTM::PSI[:Long]
|
|
164
|
+
end
|
|
165
|
+
it "should create a variant if datatye is xsd:integer" do
|
|
166
|
+
number = 9999999999999999999
|
|
167
|
+
number.class.should == Bignum
|
|
168
|
+
@var = @testname.create_variant(number.to_s, RTM::PSI[:Integer], ["short_form"])
|
|
169
|
+
@var.value.should == number.to_s
|
|
170
|
+
@var.datatype.reference.should == RTM::PSI[:Integer]
|
|
171
|
+
end
|
|
172
|
+
describe "but value is not a number" do
|
|
173
|
+
it "should create a variant if datatye is xsd:float" do
|
|
174
|
+
@var = @testname.create_variant("no number", RTM::PSI[:Float], ["short_form"])
|
|
175
|
+
@var.value.should == "no number"
|
|
176
|
+
@var.datatype.reference.should == RTM::PSI[:Float]
|
|
177
|
+
end
|
|
178
|
+
it "should create a variant if datatye is xsd:long" do
|
|
179
|
+
@var = @testname.create_variant("no number", RTM::PSI[:Long], ["short_form"])
|
|
180
|
+
@var.value.should == "no number"
|
|
181
|
+
@var.datatype.reference.should == RTM::PSI[:Long]
|
|
182
|
+
end
|
|
183
|
+
it "should create a variant if datatye is xsd:integer" do
|
|
184
|
+
if implementation_for_spec == :tinytim
|
|
185
|
+
lambda{@testname.create_variant("no number", RTM::PSI[:Integer], ["short_form"])}.should raise_error
|
|
186
|
+
else
|
|
187
|
+
@var = @testname.create_variant("no number", RTM::PSI[:Integer], ["short_form"])
|
|
188
|
+
@var.value.should == "no number"
|
|
189
|
+
@var.datatype.reference.should == RTM::PSI[:Integer]
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
describe "and value is a Locator" do
|
|
195
|
+
it "should create a variant if value is a Number and datatype is xsd:string"
|
|
196
|
+
it "should create a variant if value is a Number and datatype is xsd:anyURI"
|
|
197
|
+
it "should create a variant if value is a Number and datatype is xsd:float"
|
|
198
|
+
it "should create a variant if value is a Number and datatype is xsd:long"
|
|
199
|
+
it "should create a variant if value is a Number and datatype is xsd:integer"
|
|
200
|
+
describe "but value is not a number" do
|
|
201
|
+
it "should create a variant if datatye is xsd:float"
|
|
202
|
+
it "should create a variant if datatye is xsd:long"
|
|
203
|
+
it "should create a variant if datatye is xsd:integer"
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
describe "and value is a Number" do
|
|
207
|
+
it "should create a variant if value is a Number and datatype is xsd:string"
|
|
208
|
+
it "should create a variant if value is a Number and datatype is xsd:anyURI"
|
|
209
|
+
it "should create a variant if value is a Number and datatype is xsd:float"
|
|
210
|
+
it "should create a variant if value is a Number and datatype is xsd:long"
|
|
211
|
+
it "should create a variant if value is a Number and datatype is xsd:integer"
|
|
212
|
+
it "should be tested further"
|
|
213
|
+
end
|
|
214
|
+
describe "given a parent name with scope" do
|
|
215
|
+
it "should create a variant" do
|
|
216
|
+
@name = @topic.create_name("University of Leipzig", ["en", "official"])
|
|
217
|
+
@name.scope.size.should == 2
|
|
218
|
+
@name.scope.should include(@tm.get("en"), @tm.get("official"))
|
|
219
|
+
@var = @name.create_variant("U o L", RTM::PSI[:IRI], ["short form"])
|
|
220
|
+
@var.scope.size.should == 3
|
|
221
|
+
@var.scope.should include(@tm.get("en"), @tm.get("official"), @tm.get("short form"))
|
|
222
|
+
@var.datatype.reference.should == RTM::PSI[:IRI]
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
describe "in hash notation" do
|
|
228
|
+
describe "given value and scope" do
|
|
229
|
+
it "should create a variant with datatype xsd:string if value is a String"
|
|
230
|
+
it "should create a variant with datatype xsd:anyURI if value is a Locator"
|
|
231
|
+
it "should create a variant with datatype xsd:float if value is a Float"
|
|
232
|
+
it "should create a variant with datatype xsd:long if value is a Fixnum"
|
|
233
|
+
it "should create a variant with datatype xsd:integer if value is a Bignum"
|
|
234
|
+
it "should create a variant if scope is an empty array"
|
|
235
|
+
it "should raise an error if value's datatype is not supported"
|
|
236
|
+
end
|
|
237
|
+
describe "given value, datatype and scope" do
|
|
238
|
+
it "should be implemented and tested"
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
end # of describe self
|
|
244
|
+
|
|
245
|
+
describe self do
|
|
246
|
+
describe "#remove" do
|
|
247
|
+
before(:each) do
|
|
248
|
+
@tm = get_used_tm_sys_tm
|
|
249
|
+
@topic1 = @tm.get!("topic1")
|
|
250
|
+
@topic2 = @tm.get!("topic2")
|
|
251
|
+
@name = @topic1.create_name("firstname","Hans")
|
|
252
|
+
@name.create_variant("Hansi",["Spitzname"])
|
|
253
|
+
@topic2.create_name("firstname","Peter")
|
|
254
|
+
@topic1.should have(1).names
|
|
255
|
+
@topic1.names.should include @name
|
|
256
|
+
end
|
|
257
|
+
after(:each) do
|
|
258
|
+
@tm.close
|
|
259
|
+
end
|
|
260
|
+
it "should remove this name from the container (topic)" do
|
|
261
|
+
@tm.literal_index.getNames("Hans").size.should == 1
|
|
262
|
+
@name.remove
|
|
263
|
+
@tm.literal_index.getNames("Hans").size.should == 0
|
|
264
|
+
@tm.literal_index.getNames("Peter").size.should == 1
|
|
265
|
+
@topic1.should have(0).names
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
end # of describe self
|
|
269
|
+
|
|
270
|
+
end # of module
|