rtm 0.2.1 → 0.3.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.
Files changed (41) hide show
  1. data/README +1 -1
  2. data/lib/rtm.rb +23 -95
  3. data/lib/rtm/connection.rb +51 -0
  4. data/lib/rtm/engine.rb +29 -18
  5. data/lib/rtm/extensions.rb +2 -5
  6. data/lib/rtm/helpers/uri.rb +1 -1
  7. data/lib/rtm/io/tmapix_from.rb +8 -8
  8. data/lib/rtm/io/tmapix_to.rb +6 -6
  9. data/lib/rtm/io/to_rdf.rb +1 -1
  10. data/lib/rtm/io/to_string.rb +22 -14
  11. data/lib/rtm/navigation/topic/supertypes.rb +2 -2
  12. data/lib/rtm/navigation/topic/types.rb +1 -1
  13. data/lib/rtm/psi.rb +3 -1
  14. data/lib/rtm/sugar.rb +8 -3
  15. data/lib/rtm/sugar/topic/best_name.rb +31 -50
  16. data/lib/rtm/sugar/topic/scoped.rb +9 -9
  17. data/lib/rtm/sugar/topic/topic_ref.rb +115 -72
  18. data/lib/rtm/sugar/topic_map/remove.rb +49 -0
  19. data/lib/rtm/sugar/topic_map/{themes.rb → scoped.rb} +9 -10
  20. data/lib/rtm/sugar/topic_map/types.rb +50 -0
  21. data/lib/rtm/sugar/variant/topic.rb +17 -0
  22. data/lib/rtm/topology.rb +134 -0
  23. data/lib/rtm/version.rb +13 -8
  24. data/spec/rtm/engine_spec.rb +45 -0
  25. data/spec/rtm/io/tmapix_from_spec.rb +8 -8
  26. data/spec/rtm/io/tmapix_to_spec.rb +38 -38
  27. data/spec/rtm/io/to_yaml_spec.rb +7 -0
  28. data/spec/rtm/javatmapi_spec.rb +64 -0
  29. data/spec/rtm/navigation/topic/scope_spec.rb +1 -1
  30. data/spec/rtm/sugar/topic/best_name_spec.rb +54 -2
  31. data/spec/rtm/sugar/topic/topic_ref_spec.rb +59 -35
  32. data/spec/rtm/sugar/topic_map/remove_spec.rb +50 -0
  33. data/spec/rtm/sugar/topic_map/{themes_spec.rb → scoped_spec.rb} +1 -1
  34. data/spec/rtm/sugar/topic_map/types_spec.rb +34 -0
  35. data/spec/rtm/sugar/variant/topic_spec.rb +28 -0
  36. data/spec/rtm/tmapi/core/name_spec.rb +1 -7
  37. data/spec/rtm/tmapi/core/topic_map_spec.rb +103 -51
  38. data/spec/rtm/tmapi/core/topic_spec.rb +3 -0
  39. data/spec/rtm_spec.rb +3 -12
  40. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  41. metadata +26 -9
@@ -4,7 +4,7 @@
4
4
  require File.dirname(__FILE__) + '/../../../spec_helper'
5
5
 
6
6
  module RTM::Sugar::TopicMap
7
- module Themes
7
+ module Scoped
8
8
  describe self do
9
9
  before(:each) do
10
10
  @tm = get_used_tm_sys_tm
