rdf 3.3.1 → 3.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e91c05a681e616afeaa013c0b52fc1c86579e4ce92ac7bdf34432e13e0792579
4
- data.tar.gz: 92cba1715c9d596487db504a6ad5ad1c8cf7ea6134aa7b316a6e0309b86f6db7
3
+ metadata.gz: b9b8e26b43854ef02542acbc81b88426f3b5989df1156e010bfb5250f3fb31c6
4
+ data.tar.gz: 7a4303eccec6cd20b29bcfcba87a9cffb36c3db7f7045bbd375264922e2a4a66
5
5
  SHA512:
6
- metadata.gz: e38d2d520c333b02f657f0b99f0d1d517a45e2c582b5004e1e33b6153b1a33db8bb67e56b84276b6d5730361f768ad2aed9feaeee97239cd94708955214d04be
7
- data.tar.gz: 7faa56d6a55c8bb5bd93ca41a5ae1f7b9cdeb55ebcd07266fb74af78750af2b7919dfb646e2e7d3a6971d11f10657cf1f9594977acbf4c4139c2946b7f40b604
6
+ metadata.gz: 31e5f916ecc25dddf44f6b6057311b784afa1a593b406e6ba1944481c3f5a2ac8f4de752a86d779d415e21c3292064c363bb9369c86ba8d401b0aebade755195
7
+ data.tar.gz: 68d96d55bc4a4ad89472b212db1b6e64a03f30936b0cc7cbc8e802505a133117c1fcf0a311f1a0f6b5c4e91255841f95cd7d4ef2963db665bb648d900aa2e05b
data/README.md CHANGED
@@ -265,9 +265,15 @@ 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 quoted triples in the _subject_ or _object_ position.
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`.
@@ -394,6 +400,9 @@ from BNode identity (i.e., they each entail the other)
394
400
  * {RDF::RDFV} - RDF Vocabulary (RDFV)
395
401
  * {RDF::XSD} - XML Schema (XSD)
396
402
 
403
+ ## Change Log
404
+
405
+ See [Release Notes on GitHub](https://github.com/ruby-rdf/rdf/releases)
397
406
 
398
407
  ## Dependencies
399
408
 
@@ -498,6 +507,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
498
507
  [SPARQL doc]: https://ruby-rdf.github.io/sparql
499
508
  [RDF 1.0]: https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/
500
509
  [RDF 1.1]: https://www.w3.org/TR/rdf11-concepts/
510
+ [RDF-star]: https://www.w3.org/2021/12/rdf-star.html
501
511
  [RDF 1.2]: https://www.w3.org/TR/rdf12-concepts/
502
512
  [SPARQL 1.1]: https://www.w3.org/TR/sparql11-query/
503
513
  [RDF.rb]: https://ruby-rdf.github.io/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.1
1
+ 3.3.2
@@ -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
- # * `:quoted_triples` supports RDF 1.2 quoted triples.
86
+ # * `:rdf_full` supports RDF 1.2 Full profile, including support for embedded Triple Terms.
87
+ # * `:quoted_triples` supports RDF-star quoted triples.
87
88
  # * `:base_direction` supports RDF 1.2 directional language-tagged strings.
88
89
  #
89
90
  # @param [Symbol, #to_sym] feature
@@ -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
@@ -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
- if statement.embedded? && respond_to?(:supports?) && !supports?(:quoted_triples)
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)
@@ -104,7 +104,8 @@ module RDF
104
104
  # @private
105
105
  # @see RDF::Enumerable#supports?
106
106
  def supports?(feature)
107
- return true if %i(graph_name quoted_triples).include?(feature)
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
 
@@ -305,8 +305,9 @@ module RDF
305
305
  # @private
306
306
  # @see RDF::Mutable#insert
307
307
  def insert_statement(statement)
308
- if statement.embedded? && !@data.supports?(:quoted_triples)
309
- raise ArgumentError, "Graph does not support quoted triples"
308
+ # FIXME: quoted triples are now deprecated
309
+ if statement.embedded? && !(@data.supports?(:quoted_triples) || @data.supports?(:rdf_full))
310
+ raise ArgumentError, "Graph does not support the RDF Full profile"
310
311
  end
311
312
  if statement.object && statement.object.literal? && statement.object.direction? && !@data.supports?(:base_direction)
312
313
  raise ArgumentError, "Graph does not support directional languaged-tagged strings"
@@ -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.downcase.to_sym if direction
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.
@@ -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] :quoted used as a marker to record that this statement quoted and appears as the subject or object of another RDF::Statement.
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] :quoted used as a marker to record that this statement quoted and appears as the subject or object of another RDF::Statement.
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
data/lib/rdf/model/uri.rb CHANGED
@@ -70,10 +70,10 @@ 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("(?:(?://#{IAUTHORITY}(?:#{IPATH_ABEMPTY}))|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_NOSCHEME})|(?:#{IPATH_EMPTY}))").freeze
74
- IRELATIVE_REF = Regexp.compile("^#{IRELATIVE_PART}(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
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("(?:(?://#{IAUTHORITY}#{IPATH_ABEMPTY})|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_ROOTLESS})|(?:#{IPATH_EMPTY}))").freeze
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
@@ -1240,17 +1240,18 @@ module RDF
1240
1240
  query.to_s.split('&').
1241
1241
  inject(return_type == Hash ? {} : []) do |memo,kv|
1242
1242
  k,v = kv.to_s.split('=', 2)
1243
- next if k.to_s.empty?
1244
- k = CGI.unescape(k)
1245
- v = CGI.unescape(v) if v
1246
- if return_type == Hash
1247
- case memo[k]
1248
- when nil then memo[k] = v
1249
- when Array then memo[k] << v
1250
- else memo[k] = [memo[k], v]
1243
+ unless k.to_s.empty?
1244
+ k = CGI.unescape(k)
1245
+ v = CGI.unescape(v) if v
1246
+ if return_type == Hash
1247
+ case memo[k]
1248
+ when nil then memo[k] = v
1249
+ when Array then memo[k] << v
1250
+ else memo[k] = [memo[k], v]
1251
+ end
1252
+ else
1253
+ memo << [k, v].compact
1251
1254
  end
1252
- else
1253
- memo << [k, v].compact
1254
1255
  end
1255
1256
  memo
1256
1257
  end
@@ -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 `string`.
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 [String, #to_s] string
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?(string)
212
- to_s.start_with?(string.to_s)
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)
@@ -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 = 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
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
- ST_START = /^<</.freeze
74
- ST_END = /^\s*>>/.freeze
73
+ TT_START = /^<<\(/.freeze
74
+ TT_END = /^\s*\)>>/.freeze
75
+
76
+ QT_START = /^<</.freeze
77
+ QT_END = /^\s*>>/.freeze
75
78
 
76
79
  # @see http://www.w3.org/TR/rdf-testcases/#ntrip_grammar
77
80
  COMMENT = /^#\s*(.*)$/.freeze
@@ -208,7 +211,7 @@ module RDF::NTriples
208
211
  begin
209
212
  read_statement
210
213
  rescue RDF::ReaderError
211
- value = read_uriref || read_node || read_literal || read_quotedTriple
214
+ value = read_uriref || read_node || read_literal || read_tripleTerm || read_quotedTriple
212
215
  log_recover
213
216
  value
214
217
  end
@@ -226,7 +229,7 @@ module RDF::NTriples
226
229
  unless blank? || read_comment
227
230
  subject = read_uriref || read_node || read_quotedTriple || fail_subject
228
231
  predicate = read_uriref(intern: true) || fail_predicate
229
- object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
232
+ object = read_uriref || read_node || read_literal || read_tripleTerm || read_quotedTriple || fail_object
230
233
 
231
234
  if validate? && !read_eos
232
235
  log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
@@ -242,12 +245,29 @@ module RDF::NTriples
242
245
 
243
246
  ##
244
247
  # @return [RDF::Statement]
248
+ def read_tripleTerm
249
+ if @options[:rdfstar] && match(TT_START)
250
+ subject = read_uriref || read_node || fail_subject
251
+ predicate = read_uriref(intern: true) || fail_predicate
252
+ object = read_uriref || read_node || read_literal || read_tripleTerm || fail_object
253
+ if !match(TT_END)
254
+ log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
255
+ end
256
+ RDF::Statement.new(subject, predicate, object, tripleTerm: true)
257
+ end
258
+ end
259
+
260
+ ##
261
+ # @return [RDF::Statement]
262
+ # @deprecated Quoted triples are now deprecated
245
263
  def read_quotedTriple
246
- if @options[:rdfstar] && match(ST_START)
264
+ if @options[:rdfstar] && !match(TT_START) && match(QT_START)
265
+ warn "[DEPRECATION] RDF-star quoted triples are deprecated and will be removed in a future version.\n" +
266
+ "Called from #{Gem.location_of_caller.join(':')}"
247
267
  subject = read_uriref || read_node || read_quotedTriple || fail_subject
248
268
  predicate = read_uriref(intern: true) || fail_predicate
249
269
  object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
250
- if !match(ST_END)
270
+ if !match(QT_END)
251
271
  log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
252
272
  end
253
273
  RDF::Statement.new(subject, predicate, object, quoted: true)
@@ -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
- # ## Quoted Triples
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
  #
@@ -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}.
@@ -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
- # Named queries either match against a specifically named
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
- # Names that are against unbound variables match either default
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
- # Named queries either match against a specifically named
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
- # Names that are against unbound variables match either default
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
- # Named queries either match against a specifically named
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
- # Names that are against unbound variables match either default
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`.
@@ -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,6 +272,7 @@ 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
275
+ when :rdf_full then true
273
276
  when :quoted_triples then true
