rtm 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. data/DISCLAIMER +10 -33
  2. data/LICENSE +201 -0
  3. data/README +3 -3
  4. data/lib/rtm.rb +148 -74
  5. data/lib/rtm/axes.rb +295 -0
  6. data/lib/rtm/axes/association.rb +76 -0
  7. data/lib/rtm/axes/associations.rb +96 -0
  8. data/lib/rtm/axes/assocs_names_occs.rb +56 -0
  9. data/lib/rtm/axes/characteristic.rb +68 -0
  10. data/lib/rtm/axes/characteristics.rb +93 -0
  11. data/lib/rtm/axes/string.rb +76 -0
  12. data/lib/rtm/axes/strings.rb +87 -0
  13. data/lib/rtm/axes/topic.rb +233 -0
  14. data/lib/rtm/axes/topics.rb +280 -0
  15. data/lib/rtm/{backward_compatibility.rb → deprecated/index_property_set.rb} +3 -0
  16. data/lib/rtm/engine.rb +58 -0
  17. data/lib/rtm/extensions.rb +11 -1
  18. data/lib/rtm/{locator_helpers.rb → helpers/locator.rb} +15 -4
  19. data/lib/rtm/{helpers.rb → helpers/no_output.rb} +3 -0
  20. data/lib/rtm/helpers/uri.rb +13 -0
  21. data/lib/rtm/io.rb +18 -0
  22. data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
  23. data/lib/rtm/io/ontopia_io.rb +25 -0
  24. data/lib/rtm/io/tmapix.rb +234 -0
  25. data/lib/rtm/io/to_hash.rb +116 -0
  26. data/lib/rtm/io/to_jtm.rb +53 -103
  27. data/lib/rtm/io/to_rdf.rb +30 -0
  28. data/lib/rtm/io/to_string.rb +8 -6
  29. data/lib/rtm/io/to_xtm1.rb +6 -4
  30. data/lib/rtm/io/to_xtm2.rb +10 -8
  31. data/lib/rtm/io/to_yaml.rb +29 -98
  32. data/lib/rtm/navigation.rb +37 -0
  33. data/lib/rtm/navigation/association/players.rb +25 -0
  34. data/lib/rtm/navigation/name/atomify.rb +19 -0
  35. data/lib/rtm/navigation/name/characteristics.rb +33 -0
  36. data/lib/rtm/navigation/occurrence/atomify.rb +19 -0
  37. data/lib/rtm/navigation/occurrence/characteristics.rb +33 -0
  38. data/lib/rtm/navigation/topic/characteristics.rb +33 -0
  39. data/lib/rtm/navigation/topic/indicators.rb +31 -0
  40. data/lib/rtm/navigation/topic/items.rb +31 -0
  41. data/lib/rtm/navigation/topic/locators.rb +31 -0
  42. data/lib/rtm/navigation/topic/players.rb +27 -0
  43. data/lib/rtm/navigation/topic/supertypes.rb +162 -0
  44. data/lib/rtm/navigation/topic/traverse.rb +51 -0
  45. data/lib/rtm/navigation/topic/types.rb +107 -0
  46. data/lib/rtm/psi.rb +33 -2
  47. data/lib/rtm/sugar.rb +34 -0
  48. data/lib/rtm/sugar/association/hash_access.rb +46 -0
  49. data/lib/rtm/sugar/occurrence/dynamic_value.rb +75 -0
  50. data/lib/rtm/{pimp_my_api.rb → sugar/occurrence/externalize.rb} +3 -0
  51. data/lib/rtm/sugar/role/counterparts.rb +133 -46
  52. data/lib/rtm/sugar/topic/characteristics.rb +126 -12
  53. data/lib/rtm/sugar/topic/counterparts.rb +130 -7
  54. data/lib/rtm/sugar/topic/hash_access.rb +140 -30
  55. data/lib/rtm/sugar/topic/scoped.rb +65 -0
  56. data/lib/rtm/sugar/topic/topic_ref.rb +35 -0
  57. data/lib/rtm/sugar/topic/typed.rb +159 -0
  58. data/lib/rtm/sugar/typed/types.rb +38 -0
  59. data/lib/rtm/validation.rb +8 -5
  60. data/lib/rtm/version.rb +18 -0
  61. data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
  62. data/spec/rtm/axes/association_spec.rb +88 -0
  63. data/spec/rtm/axes/associations_spec.rb +60 -0
  64. data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
  65. data/spec/rtm/axes/characteristic_spec.rb +90 -0
  66. data/spec/rtm/axes/characteristics_spec.rb +85 -0
  67. data/spec/rtm/axes/string_spec.rb +145 -0
  68. data/spec/rtm/axes/strings_spec.rb +168 -0
  69. data/spec/rtm/axes/topic_spec.rb +124 -0
  70. data/spec/rtm/axes/topics_spec.rb +103 -0
  71. data/spec/rtm/base_spec.rb +32 -0
  72. data/spec/rtm/io/tmapix_spec.rb +85 -0
  73. data/spec/rtm/navigation/association/players_spec.rb +58 -0
  74. data/spec/rtm/navigation/association_spec.rb +52 -0
  75. data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
  76. data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
  77. data/spec/rtm/navigation/name_spec.rb +52 -0
  78. data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
  79. data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
  80. data/spec/rtm/navigation/occurrence_spec.rb +52 -0
  81. data/spec/rtm/navigation/string_spec.rb +51 -0
  82. data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
  83. data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
  84. data/spec/rtm/navigation/topic/items_spec.rb +44 -0
  85. data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
  86. data/spec/rtm/navigation/topic/players_spec.rb +48 -0
  87. data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
  88. data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
  89. data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
  90. data/spec/rtm/navigation/topic/types_spec.rb +195 -0
  91. data/spec/rtm/navigation/topic_spec.rb +153 -0
  92. data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
  93. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +16 -0
  94. data/spec/rtm/sugar/role/counterparts_spec.rb +191 -0
  95. data/spec/rtm/sugar/topic/characteristics_spec.rb +318 -0
  96. data/spec/rtm/sugar/topic/counterparts_spec.rb +184 -0
  97. data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
  98. data/spec/rtm/sugar/topic/scoped_spec.rb +131 -0
  99. data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
  100. data/spec/rtm/sugar/topic/typed_spec.rb +155 -0
  101. data/spec/rtm/sugar/typed/types_spec.rb +24 -0
  102. data/spec/rtm/tmapi/core/association_spec.rb +169 -0
  103. data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
  104. data/spec/rtm/tmapi/core/name_spec.rb +85 -0
  105. data/spec/rtm/tmapi/core/occurrence_spec.rb +96 -0
  106. data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
  107. data/spec/rtm/tmapi/core/role_spec.rb +73 -0
  108. data/spec/rtm/tmapi/core/scoped_spec.rb +403 -0
  109. data/spec/rtm/tmapi/core/topic_map_spec.rb +648 -0
  110. data/spec/rtm/tmapi/core/topic_spec.rb +992 -0
  111. data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
  112. data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
  113. data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
  114. data/spec/rtm/tmapi_spec.rb +44 -0
  115. data/spec/rtm/utils/sparql_spec.rb +26 -0
  116. data/spec/rtm_spec.rb +94 -0
  117. data/spec/spec_helper.rb +23 -0
  118. data/test/base_unit_test.rb +161 -0
  119. data/test/{base_test.rb → base_unit_test_tmapi.rb} +46 -43
  120. metadata +122 -66
  121. data/COPYRIGHT +0 -4
  122. data/lib/Rakefile.rb +0 -42
  123. data/lib/activetopicmaps.rb +0 -278
  124. data/lib/rtm/backend/active_record.rb +0 -58
  125. data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
  126. data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
  127. data/lib/rtm/backend/active_record/locators.rb +0 -55
  128. data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
  129. data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
  130. data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
  131. data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
  132. data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
  133. data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
  134. data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
  135. data/lib/rtm/backend/active_record/tmdm.rb +0 -298
  136. data/lib/rtm/backend/active_record/topic.rb +0 -87
  137. data/lib/rtm/backend/active_record/topic_map.rb +0 -314
  138. data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
  139. data/lib/rtm/base.rb +0 -92
  140. data/lib/rtm/connect.rb +0 -92
  141. data/lib/rtm/core_ext.rb +0 -6
  142. data/lib/rtm/io/from_xtm2.rb +0 -263
  143. data/lib/rtm/merging/merging.rb +0 -307
  144. data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
  145. data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
  146. data/lib/run_main_project.rb +0 -16
