rtm 0.1.6 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,53 @@
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
2
|
+
# License: Apache License, Version 2.0
|
3
|
+
|
4
|
+
|
5
|
+
module RTM::Sugar
|
6
|
+
module TopicMap
|
7
|
+
module Themes
|
8
|
+
|
9
|
+
# Returns all topics in the topic map used
|
10
|
+
# in the scope property of Associations.
|
11
|
+
#
|
12
|
+
# The result may be empty.
|
13
|
+
#
|
14
|
+
# :call-seq:
|
15
|
+
# association_themes -> Array of Topics
|
16
|
+
#
|
17
|
+
def association_themes
|
18
|
+
scoped_index.get_association_themes.to_a
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns all topics in the topic map used
|
22
|
+
# in the scope property of Names.
|
23
|
+
#
|
24
|
+
# :call-seq:
|
25
|
+
# name_themes -> Array of Topics
|
26
|
+
#
|
27
|
+
def name_themes
|
28
|
+
scoped_index.get_name_themes.to_a
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns all topics in the topic map used
|
32
|
+
# in the scope property of Occurrences.
|
33
|
+
#
|
34
|
+
# :call-seq:
|
35
|
+
# occurrence_themes -> Array of Topics
|
36
|
+
#
|
37
|
+
def occurrence_themes
|
38
|
+
scoped_index.get_occurrence_themes.to_a
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns all topics in the topic map used
|
42
|
+
# in the scope property of Variants.
|
43
|
+
#
|
44
|
+
# :call-seq:
|
45
|
+
# variant_themes -> Array of Topics
|
46
|
+
#
|
47
|
+
def variant_themes
|
48
|
+
scoped_index.get_variant_themes.to_a
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
2
|
+
# License: Apache License, Version 2.0
|
3
|
+
|
4
|
+
module RTM::Sugar
|
5
|
+
module Typed
|
6
|
+
module Types
|
7
|
+
|
8
|
+
# Returns the type of this typed construct
|
9
|
+
# (occurrence, role, association or name)
|
10
|
+
# as Array.
|
11
|
+
#
|
12
|
+
# :call-seq:
|
13
|
+
# types -> Array of Topics
|
14
|
+
#
|
15
|
+
def types
|
16
|
+
Array.new(type)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns the type and the transitive supertypes of this type
|
20
|
+
# of this typed construct (occurrence, role, association or name)
|
21
|
+
# as Array.
|
22
|
+
#
|
23
|
+
# :call-seq:
|
24
|
+
# transitive_types -> Array of Topics
|
25
|
+
#
|
26
|
+
def transitive_types
|
27
|
+
sup_types = type.transitive_supertypes
|
28
|
+
if sup_types.empty?
|
29
|
+
sup_types = types
|
30
|
+
else
|
31
|
+
sup_types << type unless sup_types.include?(type)
|
32
|
+
end
|
33
|
+
return sup_types
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/rtm/validation.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
2
|
+
# License: Apache License, Version 2.0
|
3
|
+
|
1
4
|
module RTM
|
2
5
|
module Validation
|
3
6
|
|
@@ -10,7 +13,7 @@ module RTM
|
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
13
|
-
module
|
16
|
+
module Role
|
14
17
|
def valid?
|
15
18
|
return false unless player
|
16
19
|
return false unless type
|
@@ -37,7 +40,7 @@ module RTM
|
|
37
40
|
module TopicMap
|
38
41
|
end
|
39
42
|
|
40
|
-
module
|
43
|
+
module Name
|
41
44
|
end
|
42
45
|
|
43
46
|
module Variant
|
@@ -50,11 +53,11 @@ module RTM
|
|
50
53
|
true
|
51
54
|
end
|
52
55
|
end
|
53
|
-
module
|
56
|
+
module Construct
|
54
57
|
def valid?
|
55
58
|
true
|
56
59
|
end
|
57
60
|
end
|
58
|
-
RTM.register_extension(
|
61
|
+
RTM.register_extension(self)
|
59
62
|
end
|
60
63
|
end
|
data/lib/rtm/version.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module RTM # :nodoc:
|
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]
|
17
|
+
ISODATE = "%04d-%02d-%02d" % DATE # => "2010-01-26"
|
18
|
+
COMPACTDATE = "%04d%02d%02d" % DATE # => "20100126"
|
19
|
+
|
20
|
+
MAJOR = 0
|
21
|
+
MINOR = 2
|
22
|
+
TINY = 1
|
23
|
+
BUILD = ENV['BUILD_NUMBER'] || COMPACTDATE
|
24
|
+
|
25
|
+
STRING = [MAJOR, MINOR, TINY].compact.join('.')
|
26
|
+
|
27
|
+
SUMMARY = "rtm #{STRING}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Spec::Example::ExampleGroup
|
2
|
+
|
3
|
+
def be_a_kind_of(expected)
|
4
|
+
Matcher.new :be_a_kind_of, expected do |_expected_|
|
5
|
+
match do |actual|
|
6
|
+
# actual.kind_of?(_expected_)
|
7
|
+
ot = _expected_.methods(true).map {|m| _expected_.method(m) }
|
8
|
+
at = actual.class.methods(true).map {|m| actual.class.method(m) }
|
9
|
+
at.select {|m| !ot.include? m }.empty?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,88 @@
|
|
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::Axes
|
7
|
+
class Association < ItemProxy
|
8
|
+
describe self do
|
9
|
+
before(:all) do
|
10
|
+
@tm = get_used_tm_sys_tm
|
11
|
+
@topic = @tm.get!("person")
|
12
|
+
@assoc = @tm.create_association("assoc_type")
|
13
|
+
@proxy = @assoc.axes
|
14
|
+
end
|
15
|
+
after(:all) do
|
16
|
+
@tm.close
|
17
|
+
end
|
18
|
+
it "should be allowed to call #tmapi and #result on a RTM::Axes::Association" do
|
19
|
+
@proxy.methods.should include("tmapi")
|
20
|
+
@proxy.methods.should include("result")
|
21
|
+
end
|
22
|
+
it "should be allowed to call #players on a RTM::Axes::Association" do
|
23
|
+
@proxy.methods.should include("players")
|
24
|
+
end
|
25
|
+
it "should be allowed to call #reverse_reifier on a RTM::Axes::Association" do
|
26
|
+
@proxy.methods.should include("reverse_reifier")
|
27
|
+
end
|
28
|
+
it "should be allowed to call #roles on a RTM::Axes::Association" do
|
29
|
+
@proxy.methods.should include("roles")
|
30
|
+
end
|
31
|
+
it "should be allowed to call #scope on a RTM::Axes::Association" do
|
32
|
+
@proxy.methods.should include("scope")
|
33
|
+
end
|
34
|
+
it "should be allowed to call #reverse_traverse on a RTM::Axes::Association" do
|
35
|
+
pending "should not" do
|
36
|
+
@proxy.methods.should include("reverse_traverse")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#new" do
|
41
|
+
it "should raise an error if the underlying construct is not an Association" do
|
42
|
+
lambda{RTM::Axes::Association.new(1,@tm)}.should raise_error
|
43
|
+
end
|
44
|
+
it "should not raise an error if the underlying construct is an Association" do
|
45
|
+
lambda{RTM::Axes::Association.new(@assoc,@tm)}.should_not raise_error
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#players" do
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#reverse_reifier" do
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#roles" do
|
58
|
+
# it "should give back an empty set if the association has no roles" do
|
59
|
+
# a_asso = @tm.create_association("asso_type")
|
60
|
+
# a_asso.roles.should be_empty
|
61
|
+
# end
|
62
|
+
# it "should give back the role types of the association" do
|
63
|
+
# a_asso = @tm.create_association("asso_type")
|
64
|
+
# a_asso["a_role_type"] = "to_a_noter_topic"
|
65
|
+
# a_asso.roles_tta.size.should == 1
|
66
|
+
# a_asso["another_role_type"] = "to_another_noter_topic"
|
67
|
+
# a_asso.roles_tta.size.should == 2
|
68
|
+
# a_asso.roles_tta.include?(@tm.get("a_role_type")).should == true
|
69
|
+
# a_asso.roles_tta.include?(@tm.get("another_role_type")).should == true
|
70
|
+
# end
|
71
|
+
# it "should give back multiple roll-typing topics if the the same role type is used multiple times" do
|
72
|
+
# a_asso = @tm.create_association("asso_type")
|
73
|
+
# a_asso["a_role_type"] = "to_a_noter_topic"
|
74
|
+
# a_asso.roles_tta.size.should == 1
|
75
|
+
# a_asso["a_role_type"] = "to_another_noter_topic"
|
76
|
+
# a_asso.roles_tta.size.should == 2
|
77
|
+
# a_asso.roles_tta.include?(@tm.get("a_role_type")).should == true
|
78
|
+
# a_asso.roles_tta.select {|t| t == @tm.get("a_role_type")}.size.should == 2
|
79
|
+
# end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#scope" do
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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::Axes
|
7
|
+
module Associations
|
8
|
+
describe self do
|
9
|
+
before(:all) do
|
10
|
+
@tm = get_used_tm_sys_tm
|
11
|
+
@assoc1 = @tm.create_association("assoc_type_1")
|
12
|
+
@assoc2 = @tm.create_association("assoc_type_2")
|
13
|
+
@proxy = [@assoc1.axes,@assoc2.axes].extend(Associations)
|
14
|
+
end
|
15
|
+
after(:all) do
|
16
|
+
@tm.close
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be allowed to call #tmapi and #result on an Associations-Array" do
|
20
|
+
@proxy.methods.should include("tmapi")
|
21
|
+
@proxy.methods.should include("result")
|
22
|
+
end
|
23
|
+
it "should be allowed to call #players on an Associations-Array" do
|
24
|
+
@proxy.methods.should include("players")
|
25
|
+
end
|
26
|
+
it "should be allowed to call #reverse_reifier on an Associations-Array" do
|
27
|
+
@proxy.methods.should include("reverse_reifier")
|
28
|
+
end
|
29
|
+
it "should be allowed to call #roles on an Associations-Array" do
|
30
|
+
@proxy.methods.should include("roles")
|
31
|
+
end
|
32
|
+
it "should be allowed to call #scope on an Associations-Array" do
|
33
|
+
@proxy.methods.should include("scope")
|
34
|
+
end
|
35
|
+
it "should be allowed to call #reverse_traverse on an Associations-Array" do
|
36
|
+
pending "should not" do
|
37
|
+
@proxy.methods.should include("reverse_traverse")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#players" do
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#reverse_reifier" do
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#roles" do
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#scope" do
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -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::Axes
|
7
|
+
class Characteristic < ItemProxy
|
8
|
+
describe self do
|
9
|
+
before(:all) do
|
10
|
+
@tm = get_used_tm_sys_tm
|
11
|
+
@topic = @tm.get!("person")
|
12
|
+
@name_value = "Hans"
|
13
|
+
@occ_value = "18"
|
14
|
+
@name = @topic.create_name(@name_value)
|
15
|
+
@occ = @topic.create_occurrence("Age", @occ_value)
|
16
|
+
@name_proxy = @name.axes
|
17
|
+
@occ_proxy = @occ.axes
|
18
|
+
end
|
19
|
+
after(:all) do
|
20
|
+
@tm.close
|
21
|
+
end
|
22
|
+
it "should be allowed to call #tmapi and #result on a RTM::TQML::Name" do
|
23
|
+
@name_proxy.methods.should include("tmapi")
|
24
|
+
@name_proxy.methods.should include("result")
|
25
|
+
end
|
26
|
+
it "should be allowed to call #atomify on a RTM::TQML::Name" do
|
27
|
+
@name_proxy.methods.should include("atomify")
|
28
|
+
end
|
29
|
+
it "should be allowed to call #reverse_characteristics on a RTM::TQML::Name" do
|
30
|
+
@name_proxy.methods.should include("reverse_characteristics")
|
31
|
+
end
|
32
|
+
it "should be allowed to call #reverse_reifier on a RTM::TQML::Name" do
|
33
|
+
@name_proxy.methods.should include("reverse_reifier")
|
34
|
+
end
|
35
|
+
it "should be allowed to call #scope on a RTM::TQML::Name" do
|
36
|
+
@name_proxy.methods.should include("scope")
|
37
|
+
end
|
38
|
+
it "should be allowed to call #tmapi and #result on a RTM::TQML::Occurrence" do
|
39
|
+
@occ_proxy.methods.should include("tmapi")
|
40
|
+
@occ_proxy.methods.should include("result")
|
41
|
+
end
|
42
|
+
it "should be allowed to call #atomify on a RTM::TQML::Occurrence" do
|
43
|
+
@occ_proxy.methods.should include("atomify")
|
44
|
+
end
|
45
|
+
it "should be allowed to call #reverse_characteristics on a RTM::TQML::Occurrence" do
|
46
|
+
@occ_proxy.methods.should include("reverse_characteristics")
|
47
|
+
end
|
48
|
+
it "should be allowed to call #reverse_reifier on a RTM::TQML::Occurrence" do
|
49
|
+
@occ_proxy.methods.should include("reverse_reifier")
|
50
|
+
end
|
51
|
+
it "should be allowed to call #scope on a RTM::TQML::Occurrence" do
|
52
|
+
@occ_proxy.methods.should include("scope")
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#new" do
|
56
|
+
it "should raise an error if the underlying construct is not a RTM::Name or RTM::Occurrence" do
|
57
|
+
lambda{RTM::Axes::Name.new(1,@tm)}.should raise_error
|
58
|
+
lambda{RTM::Axes::Occurrence.new(1,@tm)}.should raise_error
|
59
|
+
end
|
60
|
+
it "should not raise an error if the underlying construct is a RTM::Name or RTM::Occurrence" do
|
61
|
+
lambda{RTM::Axes::Name.new(@name,@tm)}.should_not raise_error
|
62
|
+
lambda{RTM::Axes::Occurrence.new(@occ,@tm)}.should_not raise_error
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#atomify" do
|
67
|
+
it "should give back a RTM::Axes::String" do
|
68
|
+
@name_proxy.atomify.should be_a_kind_of RTM::Axes::String
|
69
|
+
@occ_proxy.atomify.should be_a_kind_of RTM::Axes::String
|
70
|
+
end
|
71
|
+
it "should give back the values" do
|
72
|
+
@name_proxy.atomify.construct.should == @name_value
|
73
|
+
@occ_proxy.atomify.construct.should == @occ_value
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#reverse_characteristics" do
|
78
|
+
it "should give back a RTM::Axes::Topic" do
|
79
|
+
@name_proxy.reverse_characteristics.should be_a_kind_of(RTM::Axes::Topic)
|
80
|
+
@occ_proxy.reverse_characteristics.should be_a_kind_of(RTM::Axes::Topic)
|
81
|
+
end
|
82
|
+
it "should give back the righ Topic" do
|
83
|
+
@name_proxy.reverse_characteristics.construct.should == @topic
|
84
|
+
@occ_proxy.reverse_characteristics.construct.should == @topic
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,85 @@
|
|
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::Axes
|
7
|
+
module Characteristics
|
8
|
+
describe self do
|
9
|
+
before(:all) do
|
10
|
+
@tm = get_used_tm_sys_tm
|
11
|
+
@name_value = "Hans"
|
12
|
+
@occ_value = "18"
|
13
|
+
@topic1 = @tm.get!("Person1")
|
14
|
+
@topic2 = @tm.get!("Person2")
|
15
|
+
@topic3 = @tm.get!("Person3")
|
16
|
+
@name1 = @topic1.create_name(@name_value)
|
17
|
+
@name2 = @topic2.create_name("Peter")
|
18
|
+
@name3 = @topic3.create_name(@name_value)
|
19
|
+
@occ1 = @topic1.create_occurrence("Number", @occ_value)
|
20
|
+
@occ2 = @topic2.create_occurrence("Age", @occ_value)
|
21
|
+
@occ3 = @topic3.create_occurrence("Friend", @name_value)
|
22
|
+
|
23
|
+
@proxy = [@name1.axes,@name3.axes,@occ1.axes,@occ2.axes,@occ3.axes].extend(Characteristics)
|
24
|
+
end
|
25
|
+
after(:all) do
|
26
|
+
@tm.close
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be allowed to call #tmapi and #result on a RTM::Axes::Characteristics" do
|
30
|
+
@proxy.methods.should include("tmapi")
|
31
|
+
@proxy.methods.should include("result")
|
32
|
+
end
|
33
|
+
it "should be allowed to call #atomify on a RTM::Axes::Characteristics" do
|
34
|
+
@proxy.methods.should include("atomify")
|
35
|
+
end
|
36
|
+
it "should be allowed to call #reverse_characteristics on a RTM::Axes::Characteristics" do
|
37
|
+
@proxy.methods.should include("reverse_characteristics")
|
38
|
+
end
|
39
|
+
it "should be allowed to call #reverse_reifier on a RTM::Axes::Characteristics" do
|
40
|
+
@proxy.methods.should include("reverse_reifier")
|
41
|
+
end
|
42
|
+
it "should be allowed to call #scope on a RTM::Axes::Characteristics" do
|
43
|
+
@proxy.methods.should include("scope")
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#atomify" do
|
47
|
+
it "should give back an Array" do
|
48
|
+
@proxy.atomify.should be_a_kind_of Array
|
49
|
+
end
|
50
|
+
it "should give back an Array consisting of RTM::Axes::String" do
|
51
|
+
@proxy.atomify.first.should be_a_kind_of RTM::Axes::String
|
52
|
+
end
|
53
|
+
it "should give back RTM::TQML::Strings" do
|
54
|
+
@proxy.atomify.should be_a_kind_of RTM::Axes::Strings
|
55
|
+
end
|
56
|
+
it "should give back the values" do
|
57
|
+
@proxy.atomify.size.should == 5
|
58
|
+
@proxy.atomify.map{|res| res.construct}.should include(@name_value)
|
59
|
+
@proxy.atomify.map{|res| res.construct}.should include(@occ_value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#reverse_characteristics" do
|
64
|
+
it "should give back an Array" do
|
65
|
+
@proxy.reverse_characteristics.should be_a_kind_of Array
|
66
|
+
end
|
67
|
+
it "should give back an Array consisting of RTM::Axes::Topic" do
|
68
|
+
@proxy.reverse_characteristics.first.should be_a_kind_of(RTM::Axes::Topic)
|
69
|
+
end
|
70
|
+
it "should give back a RTM::Axes::Topics" do
|
71
|
+
@proxy.reverse_characteristics.should be_a_kind_of RTM::Axes::Topics
|
72
|
+
end
|
73
|
+
it "should give back the right Topics" do
|
74
|
+
@proxy.reverse_characteristics.size.should == 3 #unique
|
75
|
+
@proxy.reverse_characteristics.map{|res| res.construct}.should include(@topic1)
|
76
|
+
@proxy.reverse_characteristics.map{|res| res.construct}.should include(@topic2)
|
77
|
+
@proxy.reverse_characteristics.map{|res| res.construct}.should include(@topic3)
|
78
|
+
@proxy.reverse_characteristics("Number").size.should == 1
|
79
|
+
@proxy.reverse_characteristics("Number").map{|res| res.construct}.should include(@topic1)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|