rtm 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
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,30 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+
5
+ module RTM::IO
6
+
7
+ # RDF Export.
8
+ # RTM::TopicMap gets a to_rdf method.
9
+ module TORDF
10
+ module TopicMap
11
+
12
+ def to_rdf
13
+ case self
14
+ when net.ontopia.topicmaps.impl.tmapi2.TopicMapImpl then to_rdf_ontopia
15
+ else raise "Not supported for #{self}"
16
+ end
17
+ end
18
+
19
+ def to_rdf_ontopia
20
+ @out = java.io.StringWriter.new
21
+ w=Java::NetOntopiaTopicmapsUtilsRdf::RDFTopicMapWriter.new @out
22
+ w.write self.getWrapped
23
+ @out.to_s
24
+ end
25
+ end
26
+
27
+ RTM.register_extension self
28
+
29
+ end
30
+ end
@@ -1,4 +1,6 @@
1
- # Ruby Topic Maps (RTM) http://rtm.rubyforge.org/
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
2
4
  module RTM::IO
3
5
  # Each Topic Maps Construct gets a custom to_s method which supports optional :short or :long output.
4
6
  module TOSTRING
@@ -53,20 +55,20 @@ module RTM::IO
53
55
  when :long
54
56
  r = " #{reifier.to_s(:short)}" if reifier
55
57
  i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
56
- "#<RTM::Association id=#{id}#{i}#{r} type=#{type.to_s(:short)} roles=[#{roles.entries.map { |ar| ar.to_s }.join(", ")}]>"
58
+ "#<RTM::Association id=#{id}#{i}#{r} type=#{type.to_s(:short)} roles=[#{roles.entries.map { |ar| ar.to_s(:long) }.join(", ")}]>"
57
59
  else
58
60
  super() # these () are needed, otherwise the own parameters are passed in
59
61
  end
60
62
  end
61
63
  end
62
64
 
63
- module AssociationRole
65
+ module Role
64
66
  def to_s(style=:short)
65
67
  case style
66
68
  when :short
67
69
  r = " #{reifier.to_s(:short)}" if reifier
68
70
  i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
69
- "#<RTM::AssociationRole id=#{id}#{i}#{r}>"
71
+ "#<RTM::Role id=#{id}#{i}#{r}>"
70
72
  when :long
71
73
  r = " #{reifier.to_s(:short)}" if reifier
72
74
  i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
@@ -77,7 +79,7 @@ module RTM::IO
77
79
  end
78
80
  end
79
81
 
80
- module TopicName
82
+ module Name
81
83
  def to_s(style=:short)
82
84
  case style
83
85
  when :short
@@ -85,7 +87,7 @@ module RTM::IO
85
87
  when :long
86
88
  r = " #{reifier.to_s(:short)}" if reifier
87
89
  i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
88
- "#<RTM::TopicName id=#{id}#{i}#{r} type=#{type.to_s(:short)} value=#{value} variants:#{variants.size}>"
90
+ "#<RTM::Name id=#{id}#{i}#{r} type=#{type.to_s(:short)} value=#{value} variants:#{variants.size}>"
89
91
  else
90
92
  super() # these () are needed, otherwise the own parameters are passed in
91
93
  end
@@ -1,4 +1,6 @@
1
- # Ruby Topic Maps (RTM) http://rtm.rubyforge.org/
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
2
4
  module RTM::IO
3
5
  # XTM1 Export
4
6
  module TOXTM1
@@ -98,9 +100,9 @@ module RTM::IO
98
100
  end
99
101
  end
100
102
 
101
- module TopicName
103
+ module Name
102
104
  def to_xtm1
103
- warn("TOXTM1: Warning: outputting invalid TopicName #{self}") unless valid?
105
+ warn("TOXTM1: Warning: outputting invalid Name #{self}") unless valid?
104
106
  # name = element name { reifiable, type?, scope?, value, variant* }
105
107
  x = REXML::Element.new 'name'