@@ -0,0 +1,34 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../../spec_helper'
5
+
6
+ module RTM::Sugar::TopicMap
7
+ module Types
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 "#association_types" do
17
+ it "should be tested"
18
+ end
19
+
20
+ describe "#role_types" do
21
+ it "should be tested"
22
+ end
23
+
24
+ describe "#occurrence_types" do
25
+ it "should be tested"
26
+ end
27
+
28
+ describe "#name_types" do
29
+ it "should be tested"
30
+ end
31
+
32
+ end # of describe self
33
+ end # of module
34
+ end # of module
@@ -0,0 +1,28 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../../spec_helper'
5
+
6
+ module RTM::Sugar::Variant::Topic
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 "#topic" do
16
+ it "should return the topic the variant belongs to" do
17
+ topic = @tm.get!("Leipzig")
18
+ name = topic.create_name("Leipzig")
19
+ variant = name.create_variant("LE", ["short name"])
20
+ topic.create_name("Leipzig in Germany")
21
+ @tm.get!("Berlin")
22
+ ###
23
+ variant.topic.should == topic
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -65,13 +65,7 @@ module RTM::Name
65
65
  lambda{@testname.create_variant("Uni Leipzig")}.should raise_error
66
66
  end
67
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
68
+ lambda{@testname.create_variant("Uni Leipzig", [])}.should raise_error
75
69
  end
76
70
  end
77
71
  describe "given value and scope" do
@@ -47,63 +47,75 @@ module RTM::TopicMap
47
47
  end
48
48
 
49
49
  describe "#add_prefix" do
50
+ before(:each) do
51
+ @reference_org = "http://www.example.org"
52
+ @reference_com = "http://www.example.com"
53
+ end
50
54
  it "should raise an error if the identifier or reference are not Strings" do
51
- lambda{@tm.add_prefix(1,"www.example.org")}.should raise_error
52
- lambda{@tm.add_prefix("a",2)}.should raise_error
55
+ lambda{@tm.add_prefix(1, "www.example.org")}.should raise_error
56
+ lambda{@tm.add_prefix("a", 2)}.should raise_error
53
57
  end
54
58
  it "should be allowed to set a prefix" do
55
- @tm.prefixes.should be_empty
56
- @tm.add_prefix("a","www.example.org")
59
+ # one prefix xsd per default
57
60
  @tm.prefixes.size.should == 1
58
- @tm.prefixes["a"].should == "www.example.org"
61
+ @tm.prefixes["xsd"] == RTM::PREFIX[:xsd]
62
+ @tm.add_prefix("a", @reference_org)
63
+ @tm.prefixes.size.should == 2
64
+ @tm.prefixes["a"].should == @reference_org
59
65
  end
60
66
  it "should replace the reference if prefix already exists" do
61
- @tm.add_prefix("a","www.example.com")
62
- @tm.prefixes["a"].should == "www.example.com"
63
- @tm.add_prefix("a","www.example.org")
64
- @tm.prefixes["a"].should == "www.example.org"
67
+ @tm.add_prefix("a", @reference_org)
68
+ @tm.prefixes["a"].should == @reference_org
69
+ @tm.add_prefix("a", @reference_com)
70
+ @tm.prefixes["a"].should == @reference_com
65
71
  end
66
72
  it "should give back the prefixes-Hash" do
67
- @tm.add_prefix("a","www.example.com").should == @tm.prefixes
68
- @tm.add_prefix("g","www.example.org").should == @tm.prefixes
69
- end
70
- # it "should warn if identifier equals sl, si or ii" do
71
- # lambda{@tm.add_prefix("sl","test")}.should ?
72
- # lambda{@tm.add_prefix("si","test")}.should ?
73
- # lambda{@tm.add_prefix("ii","test")}.should ?
74
- # end
73
+ @tm.add_prefix("a", @reference_com).should == @tm.prefixes
74
+ @tm.add_prefix("g", @reference_org).should == @tm.prefixes
75
+ end
76
+ it "should raise an error if identifier equals sl, si or ii" do
77
+ lambda{@tm.add_prefix("sl", @reference_org)}.should raise_error
78
+ lambda{@tm.add_prefix("si", @reference_org)}.should raise_error
79
+ lambda{@tm.add_prefix("ii", @reference_org)}.should raise_error
80
+ end
81
+ it "should raise an error if identifier or reference is empty" do
82
+ lambda{@tm.add_prefix("", @reference_org)}.should raise_error
83
+ lambda{@tm.add_prefix("test", "")}.should raise_error
84
+ lambda{@tm.add_prefix("", "")}.should raise_error
85
+ end
75
86
  end
