rtm 0.1.6 → 0.2.0
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 +3 -3
- data/lib/rtm.rb +148 -74
- data/lib/rtm/axes.rb +295 -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 +58 -0
- data/lib/rtm/extensions.rb +11 -1
- 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 +18 -0
- data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
- data/lib/rtm/io/ontopia_io.rb +25 -0
- data/lib/rtm/io/tmapix.rb +234 -0
- data/lib/rtm/io/to_hash.rb +116 -0
- data/lib/rtm/io/to_jtm.rb +53 -103
- data/lib/rtm/io/to_rdf.rb +30 -0
- data/lib/rtm/io/to_string.rb +8 -6
- 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 +29 -98
- data/lib/rtm/navigation.rb +37 -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 +162 -0
- data/lib/rtm/navigation/topic/traverse.rb +51 -0
- data/lib/rtm/navigation/topic/types.rb +107 -0
- data/lib/rtm/psi.rb +33 -2
- data/lib/rtm/sugar.rb +34 -0
- data/lib/rtm/sugar/association/hash_access.rb +46 -0
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +75 -0
- data/lib/rtm/{pimp_my_api.rb → sugar/occurrence/externalize.rb} +3 -0
- data/lib/rtm/sugar/role/counterparts.rb +133 -46
- data/lib/rtm/sugar/topic/characteristics.rb +126 -12
- data/lib/rtm/sugar/topic/counterparts.rb +130 -7
- data/lib/rtm/sugar/topic/hash_access.rb +140 -30
- data/lib/rtm/sugar/topic/scoped.rb +65 -0
- data/lib/rtm/sugar/topic/topic_ref.rb +35 -0
- data/lib/rtm/sugar/topic/typed.rb +159 -0
- data/lib/rtm/sugar/typed/types.rb +38 -0
- data/lib/rtm/validation.rb +8 -5
- data/lib/rtm/version.rb +18 -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_spec.rb +85 -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 +16 -0
- data/spec/rtm/sugar/role/counterparts_spec.rb +191 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +318 -0
- data/spec/rtm/sugar/topic/counterparts_spec.rb +184 -0
- data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
- data/spec/rtm/sugar/topic/scoped_spec.rb +131 -0
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
- data/spec/rtm/sugar/topic/typed_spec.rb +155 -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/name_spec.rb +85 -0
- data/spec/rtm/tmapi/core/occurrence_spec.rb +96 -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 +403 -0
- data/spec/rtm/tmapi/core/topic_map_spec.rb +648 -0
- data/spec/rtm/tmapi/core/topic_spec.rb +992 -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 +94 -0
- data/spec/spec_helper.rb +23 -0
- data/test/base_unit_test.rb +161 -0
- data/test/{base_test.rb → base_unit_test_tmapi.rb} +46 -43
- metadata +122 -66
- 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/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
@@ -0,0 +1,280 @@
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
2
|
+
# License: Apache License, Version 2.0
|
3
|
+
|
4
|
+
module RTM::Axes
|
5
|
+
module Topics
|
6
|
+
|
7
|
+
def self.extended(k)
|
8
|
+
k.extend ArrayProxy
|
9
|
+
end
|
10
|
+
|
11
|
+
def result
|
12
|
+
self.map{|i| i.construct}
|
13
|
+
end
|
14
|
+
alias :tmapi :result
|
15
|
+
|
16
|
+
# ---- characteristics-axis ----------------------------------------------#
|
17
|
+
|
18
|
+
# Returns all Names and Occurrences of these Topics.
|
19
|
+
# If an identifier is given, only those Names and Occurrences are returned,
|
20
|
+
# whose type or supertypes include the identifier.
|
21
|
+
#
|
22
|
+
# Identifier may be a Topic or Topic-Reference.
|
23
|
+
#
|
24
|
+
# The result may be empty.
|
25
|
+
#
|
26
|
+
# :call-seq:
|
27
|
+
# characteristics -> Array of Names and Occurrences
|
28
|
+
# characteristics(identifier) -> Array of Names and Occurrences
|
29
|
+
#
|
30
|
+
def characteristics(type=:any)
|
31
|
+
_res = self.inject([]){|all,containee| all << containee.send(:characteristics,type)}.flatten
|
32
|
+
### NO UNIQUE NEEDED
|
33
|
+
_res = _res.extend(Characteristics)
|
34
|
+
_res
|
35
|
+
end
|
36
|
+
|
37
|
+
# ---- indicators-axis ---------------------------------------------------#
|
38
|
+
|
39
|
+
# Returns all indicators (subject identifiers) of these Topics.
|
40
|
+
#
|
41
|
+
# The result may be empty.
|
42
|
+
#
|
43
|
+
# :call-seq:
|
44
|
+
# indicators -> Array of Strings
|
45
|
+
#
|
46
|
+
def indicators
|
47
|
+
#self = Array of TopicProxies
|
48
|
+
#containee: RTM::Axes::Topic
|
49
|
+
#send -> Array of Strings
|
50
|
+
self.inject([]){|all,containee| all << containee.send(:indicators)}.flatten
|
51
|
+
### NO UNIQUE NEEDED
|
52
|
+
end
|
53
|
+
|
54
|
+
# ---- item-axis ---------------------------------------------------------#
|
55
|
+
|
56
|
+
# Returns one item identifier for each of these Topics, only if
|
57
|
+
# if the Topic has an item identifier.
|
58
|
+
#
|
59
|
+
# The result may be an empty Array.
|
60
|
+
#
|
61
|
+
# :call-seq:
|
62
|
+
# item -> Array of Strings
|
63
|
+
#
|
64
|
+
def item
|
65
|
+
#self = Array of TopicProxies
|
66
|
+
#containee: RTM::Axes::Topic
|
67
|
+
#send -> Array of (String or nil)s
|
68
|
+
_res = self.inject([]){|all,containee| all << containee.send(:item)}.flatten
|
69
|
+
_res = _res.select{|i| i}
|
70
|
+
### NO UNIQUE NEEDED
|
71
|
+
end
|
72
|
+
|
73
|
+
# ---- locators-axis -----------------------------------------------------#
|
74
|
+
|
75
|
+
# Returns all subject locators of these Topics.
|
76
|
+
#
|
77
|
+
# The result may be empty.
|
78
|
+
#
|
79
|
+
# :call-seq:
|
80
|
+
# locators -> Array of Strings
|
81
|
+
#
|
82
|
+
def locators
|
83
|
+
self.inject([]){|all,containee| all << containee.send(:locators)}.flatten
|
84
|
+
### NO UNIQUE NEEDED
|
85
|
+
end
|
86
|
+
|
87
|
+
# ---- players-axis ------------------------------------------------------#
|
88
|
+
|
89
|
+
# Returns all Associations in which these Topics play a Role.
|
90
|
+
#
|
91
|
+
# The optional
|
92
|
+
# identifier specifies the type of the Roles to be considered.
|
93
|
+
# The identifier may be a Topic or Topic-Reference.
|
94
|
+
#
|
95
|
+
# Multiple instances of the same Association are possible.
|
96
|
+
# The result may be empty.
|
97
|
+
#
|
98
|
+
# :call-seq:
|
99
|
+
# reverse_players -> Array of Associations
|
100
|
+
# reverse_players(identifier) -> Array of Associations
|
101
|
+
#
|
102
|
+
def reverse_players(type=:any)
|
103
|
+
_res = self.inject([]){|all,containee| all << containee.send(:reverse_players,type)}.flatten
|
104
|
+
### NO UNIQUE ###
|
105
|
+
_res = _res.extend(Associations)
|
106
|
+
_res
|
107
|
+
end
|
108
|
+
|
109
|
+
# ---- reifier-axis ------------------------------------------------------#
|
110
|
+
|
111
|
+
# Returns the Constructs which are reified by one of these Topics
|
112
|
+
# only if such Constructs exist.
|
113
|
+
#
|
114
|
+
# :call-seq:
|
115
|
+
# reifier -> Array of Associations, Names and Occurrences
|
116
|
+
#
|
117
|
+
def reifier
|
118
|
+
_res = self.inject([]){|all,containee| all << containee.send(:reifier)}.flatten
|
119
|
+
_res = _res.select{|i| i} #reject nil
|
120
|
+
### NO UNIQUE NEEDED
|
121
|
+
_res = _res.extend(AssocsNamesOccs)
|
122
|
+
_res
|
123
|
+
end
|
124
|
+
|
125
|
+
# ---- roles-axis --------------------------------------------------------#
|
126
|
+
|
127
|
+
# Returns all Associations that have Roles that have one of
|
128
|
+
# these Topics as Roletype. Multiple instances of the same
|
129
|
+
# Association are possible.
|
130
|
+
#
|
131
|
+
# The result may be empty.
|
132
|
+
#
|
133
|
+
# :call-seq:
|
134
|
+
# reverse_roles -> Array of Associations
|
135
|
+
#
|
136
|
+
def reverse_roles
|
137
|
+
_res = self.inject([]){|all,containee| all << containee.send(:reverse_roles)}.flatten
|
138
|
+
### NO UNIQUE ###
|
139
|
+
_res = _res.extend(Associations)
|
140
|
+
_res
|
141
|
+
end
|
142
|
+
|
143
|
+
# ---- scope-axis --------------------------------------------------------#
|
144
|
+
|
145
|
+
# Returns all Associations, Names and Occurrences that include at least one of these
|
146
|
+
# Topics (themes) in their scope.
|
147
|
+
#
|
148
|
+
# The result may be empty.
|
149
|
+
#
|
150
|
+
# :call-seq:
|
151
|
+
# reverse_scope -> Array of Names, Associations and Occurrences
|
152
|
+
#
|
153
|
+
def reverse_scope
|
154
|
+
_res = self.inject([]){|all,containee| all << containee.send(:reverse_scope)}.flatten
|
155
|
+
### FLAG UNIQUE ###
|
156
|
+
_res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
|
157
|
+
### ###
|
158
|
+
_res = _res.extend(AssocsNamesOccs)
|
159
|
+
_res
|
160
|
+
end
|
161
|
+
|
162
|
+
# ---- supertypes-axis ---------------------------------------------------#
|
163
|
+
|
164
|
+
# Returns all supertypes of all of these Topics. The result includes
|
165
|
+
# all direct supertypes
|
166
|
+
# and the supertypes of these direct supertypes.
|
167
|
+
#
|
168
|
+
# The result may be an empty Array.
|
169
|
+
#
|
170
|
+
# :call-seq:
|
171
|
+
# supertypes -> Array of Topics
|
172
|
+
#
|
173
|
+
def supertypes
|
174
|
+
_res = self.define_helper(:supertypes)
|
175
|
+
#_res = self.inject([]){|all,containee| all << containee.send(:supertypes)}.flatten
|
176
|
+
### FLAG UNIQUE ###
|
177
|
+
_res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
|
178
|
+
### ###
|
179
|
+
_res = _res.extend(Topics)
|
180
|
+
_res
|
181
|
+
end
|
182
|
+
|
183
|
+
# Returns all subtypes of all of these Topics. The result includes the direct subtypes
|
184
|
+
# and the subtypes of these direct subtypes.
|
185
|
+
#
|
186
|
+
# The result may be an empty Array.
|
187
|
+
#
|
188
|
+
# :call-seq:
|
189
|
+
# subtypes -> Array of Topics
|
190
|
+
#
|
191
|
+
def subtypes
|
192
|
+
_res = self.inject([]){|all,containee| all << containee.send(:subtypes)}.flatten
|
193
|
+
### FLAG UNIQUE ###
|
194
|
+
_res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
|
195
|
+
### ###
|
196
|
+
_res = _res.extend(Topics)
|
197
|
+
_res
|
198
|
+
end
|
199
|
+
|
200
|
+
alias reverse_subtypes supertypes
|
201
|
+
alias reverse_supertypes subtypes
|
202
|
+
|
203
|
+
# ---- traverse-axis ---------------------------------------------------#
|
204
|
+
|
205
|
+
# First computes all Associations where these Topics play a Role.
|
206
|
+
# There, the optional identifier filters the Associations for their type.
|
207
|
+
#
|
208
|
+
# Returns all Players of all Roles in these Associations.
|
209
|
+
# Each Topic is deducted ones from the returned Array.
|
210
|
+
# The result may be empty.
|
211
|
+
#
|
212
|
+
# The identifier may be a Topic or Topic-Reference.
|
213
|
+
#
|
214
|
+
# :call-seq:
|
215
|
+
# traverse(identifier) -> Array of Topics
|
216
|
+
#
|
217
|
+
def traverse(type=:any)
|
218
|
+
_res = self.inject([]){|all,containee| all << containee.send(:traverse,type)}.flatten
|
219
|
+
### NO UNIQUE ###
|
220
|
+
_res = _res.extend(Topics)
|
221
|
+
_res
|
222
|
+
end
|
223
|
+
|
224
|
+
# Always returns an empty Array
|
225
|
+
#
|
226
|
+
# :call-seq:
|
227
|
+
# reverse_traverse -> Array of Topics
|
228
|
+
#
|
229
|
+
def reverse_traverse
|
230
|
+
_res = [] #HARDCODED
|
231
|
+
_res.extend(Topics)
|
232
|
+
end
|
233
|
+
|
234
|
+
# ---- types-axis --------------------------------------------------------#
|
235
|
+
|
236
|
+
# Returns the Topics these Topics are instances of. Calls
|
237
|
+
# the TMAPI getTypes method.
|
238
|
+
#
|
239
|
+
# The result may be empty.
|
240
|
+
#
|
241
|
+
# :call-seq:
|
242
|
+
# types -> Array of Topics
|
243
|
+
#
|
244
|
+
def types
|
245
|
+
#self = Array of TopicProxies
|
246
|
+
#containee: RTM::Axes::Topic
|
247
|
+
#send -> Array of TopicProxies
|
248
|
+
#uniq -> Topics in Array, call unique on Array
|
249
|
+
#convert to TopicProxies again
|
250
|
+
#extend result-Array
|
251
|
+
_res = self.inject([]){|all,containee| all << containee.send(:types)}.flatten
|
252
|
+
### FLAG UNIQUE ###
|
253
|
+
_res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
|
254
|
+
### ###
|
255
|
+
_res.extend(Topics)
|
256
|
+
_res
|
257
|
+
end
|
258
|
+
|
259
|
+
# Returns the Topics which are instances of these Topics.
|
260
|
+
# Uses the TMAPI TypeInstanceIndex.
|
261
|
+
#
|
262
|
+
# The result may be empty.
|
263
|
+
#
|
264
|
+
# :call-seq:
|
265
|
+
# instances -> Array of Topics
|
266
|
+
#
|
267
|
+
def instances
|
268
|
+
_res = self.inject([]){|all,containee| all << containee.send(:instances)}.flatten
|
269
|
+
### FLAG UNIQUE ###
|
270
|
+
_res = _res.map{|i| i.construct}.uniq.map{|i| i.axes}
|
271
|
+
### ###
|
272
|
+
_res.extend(Topics)
|
273
|
+
_res
|
274
|
+
end
|
275
|
+
|
276
|
+
alias reverse_types instances
|
277
|
+
alias reverse_instances types
|
278
|
+
|
279
|
+
end
|
280
|
+
end
|
data/lib/rtm/engine.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module RTM
|
2
|
+
class Engine
|
3
|
+
def self.abstract?
|
4
|
+
self == Engine
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.inherited(subclass)
|
8
|
+
Engine.add(subclass) # this MUST be Engine and not self! Otherwise every intermediate class in the inheritance chain will have it's own list
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.add(engine)
|
12
|
+
@engines ||= []
|
13
|
+
@engines << engine
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.identifier(i=nil)
|
17
|
+
if i
|
18
|
+
# setter / declaration
|
19
|
+
@identifier = i
|
20
|
+
else
|
21
|
+
# getter
|
22
|
+
@identifier
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.all
|
27
|
+
@engines ||= []
|
28
|
+
@engines.reject!{|e| e.abstract?} # this needs to be done here because in the inherited hook the method is not yet available.
|
29
|
+
@engines
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.list
|
33
|
+
all.map{|e| e.identifier}
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.[](identifier)
|
37
|
+
all.find {|e| e.identifier == identifier}
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.load(engine_name)
|
41
|
+
begin
|
42
|
+
require "rtm/#{engine_name}"
|
43
|
+
rescue LoadError
|
44
|
+
engine_path = File.expand_path(File.join(File.dirname(__FILE__), "../../../rtm-#{engine_name}/lib"))
|
45
|
+
if File.directory?(engine_path)
|
46
|
+
$:.unshift engine_path
|
47
|
+
require "rtm/#{engine_name}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
attr_reader :connections
|
53
|
+
def initialize(params={})
|
54
|
+
@params = params
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
data/lib/rtm/extensions.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
|
# Register a module as extension.
|
3
6
|
#
|
@@ -16,4 +19,11 @@ module RTM
|
|
16
19
|
const_get(const).send(:include, plugin_mod.const_get(const) ) if const_defined?(const)
|
17
20
|
end
|
18
21
|
end
|
19
|
-
|
22
|
+
module AR
|
23
|
+
def self.register_extension(plugin_mod)
|
24
|
+
plugin_mod.constants.each do |const|
|
25
|
+
const_get(const).send(:include, plugin_mod.const_get(const) ) if const_defined?(const)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -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
|
# Some helpers for locators which could ideally mixed into String and Locator.
|
3
6
|
# Anyway, they are not here to not clutter up the namespace too much.
|
@@ -5,7 +8,9 @@ module RTM
|
|
5
8
|
# removes "=" (and possible whitespace thereafter) from the beginning of a String or Locator if it is there
|
6
9
|
def self.slo2iri(slo)
|
7
10
|
slo = slo.to_s
|
8
|
-
slo
|
11
|
+
slo =~ /^(=|sl:)\s*(.+)/
|
12
|
+
return $2 if $2
|
13
|
+
# old: slo[1..-1].lstrip if slo[0] == "="[0] # remove = if slo starts with it
|
9
14
|
slo
|
10
15
|
end
|
11
16
|
|
@@ -17,7 +22,8 @@ module RTM
|
|
17
22
|
|
18
23
|
# returns true if the String or Locator given starts with "="
|
19
24
|
def self.is_a_slo?(iri)
|
20
|
-
iri.to_s[0] == "="[0]
|
25
|
+
# iri.to_s[0] == "="[0] # old version
|
26
|
+
iri =~ /^(=|sl:)\s*(.+)/
|
21
27
|
end
|
22
28
|
|
23
29
|
def self.iid2iri(slo)
|
@@ -33,7 +39,12 @@ module RTM
|
|
33
39
|
# returns true if the String or Locator given starts with "^".
|
34
40
|
# This catches only the prefixing-style, not the local-identifier (non-absolute-iri) style
|
35
41
|
def self.is_a_iid?(iri)
|
36
|
-
iri
|
37
|
-
|
42
|
+
iri =~ /^(\^|ii:)\s*(.*)/
|
43
|
+
# iri.to_s[0] == "^"[0] # old version
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.is_a_sid?(iri)
|
47
|
+
iri =~ /^(si:)\s*(.+)/
|
48
|
+
end
|
38
49
|
end
|
39
50
|
end
|
data/lib/rtm/io.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
|
2
|
+
# License: Apache License, Version 2.0
|
3
|
+
|
4
|
+
require 'rtm/io/to_rdf'
|
5
|
+
require 'rtm/io/to_hash'
|
6
|
+
|
7
|
+
|
8
|
+
# Check if JSON is available and load JTM if it is
|
9
|
+
if Object.const_defined?(:JSON)
|
10
|
+
require 'rtm/io/to_jtm'
|
11
|
+
end
|
12
|
+
# old code to check for JSON (has Gem-dependency)
|
13
|
+
#require 'rtm/io/to_jtm' unless (Gem.source_index.find_name('json/ext').empty? && Gem.source_index.find_name('json/pure').empty?)
|
14
|
+
|
15
|
+
|
16
|
+
require 'rtm/io/to_yaml'
|
17
|
+
require 'rtm/io/tmapix'
|
18
|
+
require 'rtm/io/to_string'
|