@@ -0,0 +1,38 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module 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
@@ -1,4 +1,7 @@
1
- module RTM
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::AR
2
5
  module Validation
3
6
 
4
7
  module Association
@@ -10,7 +13,7 @@ module RTM
10
13
  end
11
14
  end
12
15
 
13
- module AssociationRole
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 TopicName
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 TopicMapConstruct
56
+ module Construct
54
57
  def valid?
55
58
  true
56
59
  end
57
60
  end
58
- RTM.register_extension( self )
61
+ RTM::AR.register_extension( self )
59
62
  end
60
63
  end
@@ -0,0 +1,18 @@
1
+ module RTM # :nodoc:
2
+ module VERSION # :nodoc:
3
+ unless defined? MAJOR
4
+ DATE = [2010, 2, 5]
5
+ ISODATE = "%04d-%02d-%02d" % DATE # => "2010-01-26"
6
+ COMPACTDATE = "%04d%02d%02d" % DATE # => "20100126"
7
+
8
+ MAJOR = 0
9
+ MINOR = 2
10
+ TINY = 0
11
+ BUILD = COMPACTDATE
12
+
13
+ STRING = [MAJOR, MINOR, TINY ].compact.join('.')
14
+
15
+ SUMMARY = "rtm #{STRING}"
16
+ end
17
+ end
18
+ 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,9 @@
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 AssocsNamesOccs
8
+ end
9
+ 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::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