106
108
  x.add_attribute('reifier', reifier.xtm1_id) if reifier
@@ -128,7 +130,7 @@ module RTM::IO
128
130
  end
129
131
  end
130
132
 
131
- module AssociationRole
133
+ module Role
132
134
  def to_xtm1
133
135
  warn("TOXTM1: Warning: outputting invalid AssociationRole #{self}") unless valid?
134
136
  # role = element role { reifiable, type, topicRef }
@@ -1,4 +1,6 @@
1
- # Ruby Topic Maps (RTM) http://rtm.rubyforge.org/
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
2
4
 
3
5
  module RTM::IO
4
6
  # XTM2 Export.
@@ -92,7 +94,7 @@ module RTM::IO
92
94
  # association = element association { reifiable, type, scope?, role+ }
93
95
  x = REXML::Element.new 'association'
94
96
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
95
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
97
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
96
98
  x << TOXTM2.type(type) if type
97
99
  x << TOXTM2.scope(scope) unless scope.empty?
98
100
  roles.each { |r| x << r.to_xtm2 }
@@ -100,13 +102,13 @@ module RTM::IO
100
102
  end
101
103
  end
102
104
 
103
- module TopicName
105
+ module Name
104
106
  def to_xtm2
105
- warn("TOXTM2: Warning: outputting invalid TopicName #{self}") unless valid?
107
+ warn("TOXTM2: Warning: outputting invalid Name #{self}") unless valid?
106
108
  # name = element name { reifiable, type?, scope?, value, variant* }
107
109
  x = REXML::Element.new 'name'
108
110
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
109
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
111
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
110
112
  x << TOXTM2.type(type) if type
111
113
  x << TOXTM2.scope(scope) unless scope.empty?
112
114
  (x << REXML::Element.new('value')).text = value # adds the value within a value-element
@@ -122,7 +124,7 @@ module RTM::IO
122
124
  # type, scope?, ( resourceRef | resourceData ) }
123
125
  x = REXML::Element.new 'occurrence'
124
126
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
125
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
127
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
126
128
  x << TOXTM2.type(type) if type
127
129
  x << TOXTM2.scope(scope) unless scope.empty?
128
130
  x << TOXTM2.value(datatype, value)
@@ -136,7 +138,7 @@ module RTM::IO
136
138
  # role = element role { reifiable, type, topicRef }
137
139
  x = REXML::Element.new 'role'
138
140
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
139
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
141
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
140
142
  x << TOXTM2.type(type) if type
141
143
  x << player.to_xtm2_ref if player
142
144
  x
@@ -149,7 +151,7 @@ module RTM::IO
149
151
  # variant = element variant { reifiable, scope, (resourceRef | resourceData) }
150
152
  x = REXML::Element.new 'variant'
151
153
  x.add_attribute('reifier', reifier.xtm2_id) if reifier
152
- item_identifiers.each { |ii| x << TOXTM2.ii(ii) } # itemIdentity
154
+ item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity
153
155
  x << TOXTM2.scope(scope)
154
156
  x << TOXTM2.value(datatype, value)
155
157
  x
@@ -1,130 +1,61 @@
1
- # Ruby Topic Maps (RTM) http://rtm.rubyforge.org/
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
2
4
  module RTM::IO
3
5
  # YAML Export.
4
- # Each Topic Maps Construct gets a to_xtm2 method.
6
+ # Each Topic Maps Construct gets a to_yaml method.
5
7
  module TOYAML
6
8
 
7
9
  module TopicMap
8
- def to_yaml_hash(*a)
9
- y={}
10
- #j['base_locator'] = base_locator, # with absolute item_identifiers its not needed
11
- y['reifier'] = reifier.to_yaml_ref if reifier
12
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
13
- y['topics'] = topics.map{|i| i.to_yaml_hash} unless topics.empty?
14
- y['associations'] = associations.map{|i| i.to_yaml_hash} unless associations.empty?
15
- y
16
- end
17
- # returns the YAML representation of this topic map
18
- def to_yaml(*a)
19
- to_yaml_hash.to_yaml(*a)
10
+ # Returns the YAML representation of this RTM::TopicMap
11
+ def to_yaml
12
+ to_hash.to_yaml
20
13
  end