76
87
 
77
88
  describe "#delete_prefix" do
78
89
  before(:each) do
79
- @tm.add_prefix("a","www.example.org/a/")
80
- @tm.add_prefix("b","www.example.org/b/")
81
- @tm.add_prefix("c","www.example.org/c/")
90
+ # one default prefix 'xsd'
91
+ @tm.add_prefix("a", "http://www.example.org/a/")
92
+ @tm.add_prefix("b", "http://www.example.org/b/")
93
+ @tm.add_prefix("c", "http://www.example.org/c/")
82
94
  end
83
95
  it "should delete the right prefix" do
84
- @tm.prefixes.length.should == 3
85
- @tm.delete_prefix("a").size.should == 2
96
+ @tm.prefixes.length.should == 4
97
+ @tm.delete_prefix("a").size.should == 3
86
98
  @tm.find_prefix(:identifier => "a").should be_empty
87
99
  @tm.find_prefix(:identifier => "b").should_not be_empty
88
100
  @tm.find_prefix(:identifier => "c").should_not be_empty
89
101
  end
90
102
  it "should delete the right prefix if the reference is given" do
91
- @tm.prefixes.length.should == 3
92
- @tm.delete_prefix("a","www.example.org/a/").size.should == 2
103
+ @tm.prefixes.length.should == 4
104
+ @tm.delete_prefix("a","http://www.example.org/a/").size.should == 3
93
105
  @tm.find_prefix(:identifier => "a").should be_empty
94
106
  @tm.find_prefix(:identifier => "b").should_not be_empty
95
107
  @tm.find_prefix(:identifier => "c").should_not be_empty
96
108
  end
97
109
  it "should delete nothing if identifier does not match" do
98
- @tm.prefixes.length.should == 3
99
- @tm.delete_prefix("x").size.should == 3
110
+ @tm.prefixes.length.should == 4
111
+ @tm.delete_prefix("x").size.should == 4
100
112
  @tm.find_prefix(:identifier => "a").should_not be_empty
101
113
  @tm.find_prefix(:identifier => "b").should_not be_empty
102
114
  @tm.find_prefix(:identifier => "c").should_not be_empty
103
115
  end
104
116
  it "should delete nothing if reference does not match" do
105
- @tm.prefixes.length.should == 3
106
- @tm.delete_prefix("a","x").size.should == 3
117
+ @tm.prefixes.length.should == 4
118
+ @tm.delete_prefix("a","x").size.should == 4
107
119
  @tm.find_prefix(:identifier => "a").should_not be_empty
108
120
  @tm.find_prefix(:identifier => "b").should_not be_empty
109
121
  @tm.find_prefix(:identifier => "c").should_not be_empty
@@ -114,7 +126,7 @@ module RTM::TopicMap
114
126
  end
115
127
 
116
128
  describe "#find_prefix" do
117
-
129
+ it "should be tested"
118
130
  end
119
131
 
120
132
  describe "#create_topic_by" do
@@ -488,36 +500,42 @@ module RTM::TopicMap
488
500
  topic2.locators.should include("http://www.example.org/y/something")
489
501
  end
490
502
  end
491
-
503
+
504
+ describe "#createLocator" do
505
+ it "should raise an error if identifier is relative" do
506
+ if implementation_for_spec == :tinytim
507
+ pending do
508
+ lambda{@tm.createLocator("xyz")}.should raise_error
509
+ end
510
+ else
511
+ lambda{@tm.createLocator("xyz")}.should raise_error
512
+ end
513
+ end
514
+ end
515
+
492
516
  describe "#create_locator" do