274
277
  when :base_direction then true
275
278
  when :snapshots then true
@@ -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
- when RDF::Statement then format_quotedTriple(term, **options)
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}#format_statement") # override in subclasses
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.1
4
+ version: 3.3.2
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: 2023-09-11 00:00:00.000000000 Z
13
+ date: 2024-07-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: link_header
@@ -46,6 +46,40 @@ dependencies:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0.2'
49
+ - !ruby/object:Gem::Dependency
50
+ name: bigdecimal
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.1'
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 3.1.5
59
+ type: :runtime
60
+ prerelease: false
61
+ version_requirements: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - "~>"
64
+ - !ruby/object:Gem::Version
65
+ version: '3.1'
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: base64
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.2'
49
83
  - !ruby/object:Gem::Dependency
50
84
  name: rdf-spec
51
85
  requirement: !ruby/object:Gem::Requirement
@@ -122,14 +156,14 @@ dependencies:
122
156
  requirements:
123
157
  - - "~>"
124
158
  - !ruby/object:Gem::Version
125
- version: '3.12'
159
+ version: '3.13'
126
160
  type: :development
127
161
  prerelease: false
128
162
  version_requirements: !ruby/object:Gem::Requirement
129
163
  requirements:
130
164
  - - "~>"
131
165
  - !ruby/object:Gem::Version
132
- version: '3.12'
166
+ version: '3.13'
133
167
  - !ruby/object:Gem::Dependency
134
168
  name: rspec-its
135
169
  requirement: !ruby/object:Gem::Requirement
@@ -150,14 +184,14 @@ dependencies:
150
184
  requirements:
151
185
  - - "~>"
152
186
  - !ruby/object:Gem::Version
153
- version: '3.19'
187
+ version: '3.23'
154
188
  type: :development
155
189
  prerelease: false
156
190
  version_requirements: !ruby/object:Gem::Requirement
157
191
  requirements:
158
192
  - - "~>"
159
193
  - !ruby/object:Gem::Version
160
- version: '3.19'
194
+ version: '3.23'
161
195
  - !ruby/object:Gem::Dependency
162
196
  name: yard
163
197
  requirement: !ruby/object:Gem::Requirement