21
14
  end
22
15
 
23
16
  module Topic
24
- # returns the YAML representation of this topic
25
- def to_yaml_hash(*a)
26
- y={}
27
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
28
- y['subject_identifiers'] = subject_identifiers.map{|i| i.reference} unless subject_identifiers.empty?
29
- unless y['item_identifiers'] || y['subject_identifiers']
30
- y['item_identifiers'] = [to_yaml_ref]
31
- end
32
- y['subject_locators'] = subject_locators.map{|i| i.reference} unless subject_locators.empty?
33
- y['names'] = names.map{|i| i.to_yaml_hash} unless names.empty?
34
- y['occurrences'] = occurrences.map{|i| i.to_yaml_hash} unless occurrences.empty?
35
- y
36
- end
37
- def to_yaml(*a)
38
- to_yaml_hash.to_yaml(*a)
39
- end
40
- def to_yaml_ref
41
- if subject_identifiers.first
42
- return subject_identifiers.first.reference
43
- end
44
- if item_identifiers.first
45
- return item_identifiers.first.reference
46
- end
47
- "t#{id}"
17
+ # Returns the YAML representation of this RTM::Topic
18
+ def to_yaml
19
+ to_hash.to_yaml
48
20
  end
49
21
  end
50
22
 
51
23
  module Association
52
- def to_yaml_hash(*a)
53
- y={}
54
- y['reifier'] = reifier.to_yaml_ref if reifier
55
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
56
- y['type'] = type.to_yaml_ref if type
57
- y['scope'] = scope.map{|i| i.to_yaml_hash} unless scope.empty?
58
- y['roles'] = roles.map{|i| i.to_yaml_hash} unless roles.empty?
59
- y
60
- end
61
- # returns the YAML representation of this association
62
- def to_yaml(*a)
63
- to_yaml_hash.to_yaml(*a)
24
+ # Returns the YAML representation of this RTM::Association
25
+ def to_yaml
26
+ to_hash.to_yaml
64
27
  end
65
28
  end
66
29
 
67
- module TopicName
68
- def to_yaml_hash(*a)
69
- y={}
70
- y['reifier'] = reifier.to_yaml_ref if reifier
71
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
72
- y['value'] = value if value
73
- y['type'] = type.to_yaml_ref if type
74
- y['scope'] = scope.map{|i| i.to_yaml_hash} unless scope.empty?
75
- y['variants'] = variants.map{|i| i.to_yaml_hash} unless variants.empty?
76
- y
77
- end
78
- def to_yaml(*a)
79
- to_yaml_hash.to_yaml(*a)
30
+ module Name
31
+ # Returns the YAML representation of this RTM::Name
32
+ def to_yaml
33
+ to_hash.to_yaml
80
34
  end
81
35
  end
82
36
 
83
37
  module Occurrence
84
- def to_yaml_hash(*a)
85
- y={}
86
- y['reifier'] = reifier.to_yaml_ref if reifier
87
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
88
- y['value'] = value if value
89
- y['datatype'] = datatype if datatype
90
- y['type'] = type.to_yaml_ref if type
91
- y['scope'] = scope.map{|i| i.to_yaml_hash} unless scope.empty?
92
- y
93
- end
94
- def to_yaml(*a)
95
- to_yaml_hash.to_yaml(*a)
38
+ # Returns the YAML representation of this RTM::Occurrence
39
+ def to_yaml
40
+ to_hash.to_yaml
96
41
  end
97
42
  end
98
43
 
