rdf 3.0.13 → 3.1.4
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.
- checksums.yaml +4 -4
- data/AUTHORS +1 -1
- data/README.md +46 -11
- data/VERSION +1 -1
- data/etc/doap.nt +74 -80
- data/lib/rdf.rb +32 -23
- data/lib/rdf/changeset.rb +87 -19
- data/lib/rdf/cli.rb +6 -6
- data/lib/rdf/format.rb +17 -10
- data/lib/rdf/mixin/enumerable.rb +3 -2
- data/lib/rdf/mixin/mutable.rb +5 -15
- data/lib/rdf/mixin/queryable.rb +12 -4
- data/lib/rdf/mixin/writable.rb +9 -14
- data/lib/rdf/model/dataset.rb +1 -1
- data/lib/rdf/model/graph.rb +5 -2
- data/lib/rdf/model/list.rb +5 -5
- data/lib/rdf/model/statement.rb +30 -7
- data/lib/rdf/model/uri.rb +42 -23
- data/lib/rdf/nquads.rb +6 -6
- data/lib/rdf/ntriples.rb +6 -4
- data/lib/rdf/ntriples/reader.rb +32 -7
- data/lib/rdf/ntriples/writer.rb +10 -1
- data/lib/rdf/query.rb +27 -35
- data/lib/rdf/query/hash_pattern_normalizer.rb +14 -12
- data/lib/rdf/query/pattern.rb +51 -18
- data/lib/rdf/query/solution.rb +20 -1
- data/lib/rdf/query/solutions.rb +15 -5
- data/lib/rdf/query/variable.rb +17 -5
- data/lib/rdf/reader.rb +76 -25
- data/lib/rdf/repository.rb +32 -18
- data/lib/rdf/transaction.rb +1 -1
- data/lib/rdf/util.rb +6 -5
- data/lib/rdf/util/cache.rb +2 -2
- data/lib/rdf/util/coercions.rb +60 -0
- data/lib/rdf/util/file.rb +2 -2
- data/lib/rdf/util/logger.rb +7 -7
- data/lib/rdf/vocab/owl.rb +401 -86
- data/lib/rdf/vocab/rdfs.rb +81 -18
- data/lib/rdf/vocab/rdfv.rb +147 -1
- data/lib/rdf/vocab/writer.rb +43 -4
- data/lib/rdf/vocab/xsd.rb +203 -2
- data/lib/rdf/vocabulary.rb +108 -14
- data/lib/rdf/writer.rb +32 -10
- metadata +28 -27
data/lib/rdf/vocab/rdfs.rb
CHANGED
@@ -5,118 +5,181 @@ require 'rdf'
|
|
5
5
|
module RDF
|
6
6
|
# @!parse
|
7
7
|
# # Vocabulary for <http://www.w3.org/2000/01/rdf-schema#>
|
8
|
+
# #
|
9
|
+
# # The RDF Schema vocabulary (RDFS)
|
10
|
+
# # @see http://www.w3.org/2000/01/rdf-schema-more
|
8
11
|
# class RDFS < RDF::StrictVocabulary
|
12
|
+
# # The class of classes.
|
13
|
+
# # @return [RDF::Vocabulary::Term]
|
14
|
+
# attr_reader :Class
|
15
|
+
#
|
16
|
+
# # The class of RDF containers.
|
17
|
+
# # @return [RDF::Vocabulary::Term]
|
18
|
+
# attr_reader :Container
|
19
|
+
#
|
20
|
+
# # The class of container membership properties, rdf:_1, rdf:_2, ..., all of which are sub-properties of 'member'.
|
21
|
+
# # @return [RDF::Vocabulary::Term]
|
22
|
+
# attr_reader :ContainerMembershipProperty
|
23
|
+
#
|
24
|
+
# # The class of RDF datatypes.
|
25
|
+
# # @return [RDF::Vocabulary::Term]
|
26
|
+
# attr_reader :Datatype
|
27
|
+
#
|
28
|
+
# # The class of literal values, eg. textual strings and integers.
|
29
|
+
# # @return [RDF::Vocabulary::Term]
|
30
|
+
# attr_reader :Literal
|
31
|
+
#
|
32
|
+
# # The class resource, everything.
|
33
|
+
# # @return [RDF::Vocabulary::Term]
|
34
|
+
# attr_reader :Resource
|
35
|
+
#
|
36
|
+
# # A description of the subject resource.
|
37
|
+
# # @return [RDF::Vocabulary::Term]
|
38
|
+
# attr_reader :comment
|
39
|
+
#
|
40
|
+
# # A domain of the subject property.
|
41
|
+
# # @return [RDF::Vocabulary::Term]
|
42
|
+
# attr_reader :domain
|
43
|
+
#
|
44
|
+
# # The defininition of the subject resource.
|
45
|
+
# # @return [RDF::Vocabulary::Term]
|
46
|
+
# attr_reader :isDefinedBy
|
47
|
+
#
|
48
|
+
# # A human-readable name for the subject.
|
49
|
+
# # @return [RDF::Vocabulary::Term]
|
50
|
+
# attr_reader :label
|
51
|
+
#
|
52
|
+
# # A member of the subject resource.
|
53
|
+
# # @return [RDF::Vocabulary::Term]
|
54
|
+
# attr_reader :member
|
55
|
+
#
|
56
|
+
# # A range of the subject property.
|
57
|
+
# # @return [RDF::Vocabulary::Term]
|
58
|
+
# attr_reader :range
|
59
|
+
#
|
60
|
+
# # Further information about the subject resource.
|
61
|
+
# # @return [RDF::Vocabulary::Term]
|
62
|
+
# attr_reader :seeAlso
|
63
|
+
#
|
64
|
+
# # The subject is a subclass of a class.
|
65
|
+
# # @return [RDF::Vocabulary::Term]
|
66
|
+
# attr_reader :subClassOf
|
67
|
+
#
|
68
|
+
# # The subject is a subproperty of a property.
|
69
|
+
# # @return [RDF::Vocabulary::Term]
|
70
|
+
# attr_reader :subPropertyOf
|
71
|
+
#
|
9
72
|
# end
|
10
|
-
|
73
|
+
RDFS = Class.new(RDF::StrictVocabulary("http://www.w3.org/2000/01/rdf-schema#")) do
|
11
74
|
|
12
75
|
# Ontology definition
|
13
76
|
ontology :"http://www.w3.org/2000/01/rdf-schema#",
|
14
|
-
"dc11:title":
|
15
|
-
"rdfs:seeAlso":
|
77
|
+
"dc11:title": "The RDF Schema vocabulary (RDFS)".freeze,
|
78
|
+
"rdfs:seeAlso": "http://www.w3.org/2000/01/rdf-schema-more".freeze,
|
16
79
|
type: "owl:Ontology".freeze
|
17
80
|
|
18
81
|
# Class definitions
|
19
82
|
term :Class,
|
20
83
|
comment: %(The class of classes.).freeze,
|
84
|
+
isDefinedBy: "rdfs:".freeze,
|
21
85
|
label: "Class".freeze,
|
22
|
-
isDefinedBy: %(rdfs:).freeze,
|
23
86
|
subClassOf: "rdfs:Resource".freeze,
|
24
87
|
type: "rdfs:Class".freeze
|
25
88
|
term :Container,
|
26
89
|
comment: %(The class of RDF containers.).freeze,
|
90
|
+
isDefinedBy: "rdfs:".freeze,
|
27
91
|
label: "Container".freeze,
|
28
|
-
isDefinedBy: %(rdfs:).freeze,
|
29
92
|
subClassOf: "rdfs:Resource".freeze,
|
30
93
|
type: "rdfs:Class".freeze
|
31
94
|
term :ContainerMembershipProperty,
|
32
95
|
comment: %(The class of container membership properties, rdf:_1, rdf:_2, ...,
|
33
96
|
all of which are sub-properties of 'member'.).freeze,
|
97
|
+
isDefinedBy: "rdfs:".freeze,
|
34
98
|
label: "ContainerMembershipProperty".freeze,
|
35
|
-
isDefinedBy: %(rdfs:).freeze,
|
36
99
|
subClassOf: "rdf:Property".freeze,
|
37
100
|
type: "rdfs:Class".freeze
|
38
101
|
term :Datatype,
|
39
102
|
comment: %(The class of RDF datatypes.).freeze,
|
103
|
+
isDefinedBy: "rdfs:".freeze,
|
40
104
|
label: "Datatype".freeze,
|
41
|
-
isDefinedBy: %(rdfs:).freeze,
|
42
105
|
subClassOf: "rdfs:Class".freeze,
|
43
106
|
type: "rdfs:Class".freeze
|
44
107
|
term :Literal,
|
45
108
|
comment: %(The class of literal values, eg. textual strings and integers.).freeze,
|
109
|
+
isDefinedBy: "rdfs:".freeze,
|
46
110
|
label: "Literal".freeze,
|
47
|
-
isDefinedBy: %(rdfs:).freeze,
|
48
111
|
subClassOf: "rdfs:Resource".freeze,
|
49
112
|
type: "rdfs:Class".freeze
|
50
113
|
term :Resource,
|
51
114
|
comment: %(The class resource, everything.).freeze,
|
115
|
+
isDefinedBy: "rdfs:".freeze,
|
52
116
|
label: "Resource".freeze,
|
53
|
-
isDefinedBy: %(rdfs:).freeze,
|
54
117
|
type: "rdfs:Class".freeze
|
55
118
|
|
56
119
|
# Property definitions
|
57
120
|
property :comment,
|
58
121
|
comment: %(A description of the subject resource.).freeze,
|
59
122
|
domain: "rdfs:Resource".freeze,
|
123
|
+
isDefinedBy: "rdfs:".freeze,
|
60
124
|
label: "comment".freeze,
|
61
125
|
range: "rdfs:Literal".freeze,
|
62
|
-
isDefinedBy: %(rdfs:).freeze,
|
63
126
|
type: "rdf:Property".freeze
|
64
127
|
property :domain,
|
65
128
|
comment: %(A domain of the subject property.).freeze,
|
66
129
|
domain: "rdf:Property".freeze,
|
130
|
+
isDefinedBy: "rdfs:".freeze,
|
67
131
|
label: "domain".freeze,
|
68
132
|
range: "rdfs:Class".freeze,
|
69
|
-
isDefinedBy: %(rdfs:).freeze,
|
70
133
|
type: "rdf:Property".freeze
|
71
134
|
property :isDefinedBy,
|
72
135
|
comment: %(The defininition of the subject resource.).freeze,
|
73
136
|
domain: "rdfs:Resource".freeze,
|
137
|
+
isDefinedBy: "rdfs:".freeze,
|
74
138
|
label: "isDefinedBy".freeze,
|
75
139
|
range: "rdfs:Resource".freeze,
|
76
|
-
isDefinedBy: %(rdfs:).freeze,
|
77
140
|
subPropertyOf: "rdfs:seeAlso".freeze,
|
78
141
|
type: "rdf:Property".freeze
|
79
142
|
property :label,
|
80
143
|
comment: %(A human-readable name for the subject.).freeze,
|
81
144
|
domain: "rdfs:Resource".freeze,
|
145
|
+
isDefinedBy: "rdfs:".freeze,
|
82
146
|
label: "label".freeze,
|
83
147
|
range: "rdfs:Literal".freeze,
|
84
|
-
isDefinedBy: %(rdfs:).freeze,
|
85
148
|
type: "rdf:Property".freeze
|
86
149
|
property :member,
|
87
150
|
comment: %(A member of the subject resource.).freeze,
|
88
151
|
domain: "rdfs:Resource".freeze,
|
152
|
+
isDefinedBy: "rdfs:".freeze,
|
89
153
|
label: "member".freeze,
|
90
154
|
range: "rdfs:Resource".freeze,
|
91
|
-
isDefinedBy: %(rdfs:).freeze,
|
92
155
|
type: "rdf:Property".freeze
|
93
156
|
property :range,
|
94
157
|
comment: %(A range of the subject property.).freeze,
|
95
158
|
domain: "rdf:Property".freeze,
|
159
|
+
isDefinedBy: "rdfs:".freeze,
|
96
160
|
label: "range".freeze,
|
97
161
|
range: "rdfs:Class".freeze,
|
98
|
-
isDefinedBy: %(rdfs:).freeze,
|
99
162
|
type: "rdf:Property".freeze
|
100
163
|
property :seeAlso,
|
101
164
|
comment: %(Further information about the subject resource.).freeze,
|
102
165
|
domain: "rdfs:Resource".freeze,
|
166
|
+
isDefinedBy: "rdfs:".freeze,
|
103
167
|
label: "seeAlso".freeze,
|
104
168
|
range: "rdfs:Resource".freeze,
|
105
|
-
isDefinedBy: %(rdfs:).freeze,
|
106
169
|
type: "rdf:Property".freeze
|
107
170
|
property :subClassOf,
|
108
171
|
comment: %(The subject is a subclass of a class.).freeze,
|
109
172
|
domain: "rdfs:Class".freeze,
|
173
|
+
isDefinedBy: "rdfs:".freeze,
|
110
174
|
label: "subClassOf".freeze,
|
111
175
|
range: "rdfs:Class".freeze,
|
112
|
-
isDefinedBy: %(rdfs:).freeze,
|
113
176
|
type: "rdf:Property".freeze
|
114
177
|
property :subPropertyOf,
|
115
178
|
comment: %(The subject is a subproperty of a property.).freeze,
|
116
179
|
domain: "rdf:Property".freeze,
|
180
|
+
isDefinedBy: "rdfs:".freeze,
|
117
181
|
label: "subPropertyOf".freeze,
|
118
182
|
range: "rdf:Property".freeze,
|
119
|
-
isDefinedBy: %(rdfs:).freeze,
|
120
183
|
type: "rdf:Property".freeze
|
121
184
|
end
|
122
185
|
end
|
data/lib/rdf/vocab/rdfv.rb
CHANGED
@@ -5,9 +5,130 @@ require 'rdf'
|
|
5
5
|
module RDF
|
6
6
|
# @!parse
|
7
7
|
# # Vocabulary for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
8
|
+
# #
|
9
|
+
# # This is the RDF Schema for the RDF vocabulary terms in the RDF Namespace, defined in RDF 1.1 Concepts.
|
8
10
|
# class RDFV < RDF::StrictVocabulary
|
11
|
+
# # The class of containers of alternatives.
|
12
|
+
# # @return [RDF::Vocabulary::Term]
|
13
|
+
# # @attr_reader :Alt
|
14
|
+
#
|
15
|
+
# # The class of unordered containers.
|
16
|
+
# # @return [RDF::Vocabulary::Term]
|
17
|
+
# # @attr_reader :Bag
|
18
|
+
#
|
19
|
+
# # A class representing a compound literal.
|
20
|
+
# # @return [RDF::Vocabulary::Term]
|
21
|
+
# # @attr_reader :CompoundLiteral
|
22
|
+
#
|
23
|
+
# # The class of RDF Lists.
|
24
|
+
# # @return [RDF::Vocabulary::Term]
|
25
|
+
# # @attr_reader :List
|
26
|
+
#
|
27
|
+
# # The class of RDF properties.
|
28
|
+
# # @return [RDF::Vocabulary::Term]
|
29
|
+
# # @attr_reader :Property
|
30
|
+
#
|
31
|
+
# # The class of ordered containers.
|
32
|
+
# # @return [RDF::Vocabulary::Term]
|
33
|
+
# # @attr_reader :Seq
|
34
|
+
#
|
35
|
+
# # The class of RDF statements.
|
36
|
+
# # @return [RDF::Vocabulary::Term]
|
37
|
+
# # @attr_reader :Statement
|
38
|
+
#
|
39
|
+
# # The direction component of a CompoundLiteral.
|
40
|
+
# # @return [RDF::Vocabulary::Term]
|
41
|
+
# # @attr_reader :direction
|
42
|
+
#
|
43
|
+
# # The first item in the subject RDF list.
|
44
|
+
# # @return [RDF::Vocabulary::Term]
|
45
|
+
# # @attr_reader :first
|
46
|
+
#
|
47
|
+
# # The object of the subject RDF statement.
|
48
|
+
# # @return [RDF::Vocabulary::Term]
|
49
|
+
# # @attr_reader :object
|
50
|
+
#
|
51
|
+
# # The language component of a CompoundLiteral.
|
52
|
+
# # @return [RDF::Vocabulary::Term]
|
53
|
+
# # @attr_reader :language
|
54
|
+
#
|
55
|
+
# # The predicate of the subject RDF statement.
|
56
|
+
# # @return [RDF::Vocabulary::Term]
|
57
|
+
# # @attr_reader :predicate
|
58
|
+
#
|
59
|
+
# # The rest of the subject RDF list after the first item.
|
60
|
+
# # @return [RDF::Vocabulary::Term]
|
61
|
+
# # @attr_reader :rest
|
62
|
+
#
|
63
|
+
# # The subject of the subject RDF statement.
|
64
|
+
# # @return [RDF::Vocabulary::Term]
|
65
|
+
# # @attr_reader :subject
|
66
|
+
#
|
67
|
+
# # The subject is an instance of a class.
|
68
|
+
# # @return [RDF::Vocabulary::Term]
|
69
|
+
# # @attr_reader :type
|
70
|
+
#
|
71
|
+
# # Idiomatic property used for structured values.
|
72
|
+
# # @return [RDF::Vocabulary::Term]
|
73
|
+
# # @attr_reader :value
|
74
|
+
#
|
75
|
+
# # The datatype of RDF literals storing fragments of HTML content.
|
76
|
+
# # @return [RDF::Vocabulary::Term]
|
77
|
+
# # @attr_reader :HTML
|
78
|
+
#
|
79
|
+
# # The datatype of RDF literals storing JSON content.
|
80
|
+
# # @return [RDF::Vocabulary::Term]
|
81
|
+
# # @attr_reader :JSON
|
82
|
+
#
|
83
|
+
# # The class of plain (i.e. untyped) literal values, as used in RIF and OWL 2.
|
84
|
+
# # @return [RDF::Vocabulary::Term]
|
85
|
+
# # @attr_reader :PlainLiteral
|
86
|
+
#
|
87
|
+
# # The datatype of XML literal values.
|
88
|
+
# # @return [RDF::Vocabulary::Term]
|
89
|
+
# # @attr_reader :XMLLiteral
|
90
|
+
#
|
91
|
+
# # The datatype of language-tagged string values.
|
92
|
+
# # @return [RDF::Vocabulary::Term]
|
93
|
+
# # @attr_reader :langString
|
94
|
+
#
|
95
|
+
# # RDF/XML node element.
|
96
|
+
# # @return [RDF::Vocabulary::Term]
|
97
|
+
# # @attr_reader :Description
|
98
|
+
#
|
99
|
+
# # RDF/XML attribute creating a Reification.
|
100
|
+
# # @return [RDF::Vocabulary::Term]
|
101
|
+
# # @attr_reader :ID
|
102
|
+
#
|
103
|
+
# # RDF/XML attribute declaring subject.
|
104
|
+
# # @return [RDF::Vocabulary::Term]
|
105
|
+
# # @attr_reader :about
|
106
|
+
#
|
107
|
+
# # RDF/XML literal datatype.
|
108
|
+
# # @return [RDF::Vocabulary::Term]
|
109
|
+
# # @attr_reader :datatype
|
110
|
+
#
|
111
|
+
# # RDF/XML container membership list element.
|
112
|
+
# # @return [RDF::Vocabulary::Term]
|
113
|
+
# # @attr_reader :li
|
114
|
+
#
|
115
|
+
# # The empty list, with no items in it. If the rest of a list is nil then the list has no more items in it.
|
116
|
+
# # @return [RDF::Vocabulary::Term]
|
117
|
+
# # @attr_reader :nil
|
118
|
+
#
|
119
|
+
# # RDF/XML Blank Node identifier.
|
120
|
+
# # @return [RDF::Vocabulary::Term]
|
121
|
+
# # @attr_reader :nodeID
|
122
|
+
#
|
123
|
+
# # Parse type for RDF/XML, either Collection, Literal or Resource.
|
124
|
+
# # @return [RDF::Vocabulary::Term]
|
125
|
+
# # @attr_reader :parseType
|
126
|
+
#
|
127
|
+
# # RDF/XML attribute declaring object.
|
128
|
+
# # @return [RDF::Vocabulary::Term]
|
129
|
+
# # @attr_reader :resource
|
9
130
|
# end
|
10
|
-
|
131
|
+
RDFV = Class.new(RDF::StrictVocabulary("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) do
|
11
132
|
|
12
133
|
class << self
|
13
134
|
def name; "RDF"; end
|
@@ -33,6 +154,12 @@ module RDF
|
|
33
154
|
isDefinedBy: %(rdf:).freeze,
|
34
155
|
subClassOf: "rdfs:Container".freeze,
|
35
156
|
type: "rdfs:Class".freeze
|
157
|
+
term :CompoundLiteral,
|
158
|
+
comment: %(A class representing a compound literal.).freeze,
|
159
|
+
label: "CompoundLiteral".freeze,
|
160
|
+
isDefinedBy: %(http://www.w3.org/1999/02/22-rdf-syntax-ns#).freeze,
|
161
|
+
subClassOf: "rdfs:Class".freeze,
|
162
|
+
type: "rdfs:Class".freeze
|
36
163
|
term :List,
|
37
164
|
comment: %(The class of RDF Lists.).freeze,
|
38
165
|
label: "List".freeze,
|
@@ -59,6 +186,13 @@ module RDF
|
|
59
186
|
type: "rdfs:Class".freeze
|
60
187
|
|
61
188
|
# Property definitions
|
189
|
+
property :direction,
|
190
|
+
comment: %(The direction component of a CompoundLiteral.).freeze,
|
191
|
+
domain: "rdf:CompoundLiteral".freeze,
|
192
|
+
label: "direction".freeze,
|
193
|
+
range: "rdfs:Resource".freeze,
|
194
|
+
isDefinedBy: %(http://www.w3.org/1999/02/22-rdf-syntax-ns#).freeze,
|
195
|
+
type: "rdf:Property".freeze
|
62
196
|
property :first,
|
63
197
|
comment: %(The first item in the subject RDF list.).freeze,
|
64
198
|
domain: "rdf:List".freeze,
|
@@ -73,6 +207,13 @@ module RDF
|
|
73
207
|
range: "rdfs:Resource".freeze,
|
74
208
|
isDefinedBy: %(rdf:).freeze,
|
75
209
|
type: "rdf:Property".freeze
|
210
|
+
property :language,
|
211
|
+
comment: %(The language component of a CompoundLiteral.).freeze,
|
212
|
+
domain: "rdf:CompoundLiteral".freeze,
|
213
|
+
label: "language".freeze,
|
214
|
+
range: "rdfs:Resource".freeze,
|
215
|
+
isDefinedBy: %(http://www.w3.org/1999/02/22-rdf-syntax-ns#).freeze,
|
216
|
+
type: "rdf:Property".freeze
|
76
217
|
property :predicate,
|
77
218
|
comment: %(The predicate of the subject RDF statement.).freeze,
|
78
219
|
domain: "rdf:Statement".freeze,
|
@@ -117,6 +258,11 @@ module RDF
|
|
117
258
|
"rdfs:seeAlso": %(http://www.w3.org/TR/rdf11-concepts/#section-html).freeze,
|
118
259
|
subClassOf: "rdfs:Literal".freeze,
|
119
260
|
type: "rdfs:Datatype".freeze
|
261
|
+
property :JSON,
|
262
|
+
comment: %(The datatype of RDF literals storing JSON content.).freeze,
|
263
|
+
label: "JSON".freeze,
|
264
|
+
isDefinedBy: %(http://www.w3.org/1999/02/22-rdf-syntax-ns#).freeze,
|
265
|
+
type: "rdfs:Datatype".freeze
|
120
266
|
term :PlainLiteral,
|
121
267
|
comment: %(The class of plain \(i.e. untyped\) literal values, as used in RIF and OWL 2).freeze,
|
122
268
|
label: "PlainLiteral".freeze,
|
data/lib/rdf/vocab/writer.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rdf'
|
2
2
|
require 'rdf/vocabulary'
|
3
|
+
require 'cgi'
|
3
4
|
|
4
5
|
module RDF
|
5
6
|
##
|
@@ -84,7 +85,7 @@ module RDF
|
|
84
85
|
on: ["--extra URIEncodedJSON"],
|
85
86
|
description: "URI Encoded JSON representation of extra data"
|
86
87
|
) do |arg|
|
87
|
-
::JSON.parse(::
|
88
|
+
::JSON.parse(::CGI.unescape(arg)).inject({}) do |m1, (term, defs)|
|
88
89
|
d1 = defs.inject({}) {|m, (k,v)| m.merge(k.to_sym => v)}
|
89
90
|
m1.merge(term.to_sym => d1)
|
90
91
|
end
|
@@ -145,11 +146,29 @@ module RDF
|
|
145
146
|
module #{module_name}
|
146
147
|
# @!parse
|
147
148
|
# # Vocabulary for <#{base_uri}>
|
148
|
-
#
|
149
|
-
# end
|
150
|
-
class #{class_name} < RDF::#{"Strict" if strict}Vocabulary("#{base_uri}")
|
149
|
+
# #
|
151
150
|
).gsub(/^ /, '')
|
152
151
|
|
152
|
+
if vocab.ontology
|
153
|
+
ont_doc = []
|
154
|
+
[:"dc:title", :"dc11:title", :label, :comment, :"dc:description", :"dc11:description"].each do |attr|
|
155
|
+
next unless vocab.ontology.attributes[attr]
|
156
|
+
Array(vocab.ontology.attributes[attr]).each do |v|
|
157
|
+
ont_doc << " # # " + v.to_s.gsub(/\n/, ' ')
|
158
|
+
end
|
159
|
+
end
|
160
|
+
@output.puts ont_doc.join("\n # #\n") unless ont_doc.empty?
|
161
|
+
# Version Info
|
162
|
+
Array(vocab.ontology.attributes[:"owl:versionInfo"]).each do |vers|
|
163
|
+
@output.puts " # # @version #{vers}"
|
164
|
+
end
|
165
|
+
# See Also
|
166
|
+
Array(vocab.ontology.attributes[:"rdfs:seeAlso"]).each do |see|
|
167
|
+
@output.puts " # # @see #{see}"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
@output.puts %( # class #{class_name} < RDF::#{"Strict" if strict}Vocabulary)
|
171
|
+
|
153
172
|
# Split nodes into Class/Property/Datatype/Other
|
154
173
|
term_nodes = {
|
155
174
|
ontology: {},
|
@@ -181,6 +200,26 @@ module RDF
|
|
181
200
|
term_nodes[kind][name] = term.attributes
|
182
201
|
end
|
183
202
|
|
203
|
+
# Yard attribute information for terms
|
204
|
+
term_nodes.each do |tt, ttv|
|
205
|
+
next if tt == :ontology
|
206
|
+
ttv.each do |name, attributes|
|
207
|
+
# Only document terms that can be accessed like a Ruby attribute
|
208
|
+
next unless name.to_s.match?(/^[_[:alpha:]](?:\w*)[!?=]?$/)
|
209
|
+
@output.puts(Array(attributes[:comment]).map do |comment|
|
210
|
+
" # # #{comment.to_s.gsub(/\n/, ' ')}"
|
211
|
+
end.join("\n # #\n")) if attributes[:comment]
|
212
|
+
@output.puts " # # @return [RDF::Vocabulary::Term]"
|
213
|
+
@output.puts " # attr_reader :#{name}"
|
214
|
+
@output.puts " #"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# End of yard preamble
|
219
|
+
@output.puts " # end"
|
220
|
+
@output.puts %( #{class_name} = Class.new(RDF::#{"Strict" if strict}Vocabulary("#{base_uri}")) do)
|
221
|
+
|
222
|
+
# Output term definitions
|
184
223
|
{
|
185
224
|
ontology: "Ontology definition",
|
186
225
|
class: "Class definitions",
|