493
- it "should handle identifier which are qnames (create_locator)" do
494
- identifier = "x"
495
- reference = "http://www.example.org/"
496
- @tm.add_prefix(identifier, reference)
497
- topic = @tm.create_topic_by(identifier + ":" + "something")
517
+ before(:each) do
518
+ @prefix_identifier = "x"
519
+ @reference = "http://www.example.org/"
520
+ end
521
+ it "should handle qname if localpart of a qname contains a '/'" do
522
+ @tm.add_prefix(@prefix_identifier, @reference)
523
+ qname = @prefix_identifier + ":" + "part/something"
524
+ topic = @tm.get!(qname)
525
+ topic.indicators.should include(qname)
526
+ end
527
+ it "should handle qnames" do
528
+ @tm.add_prefix(@prefix_identifier, @reference)
529
+ qname = @prefix_identifier + ":" + "something"
530
+ topic = @tm.get!(qname)
498
531
  topic.should be_a_kind_of RTM::Topic
499
- topic.indicators.should include(reference + "something")
532
+ topic.indicators.should include(@reference + "something")
500
533
  end
501
534
  it "should use the base_iri to create absolute IRIS" do
502
535
  @tm.create_locator("xxx").value.should == (@tm.base_iri + "xxx")
503
536
  end
504
- it "should use the base_iri + # to create absolute IRIs if base_iri does not end with a /"
505
- it "should only create Locators out of absolute IRIs"
506
- end
507
-
508
- describe "#occurrence_types" do
509
- it "should allow to crate a topic " do
510
- @tm.get!("foo:bar")["myoccurene"] = "hallo"
511
- @tm.get!("foo:bar")["myoccurenex"] = "hallo"
512
- end
513
537
  end
514
538
 
515
- describe "#name_types" do
516
- it "should give the org::tmapi::index::TypeInstanceIndex.getNameTypes" do
517
- @tm.name_types.should == @tm.type_instance_index.getNameTypes
518
- end
519
- end
520
-
521
539
  describe "#instances" do
522
540
  before(:each) do
523
541
  @t1, @t2, @t3, @t4, @t5, @t6 = @tm.get!(["t1","t2", "t3", "t4", "t5", "t6"])
@@ -700,6 +718,40 @@ module RTM::TopicMap
700
718
  end
701
719
  end
702
720
 
721
+ describe "and statistic methods:" do
722
+ before(:each) do
723
+ @tm.from_xtm(File.dirname(__FILE__) + "/../../../resources/toyTM.xtm")
724
+ end
725
+ describe "#names" do
726
+ it "should give back all names in the topic map" do
727
+ @tm.should have(165).names
728
+ end
729
+ end
730
+ describe "#occurrences" do
731
+ it "should give back all names in the topic map" do
732
+ @tm.should have(24).occurrences
733
+ end
734
+ end
735
+ describe "#roles" do
736
+ it "should give back all names in the topic map" do
737
+ pending if implementation_for_spec == :sesametm
738
+ @tm.should have(131).roles
739
+ end
740
+ end
741
+ describe "#variants" do
742
+ it "should give back all names in the topic map" do
743
+ @tm.should have(44).variants
744
+ end
745
+ end
746
+ end
747
+
748
+ describe "#locator" do
749
+ it "should give back a locator" do
750
+ @tm.locator.should be_a_kind_of RTM::Locator
751
+ @tm.getLocator.should be_a_kind_of RTM::Locator
752
+ end
753
+ end
754
+
703
755
  end # of describe self
704
756
 
705
757
  describe self do
@@ -296,6 +296,7 @@ module RTM::Topic
296
296
  @t2.instances.should include @t1, @t4
297
297
  end
298
298
  it "should remove an instance if argument is a String" do
299
+ pending if implementation_for_spec == :sesametm
299
300
  @t2.remove_instance("t1")
300
301
  @t2.should have(1).instances
301
302
  @t2.instances.should include @t4
@@ -303,6 +304,7 @@ module RTM::Topic
303
304
  @t2.should have(0).instances