99
- module AssociationRole
100
- def to_yaml_hash(*a)
101
- y={}
102
- y['reifier'] = reifier.to_yaml_ref if reifier
103
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
104
- y['player'] = player.to_yaml_ref if player
105
- y['type'] = type.to_yaml_ref if type
106
- y
107
- end
108
- def to_yaml(*a)
109
- to_yaml_hash.to_yaml(*a)
44
+ module Role
45
+ # Returns the YAML representation of this RTM::Role
46
+ def to_yaml
47
+ to_yaml_hash.to_yaml
110
48
  end
111
49
  end
112
50
 
113
51
  module Variant
114
- def to_yaml_hash(*a)
115
- y={}
116
- y['reifier'] = reifier.to_yaml_ref if reifier
117
- y['item_identifiers'] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
118
- y['value'] = value if value
119
- y['scope'] = scope.map{|i| i.to_yaml_hash} unless scope.empty?
120
- y
121
- end
122
- def to_yaml(*a)
123
- to_yaml_hash.to_yaml(*a)
52
+ # Returns the YAML representation of this RTM::Variant
53
+ def to_yaml
54
+ to_yaml_hash.to_yaml
124
55
  end
125
56
  end
126
-
57
+
127
58
  RTM.register_extension( self )
59
+
128
60
  end
129
61
  end
130
-
@@ -0,0 +1,37 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ end
7
+ end
8
+
9
+ require "rtm/navigation/association/players"
10
+ require "rtm/navigation/name/characteristics"
11
+ require "rtm/navigation/name/atomify"
12
+ require "rtm/navigation/occurrence/characteristics"
13
+ require "rtm/navigation/occurrence/atomify"
14
+ require "rtm/navigation/topic/characteristics"
15
+ require "rtm/navigation/topic/indicators"
16
+ require "rtm/navigation/topic/items"
17
+ require "rtm/navigation/topic/locators"
18
+ require "rtm/navigation/topic/players"
19
+ require "rtm/navigation/topic/supertypes"
20
+ require "rtm/navigation/topic/traverse"
21
+ require "rtm/navigation/topic/types"
22
+
23
+ module RTM::Topic
24
+ include RTM::Navigation::Topic
25
+ end
26
+
27
+ module RTM::Name
28
+ include RTM::Navigation::Name
29
+ end
30
+
31
+ module RTM::Occurrence
32
+ include RTM::Navigation::Occurrence
33
+ end
34
+
35
+ module RTM::Association
36
+ include RTM::Navigation::Association
37
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Association
7
+
8
+ # Returns all players of roles in this association.
9
+ #
10
+ # The optional identifier specifies the type of the roles to be considered.
11
+ # The identifier may be a topic or topic reference.
12
+ #
13
+ # Multiple instances of the same topics are possible.
14
+ #
15
+ # :call-seq:
16
+ # players -> Array of Topics
17
+ # players(identifier) -> Array of Topics
18
+ #
19
+ def players(type = :any)
20
+ return roles(type).map{|r| r.player}
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Name
7
+
8
+ # Returns the atomic value of the Characteristic (Name/Occurrence).
9
+ #
10
+ # :call-seq:
11
+ # atomify -> String
12
+ #
13
+ def atomify
14
+ value
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+ module Navigation
6
+ module Name
7
+
8
+ # Returns the Topic this Characteristic (Name/Occurrence) belongs to.
9
+ # The optional argument identifier filters the
10
+ # Characteristic for its type. If the type
11
+ # does not match, nil is returned.
12
+ #
13
+ # The identifier may be a Topic or Topic-Reference.
14
+ #
15
+ # :call-seq:
16
+ # reverse_characteristics -> Topic
17
+ # reverse_characteristics(identifier) -> Topic or nil
18
+ #
19
+ def reverse_characteristics(type=:any)
20
+ return parent if type == :any
21
+ _topic = topic_map.get(type)
22
+ return nil unless _topic
23
+ #filter the Name/Occurrence for its type:
24
+ if _topic == self.type
25
+ return parent
26
+ else
27
+ return nil
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end