rtm 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +38 -3
- data/lib/rtm.rb +25 -47
- data/lib/rtm/axes.rb +7 -4
- data/lib/rtm/axes/association.rb +1 -1
- data/lib/rtm/axes/associations.rb +1 -1
- data/lib/rtm/axes/characteristic.rb +1 -1
- data/lib/rtm/axes/characteristics.rb +1 -1
- data/lib/rtm/axes/topic.rb +3 -3
- data/lib/rtm/axes/topics.rb +3 -3
- data/lib/rtm/engine.rb +48 -5
- data/lib/rtm/extensions.rb +58 -8
- data/lib/rtm/io.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 +79 -41
- data/lib/rtm/io/to_jtm.rb +1 -1
- data/lib/rtm/io/to_rdf.rb +20 -5
- data/lib/rtm/io/to_string.rb +13 -2
- data/lib/rtm/io/to_yaml.rb +39 -11
- data/lib/rtm/navigation.rb +1 -15
- data/lib/rtm/navigation/association/players.rb +1 -1
- data/lib/rtm/navigation/name/characteristics.rb +1 -1
- data/lib/rtm/navigation/occurrence/characteristics.rb +1 -1
- data/lib/rtm/navigation/topic/characteristics.rb +1 -1
- data/lib/rtm/navigation/topic/players.rb +1 -1
- data/lib/rtm/navigation/topic/supertypes.rb +21 -17
- data/lib/rtm/navigation/topic/traverse.rb +1 -1
- data/lib/rtm/navigation/topic/types.rb +6 -4
- data/lib/rtm/psi.rb +6 -0
- data/lib/rtm/sugar.rb +42 -29
- data/lib/rtm/sugar/association/hash_access.rb +3 -3
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +39 -56
- 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 +12 -6
- data/lib/rtm/sugar/topic/best_name.rb +74 -0
- data/lib/rtm/sugar/topic/characteristics.rb +10 -10
- data/lib/rtm/sugar/topic/counterparts.rb +131 -119
- data/lib/rtm/sugar/topic/scoped.rb +102 -53
- data/lib/rtm/sugar/topic/topic_ref.rb +63 -12
- data/lib/rtm/sugar/topic/typed.rb +50 -2
- 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 +1 -1
- data/lib/rtm/validation.rb +2 -2
- data/lib/rtm/version.rb +18 -6
- data/spec/rtm/axes/string_spec.rb +7 -7
- data/spec/rtm/axes/strings_spec.rb +10 -10
- 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/sugar/occurrence/dynamic_value_spec.rb +156 -1
- 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 +174 -172
- data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +20 -5
- data/spec/rtm/sugar/topic/counterparts_spec.rb +41 -1
- data/spec/rtm/sugar/topic/hash_access_spec.rb +1 -1
- data/spec/rtm/sugar/topic/scoped_spec.rb +178 -114
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +10 -10
- data/spec/rtm/sugar/topic/typed_spec.rb +196 -134
- data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
- data/spec/rtm/sugar/typed/types_spec.rb +1 -1
- data/spec/rtm/tmapi/core/association_spec.rb +2 -2
- data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
- data/spec/rtm/tmapi/core/name_spec.rb +186 -1
- data/spec/rtm/tmapi/core/occurrence_spec.rb +24 -67
- data/spec/rtm/tmapi/core/reifiable_spec.rb +2 -2
- data/spec/rtm/tmapi/core/scoped_spec.rb +40 -2
- data/spec/rtm/tmapi/core/topic_map_spec.rb +98 -30
- data/spec/rtm/tmapi/core/topic_spec.rb +558 -82
- data/spec/rtm/tmapi/core/variant_spec.rb +3 -3
- data/spec/rtm_spec.rb +0 -1
- data/spec/spec_helper.rb +7 -2
- 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 +66 -11
- data/lib/rtm/io/ontopia_io.rb +0 -25
- data/lib/rtm/io/tmapix.rb +0 -234
- data/lib/rtm/sugar/occurrence/externalize.rb +0 -31
- data/spec/rtm/io/tmapix_spec.rb +0 -85
- data/test/base_unit_test.rb +0 -161
- data/test/base_unit_test_tmapi.rb +0 -165
data/lib/rtm/validation.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
2
|
# License: Apache License, Version 2.0
|
|
3
3
|
|
|
4
|
-
module RTM
|
|
4
|
+
module RTM
|
|
5
5
|
module Validation
|
|
6
6
|
|
|
7
7
|
module Association
|
|
@@ -58,6 +58,6 @@ module RTM::AR
|
|
|
58
58
|
true
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
|
-
RTM
|
|
61
|
+
RTM.register_extension(self)
|
|
62
62
|
end
|
|
63
63
|
end
|
data/lib/rtm/version.rb
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
module RTM # :nodoc:
|
|
2
|
-
module VERSION # :nodoc:
|
|
3
|
-
unless
|
|
4
|
-
|
|
2
|
+
module VERSION # :nodoc:
|
|
3
|
+
unless self.const_defined?("MAJOR")
|
|
4
|
+
require 'date'
|
|
5
|
+
if Object.const_defined?("Gem") && rtmgem = Gem.loaded_specs["rtm"]
|
|
6
|
+
# Try to determine version from Gem, if we're loaded from there
|
|
7
|
+
today = rtmgem.date
|
|
8
|
+
elsif File.exist?(File.join(File.dirname(__FILE__), "../../../.hg"))
|
|
9
|
+
# Try to get the latest Mercurial commit date
|
|
10
|
+
hg_date_string = `hg --cwd "#{File.dirname(__FILE__)}" parent --template "{date|isodate}"`
|
|
11
|
+
today = Date.parse(hg_date_string)
|
|
12
|
+
else
|
|
13
|
+
# Fall back to current day
|
|
14
|
+
today = Date.today
|
|
15
|
+
end
|
|
16
|
+
DATE = [today.year, today.month, today.day]
|
|
5
17
|
ISODATE = "%04d-%02d-%02d" % DATE # => "2010-01-26"
|
|
6
18
|
COMPACTDATE = "%04d%02d%02d" % DATE # => "20100126"
|
|
7
19
|
|
|
8
20
|
MAJOR = 0
|
|
9
21
|
MINOR = 2
|
|
10
|
-
TINY =
|
|
11
|
-
BUILD = COMPACTDATE
|
|
22
|
+
TINY = 1
|
|
23
|
+
BUILD = ENV['BUILD_NUMBER'] || COMPACTDATE
|
|
12
24
|
|
|
13
|
-
STRING = [MAJOR, MINOR, TINY
|
|
25
|
+
STRING = [MAJOR, MINOR, TINY].compact.join('.')
|
|
14
26
|
|
|
15
27
|
SUMMARY = "rtm #{STRING}"
|
|
16
28
|
end
|
|
@@ -82,17 +82,17 @@ module RTM::Axes
|
|
|
82
82
|
|
|
83
83
|
describe "reverse identifier methods" do
|
|
84
84
|
before(:all) do
|
|
85
|
-
@value = "http://www.
|
|
86
|
-
@si_value = "http://www.
|
|
87
|
-
@ii_value = "http://www.
|
|
88
|
-
@sl_value = "http://www.
|
|
85
|
+
@value = "http://www.example.org/anything"
|
|
86
|
+
@si_value = "http://www.example.org/test_si"
|
|
87
|
+
@ii_value = "http://www.example.org/test_ii"
|
|
88
|
+
@sl_value = "http://www.example.org/test_sl"
|
|
89
89
|
@si_topic = @tm.get!("si:" + @si_value)
|
|
90
90
|
@ii_topic = @tm.get!("ii:" + @ii_value)
|
|
91
91
|
@sl_topic = @tm.get!("=" + @sl_value)
|
|
92
92
|
@all_topic = @tm.create_topic
|
|
93
|
-
@all_si_value = "http://www.
|
|
94
|
-
@all_ii_value = "http://www.
|
|
95
|
-
@all_sl_value = "http://www.
|
|
93
|
+
@all_si_value = "http://www.example.org/all_si"
|
|
94
|
+
@all_ii_value = "http://www.example.org/all_ii"
|
|
95
|
+
@all_sl_value = "http://www.example.org/all_sl"
|
|
96
96
|
@all_topic.add_subject_identifier(@all_si_value)
|
|
97
97
|
@all_topic.add_item_identifier(@all_ii_value)
|
|
98
98
|
@all_topic.add_subject_locator(@all_sl_value)
|
|
@@ -68,13 +68,13 @@ module RTM::Axes
|
|
|
68
68
|
|
|
69
69
|
describe "reverse identifier methods" do
|
|
70
70
|
before(:all) do
|
|
71
|
-
@value = "http://www.
|
|
72
|
-
@si_value1 = "http://www.
|
|
73
|
-
@ii_value1 = "http://www.
|
|
74
|
-
@sl_value1 = "http://www.
|
|
75
|
-
@si_value2 = "http://www.
|
|
76
|
-
@ii_value2 = "http://www.
|
|
77
|
-
@sl_value2 = "http://www.
|
|
71
|
+
@value = "http://www.example.org/anything"
|
|
72
|
+
@si_value1 = "http://www.example.org/test_si_1"
|
|
73
|
+
@ii_value1 = "http://www.example.org/test_ii_1"
|
|
74
|
+
@sl_value1 = "http://www.example.org/test_sl_1"
|
|
75
|
+
@si_value2 = "http://www.example.org/test_si_2"
|
|
76
|
+
@ii_value2 = "http://www.example.org/test_ii_2"
|
|
77
|
+
@sl_value2 = "http://www.example.org/test_sl_2"
|
|
78
78
|
@si_topic1 = @tm.get!("si:" + @si_value1)
|
|
79
79
|
@ii_topic1 = @tm.get!("ii:" + @ii_value1)
|
|
80
80
|
@sl_topic1 = @tm.get!("=" + @sl_value1)
|
|
@@ -82,9 +82,9 @@ module RTM::Axes
|
|
|
82
82
|
@ii_topic2 = @tm.get!("ii:" + @ii_value2)
|
|
83
83
|
@sl_topic2 = @tm.get!("=" + @sl_value2)
|
|
84
84
|
@all_topic = @tm.create_topic
|
|
85
|
-
@all_si_value = "http://www.
|
|
86
|
-
@all_ii_value = "http://www.
|
|
87
|
-
@all_sl_value = "http://www.
|
|
85
|
+
@all_si_value = "http://www.example.org/all_si"
|
|
86
|
+
@all_ii_value = "http://www.example.org/all_ii"
|
|
87
|
+
@all_sl_value = "http://www.example.org/all_sl"
|
|
88
88
|
@all_topic.add_subject_identifier(@all_si_value)
|
|
89
89
|
@all_topic.add_item_identifier(@all_ii_value)
|
|
90
90
|
@all_topic.add_subject_locator(@all_sl_value)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
5
|
+
|
|
6
|
+
module RTM::IO::TmapiXFrom::TopicMap
|
|
7
|
+
|
|
8
|
+
describe self do
|
|
9
|
+
before(:each) do
|
|
10
|
+
@tm = get_used_tm_sys_tm
|
|
11
|
+
end
|
|
12
|
+
after(:each) do
|
|
13
|
+
@tm.close
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#from_ltm" do
|
|
17
|
+
it "import into an empty topic map" do
|
|
18
|
+
@tm.from_ltm(File.dirname(__FILE__) + "/../../resources/toyTM.ltm")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "#from_ctm" do
|
|
23
|
+
it "import into an empty topic map" do
|
|
24
|
+
@tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "#from_jtm" do
|
|
29
|
+
it "import into an empty topic map" do
|
|
30
|
+
#@tm.from_jtm(File.dirname(__FILE__) + "/../../resources/toyTM.jtm")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "#from_tmxml" do
|
|
35
|
+
it "import into an empty topic map" do
|
|
36
|
+
#@tm.from_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM.tmxml")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "#from_xtm10" do
|
|
41
|
+
it "import into an empty topic map" do
|
|
42
|
+
#@tm.from_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_xtm10.xtm")
|
|
43
|
+
end
|
|
44
|
+
it "should provide an alias for from_xtm1" do
|
|
45
|
+
@tm.method(:from_xtm1).should == @tm.method(:from_xtm10)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "#from_xtm20" do
|
|
50
|
+
it "import into an empty topic map" do
|
|
51
|
+
@tm.from_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM.xtm")
|
|
52
|
+
end
|
|
53
|
+
it "should provide an alias for from_xtm2" do
|
|
54
|
+
@tm.method(:from_xtm2).should == @tm.method(:from_xtm20)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe "#from_xtm" do
|
|
59
|
+
it "import into an empty topic map from xtm v2.0" do
|
|
60
|
+
@tm.from_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM.xtm")
|
|
61
|
+
end
|
|
62
|
+
it "import into an empty topic map from xtm v1.0" do
|
|
63
|
+
#@tm.from_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_xtm10.xtm")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "#from_n3" do
|
|
68
|
+
it "should be tested"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "#from_rdfxml" do
|
|
72
|
+
it "should be tested"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
5
|
+
|
|
6
|
+
module RTM::IO::TmapiXTo::TopicMap
|
|
7
|
+
|
|
8
|
+
describe self do
|
|
9
|
+
before(:each) do
|
|
10
|
+
@tm = get_used_tm_sys_tm
|
|
11
|
+
end
|
|
12
|
+
after(:each) do
|
|
13
|
+
@tm.close
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#to_xtm20" do
|
|
17
|
+
before(:each) do
|
|
18
|
+
@tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
|
|
19
|
+
end
|
|
20
|
+
it "should serialize a topic map to String" do
|
|
21
|
+
@tm.to_xtm20.should be_a_kind_of String
|
|
22
|
+
end
|
|
23
|
+
it "should serialize a topic map to a file" do
|
|
24
|
+
@tm.to_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm20").should be_true
|
|
25
|
+
end
|
|
26
|
+
it "should serialize a topic map to a file given a base iri" do
|
|
27
|
+
@tm.to_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm20", "http://www.example.org/testtm").should be_true
|
|
28
|
+
end
|
|
29
|
+
it "should serialize a topic map to a java.io.Stream" do
|
|
30
|
+
@tm.to_xtm20(java.io.ByteArrayOutputStream.new).should be_true
|
|
31
|
+
end
|
|
32
|
+
it "should be the case that the xtm20 writer does not respond to :setProperty" do
|
|
33
|
+
org.tmapix.io.XTM20TopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
|
|
34
|
+
end
|
|
35
|
+
it "should provide an alias for to_xtm" do
|
|
36
|
+
@tm.method(:to_xtm).should == @tm.method(:to_xtm20)
|
|
37
|
+
end
|
|
38
|
+
it "should provide an alias for to_xtm2" do
|
|
39
|
+
@tm.method(:to_xtm2).should == @tm.method(:to_xtm20)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "#to_xtm10" do
|
|
44
|
+
before(:each) do
|
|
45
|
+
@tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
|
|
46
|
+
end
|
|
47
|
+
it "should serialize a topic map to String" do
|
|
48
|
+
@tm.to_xtm10.should be_a_kind_of String
|
|
49
|
+
end
|
|
50
|
+
it "should serialize a topic map to a file" do
|
|
51
|
+
@tm.to_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm10").should be_true
|
|
52
|
+
end
|
|
53
|
+
it "should serialize a topic map to a file given a base iri" do
|
|
54
|
+
@tm.to_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm10", "http://www.example.org/testtm").should be_true
|
|
55
|
+
end
|
|
56
|
+
it "should serialize a topic map to a java.io.Stream" do
|
|
57
|
+
@tm.to_xtm10(java.io.ByteArrayOutputStream.new).should be_true
|
|
58
|
+
end
|
|
59
|
+
it "should be the case that the xtm10 writer does not respond to :setProperty" do
|
|
60
|
+
org.tmapix.io.XTM10TopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
|
|
61
|
+
end
|
|
62
|
+
it "should provide an alias for to_xtm1" do
|
|
63
|
+
@tm.method(:to_xtm1).should == @tm.method(:to_xtm10)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "#to_jtm" do
|
|
68
|
+
before(:each) do
|
|
69
|
+
@tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
|
|
70
|
+
end
|
|
71
|
+
it "should serialize a topic map to String" do
|
|
72
|
+
@tm.to_jtm.should be_a_kind_of String
|
|
73
|
+
end
|
|
74
|
+
it "should serialize a topic map to a file" do
|
|
75
|
+
@tm.to_jtm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.jtm").should be_true
|
|
76
|
+
end
|
|
77
|
+
it "should serialize a topic map to a file given a base iri" do
|
|
78
|
+
@tm.to_jtm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.jtm", "http://www.example.org/testtm").should be_true
|
|
79
|
+
end
|
|
80
|
+
it "should serialize a topic map to a java.io.Stream" do
|
|
81
|
+
@tm.to_jtm(java.io.ByteArrayOutputStream.new).should be_true
|
|
82
|
+
end
|
|
83
|
+
it "should be the case that the xtm10 writer does not respond to :setProperty" do
|
|
84
|
+
org.tmapix.io.JTMTopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
|
|
85
|
+
end
|
|
86
|
+
it "should provide an alias fpr to_json" do
|
|
87
|
+
@tm.method(:to_json).should == @tm.method(:to_jtm)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe "#to_ltm" do
|
|
92
|
+
before(:each) do
|
|
93
|
+
@tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
|
|
94
|
+
end
|
|
95
|
+
it "should serialize a topic map to String" do
|
|
96
|
+
@tm.to_ltm.should be_a_kind_of String
|
|
97
|
+
end
|
|
98
|
+
it "should serialize a topic map to a file" do
|
|
99
|
+
@tm.to_ltm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ltm").should be_true
|
|
100
|
+
end
|
|
101
|
+
it "should serialize a topic map to a file given a base iri" do
|
|
102
|
+
@tm.to_ltm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ltm", "http://www.example.org/testtm").should be_true
|
|
103
|
+
end
|
|
104
|
+
it "should serialize a topic map to a java.io.Stream" do
|
|
105
|
+
@tm.to_ltm(java.io.ByteArrayOutputStream.new).should be_true
|
|
106
|
+
end
|
|
107
|
+
it "should be the case that the xtm10 writer does not respond to :setProperty" do
|
|
108
|
+
org.tmapix.io.LTMTopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe "#to_tmxml" do
|
|
113
|
+
before(:each) do
|
|
114
|
+
@tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm")
|
|
115
|
+
end
|
|
116
|
+
it "should serialize a topic map to String" do
|
|
117
|
+
@tm.to_tmxml.should be_a_kind_of String
|
|
118
|
+
end
|
|
119
|
+
it "should serialize a topic map to a file" do
|
|
120
|
+
@tm.to_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.tmxml").should be_true
|
|
121
|
+
end
|
|
122
|
+
it "should serialize a topic map to a file given a base iri" do
|
|
123
|
+
@tm.to_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.tmxml", "http://www.example.org/testtm").should be_true
|
|
124
|
+
end
|
|
125
|
+
it "should serialize a topic map to a java.io.Stream" do
|
|
126
|
+
@tm.to_tmxml(java.io.ByteArrayOutputStream.new).should be_true
|
|
127
|
+
end
|
|
128
|
+
it "should be the case that the xtm10 writer does not respond to :setProperty" do
|
|
129
|
+
org.tmapix.io.TMXMLTopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe "#to_ctm" do
|
|
134
|
+
before(:each) do
|
|
135
|
+
@tm.from_xtm(File.dirname(__FILE__) + "/../../resources/toyTM.xtm")
|
|
136
|
+
end
|
|
137
|
+
it "should serialize a topic map to String" do
|
|
138
|
+
@tm.to_ctm.should be_a_kind_of String
|
|
139
|
+
end
|
|
140
|
+
it "should serialize a topic map to a file" do
|
|
141
|
+
@tm.to_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm").should be_true
|
|
142
|
+
end
|
|
143
|
+
it "should serialize a topic map to a file given a base iri" do
|
|
144
|
+
@tm.to_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm", "http://www.example.org/testtm").should be_true
|
|
145
|
+
end
|
|
146
|
+
it "should serialize a topic map to a java.io.Stream" do
|
|
147
|
+
@tm.to_ctm(java.io.ByteArrayOutputStream.new).should be_true
|
|
148
|
+
end
|
|
149
|
+
it "should be the case that the xtm10 writer does respond to :setProperty" do
|
|
150
|
+
de.topicmapslab.ctm.writer.core.CTMTopicMapWriter.new(java.io.ByteArrayOutputStream.new,"http://www.example.org/testtm").should respond_to(:setProperty)
|
|
151
|
+
end
|
|
152
|
+
it "should read it afterwards" do
|
|
153
|
+
emptyTM = get_used_tm_sys.create("http://blub.org/")
|
|
154
|
+
emptyTM.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm")
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
|
2
|
+
# License: Apache License, Version 2.0
|
|
3
|
+
|
|
4
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
5
|
+
|
|
6
|
+
module RTM::IO::ToHash
|
|
7
|
+
|
|
8
|
+
describe self do
|
|
9
|
+
before(:each) do
|
|
10
|
+
@tm = get_used_tm_sys_tm
|
|
11
|
+
@tm.reifier!
|
|
12
|
+
@topic = @tm.get!("a:b")
|
|
13
|
+
@name = @topic.create_name("name type", "name value", ["theme1", "theme2"])
|
|
14
|
+
@name.reifier!
|
|
15
|
+
@var = @name.create_variant(1234, RTM::PSI[:String], ["theme5"])
|
|
16
|
+
@var.reifier!
|
|
17
|
+
@occ = @topic.create_occurrence("occ type", "occ value", :datatype => RTM::PSI[:IRI], :scope => ["theme3", "theme4"])
|
|
18
|
+
@occ.reifier!
|
|
19
|
+
@assoc = @tm.create_association("assoc type", ["theme6", "theme7"])
|
|
20
|
+
@assoc.reifier!
|
|
21
|
+
@role = @assoc.create_role("role type", "role player")
|
|
22
|
+
@role.reifier!
|
|
23
|
+
@locator = @tm.create_locator("http://www.example.org/test this locator")
|
|
24
|
+
end
|
|
25
|
+
after(:each) do
|
|
26
|
+
@output.should be_a_kind_of Hash
|
|
27
|
+
@tm.close
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#to_hash" do
|
|
31
|
+
describe "for TopicMap" do
|
|
32
|
+
before(:each) do
|
|
33
|
+
@tm.should be_a_kind_of RTM::TopicMap
|
|
34
|
+
end
|
|
35
|
+
it "should give back a Hash" do
|
|
36
|
+
@output = @tm.to_hash
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
describe "for Topic" do
|
|
40
|
+
before(:each) do
|
|
41
|
+
@topic.should be_a_kind_of RTM::Topic
|
|
42
|
+
end
|
|
43
|
+
it "should give back a Hash" do
|
|
44
|
+
@output = @topic.to_hash
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
describe "for Association" do
|
|
48
|
+
before(:each) do
|
|
49
|
+
@assoc.should be_a_kind_of RTM::Association
|
|
50
|
+
end
|
|
51
|
+
it "should give back a Hash" do
|
|
52
|
+
@output = @assoc.to_hash
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
describe "for Role" do
|
|
56
|
+
before(:each) do
|
|
57
|
+
@role.should be_a_kind_of RTM::Role
|
|
58
|
+
end
|
|
59
|
+
it "should give back a Hash" do
|
|
60
|
+
@output = @role.to_hash
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
describe "for Name" do
|
|
64
|
+
before(:each) do
|
|
65
|
+
@name.should be_a_kind_of RTM::Name
|
|
66
|
+
end
|
|
67
|
+
it "should give back a Hash" do
|
|
68
|
+
@output = @name.to_hash
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
describe "for Occurrence" do
|
|
72
|
+
before(:each) do
|
|
73
|
+
@occ.should be_a_kind_of RTM::Occurrence
|
|
74
|
+
end
|
|
75
|
+
it "should give back a Hash" do
|
|
76
|
+
@output = @occ.to_hash
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
describe "for Variant" do
|
|
80
|
+
before(:each) do
|
|
81
|
+
@var.should be_a_kind_of RTM::Variant
|
|
82
|
+
end
|
|
83
|
+
it "should give back a Hash" do
|
|
84
|
+
@output = @var.to_hash
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|