304
305
  end
305
306
  it "should remove an instance if argument is a Locator" do
307
+ pending if implementation_for_spec == :sesametm
306
308
  @t2.remove_instance(@tm.create_locator("t4"))
307
309
  @t2.should have(1).instances
308
310
  @t2.instances.should include @t1
@@ -310,6 +312,7 @@ module RTM::Topic
310
312
  @t2.should have(0).instances
311
313
  end
312
314
  it "should remove an instance if argument is a Topic" do
315
+ pending if implementation_for_spec == :sesametm
313
316
  @t2.remove_instance(@t1)
314
317
  @t2.should have(1).instances
315
318
  @t2.instances.should include @t4
@@ -4,18 +4,14 @@
4
4
  require File.dirname(__FILE__) + '/spec_helper'
5
5
 
6
6
  describe RTM do
7
- # describe "#[]" do
8
- # it "should be empty if no TopicMapSystems are created" do
9
- # RTM[].should be_empty
10
- # end Fails since already reated tms are found
11
- # end
12
7
  describe "#connect" do
13
8
  it "should have a TMAPI engine as default backend" do
14
9
  tms_tmapi = RTM.connect(:implementation => implementation_for_spec)
15
10
  tms_tmapi.should be_a_kind_of RTM::JavaTMAPI
16
- tms_tmapi.should be_a_kind_of org.tmapi.core.TopicMapSystem
11
+ tms_tmapi.should be_a_kind_of Java::OrgTmapiCore::TopicMapSystem
17
12
  end
18
13
  it "should allow multiple backends of the same kind in case of TMAPI" do
14
+ pending "this is currently refactored: RTM[] is no longer supported - maybe we introduce it again later?"
19
15
  if RTM[implementation_for_spec]
20
16
  number_of_already_existing_connections = RTM[implementation_for_spec].length
21
17
  else
@@ -38,7 +34,7 @@ describe RTM do
38
34
  # tmsar2.should == tmsar1
39
35
  # tmsar1.should be_a_kind_of RTM::TopicMapSystem
40
36
  # tmsar1.should_not be_a_kind_of RTM::JavaTMAPI
41
- # tmsar1.should_not be_a_kind_of org.tmapi.core.TopicMapSystem
37
+ # tmsar1.should_not be_a_kind_of Java::OrgTmapiCore::TopicMapSystem
42
38
  # end
43
39
  # end
44
40
  end
@@ -50,11 +46,6 @@ describe RTM do
50
46
  #TODO how to test this?
51
47
  end
52
48
  end
53
-
54
- describe "#[]" do
55
- # TODO
56
- end
57
-
58
49
  end
59
50
 
60
51
  # if ar_available?
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Benjamin Bock
@@ -12,7 +17,7 @@ autorequire:
12
17
  bindir: bin
13
18
  cert_chain: []
14
19
 
15
- date: 2010-02-21 00:00:00 +01:00
20
+ date: 2010-04-13 00:00:00 +02:00
16
21
  default_executable:
17
22
  dependencies: []
18
23
 
@@ -53,11 +58,11 @@ description: |
53
58
  * rtm-tmql: Adds support for the Topic Maps Query Language (TMQL), http://isotopicmaps.org/tmql/
54
59
  * rtm-tmcl: Adds support for the Topic Maps Constraint Language (TMCL), http://isotopicmaps.org/tmcl/
55
60
 
56
- ==== License
61
+ ==== License
57
62
  Copyright 2009 Topic Maps Lab, University of Leipzig.
58
63
  Apache License, Version 2.0
59
64
 
60
- email: rtm+rtm-gem-20100221@topicmapslab.de
65
+ email: rtm+rtm-gem-20100413@topicmapslab.de
61
66
  executables: []
62
67
 
63
68
  extensions: []
@@ -75,6 +80,7 @@ files:
75
80
  - lib/rtm/axes/topic.rb
