rdf 3.3.1 → 3.3.3
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/README.md +23 -6
- data/VERSION +1 -1
- data/lib/rdf/mixin/enumerable.rb +2 -1
- data/lib/rdf/mixin/queryable.rb +2 -0
- data/lib/rdf/mixin/writable.rb +3 -2
- data/lib/rdf/model/dataset.rb +2 -1
- data/lib/rdf/model/graph.rb +34 -3
- data/lib/rdf/model/literal/date.rb +1 -3
- data/lib/rdf/model/literal/decimal.rb +2 -2
- data/lib/rdf/model/literal/double.rb +2 -2
- data/lib/rdf/model/literal.rb +11 -1
- data/lib/rdf/model/statement.rb +12 -3
- data/lib/rdf/model/uri.rb +45 -23
- data/lib/rdf/model/value.rb +5 -4
- data/lib/rdf/nquads.rb +2 -1
- data/lib/rdf/ntriples/reader.rb +42 -32
- data/lib/rdf/ntriples/writer.rb +13 -0
- data/lib/rdf/ntriples.rb +5 -1
- data/lib/rdf/query/pattern.rb +2 -2
- data/lib/rdf/query/variable.rb +2 -0
- data/lib/rdf/query.rb +6 -9
- data/lib/rdf/reader.rb +1 -1
- data/lib/rdf/repository.rb +4 -1
- data/lib/rdf/util/file.rb +10 -1
- data/lib/rdf/vocab/rdfv.rb +10 -0
- data/lib/rdf/writer.rb +20 -3
- metadata +71 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 061dd8c1cc1312a0637faec70a4aff5c8f6872e333c225563cd0f426e46b1021
|
4
|
+
data.tar.gz: 1abd0cfb43de3db148b5930165c0fdf494e1313c577a14b93d8385def05885d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 272d88f2911164ecc3a2fa71f485e4f6f789252b9f7f5d2c5b222e60dd65ebf5acf0843de3c68910e6e795ebe3003eca2f956ca309eff8afae13694fe5de94a5
|
7
|
+
data.tar.gz: 385f3ff6159082e189d8cfb47bfe4c77243e7c5c18558e5d7a3cd5701d75cebab29f250d7ba28c1f4d7ba5e6564a51236ca367a832534d666c7fc4a4a831bb8a
|
data/README.md
CHANGED
@@ -265,28 +265,39 @@ A separate [SPARQL][SPARQL doc] gem builds on basic BGP support to provide full
|
|
265
265
|
foaf[:name] #=> RDF::URI("http://xmlns.com/foaf/0.1/name")
|
266
266
|
foaf['mbox'] #=> RDF::URI("http://xmlns.com/foaf/0.1/mbox")
|
267
267
|
|
268
|
+
## RDF-star CG
|
269
|
+
|
270
|
+
[RDF.rb][] includes provisional support for [RDF-star][] with an N-Triples/N-Quads syntax for quoted triples in the _subject_ or _object_ position.
|
271
|
+
|
272
|
+
Support for RDF-star quoted triples is now deprecated, use RDF 1.2 triple terms instead.
|
273
|
+
|
268
274
|
## RDF 1.2
|
269
275
|
|
270
|
-
[RDF.rb][] includes provisional support for [RDF 1.2][] with an N-Triples/N-Quads syntax for
|
276
|
+
[RDF.rb][] includes provisional support for [RDF 1.2][] with an N-Triples/N-Quads syntax for triple terms in the _object_ position.
|
271
277
|
[RDF.rb][] includes provisional support for [RDF 1.2][] directional language-tagged strings, which are literals of type `rdf:dirLangString` having both a `language` and `direction`.
|
272
278
|
|
273
279
|
Internally, an `RDF::Statement` is treated as another resource, along with `RDF::URI` and `RDF::Node`, which allows an `RDF::Statement` to have a `#subject` or `#object` which is also an `RDF::Statement`.
|
274
280
|
|
275
281
|
**Note: This feature is subject to change or elimination as the standards process progresses.**
|
276
282
|
|
277
|
-
### Serializing a Graph containing
|
283
|
+
### Serializing a Graph containing triple terms
|
278
284
|
|
279
285
|
require 'rdf/ntriples'
|
280
286
|
statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
|
281
|
-
|
287
|
+
reifier = RDF::Node.new
|
288
|
+
graph = RDF::Graph.new do |g|
|
289
|
+
g << [reifier, RDF.reifies, statement]
|
290
|
+
g << [reifier, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
|
291
|
+
end
|
282
292
|
graph.dump(:ntriples, validate: false)
|
283
|
-
#
|
293
|
+
# ==> '_:bn <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>)>> .
|
294
|
+
_:bn <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
|
284
295
|
|
285
|
-
### Reading a Graph containing
|
296
|
+
### Reading a Graph containing triple terms
|
286
297
|
|
287
298
|
By default, the N-Triples reader will reject a document containing a subject resource.
|
288
299
|
|
289
|
-
nt = '
|
300
|
+
nt = '<<(<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>)>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
|
290
301
|
graph = RDF::Graph.new do |graph|
|
291
302
|
RDF::NTriples::Reader.new(nt) {|reader| graph << reader}
|
292
303
|
end
|
@@ -340,6 +351,7 @@ other gems:
|
|
340
351
|
* [RDF::TriG][] (extension)
|
341
352
|
* [RDF::TriX][] (extension)
|
342
353
|
* [RDF::Turtle][] (extension)
|
354
|
+
* [RDF::Borsh][] (extension)
|
343
355
|
|
344
356
|
The meta-gem [LinkedData][LinkedData doc] includes many of these gems.
|
345
357
|
|
@@ -394,6 +406,9 @@ from BNode identity (i.e., they each entail the other)
|
|
394
406
|
* {RDF::RDFV} - RDF Vocabulary (RDFV)
|
395
407
|
* {RDF::XSD} - XML Schema (XSD)
|
396
408
|
|
409
|
+
## Change Log
|
410
|
+
|
411
|
+
See [Release Notes on GitHub](https://github.com/ruby-rdf/rdf/releases)
|
397
412
|
|
398
413
|
## Dependencies
|
399
414
|
|
@@ -498,9 +513,11 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
|
498
513
|
[SPARQL doc]: https://ruby-rdf.github.io/sparql
|
499
514
|
[RDF 1.0]: https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/
|
500
515
|
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts/
|
516
|
+
[RDF-star]: https://www.w3.org/2021/12/rdf-star.html
|
501
517
|
[RDF 1.2]: https://www.w3.org/TR/rdf12-concepts/
|
502
518
|
[SPARQL 1.1]: https://www.w3.org/TR/sparql11-query/
|
503
519
|
[RDF.rb]: https://ruby-rdf.github.io/
|
520
|
+
[RDF::Borsh]: https://ruby-rdf.github.io/rdf-borsh
|
504
521
|
[RDF::DO]: https://ruby-rdf.github.io/rdf-do
|
505
522
|
[RDF::Mongo]: https://ruby-rdf.github.io/rdf-mongo
|
506
523
|
[RDF::Sesame]: https://ruby-rdf.github.io/rdf-sesame
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.3.
|
1
|
+
3.3.3
|
data/lib/rdf/mixin/enumerable.rb
CHANGED
@@ -83,7 +83,8 @@ module RDF
|
|
83
83
|
# * `:literal_equality' preserves [term-equality](https://www.w3.org/TR/rdf11-concepts/#dfn-literal-term-equality) for literals. Literals are equal only if their lexical values and datatypes are equal, character by character. Literals may be "inlined" to value-space for efficiency only if `:literal_equality` is `false`.
|
84
84
|
# * `:validity` allows a concrete Enumerable implementation to indicate that it does or does not support valididty checking. By default implementations are assumed to support validity checking.
|
85
85
|
# * `:skolemize` supports [Skolemization](https://www.w3.org/wiki/BnodeSkolemization) of an `Enumerable`. Implementations supporting this feature must implement a `#skolemize` method, taking a base URI used for minting URIs for BNodes as stable identifiers and a `#deskolemize` method, also taking a base URI used for turning URIs having that prefix back into the same BNodes which were originally skolemized.
|
86
|
-
# * `:
|
86
|
+
# * `:rdf_full` supports RDF 1.2 Full profile, including support for embedded Triple Terms.
|
87
|
+
# * `:quoted_triples` supports RDF-star quoted triples. (DEPRECATED)
|
87
88
|
# * `:base_direction` supports RDF 1.2 directional language-tagged strings.
|
88
89
|
#
|
89
90
|
# @param [Symbol, #to_sym] feature
|
data/lib/rdf/mixin/queryable.rb
CHANGED
@@ -146,6 +146,8 @@ module RDF
|
|
146
146
|
#
|
147
147
|
# Patterns may also have embedded patterns as either a subject or object, recursively.
|
148
148
|
#
|
149
|
+
# Patterns with a variable `graph_name` do not match the default graph.
|
150
|
+
#
|
149
151
|
# When matching, match an embedded pattern against embedded statements, recursively. (see {RDF::Query::Pattern#eql?})
|
150
152
|
#
|
151
153
|
# @param [RDF::Query::Pattern] pattern
|
data/lib/rdf/mixin/writable.rb
CHANGED
@@ -127,10 +127,11 @@ module RDF
|
|
127
127
|
def insert_statements(statements)
|
128
128
|
each = statements.respond_to?(:each_statement) ? :each_statement : :each
|
129
129
|
statements.__send__(each) do |statement|
|
130
|
-
|
130
|
+
# FIXME: quoted triples are now deprecated
|
131
|
+
if statement.embedded? && respond_to?(:supports?) && !(supports?(:quoted_triples) || supports?(:rdf_full))
|
131
132
|
raise ArgumentError, "Writable does not support quoted triples"
|
132
133
|
end
|
133
|
-
if statement.object && statement.object.literal? && statement.object.direction? && !supports?(:base_direction)
|
134
|
+
if statement.object && statement.object.literal? && statement.object.direction? && respond_to?(:supports?) && !supports?(:base_direction)
|
134
135
|
raise ArgumentError, "Writable does not support directional languaged-tagged strings"
|
135
136
|
end
|
136
137
|
insert_statement(statement)
|
data/lib/rdf/model/dataset.rb
CHANGED
@@ -104,7 +104,8 @@ module RDF
|
|
104
104
|
# @private
|
105
105
|
# @see RDF::Enumerable#supports?
|
106
106
|
def supports?(feature)
|
107
|
-
|
107
|
+
# FIXME: quoted triples are now deprecated
|
108
|
+
return true if %i(graph_name quoted_triples rdf_full).include?(feature)
|
108
109
|
super
|
109
110
|
end
|
110
111
|
|
data/lib/rdf/model/graph.rb
CHANGED
@@ -20,7 +20,7 @@ module RDF
|
|
20
20
|
#
|
21
21
|
# @example Loading graph data from a URL
|
22
22
|
# require 'rdf/rdfxml' # for RDF/XML support
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# graph = RDF::Graph.load("http://www.bbc.co.uk/programmes/b0081dq5.rdf")
|
25
25
|
#
|
26
26
|
# @example Accessing a specific named graph within a {RDF::Repository}
|
@@ -250,6 +250,36 @@ module RDF
|
|
250
250
|
end
|
251
251
|
alias_method :has_statement?, :statement?
|
252
252
|
|
253
|
+
##
|
254
|
+
# Returns `true` if `self` contains the given RDF subject term.
|
255
|
+
#
|
256
|
+
# @param [RDF::Resource] value
|
257
|
+
# @return [Boolean]
|
258
|
+
def subject? value
|
259
|
+
!@data.query({ subject: value, graph_name: graph_name || false }).empty?
|
260
|
+
end
|
261
|
+
alias_method :has_subject?, :subject?
|
262
|
+
|
263
|
+
##
|
264
|
+
# Returns `true` if `self` contains the given RDF predicate term.
|
265
|
+
#
|
266
|
+
# @param [RDF::URI] value
|
267
|
+
# @return [Boolean]
|
268
|
+
def predicate? value
|
269
|
+
!@data.query({ predicate: value, graph_name: graph_name || false }).empty?
|
270
|
+
end
|
271
|
+
alias_method :has_predicate?, :predicate?
|
272
|
+
|
273
|
+
##
|
274
|
+
# Returns `true` if `self` contains the given RDF object term.
|
275
|
+
#
|
276
|
+
# @param [RDF::Term] value
|
277
|
+
# @return [Boolean]
|
278
|
+
def object? value
|
279
|
+
!@data.query({ object: value, graph_name: graph_name || false }).empty?
|
280
|
+
end
|
281
|
+
alias_method :has_object?, :object?
|
282
|
+
|
253
283
|
##
|
254
284
|
# Enumerates each RDF statement in this graph.
|
255
285
|
#
|
@@ -305,8 +335,9 @@ module RDF
|
|
305
335
|
# @private
|
306
336
|
# @see RDF::Mutable#insert
|
307
337
|
def insert_statement(statement)
|
308
|
-
|
309
|
-
|
338
|
+
# FIXME: quoted triples are now deprecated
|
339
|
+
if statement.embedded? && !(@data.supports?(:quoted_triples) || @data.supports?(:rdf_full))
|
340
|
+
raise ArgumentError, "Graph does not support the RDF Full profile"
|
310
341
|
end
|
311
342
|
if statement.object && statement.object.literal? && statement.object.direction? && !@data.supports?(:base_direction)
|
312
343
|
raise ArgumentError, "Graph does not support directional languaged-tagged strings"
|
@@ -26,9 +26,7 @@ module RDF; class Literal
|
|
26
26
|
# Use midnight as midpoint of the interval
|
27
27
|
::DateTime.parse(value.strftime('%FT00:00:00'))
|
28
28
|
when value.respond_to?(:to_datetime)
|
29
|
-
|
30
|
-
@zone = dt.zone
|
31
|
-
dt
|
29
|
+
value.to_datetime
|
32
30
|
else
|
33
31
|
md = value.to_s.match(GRAMMAR)
|
34
32
|
_, dt, tz = Array(md)
|
@@ -12,10 +12,10 @@ module RDF; class Literal
|
|
12
12
|
# @since 0.2.1
|
13
13
|
class Decimal < Numeric
|
14
14
|
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#decimal")
|
15
|
-
GRAMMAR = /^[\+\-]
|
15
|
+
GRAMMAR = /^[\+\-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))$/.freeze
|
16
16
|
|
17
17
|
##
|
18
|
-
# @param [String,
|
18
|
+
# @param [String, BigDecimal, Numeric] value
|
19
19
|
# @param (see Literal#initialize)
|
20
20
|
def initialize(value, datatype: nil, lexical: nil, **options)
|
21
21
|
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
|
@@ -12,7 +12,7 @@ module RDF; class Literal
|
|
12
12
|
# @since 0.2.1
|
13
13
|
class Double < Numeric
|
14
14
|
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#double")
|
15
|
-
GRAMMAR = /^(?:NaN
|
15
|
+
GRAMMAR = /^(?:NaN|[+\-]?INF|[+\-]?(?:\d+(:?\.\d*)?|\.\d+)(?:[eE][\+\-]?\d+)?)$/.freeze
|
16
16
|
|
17
17
|
##
|
18
18
|
# @param [String, Float, #to_f] value
|
@@ -26,7 +26,7 @@ module RDF; class Literal
|
|
26
26
|
when 'INF' then 1/0.0
|
27
27
|
when '-INF' then -1/0.0
|
28
28
|
when 'NAN' then 0/0.0
|
29
|
-
else Float(value.sub(/\.[eE]/, '.0E')) rescue nil
|
29
|
+
else Float(value.sub(/\.[eE]/, '.0E').sub(/\.$/, '.0')) rescue nil
|
30
30
|
end
|
31
31
|
when value.is_a?(::Float) then value
|
32
32
|
when value.respond_to?(:to_f) then value.to_f
|
data/lib/rdf/model/literal.rb
CHANGED
@@ -194,7 +194,7 @@ module RDF
|
|
194
194
|
@string = @string.encode(Encoding::UTF_8).freeze if instance_variable_defined?(:@string)
|
195
195
|
@object = @string if instance_variable_defined?(:@string) && @object.is_a?(String)
|
196
196
|
@language = language.to_s.downcase.to_sym if language
|
197
|
-
@direction = direction.to_s.
|
197
|
+
@direction = direction.to_s.to_sym if direction
|
198
198
|
@datatype = RDF::URI(datatype).freeze if datatype
|
199
199
|
@datatype ||= self.class.const_get(:DATATYPE) if self.class.const_defined?(:DATATYPE)
|
200
200
|
@datatype ||= if instance_variable_defined?(:@language) && @language &&
|
@@ -451,6 +451,16 @@ module RDF
|
|
451
451
|
false
|
452
452
|
end
|
453
453
|
|
454
|
+
##
|
455
|
+
# Returns `true` if this is a language-tagged literal in the English
|
456
|
+
# language.
|
457
|
+
#
|
458
|
+
# @return [Boolean] `true` or `false`
|
459
|
+
# @since 3.3.2
|
460
|
+
def english?
|
461
|
+
/\Aen(?:-[A-Za-z]{2})?\z/ === language.to_s
|
462
|
+
end
|
463
|
+
|
454
464
|
##
|
455
465
|
# Validates the value using {RDF::Value#valid?}, raising an error if the value is
|
456
466
|
# invalid.
|
data/lib/rdf/model/statement.rb
CHANGED
@@ -71,7 +71,8 @@ module RDF
|
|
71
71
|
# @option options [RDF::Term] :graph_name (nil)
|
72
72
|
# Note, in RDF 1.1, a graph name MUST be an {Resource}.
|
73
73
|
# @option options [Boolean] :inferred used as a marker to record that this statement was inferred based on semantic relationships (T-Box).
|
74
|
-
# @option options [Boolean] :
|
74
|
+
# @option options [Boolean] :tripleTerm used as a marker to record that this statement appears as the object of another RDF::Statement.
|
75
|
+
# @option options [Boolean] :quoted used as a marker to record that this statement quoted and appears as the subject or object of another RDF::Statement (deprecated).
|
75
76
|
# @return [RDF::Statement]
|
76
77
|
#
|
77
78
|
# @overload initialize(subject, predicate, object, **options)
|
@@ -84,7 +85,8 @@ module RDF
|
|
84
85
|
# @option options [RDF::Term] :graph_name (nil)
|
85
86
|
# Note, in RDF 1.1, a graph name MUST be an {Resource}.
|
86
87
|
# @option options [Boolean] :inferred used as a marker to record that this statement was inferred based on semantic relationships (T-Box).
|
87
|
-
# @option options [Boolean] :
|
88
|
+
# @option options [Boolean] :tripleTerm used as a marker to record that this statement appears as the object of another RDF::Statement.
|
89
|
+
# @option options [Boolean] :quoted used as a marker to record that this statement quoted and appears as the subject or object of another RDF::Statement (deprecated).
|
88
90
|
# @return [RDF::Statement]
|
89
91
|
def initialize(subject = nil, predicate = nil, object = nil, options = {})
|
90
92
|
if subject.is_a?(Hash)
|
@@ -211,6 +213,13 @@ module RDF
|
|
211
213
|
|
212
214
|
##
|
213
215
|
# @return [Boolean]
|
216
|
+
def tripleTerm?
|
217
|
+
!!@options[:tripleTerm]
|
218
|
+
end
|
219
|
+
|
220
|
+
##
|
221
|
+
# @return [Boolean]
|
222
|
+
# @deprecated Quoted triples are now deprecated
|
214
223
|
def quoted?
|
215
224
|
!!@options[:quoted]
|
216
225
|
end
|
@@ -467,7 +476,7 @@ module RDF
|
|
467
476
|
def to_s
|
468
477
|
(graph_name ? to_quad : to_triple).map do |term|
|
469
478
|
if term.is_a?(Statement)
|
470
|
-
"
|
479
|
+
"<<(#{term.to_s[0..-3]})>>"
|
471
480
|
elsif term.respond_to?(:to_base)
|
472
481
|
term.to_base
|
473
482
|
else
|
data/lib/rdf/model/uri.rb
CHANGED
@@ -70,16 +70,20 @@ module RDF
|
|
70
70
|
IUSERINFO = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|:)*").freeze
|
71
71
|
IAUTHORITY = Regexp.compile("(?:#{IUSERINFO}@)?#{IHOST}(?::#{PORT})?").freeze
|
72
72
|
|
73
|
-
IRELATIVE_PART = Regexp.compile("
|
74
|
-
IRELATIVE_REF = Regexp.compile("
|
73
|
+
IRELATIVE_PART = Regexp.compile("//#{IAUTHORITY}(?:#{IPATH_ABEMPTY})|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_NOSCHEME})|(?:#{IPATH_EMPTY})").freeze
|
74
|
+
IRELATIVE_REF = Regexp.compile("^(?:#{IRELATIVE_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
|
75
75
|
|
76
|
-
IHIER_PART = Regexp.compile("
|
76
|
+
IHIER_PART = Regexp.compile("//#{IAUTHORITY}(?:#{IPATH_ABEMPTY})|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_ROOTLESS})|(?:#{IPATH_EMPTY})").freeze
|
77
77
|
IRI = Regexp.compile("^#{SCHEME}:(?:#{IHIER_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
|
78
78
|
|
79
79
|
# Split an IRI into it's component parts
|
80
80
|
# scheme, authority, path, query, fragment
|
81
81
|
IRI_PARTS = /^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(\?[^#]*)?(#.*)?$/.freeze
|
82
82
|
|
83
|
+
# Special version for file-scheme on Windows (path SHOULD begin with /, but may not)
|
84
|
+
# scheme, authority, path, query, fragment
|
85
|
+
FILE_PARTS = /^file:(?:\/\/(#{IHOST}))?(\/?[^?#]*)(\?[^#]*)?(#.*)?$/.freeze
|
86
|
+
|
83
87
|
# Remove dot expressions regular expressions
|
84
88
|
RDS_2A = /^\.?\.\/(.*)$/.freeze
|
85
89
|
RDS_2B1 = /^\/\.$/.freeze
|
@@ -160,7 +164,7 @@ module RDF
|
|
160
164
|
# (see #initialize)
|
161
165
|
# @return [RDF::URI] an immutable, frozen URI object
|
162
166
|
def self.intern(str, *args, **options)
|
163
|
-
(cache[(str = str.to_s).to_sym] ||= self.new(str, *args, **options)).freeze
|
167
|
+
(cache[(str = str.to_s).to_sym] ||= self.new(str.to_s, *args, **options)).freeze
|
164
168
|
end
|
165
169
|
|
166
170
|
##
|
@@ -716,8 +720,8 @@ module RDF
|
|
716
720
|
##
|
717
721
|
# @private
|
718
722
|
def freeze
|
719
|
-
|
720
|
-
|
723
|
+
@mutex.synchronize do
|
724
|
+
unless frozen?
|
721
725
|
# Create derived components
|
722
726
|
authority; userinfo; user; password; host; port
|
723
727
|
@value = value.freeze
|
@@ -851,8 +855,7 @@ module RDF
|
|
851
855
|
# lexical representation of URI, either absolute or relative
|
852
856
|
# @return [String]
|
853
857
|
def value
|
854
|
-
|
855
|
-
@value = [
|
858
|
+
@value ||= [
|
856
859
|
("#{scheme}:" if absolute?),
|
857
860
|
("//#{authority}" if authority),
|
858
861
|
path,
|
@@ -883,17 +886,35 @@ module RDF
|
|
883
886
|
#
|
884
887
|
# @param [String, to_s] value
|
885
888
|
# @return [Object{Symbol => String}]
|
889
|
+
# @see https://datatracker.ietf.org/doc/html/rfc8089
|
886
890
|
def parse(value)
|
887
|
-
value = value.to_s.dup.force_encoding(Encoding::
|
891
|
+
value = value.to_s.dup.force_encoding(Encoding::UTF_8) unless value && value.encoding == Encoding::UTF_8
|
888
892
|
parts = {}
|
889
|
-
if matchdata =
|
893
|
+
if matchdata = FILE_PARTS.match(value)
|
894
|
+
# A file-based URI is always in the folloring form:
|
895
|
+
# * file:/path - absolute path, no host name
|
896
|
+
# * file:///path - absolute path, empty host name
|
897
|
+
# * file://hostname/path - absolute path with authority.
|
898
|
+
# * file://path – is invalid, but treated as file:///path
|
899
|
+
scheme = 'file'
|
900
|
+
authority, path, query, fragment = matchdata[1..-1]
|
901
|
+
if authority && authority.match?(/^[A-Za-z]$/) && Gem.win_platform?
|
902
|
+
# In this case, if the authority is a drive letter and part of the path
|
903
|
+
authority, path = nil, "#{authority}#{path}"
|
904
|
+
end
|
905
|
+
# We accept paths that aren't absolute, but coerce them to be absolute
|
906
|
+
path = "/#{path}" unless path.start_with?('/')
|
907
|
+
elsif matchdata = IRI_PARTS.match(value)
|
890
908
|
scheme, authority, path, query, fragment = matchdata[1..-1]
|
909
|
+
authority = nil if authority && authority.empty?
|
891
910
|
|
892
|
-
if
|
893
|
-
#
|
894
|
-
scheme, path = nil, "
|
911
|
+
if scheme && scheme.match?(/^[A-Za-z]$/) && Gem.win_platform?
|
912
|
+
# On Windows treat D:/foo/bar as a path, not a scheme
|
913
|
+
scheme, authority, path = 'file', nil, "/#{scheme}:#{path}"
|
895
914
|
end
|
915
|
+
end
|
896
916
|
|
917
|
+
if matchdata
|
897
918
|
userinfo, hostport = authority.to_s.split('@', 2)
|
898
919
|
hostport, userinfo = userinfo, nil unless hostport
|
899
920
|
user, password = userinfo.to_s.split(':', 2)
|
@@ -1240,17 +1261,18 @@ module RDF
|
|
1240
1261
|
query.to_s.split('&').
|
1241
1262
|
inject(return_type == Hash ? {} : []) do |memo,kv|
|
1242
1263
|
k,v = kv.to_s.split('=', 2)
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1264
|
+
unless k.to_s.empty?
|
1265
|
+
k = CGI.unescape(k)
|
1266
|
+
v = CGI.unescape(v) if v
|
1267
|
+
if return_type == Hash
|
1268
|
+
case memo[k]
|
1269
|
+
when nil then memo[k] = v
|
1270
|
+
when Array then memo[k] << v
|
1271
|
+
else memo[k] = [memo[k], v]
|
1272
|
+
end
|
1273
|
+
else
|
1274
|
+
memo << [k, v].compact
|
1251
1275
|
end
|
1252
|
-
else
|
1253
|
-
memo << [k, v].compact
|
1254
1276
|
end
|
1255
1277
|
memo
|
1256
1278
|
end
|
data/lib/rdf/model/value.rb
CHANGED
@@ -197,19 +197,20 @@ module RDF
|
|
197
197
|
alias_method :validate, :validate!
|
198
198
|
|
199
199
|
##
|
200
|
-
# Returns `true` if this Value starts with the given
|
200
|
+
# Returns `true` if this Value starts with any of the given strings.
|
201
201
|
#
|
202
202
|
# @example
|
203
203
|
# RDF::URI('http://example.org/').start_with?('http') #=> true
|
204
204
|
# RDF::Node('_:foo').start_with?('_:bar') #=> false
|
205
205
|
# RDF::Litera('Apple').start_with?('Orange') #=> false
|
206
|
+
# RDF::Litera('Apple').start_with?('Orange', 'Apple') #=> true
|
206
207
|
#
|
207
|
-
# @param [
|
208
|
+
# @param [Array<#to_s>] *args Any number of strings to check against.
|
208
209
|
# @return [Boolean] `true` or `false`
|
209
210
|
# @see String#start_with?
|
210
211
|
# @since 0.3.0
|
211
|
-
def start_with?(
|
212
|
-
to_s.start_with?(
|
212
|
+
def start_with?(*args)
|
213
|
+
to_s.start_with?(*args.map(&:to_s))
|
213
214
|
end
|
214
215
|
alias_method :starts_with?, :start_with?
|
215
216
|
|
data/lib/rdf/nquads.rb
CHANGED
@@ -71,9 +71,10 @@ module RDF
|
|
71
71
|
|
72
72
|
begin
|
73
73
|
unless blank? || read_comment
|
74
|
+
# FIXME: quoted triples are now deprecated
|
74
75
|
subject = read_uriref || read_node || read_quotedTriple || fail_subject
|
75
76
|
predicate = read_uriref(intern: true) || fail_predicate
|
76
|
-
object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
|
77
|
+
object = read_uriref || read_node || read_literal || read_tripleTerm || read_quotedTriple || fail_object
|
77
78
|
graph_name = read_uriref || read_node
|
78
79
|
if validate? && !read_eos
|
79
80
|
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
|
data/lib/rdf/ntriples/reader.rb
CHANGED
@@ -30,7 +30,7 @@ module RDF::NTriples
|
|
30
30
|
#
|
31
31
|
# ** RDF=star
|
32
32
|
#
|
33
|
-
# Supports statements as resources using `<<s p o>>`.
|
33
|
+
# Supports statements as resources using `<<(s p o)>>`.
|
34
34
|
#
|
35
35
|
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
|
36
36
|
# @see http://www.w3.org/TR/n-triples/
|
@@ -40,8 +40,8 @@ module RDF::NTriples
|
|
40
40
|
|
41
41
|
# @see http://www.w3.org/TR/rdf-testcases/#ntrip_strings
|
42
42
|
ESCAPE_CHARS = ["\b", "\f", "\t", "\n", "\r", "\"", "'", "\\"].freeze
|
43
|
-
UCHAR4 =
|
44
|
-
UCHAR8 =
|
43
|
+
UCHAR4 = /(?<!\\)\\(?!\\)u([0-9A-Fa-f]{4,4})/.freeze
|
44
|
+
UCHAR8 = /(?<!\\)\\(?!\\)U([0-9A-Fa-f]{8,8})/.freeze
|
45
45
|
UCHAR = Regexp.union(UCHAR4, UCHAR8).freeze
|
46
46
|
|
47
47
|
|
@@ -51,14 +51,14 @@ module RDF::NTriples
|
|
51
51
|
# @see http://www.w3.org/TR/turtle/
|
52
52
|
##
|
53
53
|
# Unicode regular expressions.
|
54
|
-
U_CHARS1
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
U_CHARS2
|
61
|
-
IRI_RANGE
|
54
|
+
U_CHARS1 = Regexp.compile(<<-EOS.gsub(/\s+/, ''))
|
55
|
+
[\\u00C0-\\u00D6]|[\\u00D8-\\u00F6]|[\\u00F8-\\u02FF]|
|
56
|
+
[\\u0370-\\u037D]|[\\u037F-\\u1FFF]|[\\u200C-\\u200D]|
|
57
|
+
[\\u2070-\\u218F]|[\\u2C00-\\u2FEF]|[\\u3001-\\uD7FF]|
|
58
|
+
[\\uF900-\\uFDCF]|[\\uFDF0-\\uFFFD]|[\\u{10000}-\\u{EFFFF}]
|
59
|
+
EOS
|
60
|
+
U_CHARS2 = Regexp.compile("\\u00B7|[\\u0300-\\u036F]|[\\u203F-\\u2040]").freeze
|
61
|
+
IRI_RANGE = Regexp.compile("[[^<>\"{}\|\^`\\\\]&&[^\\x00-\\x20]]").freeze
|
62
62
|
|
63
63
|
PN_CHARS_BASE = /[A-Z]|[a-z]|#{U_CHARS1}/.freeze
|
64
64
|
PN_CHARS_U = /_|#{PN_CHARS_BASE}/.freeze
|
@@ -70,8 +70,11 @@ module RDF::NTriples
|
|
70
70
|
LANG_DIR = /@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*(?:--[a-zA-Z]+)?)/.freeze
|
71
71
|
STRING_LITERAL_QUOTE = /"((?:[^\"\\\n\r]|#{ECHAR}|#{UCHAR})*)"/.freeze
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
TT_START = /^<<\(/.freeze
|
74
|
+
TT_END = /^\s*\)>>/.freeze
|
75
|
+
|
76
|
+
QT_START = /^<</.freeze # DEPRECATED
|
77
|
+
QT_END = /^\s*>>/.freeze # DEPRECATED
|
75
78
|
|
76
79
|
# @see http://www.w3.org/TR/rdf-testcases/#ntrip_grammar
|
77
80
|
COMMENT = /^#\s*(.*)$/.freeze
|
@@ -184,22 +187,12 @@ module RDF::NTriples
|
|
184
187
|
# Note: avoiding copying the input string when no escaping is needed
|
185
188
|
# greatly reduces the number of allocations and the processing time.
|
186
189
|
string = string.dup.force_encoding(Encoding::UTF_8) unless string.encoding == Encoding::UTF_8
|
187
|
-
scanner = StringScanner.new(string)
|
188
|
-
|
189
|
-
buffer = ""
|
190
|
-
|
191
|
-
while !scanner.eos?
|
192
|
-
buffer << if scanner.scan(ESCAPE_CHARS_ESCAPED_REGEXP)
|
193
|
-
ESCAPE_CHARS_ESCAPED[scanner.matched]
|
194
|
-
elsif scanner.scan(UCHAR)
|
195
|
-
scanner.matched.sub(UCHAR) {[($1 || $2).hex].pack('U*')}
|
196
|
-
else
|
197
|
-
# Scan one character
|
198
|
-
scanner.getch
|
199
|
-
end
|
200
|
-
end
|
201
190
|
|
202
|
-
|
191
|
+
string
|
192
|
+
.gsub(UCHAR) do
|
193
|
+
[($1 || $2).hex].pack('U*')
|
194
|
+
end
|
195
|
+
.gsub(ESCAPE_CHARS_ESCAPED_REGEXP, ESCAPE_CHARS_ESCAPED)
|
203
196
|
end
|
204
197
|
|
205
198
|
##
|
@@ -208,7 +201,7 @@ module RDF::NTriples
|
|
208
201
|
begin
|
209
202
|
read_statement
|
210
203
|
rescue RDF::ReaderError
|
211
|
-
value = read_uriref || read_node || read_literal || read_quotedTriple
|
204
|
+
value = read_uriref || read_node || read_literal || read_tripleTerm || read_quotedTriple
|
212
205
|
log_recover
|
213
206
|
value
|
214
207
|
end
|
@@ -226,7 +219,7 @@ module RDF::NTriples
|
|
226
219
|
unless blank? || read_comment
|
227
220
|
subject = read_uriref || read_node || read_quotedTriple || fail_subject
|
228
221
|
predicate = read_uriref(intern: true) || fail_predicate
|
229
|
-
object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
|
222
|
+
object = read_uriref || read_node || read_literal || read_tripleTerm || read_quotedTriple || fail_object
|
230
223
|
|
231
224
|
if validate? && !read_eos
|
232
225
|
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
|
@@ -242,12 +235,29 @@ module RDF::NTriples
|
|
242
235
|
|
243
236
|
##
|
244
237
|
# @return [RDF::Statement]
|
238
|
+
def read_tripleTerm
|
239
|
+
if @options[:rdfstar] && match(TT_START)
|
240
|
+
subject = read_uriref || read_node || fail_subject
|
241
|
+
predicate = read_uriref(intern: true) || fail_predicate
|
242
|
+
object = read_uriref || read_node || read_literal || read_tripleTerm || fail_object
|
243
|
+
if !match(TT_END)
|
244
|
+
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
|
245
|
+
end
|
246
|
+
RDF::Statement.new(subject, predicate, object, tripleTerm: true)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
##
|
251
|
+
# @return [RDF::Statement]
|
252
|
+
# @deprecated Quoted triples are now deprecated (not supported when validating)
|
245
253
|
def read_quotedTriple
|
246
|
-
if @options[:rdfstar] && match(
|
254
|
+
if @options[:rdfstar] && !match(TT_START) && match(QT_START) && !validate?
|
255
|
+
warn "[DEPRECATION] RDF-star quoted triples are deprecated and will be removed in a future version.\n" +
|
256
|
+
"Called from #{Gem.location_of_caller.join(':')}"
|
247
257
|
subject = read_uriref || read_node || read_quotedTriple || fail_subject
|
248
258
|
predicate = read_uriref(intern: true) || fail_predicate
|
249
259
|
object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
|
250
|
-
if !match(
|
260
|
+
if !match(QT_END)
|
251
261
|
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
|
252
262
|
end
|
253
263
|
RDF::Statement.new(subject, predicate, object, quoted: true)
|
data/lib/rdf/ntriples/writer.rb
CHANGED
@@ -223,15 +223,28 @@ module RDF::NTriples
|
|
223
223
|
format_triple(*statement.to_triple, **options)
|
224
224
|
end
|
225
225
|
|
226
|
+
##
|
227
|
+
# Returns the N-Triples representation of an RDF 1.2 triple term.
|
228
|
+
#
|
229
|
+
# @param [RDF::Statement] statement
|
230
|
+
# @param [Hash{Symbol => Object}] options ({})
|
231
|
+
# @return [String]
|
232
|
+
def format_tripleTerm(statement, **options)
|
233
|
+
"<<( %s %s %s )>>" % statement.to_a.map { |value| format_term(value, **options) }
|
234
|
+
end
|
235
|
+
|
226
236
|
##
|
227
237
|
# Returns the N-Triples representation of an RDF-star quoted triple.
|
228
238
|
#
|
229
239
|
# @param [RDF::Statement] statement
|
230
240
|
# @param [Hash{Symbol => Object}] options ({})
|
231
241
|
# @return [String]
|
242
|
+
# @deprecated Quoted triples are now deprecated
|
232
243
|
def format_quotedTriple(statement, **options)
|
244
|
+
# FIXME: quoted triples are now deprecated
|
233
245
|
"<<%s %s %s>>" % statement.to_a.map { |value| format_term(value, **options) }
|
234
246
|
end
|
247
|
+
|
235
248
|
##
|
236
249
|
# Returns the N-Triples representation of a triple.
|
237
250
|
#
|
data/lib/rdf/ntriples.rb
CHANGED
@@ -15,7 +15,11 @@ module RDF
|
|
15
15
|
#
|
16
16
|
# <https://rubygems.org/gems/rdf> <http://purl.org/dc/terms/title> "rdf" .
|
17
17
|
#
|
18
|
-
# ##
|
18
|
+
# ## Triple terms
|
19
|
+
#
|
20
|
+
# Supports statements as resources using `<<(s p o)>>`.
|
21
|
+
|
22
|
+
# ## Quoted Triples (Deprecated)
|
19
23
|
#
|
20
24
|
# Supports statements as resources using `<<s p o>>`.
|
21
25
|
#
|
data/lib/rdf/query/pattern.rb
CHANGED
@@ -23,7 +23,7 @@ module RDF; class Query
|
|
23
23
|
# @option options [Variable, URI, Symbol, nil] :predicate (nil)
|
24
24
|
# @option options [Variable, Term, Symbol, nil] :object (nil)
|
25
25
|
# @option options [Variable, Resource, Symbol, nil, false] :graph_name (nil)
|
26
|
-
# A graph_name of nil matches any graph, a graph_name of false, matches only the default graph.
|
26
|
+
# A graph_name of nil matches any graph, a graph_name of false, matches only the default graph. (See {RDF::Query#initialize})
|
27
27
|
# @option options [Boolean] :optional (false)
|
28
28
|
#
|
29
29
|
# @overload initialize(subject, predicate, object, options = {})
|
@@ -32,7 +32,7 @@ module RDF; class Query
|
|
32
32
|
# @param [Variable, Termm, Symbol, nil] object
|
33
33
|
# @param [Hash{Symbol => Object}] options
|
34
34
|
# @option options [Variable, Resource, Symbol, nil, false] :graph_name (nil)
|
35
|
-
# A graph_name of nil matches any graph, a graph_name of false, matches only the default graph.
|
35
|
+
# A graph_name of nil matches any graph, a graph_name of false, matches only the default graph. (See {RDF::Query#initialize})
|
36
36
|
# @option options [Boolean] :optional (false)
|
37
37
|
#
|
38
38
|
# @note {Statement} treats symbols as interned {Node} instances, in a {Pattern}, they are treated as {Variable}.
|
data/lib/rdf/query/variable.rb
CHANGED
@@ -233,6 +233,8 @@ class RDF::Query
|
|
233
233
|
# Returns `true` if this variable is equivalent to a given `other`
|
234
234
|
# variable. Or, to another Term if bound, or to any other Term
|
235
235
|
#
|
236
|
+
# @note when comparing against the default graph in an {RDF::Dataset}, `other` will be `false` and not be equal to an unbound variable.
|
237
|
+
#
|
236
238
|
# @param [Object] other
|
237
239
|
# @return [Boolean] `true` or `false`
|
238
240
|
# @since 0.3.0
|
data/lib/rdf/query.rb
CHANGED
@@ -151,10 +151,9 @@ module RDF
|
|
151
151
|
# @option options [RDF::Query::Solutions] :solutions (Solutions.new)
|
152
152
|
# @option options [RDF::Resource, RDF::Query::Variable, false] :graph_name (nil)
|
153
153
|
# Default graph name for matching against queryable.
|
154
|
-
#
|
154
|
+
# Queries with a graph name match against a specifically named
|
155
155
|
# graphs if the name is an {RDF::Resource} or bound {RDF::Query::Variable}.
|
156
|
-
#
|
157
|
-
# or named graphs.
|
156
|
+
# Queries using an unbound variable as a graph name only match against named graphs, and will not match the default graph.
|
158
157
|
# The name of `false` will only match against the default graph.
|
159
158
|
# @option options [RDF::Resource, RDF::Query::Variable, false] :name (nil)
|
160
159
|
# Alias for `:graph_name`.
|
@@ -168,10 +167,9 @@ module RDF
|
|
168
167
|
# @param [RDF::Query::Solutions] solutions (Solutions.new)
|
169
168
|
# @param [RDF::Resource, RDF::Query::Variable, false] graph_name (false)
|
170
169
|
# Default graph name for matching against queryable.
|
171
|
-
#
|
170
|
+
# Queries with a graph name match against a specifically named
|
172
171
|
# graphs if the name is an {RDF::Resource} or bound {RDF::Query::Variable}.
|
173
|
-
#
|
174
|
-
# or named graphs.
|
172
|
+
# Queries using an unbound variable as a graph name only match against named graphs, and will not match the default graph.
|
175
173
|
# The name of `false` will only match against the default graph.
|
176
174
|
# @param [RDF::Resource, RDF::Query::Variable, false] name (false)
|
177
175
|
# Alias for `:graph_name`.
|
@@ -285,10 +283,9 @@ module RDF
|
|
285
283
|
# @param [RDF::Query::Solutions] solutions (Solutions.new)
|
286
284
|
# @param [RDF::Resource, RDF::Query::Variable, false] graph_name (nil)
|
287
285
|
# Default graph name for matching against queryable.
|
288
|
-
#
|
286
|
+
# Queries with a graph name match against a specifically named
|
289
287
|
# graphs if the name is an {RDF::Resource} or bound {RDF::Query::Variable}.
|
290
|
-
#
|
291
|
-
# or named graphs.
|
288
|
+
# Queries using an unbound variable as a graph name only match against named graphs, and will not match the default graph.
|
292
289
|
# The name of `false` will only match against the default graph.
|
293
290
|
# @param [RDF::Resource, RDF::Query::Variable, false] name (nil)
|
294
291
|
# Alias for `:graph_name`.
|
data/lib/rdf/reader.rb
CHANGED
@@ -333,7 +333,7 @@ module RDF
|
|
333
333
|
# Returns the base URI determined by this reader.
|
334
334
|
#
|
335
335
|
# @example
|
336
|
-
# reader.
|
336
|
+
# reader.base_uri #=> RDF::URI('http://example.com/')
|
337
337
|
#
|
338
338
|
# @return [RDF::URI]
|
339
339
|
# @since 0.3.0
|
data/lib/rdf/repository.rb
CHANGED
@@ -182,6 +182,8 @@ module RDF
|
|
182
182
|
when :validity then @options.fetch(:with_validity, true)
|
183
183
|
when :literal_equality then true
|
184
184
|
when :atomic_write then false
|
185
|
+
when :rdf_full then false
|
186
|
+
# FIXME: quoted triples are now deprecated
|
185
187
|
when :quoted_triples then false
|
186
188
|
when :base_direction then false
|
187
189
|
when :snapshots then false
|
@@ -270,7 +272,8 @@ module RDF
|
|
270
272
|
when :validity then @options.fetch(:with_validity, true)
|
271
273
|
when :literal_equality then true
|
272
274
|
when :atomic_write then true
|
273
|
-
when :
|
275
|
+
when :rdf_full then true
|
276
|
+
when :quoted_triples then true # DEPRECATED
|
274
277
|
when :base_direction then true
|
275
278
|
when :snapshots then true
|
276
279
|
else false
|
data/lib/rdf/util/file.rb
CHANGED
@@ -297,7 +297,6 @@ module RDF; module Util
|
|
297
297
|
# @yieldreturn [Object] returned from open_file
|
298
298
|
# @raise [IOError] if not found
|
299
299
|
def self.open_file(filename_or_url, proxy: nil, headers: {}, verify_none: false, **options, &block)
|
300
|
-
filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
|
301
300
|
remote_document = nil
|
302
301
|
|
303
302
|
if filename_or_url.to_s.match?(/^https?/)
|
@@ -319,6 +318,16 @@ module RDF; module Util
|
|
319
318
|
url_no_frag_or_query.query = nil
|
320
319
|
url_no_frag_or_query.fragment = nil
|
321
320
|
options[:encoding] ||= Encoding::UTF_8
|
321
|
+
|
322
|
+
# Just use path if there's a file scheme. This leaves out a potential host, which isn't supported anyway.
|
323
|
+
if url_no_frag_or_query.scheme == 'file'
|
324
|
+
url_no_frag_or_query = url_no_frag_or_query.path
|
325
|
+
if url_no_frag_or_query.match?(/^\/[A-Za-z]:/) && Gem.win_platform?
|
326
|
+
# Turns "/D:foo" into "D:foo"
|
327
|
+
url_no_frag_or_query = url_no_frag_or_query[1..-1]
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
322
331
|
Kernel.open(url_no_frag_or_query, "r", **options) do |file|
|
323
332
|
document_options = {
|
324
333
|
base_uri: filename_or_url.to_s,
|
data/lib/rdf/vocab/rdfv.rb
CHANGED
@@ -72,6 +72,10 @@ module RDF
|
|
72
72
|
# # @return [RDF::Vocabulary::Term]
|
73
73
|
# # @attr_reader :value
|
74
74
|
#
|
75
|
+
# # Reification predicate
|
76
|
+
# # @return [RDF::Vocabulary::Term]
|
77
|
+
# # @attr_reader :reifies
|
78
|
+
#
|
75
79
|
# # The datatype of RDF literals storing fragments of HTML content.
|
76
80
|
# # @return [RDF::Vocabulary::Term]
|
77
81
|
# # @attr_reader :HTML
|
@@ -253,6 +257,12 @@ module RDF
|
|
253
257
|
range: "http://www.w3.org/2000/01/rdf-schema#Resource".freeze,
|
254
258
|
isDefinedBy: %(http://www.w3.org/1999/02/22-rdf-syntax-ns#).freeze,
|
255
259
|
type: "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property".freeze
|
260
|
+
property :reifies,
|
261
|
+
comment: %(Property relating to a Triple Term.).freeze,
|
262
|
+
domain: "http://www.w3.org/2000/01/rdf-schema#Resource".freeze,
|
263
|
+
label: "reifies".freeze,
|
264
|
+
isDefinedBy: %(http://www.w3.org/1999/02/22-rdf-syntax-ns#).freeze,
|
265
|
+
type: "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property".freeze
|
256
266
|
|
257
267
|
# Datatype definitions
|
258
268
|
term :HTML,
|
data/lib/rdf/writer.rb
CHANGED
@@ -518,7 +518,8 @@ module RDF
|
|
518
518
|
when RDF::Literal then format_literal(term, **options)
|
519
519
|
when RDF::URI then format_uri(term, **options)
|
520
520
|
when RDF::Node then format_node(term, **options)
|
521
|
-
|
521
|
+
# FIXME: quoted triples are now deprecated
|
522
|
+
when RDF::Statement then term.tripleTerm? ? format_tripleTerm(term, **options) : format_quotedTriple(term, **options)
|
522
523
|
else nil
|
523
524
|
end
|
524
525
|
end
|
@@ -566,7 +567,7 @@ module RDF
|
|
566
567
|
end
|
567
568
|
|
568
569
|
##
|
569
|
-
# Formats a referenced triple.
|
570
|
+
# Formats a referenced triple term.
|
570
571
|
#
|
571
572
|
# @example
|
572
573
|
# <<<s> <p> <o>>> <p> <o> .
|
@@ -576,8 +577,24 @@ module RDF
|
|
576
577
|
# @return [String]
|
577
578
|
# @raise [NotImplementedError] unless implemented in subclass
|
578
579
|
# @abstract
|
580
|
+
def format_tripleTerm(value, **options)
|
581
|
+
raise NotImplementedError.new("#{self.class}#format_tripleTerm") # override in subclasses
|
582
|
+
end
|
583
|
+
|
584
|
+
##
|
585
|
+
# Formats a referenced quoted triple.
|
586
|
+
#
|
587
|
+
# @example
|
588
|
+
# <<<s> <p> <o>>> <p> <o> .
|
589
|
+
#
|
590
|
+
# @param [RDF::Statement] value
|
591
|
+
# @param [Hash{Symbol => Object}] options = ({})
|
592
|
+
# @return [String]
|
593
|
+
# @raise [NotImplementedError] unless implemented in subclass
|
594
|
+
# @abstract
|
595
|
+
# @deprecated Quoted Triples are now deprecated in favor of Triple Terms
|
579
596
|
def format_quotedTriple(value, **options)
|
580
|
-
raise NotImplementedError.new("#{self.class}#
|
597
|
+
raise NotImplementedError.new("#{self.class}#format_quotedTriple") # override in subclasses
|
581
598
|
end
|
582
599
|
|
583
600
|
protected
|
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.3.
|
4
|
+
version: 3.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arto Bendiken
|
@@ -10,8 +10,42 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2025-06-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bcp47_spec
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0.2'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bigdecimal
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '3.1'
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 3.1.5
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - "~>"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.1'
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 3.1.5
|
15
49
|
- !ruby/object:Gem::Dependency
|
16
50
|
name: link_header
|
17
51
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,14 +67,42 @@ dependencies:
|
|
33
67
|
- !ruby/object:Gem::Version
|
34
68
|
version: 0.0.8
|
35
69
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
70
|
+
name: logger
|
37
71
|
requirement: !ruby/object:Gem::Requirement
|
38
72
|
requirements:
|
39
73
|
- - "~>"
|
40
74
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
75
|
+
version: '1.5'
|
42
76
|
type: :runtime
|
43
77
|
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: ostruct
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.6'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: base64
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
44
106
|
version_requirements: !ruby/object:Gem::Requirement
|
45
107
|
requirements:
|
46
108
|
- - "~>"
|
@@ -122,14 +184,14 @@ dependencies:
|
|
122
184
|
requirements:
|
123
185
|
- - "~>"
|
124
186
|
- !ruby/object:Gem::Version
|
125
|
-
version: '3.
|
187
|
+
version: '3.13'
|
126
188
|
type: :development
|
127
189
|
prerelease: false
|
128
190
|
version_requirements: !ruby/object:Gem::Requirement
|
129
191
|
requirements:
|
130
192
|
- - "~>"
|
131
193
|
- !ruby/object:Gem::Version
|
132
|
-
version: '3.
|
194
|
+
version: '3.13'
|
133
195
|
- !ruby/object:Gem::Dependency
|
134
196
|
name: rspec-its
|
135
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,14 +212,14 @@ dependencies:
|
|
150
212
|
requirements:
|
151
213
|
- - "~>"
|
152
214
|
- !ruby/object:Gem::Version
|
153
|
-
version: '3.
|
215
|
+
version: '3.23'
|
154
216
|
type: :development
|
155
217
|
prerelease: false
|
156
218
|
version_requirements: !ruby/object:Gem::Requirement
|
157
219
|
requirements:
|
158
220
|
- - "~>"
|
159
221
|
- !ruby/object:Gem::Version
|
160
|
-
version: '3.
|
222
|
+
version: '3.23'
|
161
223
|
- !ruby/object:Gem::Dependency
|
162
224
|
name: yard
|
163
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -302,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
302
364
|
- !ruby/object:Gem::Version
|
303
365
|
version: '0'
|
304
366
|
requirements: []
|
305
|
-
rubygems_version: 3.
|
367
|
+
rubygems_version: 3.2.33
|
306
368
|
signing_key:
|
307
369
|
specification_version: 4
|
308
370
|
summary: A Ruby library for working with Resource Description Framework (RDF) data.
|