poseidon_rdf 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +165 -0
- data/README.md +363 -0
- data/Rakefile +6 -0
- data/examples/mixin_examples.rb +26 -0
- data/examples/mixin_examples/another_example_class_mixin.rb +24 -0
- data/examples/mixin_examples/example_class_mixin.rb +30 -0
- data/examples/rdf_examples.rb +28 -0
- data/examples/rdf_examples/multi_value_example.rb +35 -0
- data/examples/rdf_examples/other_class_config_example.rb +28 -0
- data/examples/rdf_examples/person.rb +56 -0
- data/examples/rdf_examples/simple_class_config_example.rb +28 -0
- data/examples/rdf_examples/thing.rb +41 -0
- data/lib/poseidon_rdf.rb +31 -0
- data/lib/poseidon_rdf/poseidon.rb +154 -0
- data/lib/poseidon_rdf/poseidon_core.rb +169 -0
- data/lib/poseidon_rdf/standard_methods.rb +68 -0
- data/lib/poseidon_rdf/version.rb +22 -0
- data/poseidon_rdf.gemspec +29 -0
- data/spec/class_mixin_spec.rb +84 -0
- data/spec/people_spec.rb +47 -0
- data/spec/poseidon_dsl_spec.rb +54 -0
- data/spec/poseidon_rdf_spec.rb +27 -0
- data/spec/spec_helper.rb +32 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OThmMGQ4ZmE5Yzc5MzgyZWEwMTc5MDQzZTNiMDU3NTRkNWQ2NWYzZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NGY2OWEzMzNhYzVlOTgyZTU4MjY0YjdkNGQzZmU2NGYxYTdlZTc1MQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTIwNTcyNzFmNDY2OTlhYjk1NjlmN2M3YmQ4MDc2ZTc1MTI4MDg5MjRiYmYy
|
10
|
+
YzQxOTUyMDdhMWZkNThmMDNmOWQ5MWJmMjdjNWNkMDc2ZThmMGZjNzk0MzZh
|
11
|
+
YTk3NzVmOTI0NjFkNDljYmExMGY2N2ExZGM0M2Y0OGJkNWU1NjE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YjhkNzVkNGM1ZGJmYTQ5Y2MwYmQxYjMzZjczNTk0MjY5ZjliMTZhNmQxMmE2
|
14
|
+
ZGZiYjQ0NTE5NzU3N2YwMDAyMTJkZDc1YmY1MTcyZjVhZTMzMjE0ZDNlOTI5
|
15
|
+
Y2Y5NGM3MTYwMGM1OTg1NTc3NmUwMjFiMTcwMzBiN2I4NzE2NzQ=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README.md
ADDED
@@ -0,0 +1,363 @@
|
|
1
|
+
# POSEIdON_RDF
|
2
|
+
|
3
|
+
POSEIdON (short for "Pimp your Objects with SEmantic InformatiON") is a small
|
4
|
+
library that lets you add RDF information to classes and their instances.
|
5
|
+
It can also add methods `as_rdf` and `to_rdf` to those classes and objects that
|
6
|
+
can be used to retrieve RDF representations in various formats, based on
|
7
|
+
the functionality provided by the [RDF gem](http://rubygems.org/gems/rdf).
|
8
|
+
|
9
|
+
__Notes on v2.0:__ This is a complete rewrite of the first POSEIdON code,
|
10
|
+
with a complete redesign of the core functionality. It changes the names
|
11
|
+
of user methods as well, so you will need to adjust your POSEIdON
|
12
|
+
definitions in your code (if you used POSEIdON 1.x, that is).
|
13
|
+
|
14
|
+
## How to use this gem
|
15
|
+
|
16
|
+
First, include the main POSEIdON module in classes where you want to use
|
17
|
+
RDF generation features:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
class Foo
|
21
|
+
include PoseidonRdf::Poseidon
|
22
|
+
# etc.
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
Now, your class contains a bunch of high-level class and instance methods for
|
27
|
+
adding RDF triples. Methods for output and serialisation of the resulting RDF
|
28
|
+
are also added.
|
29
|
+
|
30
|
+
In order to configure your class to use POSEIdON, you call the `poseidon`
|
31
|
+
method with a block that contains statements using the POSEIdON DSL:
|
32
|
+
|
33
|
+
### Example
|
34
|
+
|
35
|
+
```Ruby
|
36
|
+
class Foo
|
37
|
+
include Poseidon
|
38
|
+
poseidon do
|
39
|
+
base 'http://example.org/'
|
40
|
+
class_uri 'http://example.org/Foo'
|
41
|
+
same_as 'http://example.org/SomeOtherFoo'
|
42
|
+
instance_uri_scheme 'http://example.org/Foo/#{id}'
|
43
|
+
...
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
This DSL will be explained step by step in the following sections.
|
49
|
+
|
50
|
+
## The POSEIdON DSL
|
51
|
+
|
52
|
+
### Class-related configuration
|
53
|
+
|
54
|
+
The DSL is divided into two sections: One that specifies how *classes*
|
55
|
+
can be represented as RDF, and another section for the configuration
|
56
|
+
of their *instances*. First, I will explain what you can do to
|
57
|
+
represent classes.
|
58
|
+
|
59
|
+
#### Identifying URIs for classes
|
60
|
+
|
61
|
+
Every RDF entity needs an URI to identify itself. In order to define
|
62
|
+
such an identifier for your class, use the `class_uri` method.
|
63
|
+
In order to reduce the lines in example code, this and the following
|
64
|
+
examples assume we want to configure a class named `Foo`, as in the
|
65
|
+
first sample above. The following examples show a POSEIdON configuration
|
66
|
+
along with the resulting snippet of RDF (in Turtle notation).
|
67
|
+
|
68
|
+
```Ruby
|
69
|
+
poseidon do
|
70
|
+
base 'http://example.org/'
|
71
|
+
class_uri 'http://example.org/Foo'
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
```
|
76
|
+
@base <http://example.org/> .
|
77
|
+
<Foo> a <owl:Class> .
|
78
|
+
```
|
79
|
+
|
80
|
+
First, a base URI is defined for the RDF output. In combination
|
81
|
+
with `<Foo>` this results in the URI we gave in the `class_uri`
|
82
|
+
configuration statement.
|
83
|
+
|
84
|
+
In addition, the RDF generator will automatically add a statement
|
85
|
+
that gives the type of your Ruby Class as `rdfs:Class` or
|
86
|
+
`owl:Class`, depending on the RDF formalism you chose for output
|
87
|
+
(see below).
|
88
|
+
|
89
|
+
In these examples, values are given as strings. It is possible to
|
90
|
+
use other objects as values (such as accessing class or instance
|
91
|
+
methods by using symbols). See below for the options.
|
92
|
+
|
93
|
+
#### Relations to other classes
|
94
|
+
|
95
|
+
You can declare *equivalence* relations and *subclass* relations
|
96
|
+
for your Ruby class:
|
97
|
+
|
98
|
+
```Ruby
|
99
|
+
poseidon do
|
100
|
+
base 'http://example.org/'
|
101
|
+
class_uri 'http://example.org/Foo'
|
102
|
+
same_as 'http://example.org/SomeOtherFoo'
|
103
|
+
subclass_of 'http://example.org/AMoreGeneralFoo'
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
```
|
108
|
+
@base <http://example.org/> .
|
109
|
+
<Foo> a <owl:Class> ;
|
110
|
+
owl:sameAs <http://example.org/SomeOtherFoo> ;
|
111
|
+
rdfs:subClassOf <http://example.org/AMoreGeneralFoo> .
|
112
|
+
```
|
113
|
+
|
114
|
+
### Instance-related configuration
|
115
|
+
|
116
|
+
There are other options to configure how *instances* of a class
|
117
|
+
should be exported.
|
118
|
+
|
119
|
+
#### Identifying URIs for classes
|
120
|
+
|
121
|
+
First, every instance itself needs an identifier. With
|
122
|
+
`instance_uri_scheme` you can provide a string that can be
|
123
|
+
evaluated in the context of the instance object. The result
|
124
|
+
should be an URL-compatible string that is unique for each
|
125
|
+
instance object. If you have some kind of id attribute, this
|
126
|
+
is an ideal candidate.
|
127
|
+
|
128
|
+
Let us assume that the `Foo` class has a numeric identifier
|
129
|
+
accessible via the instance method `id`, and there is one
|
130
|
+
instance object with the ID `1`. Then, the following
|
131
|
+
code defines a string scheme for instances:
|
132
|
+
|
133
|
+
```Ruby
|
134
|
+
poseidon do
|
135
|
+
base 'http://example.org/'
|
136
|
+
class_uri 'http://example.org/Foo'
|
137
|
+
instance_uri_scheme 'http://example.org/Foo/#{id}'
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
141
|
+
```
|
142
|
+
@base <http://example.org/> .
|
143
|
+
<Foo> a <owl:Class> .
|
144
|
+
|
145
|
+
<Foo/1> a <Foo> .
|
146
|
+
```
|
147
|
+
|
148
|
+
It is important to use **single quotes** for the string scheme
|
149
|
+
in order to avoid the string to be evaluated right away. The
|
150
|
+
string scheme internally uses the interpolation `#{id}`, but
|
151
|
+
the interpolation will be computed in the context of the
|
152
|
+
object to be represented, so for our single object, this part
|
153
|
+
of the string will yield `'1'`.
|
154
|
+
|
155
|
+
#### Mapping attributes to RDF statements
|
156
|
+
|
157
|
+
You can declare how atomic attributes of an instance shall be
|
158
|
+
represented in RDF. For this you basically need to provide
|
159
|
+
information about the URI that shall serve as the RDF
|
160
|
+
*predicate* linking the instance (subject) to the attribute
|
161
|
+
(object).
|
162
|
+
|
163
|
+
This can be done with the `instance_attributes` method
|
164
|
+
(assuming that the instance object has an attribute `name`
|
165
|
+
set to the value of 'Bar'):
|
166
|
+
|
167
|
+
```Ruby
|
168
|
+
poseidon do
|
169
|
+
base 'http://example.org/'
|
170
|
+
class_uri 'http://example.org/Foo'
|
171
|
+
instance_uri_scheme 'http://example.org/Foo/#{id}'
|
172
|
+
instance_attributes :name, 'http://example.org/hasName'
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
176
|
+
```
|
177
|
+
@base <http://example.org/> .
|
178
|
+
<Foo> a <owl:Class> .
|
179
|
+
|
180
|
+
<Foo/1> a <Foo> ;
|
181
|
+
<hasName> "Bar" .
|
182
|
+
```
|
183
|
+
|
184
|
+
You provide a Hash to this method, where the keys are symbols
|
185
|
+
indicating the method names for your attributes, and the values
|
186
|
+
are (in the default case) strings indicating the predicate URI.
|
187
|
+
|
188
|
+
> Note: In the future, it will also be possible to use more
|
189
|
+
complicated configurations here, e.g., if you need to transform
|
190
|
+
attribute values first, or if you need to export the value of
|
191
|
+
an attribute more than one time using different predicates.
|
192
|
+
|
193
|
+
You can call `instance_attributes` multiple times without
|
194
|
+
losing information from earlier calls.
|
195
|
+
|
196
|
+
#### Mapping member objects to RDF statements
|
197
|
+
|
198
|
+
This method is useful for atomic attributes (such as strings or
|
199
|
+
numbers). If you need to export more complex objects along with
|
200
|
+
an instance, you can do so with `describe_member` This method
|
201
|
+
evaluates one or more member objects and
|
202
|
+
|
203
|
+
1. expresses their membership inside the instance using a given
|
204
|
+
predicate URI,
|
205
|
+
2. and, optionally, adds their RDF to the output.
|
206
|
+
|
207
|
+
In both cases, the class of the member objects needs to be configured
|
208
|
+
to use POSEIdON, too. However, in the first case, only the instance
|
209
|
+
URI has to be configured.
|
210
|
+
|
211
|
+
Let us assume that our instance of Foo has the following member
|
212
|
+
objects:
|
213
|
+
|
214
|
+
1. an `owner`, which is some kind of person or agent for whom
|
215
|
+
RDF descriptions are already available at some external URL,
|
216
|
+
2. and a collection `tidbits` of instances of the `Tidbit` class
|
217
|
+
which we want to describe in RDF inside the main RDF of the
|
218
|
+
Foo instance itself.
|
219
|
+
|
220
|
+
The owner object points to the existing RDF description with an URL
|
221
|
+
field, and the Foo instance possesses two tidbits, a "gadget" and
|
222
|
+
a "gimmick".
|
223
|
+
|
224
|
+
This can be configured with the following configuration:
|
225
|
+
|
226
|
+
```Ruby
|
227
|
+
poseidon do
|
228
|
+
...
|
229
|
+
describe_member :owner, {
|
230
|
+
membership: 'http://example.org/belongsTo',
|
231
|
+
with_data: false
|
232
|
+
}
|
233
|
+
describe_member :tidbits, {
|
234
|
+
membership: 'http://example.org/hasTidBit',
|
235
|
+
with_data: true
|
236
|
+
}
|
237
|
+
end
|
238
|
+
```
|
239
|
+
|
240
|
+
The first configuration gives a membership predicate URI
|
241
|
+
for the owner relation,
|
242
|
+
and tells POSEIdON *not to export* the owner's RDF data
|
243
|
+
except for its instance URI.
|
244
|
+
|
245
|
+
The second configuration gives a membership predicate URI
|
246
|
+
for the possession of the tidbit, and tells POSEIdON
|
247
|
+
*export* the tidbits' RDF *along with the Foo RDF*:
|
248
|
+
|
249
|
+
```
|
250
|
+
@base <http://example.org/> .
|
251
|
+
<Foo/1> a <Foo> ;
|
252
|
+
<belongsTo> <http://some/external/uri> ;
|
253
|
+
<hasTidBit> <Tidbit/1>, <Tidbit/2> .
|
254
|
+
|
255
|
+
<Tidbit/1> a <Tidbit> ;
|
256
|
+
<hasName> "gadget" .
|
257
|
+
|
258
|
+
<Tidbit/2> a <Tidbit> ;
|
259
|
+
<hasName> "gimmick" .
|
260
|
+
|
261
|
+
```
|
262
|
+
|
263
|
+
We see that POSEIdON checks whether the member object is an enumeration.
|
264
|
+
If yes, every item in the enumeration will be exported. If not, the
|
265
|
+
single member will be exported.
|
266
|
+
|
267
|
+
> The configuration for the owner and for the `Tidbit` class is omitted here, but the
|
268
|
+
example should be clear, anyway.
|
269
|
+
|
270
|
+
## How to provide values
|
271
|
+
|
272
|
+
URIs can be given in the following formats:
|
273
|
+
|
274
|
+
1. As `RDF::URI` objects. These will be used without change.
|
275
|
+
2. As __strings__. These will be used as-is, and will automatically be
|
276
|
+
converted to URIs.
|
277
|
+
3. As __symbols__. These stand for methods that will be called during
|
278
|
+
RDF generation. Depending on the context, class or instance methods
|
279
|
+
will be called. Their result will be converted to RDF URIs, if they
|
280
|
+
are of a different type.
|
281
|
+
|
282
|
+
Thus, it is also possible to use predefined or ad-hoc vocabularies from
|
283
|
+
[the Ruby RDF library](https://github.com/ruby-rdf/rdf) here, such as
|
284
|
+
`FOAF.surname`, `DC.title`, and so on.
|
285
|
+
|
286
|
+
[The people example](examples/rdf_examples/person.rb) contains some of
|
287
|
+
these predefined vocabularies in action.
|
288
|
+
|
289
|
+
## Export
|
290
|
+
|
291
|
+
When POSEIdON has been mixed in, two methods are provided to classes
|
292
|
+
and instances that generate and serialise RDF:
|
293
|
+
|
294
|
+
1. `poseidon_as_rdf`, which generates the RDF graph,
|
295
|
+
2. and `poseidon_to_rdf`, which returns a serialised string of the
|
296
|
+
RDF in a given format.
|
297
|
+
|
298
|
+
`poseidon_to_rdf(mode, format)` expects two parameters:
|
299
|
+
|
300
|
+
1. The __mode__, which determines what RDF vocabularies to use. At
|
301
|
+
the moment this defaults to `:owl`, which is also the only option
|
302
|
+
(but more will follow).
|
303
|
+
2. The __format__, which selects an RDF serialisation format. It
|
304
|
+
defaults to `:turtle`, other options are `:ntriples` or `:rdfxml`.
|
305
|
+
|
306
|
+
|
307
|
+
### Providing standard `as_rdf` and `to_rdf` methods
|
308
|
+
|
309
|
+
The two methods `as_rdf` and `to_rdf` are not automatically defined because
|
310
|
+
they could cause conflicts. If you want them, include the module
|
311
|
+
`PoseidonRdf::StandardMethods` after `include PoseidonRdf::Poseidon`.
|
312
|
+
|
313
|
+
Now, if you want to change mode or format, you can do so using the
|
314
|
+
following methods:
|
315
|
+
|
316
|
+
```Ruby
|
317
|
+
@example_class.poseidon_set_standard_mode(:owl)
|
318
|
+
@example_class.poseidon_set_standard_format(:rdfxml)
|
319
|
+
```
|
320
|
+
|
321
|
+
While the mode must be adjusted for every class that has POSEIdON mixed in,
|
322
|
+
the format change is only relevant to classes that act as a starting point
|
323
|
+
of RDF generation – that is, those that actually call `to_rdf` (since the
|
324
|
+
collection of RDF under the hood only consists of calls to `as_rdf`, where
|
325
|
+
the serialisation format is irrelevant).
|
326
|
+
|
327
|
+
|
328
|
+
## Release history:
|
329
|
+
|
330
|
+
### 2.0 (29.05.2014)
|
331
|
+
|
332
|
+
Major redesign, improvement of DSL and internal functionality.
|
333
|
+
Re-release under the available gem name "poseidon_rdf".
|
334
|
+
|
335
|
+
### 1.1.1 (17 July 2013)
|
336
|
+
|
337
|
+
- Turtle format
|
338
|
+
- minor bux fixes
|
339
|
+
|
340
|
+
### 1.0.0 (23 June 2013) initial relase
|
341
|
+
|
342
|
+
- initial, minimal release
|
343
|
+
|
344
|
+
## Plans
|
345
|
+
|
346
|
+
_(none at the moment.)_
|
347
|
+
|
348
|
+
|
349
|
+
## Contributing to POSEIdON
|
350
|
+
|
351
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
352
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
353
|
+
* Fork the project.
|
354
|
+
* Start a feature/bugfix branch.
|
355
|
+
* Commit and push until you are happy with your contribution.
|
356
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
357
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
358
|
+
|
359
|
+
## Copyright
|
360
|
+
|
361
|
+
Copyright (c) 2012–2104 Peter Menke, SFB 673.
|
362
|
+
Licensed under the GNU LGPL v3. See LICENSE.txt for further details.
|
363
|
+
|