76
81
  - lib/rtm/axes/topics.rb
77
82
  - lib/rtm/axes.rb
83
+ - lib/rtm/connection.rb
78
84
  - lib/rtm/deprecated/index_property_set.rb
79
85
  - lib/rtm/engine.rb
80
86
  - lib/rtm/extensions.rb
@@ -120,9 +126,13 @@ files:
120
126
  - lib/rtm/sugar/topic/topic_ref.rb
121
127
  - lib/rtm/sugar/topic/typed.rb
122
128
  - lib/rtm/sugar/topic_map/query_cache.rb
123
- - lib/rtm/sugar/topic_map/themes.rb
129
+ - lib/rtm/sugar/topic_map/remove.rb
130
+ - lib/rtm/sugar/topic_map/scoped.rb
131
+ - lib/rtm/sugar/topic_map/types.rb
124
132
  - lib/rtm/sugar/typed/types.rb
133
+ - lib/rtm/sugar/variant/topic.rb
125
134
  - lib/rtm/sugar.rb
135
+ - lib/rtm/topology.rb
126
136
  - lib/rtm/validation.rb
127
137
  - lib/rtm/version.rb
128
138
  - lib/rtm.rb
@@ -137,12 +147,14 @@ files:
137
147
  - spec/rtm/axes/topic_spec.rb
138
148
  - spec/rtm/axes/topics_spec.rb
139
149
  - spec/rtm/base_spec.rb
150
+ - spec/rtm/engine_spec.rb
140
151
  - spec/rtm/io/tmapix_from_spec.rb
141
152
  - spec/rtm/io/tmapix_to_spec.rb
142
153
  - spec/rtm/io/to_hash_spec.rb
143
154
  - spec/rtm/io/to_rdf_spec.rb
144
155
  - spec/rtm/io/to_string_spec.rb
145
156
  - spec/rtm/io/to_yaml_spec.rb
157
+ - spec/rtm/javatmapi_spec.rb
146
158
  - spec/rtm/navigation/association/players_spec.rb
147
159
  - spec/rtm/navigation/association_spec.rb
148
160
  - spec/rtm/navigation/name/atomify_spec.rb
@@ -174,8 +186,11 @@ files:
174
186
  - spec/rtm/sugar/topic/scoped_spec.rb
175
187
  - spec/rtm/sugar/topic/topic_ref_spec.rb
176
188
  - spec/rtm/sugar/topic/typed_spec.rb
177
- - spec/rtm/sugar/topic_map/themes_spec.rb
189
+ - spec/rtm/sugar/topic_map/remove_spec.rb
190
+ - spec/rtm/sugar/topic_map/scoped_spec.rb
191
+ - spec/rtm/sugar/topic_map/types_spec.rb
178
192
  - spec/rtm/sugar/typed/types_spec.rb
193
+ - spec/rtm/sugar/variant/topic_spec.rb
179
194
  - spec/rtm/tmapi/core/association_spec.rb
180
195
  - spec/rtm/tmapi/core/construct_spec.rb
181
196
  - spec/rtm/tmapi/core/datatype_aware_spec.rb
@@ -212,18 +227,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
212
227
  requirements:
213
228
  - - ">="
214
229
  - !ruby/object:Gem::Version
230
+ segments:
231
+ - 0
215
232
  version: "0"
216
- version:
217
233
  required_rubygems_version: !ruby/object:Gem::Requirement
218
234
  requirements:
219
235
  - - ">="
220
236
  - !ruby/object:Gem::Version
237
+ segments:
238
+ - 0
221
239
  version: "0"
222
- version:
223
240
  requirements: []
224
241
 
225
242
  rubyforge_project: rtm
226
- rubygems_version: 1.3.5
243
+ rubygems_version: 1.3.6
227
244
  signing_key:
228
245
  specification_version: 3
229
246
  summary: Ruby Topic Maps is a Topic Maps engine written in Ruby.