rdf 3.2.3 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -37
- data/VERSION +1 -1
- data/lib/rdf/mixin/countable.rb +5 -1
- data/lib/rdf/mixin/enumerable.rb +13 -1
- data/lib/rdf/mixin/queryable.rb +13 -1
- data/lib/rdf/model/list.rb +1 -1
- data/lib/rdf/model/literal/date.rb +27 -82
- data/lib/rdf/model/literal/datetime.rb +22 -122
- data/lib/rdf/model/literal/decimal.rb +12 -0
- data/lib/rdf/model/literal/double.rb +20 -0
- data/lib/rdf/model/literal/integer.rb +6 -0
- data/lib/rdf/model/literal/numeric.rb +154 -4
- data/lib/rdf/model/literal/temporal.rb +310 -0
- data/lib/rdf/model/literal/time.rb +29 -98
- data/lib/rdf/model/literal.rb +2 -1
- data/lib/rdf/model/statement.rb +3 -1
- data/lib/rdf/model/uri.rb +3 -2
- data/lib/rdf/ntriples/reader.rb +1 -1
- data/lib/rdf/query/solution.rb +1 -2
- data/lib/rdf/query/solutions.rb +21 -0
- data/lib/rdf/vocab/owl.rb +450 -445
- data/lib/rdf/vocab/rdfs.rb +89 -88
- data/lib/rdf/vocab/writer.rb +84 -51
- data/lib/rdf/vocab/xsd.rb +249 -249
- data/lib/rdf/vocabulary.rb +109 -124
- data/lib/rdf.rb +0 -3
- metadata +11 -5
- data/lib/rdf/mixin/enumerator.rb +0 -40
data/lib/rdf/vocabulary.rb
CHANGED
@@ -5,7 +5,14 @@ module RDF
|
|
5
5
|
# A {Vocabulary} can also serve as a Domain Specific Language (DSL) for generating an RDF Graph definition for the vocabulary (see {RDF::Vocabulary#to_enum}).
|
6
6
|
#
|
7
7
|
# ### Defining a vocabulary using the DSL
|
8
|
-
# Vocabularies can be defined based on {RDF::Vocabulary} or {RDF::StrictVocabulary} using a simple Domain Specific Language (DSL).
|
8
|
+
# Vocabularies can be defined based on {RDF::Vocabulary} or {RDF::StrictVocabulary} using a simple Domain Specific Language (DSL).
|
9
|
+
#
|
10
|
+
# * Ontology information for the vocabulary itself can be specified using the {ontology} method.
|
11
|
+
# * Terms of the vocabulary are specified using either `property` or `term` (alias), with the attributes of the term listed in a hash. See {property} for description of the hash. Term attributes become properties of the associated {RDF::Vocabulary::Term} (see {RDF::Vocabulary::Term#attributes}).
|
12
|
+
#
|
13
|
+
# Note that, by default, the prefix associated with the vocabulary for forming and interpreting PNames is created from the class name of the vocabulary. See {\_\_prefix\_\_=} for overriding this at runtime.
|
14
|
+
#
|
15
|
+
# The simplest way to generate a DSL representation of a vocabulary is using {RDF::Vocabulary::Writer} given an {RDF::Graph} representation of the vocabulary.
|
9
16
|
#
|
10
17
|
# ### Vocabularies:
|
11
18
|
#
|
@@ -31,6 +38,31 @@ module RDF
|
|
31
38
|
# foaf.knows #=> RDF::URI("http://xmlns.com/foaf/0.1/knows")
|
32
39
|
# foaf[:name] #=> RDF::URI("http://xmlns.com/foaf/0.1/name")
|
33
40
|
# foaf['mbox'] #=> RDF::URI("http://xmlns.com/foaf/0.1/mbox")
|
41
|
+
#
|
42
|
+
# @example Defining a simple vocabulary
|
43
|
+
# EX = Class.new(RDF::StrictVocabulay("http://example/ns#")) do
|
44
|
+
# # Ontology definition
|
45
|
+
# ontology :"http://example/ns#",
|
46
|
+
# label: "The RDF Example Vocablary",
|
47
|
+
# type: "http://www.w3.org/2002/07/owl#Ontology"
|
48
|
+
#
|
49
|
+
# # Class definitions
|
50
|
+
# term :Class,
|
51
|
+
# label: "My Class",
|
52
|
+
# comment: "Good to use as an example",
|
53
|
+
# type: "rdfs:Class",
|
54
|
+
# subClassOf: "http://example/SuperClass",
|
55
|
+
# "ex:prop": "Some annotation property not having a shortcut"
|
56
|
+
#
|
57
|
+
# # Property definitions
|
58
|
+
# property :prop,
|
59
|
+
# comment: "A description of the property",
|
60
|
+
# label: "property",
|
61
|
+
# domain: "http://example/ns#Class",
|
62
|
+
# range: "rdfs:Literal",
|
63
|
+
# isDefinedBy: %(ex:),
|
64
|
+
# type: "rdf:Property"
|
65
|
+
# end
|
34
66
|
#
|
35
67
|
# @example Method calls are converted to the typical RDF camelcase convention
|
36
68
|
# foaf = RDF::Vocabulary.new("http://xmlns.com/foaf/0.1/")
|
@@ -44,15 +76,6 @@ module RDF
|
|
44
76
|
# graph = RDF::Graph.new << RDF::RDFS.to_enum
|
45
77
|
# graph.dump(:ntriples)
|
46
78
|
#
|
47
|
-
# @example Defining a simple vocabulary
|
48
|
-
# class EX < RDF::StrictVocabulay("http://example/ns#")
|
49
|
-
# term :Class,
|
50
|
-
# label: "My Class",
|
51
|
-
# comment: "Good to use as an example",
|
52
|
-
# "rdf:type" => "rdfs:Class",
|
53
|
-
# "rdfs:subClassOf" => "http://example/SuperClass"
|
54
|
-
# end
|
55
|
-
#
|
56
79
|
# @see https://www.w3.org/TR/rdf-sparql-query/#prefNames
|
57
80
|
class Vocabulary
|
58
81
|
extend ::Enumerable
|
@@ -176,16 +199,28 @@ module RDF
|
|
176
199
|
# @return [RDF::Vocabulary::Term]
|
177
200
|
#
|
178
201
|
# @overload property(name, options)
|
179
|
-
# Defines a new property or class in the vocabulary.
|
202
|
+
# Defines a new property or class in the vocabulary as a {RDF::Vocabulary::Term}.
|
180
203
|
#
|
181
204
|
# @example A simple term definition
|
182
205
|
# property :domain,
|
183
|
-
# comment: %(A domain of the subject property.)
|
184
|
-
# domain: "rdf:Property"
|
185
|
-
# label: "domain"
|
186
|
-
# range: "rdfs:Class"
|
187
|
-
# isDefinedBy: %(rdfs:)
|
188
|
-
# type: "rdf:Property"
|
206
|
+
# comment: %(A domain of the subject property.),
|
207
|
+
# domain: "rdf:Property",
|
208
|
+
# label: "domain",
|
209
|
+
# range: "rdfs:Class",
|
210
|
+
# isDefinedBy: %(rdfs:),
|
211
|
+
# type: "rdf:Property"
|
212
|
+
#
|
213
|
+
# @example A term definition with tagged values
|
214
|
+
# property :actor,
|
215
|
+
# comment: {en: "Subproperty of as:attributedTo that identifies the primary actor"},
|
216
|
+
# domain: "https://www.w3.org/ns/activitystreams#Activity",
|
217
|
+
# label: {en: "actor"},
|
218
|
+
# range: term(
|
219
|
+
# type: "http://www.w3.org/2002/07/owl#Class",
|
220
|
+
# unionOf: list("https://www.w3.org/ns/activitystreams#Object", "https://www.w3.org/ns/activitystreams#Link")
|
221
|
+
# ),
|
222
|
+
# subPropertyOf: "https://www.w3.org/ns/activitystreams#attributedTo",
|
223
|
+
# type: "http://www.w3.org/2002/07/owl#ObjectProperty"
|
189
224
|
#
|
190
225
|
# @example A SKOS term with anonymous values
|
191
226
|
# term: :af,
|
@@ -204,76 +239,8 @@ module RDF
|
|
204
239
|
# "foaf:name": "Aland Islands"
|
205
240
|
#
|
206
241
|
# @param [String, #to_s] name
|
207
|
-
# @param [Hash{Symbol=>String,Array<String
|
208
|
-
# Any other values are expected to expands to a {URI} using built-in vocabulary prefixes. The value is a `String`,
|
209
|
-
# @option options [String, Array<String,Term>] :type
|
210
|
-
# Shortcut for `rdf:type`, values are interpreted as a {Term}.
|
211
|
-
# @option options [String, Array<String>] :comment
|
212
|
-
# Shortcut for `rdfs:comment`, values are interpreted as a {Literal}.
|
213
|
-
# @option options [String, Array<String,Term>] :domain
|
214
|
-
# Shortcut for `rdfs:domain`, values are interpreted as a {Term}.
|
215
|
-
# @option options [String, Array<String,Term>] :isDefinedBy
|
216
|
-
# Shortcut for `rdfs:isDefinedBy`, values are interpreted as a {Term}.
|
217
|
-
# @option options [String, Array<String>] :label
|
218
|
-
# Shortcut for `rdfs:label`, values are interpreted as a {Literal}.
|
219
|
-
# @option options [String, Array<String,Term>] :range
|
220
|
-
# Shortcut for `rdfs:range`, values are interpreted as a {Term}.
|
221
|
-
# @option options [String, Array<String,Term>] :subClassOf
|
222
|
-
# Shortcut for `rdfs:subClassOf`, values are interpreted as a {Term}.
|
223
|
-
# @option options [String, Array<String,Term>] :subPropertyOf
|
224
|
-
# Shortcut for `rdfs:subPropertyOf`, values are interpreted as a {Term}.
|
225
|
-
# @option options [String, Array<String,Term>] :allValuesFrom
|
226
|
-
# Shortcut for `owl:allValuesFrom`, values are interpreted as a {Term}.
|
227
|
-
# @option options [String, Array<String,Term>] :cardinality
|
228
|
-
# Shortcut for `owl:cardinality`, values are interpreted as a {Literal}.
|
229
|
-
# @option options [String, Array<String,Term>] :equivalentClass
|
230
|
-
# Shortcut for `owl:equivalentClass`, values are interpreted as a {Term}.
|
231
|
-
# @option options [String, Array<String,Term>] :equivalentProperty
|
232
|
-
# Shortcut for `owl:equivalentProperty`, values are interpreted as a {Term}.
|
233
|
-
# @option options [String, Array<String,Term>] :intersectionOf
|
234
|
-
# Shortcut for `owl:intersectionOf`, values are interpreted as a {Term}.
|
235
|
-
# @option options [String, Array<String,Term>] :inverseOf
|
236
|
-
# Shortcut for `owl:inverseOf`, values are interpreted as a {Term}.
|
237
|
-
# @option options [String, Array<String,Term>] :maxCardinality
|
238
|
-
# Shortcut for `owl:maxCardinality`, values are interpreted as a {Literal}.
|
239
|
-
# @option options [String, Array<String,Term>] :minCardinality
|
240
|
-
# Shortcut for `owl:minCardinality`, values are interpreted as a {Literal}.
|
241
|
-
# @option options [String, Array<String,Term>] :onProperty
|
242
|
-
# Shortcut for `owl:onProperty`, values are interpreted as a {Term}.
|
243
|
-
# @option options [String, Array<String,Term>] :someValuesFrom
|
244
|
-
# Shortcut for `owl:someValuesFrom`, values are interpreted as a {Term}.
|
245
|
-
# @option options [String, Array<String,Term>] :unionOf
|
246
|
-
# Shortcut for `owl:unionOf`, values are interpreted as a {Term}.
|
247
|
-
# @option options [String, Array<String,Term>] :domainIncludes
|
248
|
-
# Shortcut for `schema:domainIncludes`, values are interpreted as a {Term}.
|
249
|
-
# @option options [String, Array<String,Term>] :rangeIncludes
|
250
|
-
# Shortcut for `schema:rangeIncludes`, values are interpreted as a {Term}.
|
251
|
-
# @option options [String, Array<String>] :altLabel
|
252
|
-
# Shortcut for `skos:altLabel`, values are interpreted as a {Literal}.
|
253
|
-
# @option options [String, Array<String,Term>] :broader
|
254
|
-
# Shortcut for `skos:broader`, values are interpreted as a {Term}.
|
255
|
-
# @option options [String, Array<String>] :definition
|
256
|
-
# Shortcut for `skos:definition`, values are interpreted as a {Literal}.
|
257
|
-
# @option options [String, Array<String>] :editorialNote
|
258
|
-
# Shortcut for `skos:editorialNote`, values are interpreted as a {Literal}.
|
259
|
-
# @option options [String, Array<String,Term>] :exactMatch
|
260
|
-
# Shortcut for `skos:exactMatch`, values are interpreted as a {Term}.
|
261
|
-
# @option options [String, Array<String,Term>] :hasTopConcept
|
262
|
-
# Shortcut for `skos:hasTopConcept`, values are interpreted as a {Term}.
|
263
|
-
# @option options [String, Array<String,Term>] :inScheme
|
264
|
-
# Shortcut for `skos:inScheme`, values are interpreted as a {Term}.
|
265
|
-
# @option options [String, Array<String,Term>] :member
|
266
|
-
# Shortcut for `skos:member`, values are interpreted as a {Term}.
|
267
|
-
# @option options [String, Array<String,Term>] :narrower
|
268
|
-
# Shortcut for `skos:narrower`, values are interpreted as a {Term}.
|
269
|
-
# @option options [String, Array<String>] :notation
|
270
|
-
# Shortcut for `skos:notation`, values are interpreted as a {Literal}.
|
271
|
-
# @option options [String, Array<String>] :note
|
272
|
-
# Shortcut for `skos:note`, values are interpreted as a {Literal}.
|
273
|
-
# @option options [String, Array<String>] :prefLabel
|
274
|
-
# Shortcut for `skos:prefLabel`, values are interpreted as a {Literal}.
|
275
|
-
# @option options [String, Array<String,Term>] :related
|
276
|
-
# Shortcut for `skos:related`, values are interpreted as a {Term}.
|
242
|
+
# @param [Hash{Symbol=>String,Array<String>}] options
|
243
|
+
# Any other values are expected to expands to a {URI} using built-in vocabulary prefixes. The value is a `String`, 'Hash{Symbol=>String,Array<String>}' or `Array<String,Hash{Symbol=>Array<String>}>` which is interpreted according to the `range` of the associated property and by heuristically determining the value datatype. See `attributes` argument to {Term#initialize}.
|
277
244
|
# @return [RDF::Vocabulary::Term]
|
278
245
|
def property(*args)
|
279
246
|
case args.length
|
@@ -286,15 +253,6 @@ module RDF
|
|
286
253
|
uri_str = [to_s, name.to_s].join('')
|
287
254
|
URI.cache.delete(uri_str.to_sym) # Clear any previous entry
|
288
255
|
|
289
|
-
# Transform attribute keys that are PNames with a warning
|
290
|
-
# FIXME: add back later
|
291
|
-
#if !@is_deprecated && options.is_a?(Hash) &&
|
292
|
-
# options.keys.map(&:to_s).any? {|k| k.include?(':') && !k.match?(/^https?:/)}
|
293
|
-
#
|
294
|
-
# @is_deprecated = true
|
295
|
-
# warn "[DEPRECATION] Vocabulary #{to_uri} includes pname attribute keys, regenerate"
|
296
|
-
#end
|
297
|
-
|
298
256
|
# Term attributes passed in a block for lazy evaluation. This helps to avoid load-time circular dependencies
|
299
257
|
prop = Term.intern(uri_str, vocab: self, attributes: options || {})
|
300
258
|
props[name.to_sym] = prop
|
@@ -389,7 +347,7 @@ module RDF
|
|
389
347
|
return pname unless pname.is_a?(String) || pname.is_a?(Symbol)
|
390
348
|
prefix, suffix = pname.to_s.split(":", 2)
|
391
349
|
# Unescape escaped PN_ESCAPE_CHARS
|
392
|
-
if suffix.match?(
|
350
|
+
if suffix.match?(RDF::URI::PN_ESCAPES)
|
393
351
|
suffix = suffix.gsub(RDF::URI::PN_ESCAPES) {|matched| matched[1..-1]}
|
394
352
|
end
|
395
353
|
if prefix == "rdf"
|
@@ -563,10 +521,6 @@ module RDF
|
|
563
521
|
statement.predicate.to_s.to_sym
|
564
522
|
end
|
565
523
|
|
566
|
-
# Skip literals other than plain or english
|
567
|
-
# This is because the ruby representation does not preserve language
|
568
|
-
next if statement.object.literal? && (statement.object.language || :en).to_s !~ /^en-?/
|
569
|
-
|
570
524
|
(term[key] ||= []) << statement.object
|
571
525
|
end
|
572
526
|
|
@@ -580,7 +534,6 @@ module RDF
|
|
580
534
|
term_defs
|
581
535
|
end
|
582
536
|
|
583
|
-
#require 'byebug'; byebug
|
584
537
|
# Pass over embedded_defs with anonymous references, once
|
585
538
|
embedded_defs.each do |term, attributes|
|
586
539
|
attributes.each do |ak, avs|
|
@@ -963,6 +916,10 @@ module RDF
|
|
963
916
|
#
|
964
917
|
# Symbols which are accessors may also be looked up by their associated URI.
|
965
918
|
#
|
919
|
+
# Values may be Strings, Hash (Map), or Terms, or an Array including a combination of these. A Hash (Map) is used to create a datatype/language map to one or more string values which represent either datatyped literals, or language-tagged literals as interpreted by {#attribute_value}.
|
920
|
+
#
|
921
|
+
# In general, this accessor is used internally. The {#properties} method interprets these values as {RDF::Value}.
|
922
|
+
#
|
966
923
|
# @note lookup by PName is DEPRECATED and will be removed in a future version.
|
967
924
|
#
|
968
925
|
# @example looking up term label
|
@@ -971,23 +928,23 @@ module RDF
|
|
971
928
|
# RDF::RDFS.Literal.attributes[RDF::RDFS.label] #=> "Literal"
|
972
929
|
# RDF::RDFS.Literal.attributes["http://www.w3.org/2000/01/rdf-schema#label"] #=> "Literal"
|
973
930
|
# RDF::RDFS.Literal.attributes[:"http://www.w3.org/2000/01/rdf-schema#label"] #=> "Literal"
|
974
|
-
# @return [Hash{Symbol,
|
931
|
+
# @return [Hash{Symbol => String, Term, Hash{Symbol => String}, Array<String, Term, Hash{Symbol => String}>}]
|
932
|
+
# @see #properties
|
975
933
|
attr_reader :attributes
|
976
934
|
|
977
935
|
##
|
978
|
-
# @overload new(uri, attributes:, **options)
|
936
|
+
# @overload new(uri, attributes:, vocab:, **options)
|
979
937
|
# @param [URI, String, #to_s] uri
|
980
938
|
# @param [Vocabulary] vocab Vocabulary of this term.
|
981
|
-
# @param [Hash{Symbol => Symbol,Array<String,
|
939
|
+
# @param [Hash{Symbol => String,Term,Hash{Symbol=>String,Array<String>},Array<String>}] attributes ({})
|
982
940
|
# Attributes of this vocabulary term, used for finding `label` and `comment` and to serialize the term back to RDF. See {#attributes} and {#properties} for other ways to access.
|
983
941
|
# @param [Hash{Symbol => Object}] options
|
984
942
|
# Options from {URI#initialize}
|
985
943
|
#
|
986
|
-
# @overload new(attributes:, **options)
|
987
|
-
# @param [Hash{Symbol => Object}] options
|
944
|
+
# @overload new(attributes:, vocab:, **options)
|
988
945
|
# @param [Vocabulary] vocab Vocabulary of this term.
|
989
|
-
# @param [Hash{Symbol => Symbol,Array<String,
|
990
|
-
# Attributes of this vocabulary term, used for finding `label` and
|
946
|
+
# @param [Hash{Symbol => String,Term,Hash{Symbol=>String,Array<String>},Array<String>}] attributes ({})
|
947
|
+
# Attributes of this vocabulary term, used for finding `label`, `comment` and other term properties, and to serialize the term back to RDF. See {#attributes} and {#properties} for other ways to access.
|
991
948
|
# @param [Hash{Symbol => Object}] options
|
992
949
|
# Options from {URI#initialize}
|
993
950
|
def self.new(*args, vocab: nil, attributes: {}, **options)
|
@@ -1110,7 +1067,7 @@ module RDF
|
|
1110
1067
|
|
1111
1068
|
##
|
1112
1069
|
# Enumerate attributes with values transformed into {RDF::Value} instances
|
1113
|
-
# Uses an empty hash with a default_proc which looks up values in attributes.
|
1070
|
+
# Uses an empty hash with a default_proc which looks up values in attributes. The prevents specific attributes from being evaluated until acessed.
|
1114
1071
|
#
|
1115
1072
|
# Properties are indexed by symbol. Symbols directly interpreted by a term are the accessors defined for the {RDF::Vocabulary::Term} class, also in {Term::ATTR_URIs}. Other keys are interpreted as absolute URIs or PNames for properties defined on this term.
|
1116
1073
|
#
|
@@ -1127,12 +1084,27 @@ module RDF
|
|
1127
1084
|
# RDF::RDFS.Literal.properties[:"http://www.w3.org/2000/01/rdf-schema#label"] #=> RDF::Literal("Literal")
|
1128
1085
|
#
|
1129
1086
|
# @return [Hash{Symbol => Array<RDF::Value>}]
|
1087
|
+
# @see #attribute_value
|
1130
1088
|
def properties
|
1131
1089
|
Hash.new {|hash, key| attribute_value(key)}
|
1132
1090
|
end
|
1133
1091
|
|
1134
1092
|
##
|
1135
|
-
# Values of an attributes as {RDF::Value}
|
1093
|
+
# Values of an attributes as {RDF::Value}.
|
1094
|
+
#
|
1095
|
+
# Attribute values are returned as either an {RDF::Value} or {Array<RDf::Value} if there is more than one value.
|
1096
|
+
#
|
1097
|
+
# Attribute values which are not already a {RDF::Value} (including strings and symbols) are converted by a heuristic loookup as follows:
|
1098
|
+
#
|
1099
|
+
# * An {RDF::URI} if it can be turned into a valid IRI using {RDF::Vocabulary.expand_pname}. This includes IRIs already in non-relative form.
|
1100
|
+
# * A {Hash{Symbol=>String,Array<String>}} is interpreted as a datatype/language map. If the key contains a ':', it is treated as a PName or IRI datatype applied to the values. Otherwise, it is treated as a language-tag applied to the values.
|
1101
|
+
# * {RDF::Literal::Date} if valid,
|
1102
|
+
# * {RDF::Literal::DateTime} if valid,
|
1103
|
+
# * {RDF::Literal::Integer} if valid,
|
1104
|
+
# * {RDF::Literal::Decimal} if valid,
|
1105
|
+
# * {RDF::Literal::Double} if valid,
|
1106
|
+
# * {RDF::Literal::Boolean} if valid
|
1107
|
+
# * Otherwise, {RDF::Literal} where type may be inferred by the class of the value.
|
1136
1108
|
#
|
1137
1109
|
# @param [Symbol] prop
|
1138
1110
|
# @return [RDF::Value, Array<RDF::Value>]
|
@@ -1144,9 +1116,22 @@ module RDF
|
|
1144
1116
|
v = value.is_a?(Symbol) ? value.to_s : value
|
1145
1117
|
value = (RDF::Vocabulary.expand_pname(v) rescue nil) if v.is_a?(String) && v.include?(':')
|
1146
1118
|
value = value.to_uri if value.respond_to?(:to_uri)
|
1147
|
-
|
1119
|
+
value = if value.is_a?(RDF::Value) && value.valid?
|
1120
|
+
value
|
1121
|
+
elsif value.is_a?(Hash)
|
1122
|
+
# type/language map
|
1123
|
+
value.inject([]) do |memo, (k,v)|
|
1124
|
+
vv = [v] unless v.is_a?(Array)
|
1125
|
+
memo << if k.to_s.include?(':')
|
1126
|
+
dt = RDF::Vocabulary.expand_pname(v) rescue nil
|
1127
|
+
vv.map {|val| RDF::Literal(val, datatype: dt)}
|
1128
|
+
else
|
1129
|
+
vv.map {|val| RDF::Literal(val, language: k)}
|
1130
|
+
end
|
1131
|
+
end.flatten.compact.select(&:valid?)
|
1132
|
+
else
|
1148
1133
|
# Use as most appropriate literal
|
1149
|
-
|
1134
|
+
[
|
1150
1135
|
RDF::Literal::Date,
|
1151
1136
|
RDF::Literal::DateTime,
|
1152
1137
|
RDF::Literal::Integer,
|
@@ -1161,9 +1146,7 @@ module RDF
|
|
1161
1146
|
end
|
1162
1147
|
end
|
1163
1148
|
end
|
1164
|
-
|
1165
|
-
value
|
1166
|
-
end
|
1149
|
+
end.flatten
|
1167
1150
|
|
1168
1151
|
prop_values.length <= 1 ? prop_values.first : prop_values
|
1169
1152
|
end
|
@@ -1247,7 +1230,9 @@ module RDF
|
|
1247
1230
|
rangeIncludes
|
1248
1231
|
end
|
1249
1232
|
|
1250
|
-
|
1233
|
+
##
|
1234
|
+
# Serialize back to a Ruby source initializer. This is used primarily by {RDF::Vocabulary::Writer}.
|
1235
|
+
#
|
1251
1236
|
# @param [String] indent
|
1252
1237
|
# @return [String]
|
1253
1238
|
def to_ruby(indent: "")
|
@@ -1259,24 +1244,24 @@ module RDF
|
|
1259
1244
|
values = [values].compact unless values.is_a?(Array)
|
1260
1245
|
values = values.map do |value|
|
1261
1246
|
if value.is_a?(Literal) && %w(: comment definition notation note editorialNote).include?(k.to_s)
|
1262
|
-
"%(#{value.to_s.gsub('(', '\(').gsub(')', '\)')})
|
1247
|
+
"%(#{value.to_s.gsub('(', '\(').gsub(')', '\)')})"
|
1263
1248
|
elsif value.node? && value.is_a?(RDF::Vocabulary::Term)
|
1264
|
-
"#{value.to_ruby(indent: indent + " ")}
|
1249
|
+
"#{value.to_ruby(indent: indent + " ")}"
|
1265
1250
|
elsif value.is_a?(RDF::Term)
|
1266
|
-
"#{value.to_s.inspect}
|
1251
|
+
"#{value.to_s.inspect}"
|
1267
1252
|
elsif value.is_a?(RDF::List)
|
1268
1253
|
list_elements = value.map do |u|
|
1269
1254
|
if u.uri?
|
1270
|
-
"#{u.to_s.inspect}
|
1255
|
+
"#{u.to_s.inspect}"
|
1271
1256
|
elsif u.node? && u.respond_to?(:to_ruby)
|
1272
1257
|
u.to_ruby(indent: indent + " ")
|
1273
1258
|
else
|
1274
|
-
"#{u.to_s.inspect}
|
1259
|
+
"#{u.to_s.inspect}"
|
1275
1260
|
end
|
1276
1261
|
end
|
1277
1262
|
"list(#{list_elements.join(', ')})"
|
1278
1263
|
else
|
1279
|
-
"#{value.inspect}
|
1264
|
+
"#{value.inspect}"
|
1280
1265
|
end
|
1281
1266
|
end
|
1282
1267
|
"#{k.to_s.include?(':') ? k.to_s.inspect : k}: " +
|
@@ -1340,7 +1325,7 @@ module RDF
|
|
1340
1325
|
def [](name)
|
1341
1326
|
props.fetch(name.to_sym)
|
1342
1327
|
rescue KeyError
|
1343
|
-
raise KeyError, "#{name} not found in vocabulary #{self.__name__}"
|
1328
|
+
raise KeyError, "#{name.inspect} not found in vocabulary #{self.__name__}"
|
1344
1329
|
end
|
1345
1330
|
end
|
1346
1331
|
end # StrictVocabulary
|
data/lib/rdf.rb
CHANGED
@@ -7,9 +7,6 @@ require "ostruct"
|
|
7
7
|
require 'rdf/version'
|
8
8
|
require 'rdf/extensions'
|
9
9
|
|
10
|
-
# When loading, issue deprecation warning on forthcoming unsupported versions of Ruby
|
11
|
-
warn "[DEPRECATION] Ruby 2.4+ required in next version 3.1 of RDF.rb" if RUBY_VERSION < "2.4"
|
12
|
-
|
13
10
|
module RDF
|
14
11
|
# RDF mixins
|
15
12
|
autoload :Countable, 'rdf/mixin/countable'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arto Bendiken
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: link_header
|
@@ -81,6 +81,9 @@ dependencies:
|
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '3.2'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 3.2.1
|
84
87
|
type: :development
|
85
88
|
prerelease: false
|
86
89
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -88,6 +91,9 @@ dependencies:
|
|
88
91
|
- - "~>"
|
89
92
|
- !ruby/object:Gem::Version
|
90
93
|
version: '3.2'
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.2.1
|
91
97
|
- !ruby/object:Gem::Dependency
|
92
98
|
name: rest-client
|
93
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,7 +215,6 @@ files:
|
|
209
215
|
- lib/rdf/mixin/countable.rb
|
210
216
|
- lib/rdf/mixin/durable.rb
|
211
217
|
- lib/rdf/mixin/enumerable.rb
|
212
|
-
- lib/rdf/mixin/enumerator.rb
|
213
218
|
- lib/rdf/mixin/indexable.rb
|
214
219
|
- lib/rdf/mixin/mutable.rb
|
215
220
|
- lib/rdf/mixin/queryable.rb
|
@@ -228,6 +233,7 @@ files:
|
|
228
233
|
- lib/rdf/model/literal/double.rb
|
229
234
|
- lib/rdf/model/literal/integer.rb
|
230
235
|
- lib/rdf/model/literal/numeric.rb
|
236
|
+
- lib/rdf/model/literal/temporal.rb
|
231
237
|
- lib/rdf/model/literal/time.rb
|
232
238
|
- lib/rdf/model/literal/token.rb
|
233
239
|
- lib/rdf/model/node.rb
|
@@ -269,9 +275,9 @@ homepage: https://github.com/ruby-rdf/rdf
|
|
269
275
|
licenses:
|
270
276
|
- Unlicense
|
271
277
|
metadata:
|
272
|
-
documentation_uri: https://
|
278
|
+
documentation_uri: https://ruby-rdf.github.io/rdf
|
273
279
|
bug_tracker_uri: https://github.com/ruby-rdf/rdf/issues
|
274
|
-
homepage_uri: https://ruby-rdf
|
280
|
+
homepage_uri: https://github.com/ruby-rdf/rdf
|
275
281
|
mailing_list_uri: https://lists.w3.org/Archives/Public/public-rdf-ruby/
|
276
282
|
source_code_uri: https://github.com/ruby-rdf/rdf
|
277
283
|
post_install_message:
|
data/lib/rdf/mixin/enumerator.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
module RDF
|
2
|
-
##
|
3
|
-
# Enumerators for different mixins. These are defined in a separate module, so that they are bound when used, allowing other mixins inheriting behavior to be included.
|
4
|
-
module Enumerable
|
5
|
-
# Extends Enumerator with {Queryable} and {Enumerable}, which is used by {Enumerable#each_statement} and {Queryable#enum_for}
|
6
|
-
class Enumerator < ::Enumerator
|
7
|
-
include Queryable
|
8
|
-
include Enumerable
|
9
|
-
|
10
|
-
##
|
11
|
-
# @return [Array]
|
12
|
-
# @note Make sure returned arrays are also queryable
|
13
|
-
def to_a
|
14
|
-
return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module Countable
|
20
|
-
# Extends Enumerator with {Countable}, which is used by {Countable#enum_for}
|
21
|
-
class Enumerator < ::Enumerator
|
22
|
-
include Countable
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
module Queryable
|
27
|
-
# Extends Enumerator with {Queryable} and {Enumerable}, which is used by {Enumerable#each_statement} and {Queryable#enum_for}
|
28
|
-
class Enumerator < ::Enumerator
|
29
|
-
include Queryable
|
30
|
-
include Enumerable
|
31
|
-
|
32
|
-
##
|
33
|
-
# @return [Array]
|
34
|
-
# @note Make sure returned arrays are also queryable
|
35
|
-
def to_a
|
36
|
-
return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|