rdf 3.1.15 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8747674533ca06af62b3ee536ea4342be3c8bedc8831b1a1838e244d927263cb
4
- data.tar.gz: fbc0593916678f9f696d4c461b29df01549da5af7d436b700d66735f5350054d
3
+ metadata.gz: fac2b932398cb302e6b2ecf300e6508879ed43314c52822d7a7ae9482127ea05
4
+ data.tar.gz: 6f78f54676b45f1bfd4767b30b545ec3016de440fcb8d5803ead213eed0e799d
5
5
  SHA512:
6
- metadata.gz: fb56f5b72af92421afb2216ca5d1dec10907860a2f1ad069e4d69e37ee3126219dfb0c60fab256c1088424b9a8dcc42f6637e98b1c52258cc88163b394e06fc5
7
- data.tar.gz: dcd897b9313decf48df3a89d4e8885ac74da1b966d194c28faa56a2edff2f4b123d093322655985ae1c0c059c6e8e49be9f18bbc9b1ef9c87634394d9090064b
6
+ metadata.gz: fa02358aa8f3362695cd433767c966a5c47fc3ba4c4bc8b95952e207dbf1e693a3468ea75735c34461d012b9efcd8f72e842d007e4dd1239b26d480d9e4f3f4c
7
+ data.tar.gz: e524ebef2e88903b3c8b0a48aa7b15b843924a8f6bc97fe06f524378d101409b1d88c07756b6a1be8002a38648b03d4ab362b6033f53bd810d05cc6dee141194
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This is a pure-Ruby library for working with [Resource Description Framework
4
4
  (RDF)][RDF] data.
5
5
 
6
- * <https://ruby-rdf.github.com/rdf>
6
+ * <https://ruby-rdf.github.io/rdf>
7
7
 
8
8
  [![Gem Version](https://badge.fury.io/rb/rdf.png)](https://badge.fury.io/rb/rdf)
9
9
  [![Build Status](https://github.com/ruby-rdf/rdf/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rdf/actions?query=workflow%3ACI)
@@ -141,11 +141,11 @@ or
141
141
  ### Reading RDF data in the [N-Triples][] format
142
142
 
143
143
  require 'rdf/ntriples'
144
- graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nt")
144
+ graph = RDF::Graph.load("https://ruby-rdf.github.io/rdf/etc/doap.nt")
145
145
 
146
146
  or
147
147
 
148
- RDF::Reader.open("https://ruby-rdf.github.com/rdf/etc/doap.nt") do |reader|
148
+ RDF::Reader.open("https://ruby-rdf.github.io/rdf/etc/doap.nt") do |reader|
149
149
  reader.each_statement do |statement|
150
150
  puts statement.inspect
151
151
  end
@@ -160,13 +160,13 @@ MimeType or file extension, where available.
160
160
 
161
161
  require 'rdf/nquads'
162
162
 
163
- graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nq", format: :nquads)
163
+ graph = RDF::Graph.load("https://ruby-rdf.github.io/rdf/etc/doap.nq", format: :nquads)
164
164
 
165
165
  A specific sub-type of Reader can also be invoked directly:
166
166
 
167
167
  require 'rdf/nquads'
168
168
 
169
- RDF::NQuads::Reader.open("https://ruby-rdf.github.com/rdf/etc/doap.nq") do |reader|
169
+ RDF::NQuads::Reader.open("https://ruby-rdf.github.io/rdf/etc/doap.nq") do |reader|
170
170
  reader.each_statement do |statement|
171
171
  puts statement.inspect
172
172
  end
@@ -220,7 +220,7 @@ Note that no prefixes are loaded automatically, however they can be provided as
220
220
 
221
221
  require 'rdf/ntriples'
222
222
 
223
- graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nt")
223
+ graph = RDF::Graph.load("https://ruby-rdf.github.io/rdf/etc/doap.nt")
224
224
  query = RDF::Query.new({
225
225
  person: {
226
226
  RDF.type => FOAF.Person,
@@ -295,7 +295,7 @@ Readers support a boolean valued `rdfstar` option.
295
295
 
296
296
  ## Documentation
297
297
 
298
- <https://rubydoc.info/github/ruby-rdf/rdf>
298
+ <https://ruby-rdf.github.io/rdf>
299
299
 
300
300
  ### RDF Object Model
301
301
 
@@ -309,7 +309,7 @@ Readers support a boolean valued `rdfstar` option.
309
309
  * {RDF::Literal::Double}
310
310
  * {RDF::Literal::Integer}
311
311
  * {RDF::Literal::Time}
312
- * [RDF::XSD](https://rubydoc.info/github/gkellogg/rdf-xsd) (extension)
312
+ * [RDF::XSD](https://ruby-rdf.github.io/rdf-xsd) (extension)
313
313
  * {RDF::Resource}
314
314
  * {RDF::Node}
315
315
  * {RDF::URI}
@@ -371,10 +371,10 @@ from BNode identity (i.e., they each entail the other)
371
371
  * {RDF::Mutable}
372
372
  * {RDF::Durable}
373
373
  * {RDF::Transaction}
374
- * [RDF::AllegroGraph](https://rubydoc.info/github/ruby-rdf/rdf-agraph) (extension)
375
- * [RDF::Mongo](https://rubydoc.info/github/ruby-rdf/rdf-mongo) (extension)
376
- * [RDF::DataObjects](https://rubydoc.info/github/ruby-rdf/rdf-do) (extension)
377
- * [RDF::Sesame](https://rubydoc.info/github/ruby-rdf/rdf-sesame) (extension)
374
+ * [RDF::AllegroGraph](https://ruby-rdf.github.io/rdf-agraph) (extension)
375
+ * [RDF::Mongo](https://ruby-rdf.github.io/rdf-mongo) (extension)
376
+ * [RDF::DataObjects](https://ruby-rdf.github.io/rdf-do) (extension)
377
+ * [RDF::Sesame](https://ruby-rdf.github.io/rdf-sesame) (extension)
378
378
 
379
379
  ### RDF Querying
380
380
 
@@ -384,7 +384,7 @@ from BNode identity (i.e., they each entail the other)
384
384
  * {RDF::Query::Solution}
385
385
  * {RDF::Query::Solutions}
386
386
  * {RDF::Query::Variable}
387
- * [SPARQL](https://rubydoc.info/github/ruby-rdf/sparql) (extension)
387
+ * [SPARQL](https://ruby-rdf.github.io/sparql) (extension)
388
388
 
389
389
 
390
390
  ### RDF Vocabularies
@@ -398,16 +398,16 @@ from BNode identity (i.e., they each entail the other)
398
398
 
399
399
  ## Dependencies
400
400
 
401
- * [Ruby](https://ruby-lang.org/) (>= 2.2)
401
+ * [Ruby](https://ruby-lang.org/) (>= 2.6)
402
402
  * [LinkHeader][] (>= 0.0.8)
403
- * Soft dependency on [RestClient][] (>= 1.7)
403
+ * Soft dependency on [RestClient][] (>= 2.1)
404
404
 
405
405
  ## Installation
406
406
 
407
407
  The recommended installation method is via [RubyGems](https://rubygems.org/).
408
408
  To install the latest official release of RDF.rb, do:
409
409
 
410
- % [sudo] gem install rdf # Ruby 2+
410
+ % [sudo] gem install rdf # Ruby 2.6+
411
411
 
412
412
  ## Download
413
413
 
@@ -422,7 +422,7 @@ follows:
422
422
 
423
423
  ## Resources
424
424
 
425
- * <https://rubydoc.info/github/ruby-rdf/rdf>
425
+ * <https://ruby-rdf.github.io/rdf>
426
426
  * <https://github.com/ruby-rdf/rdf>
427
427
  * <https://rubygems.org/gems/rdf>
428
428
  * <https://www.ohloh.net/p/rdf>
@@ -486,33 +486,33 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
486
486
  [YARD]: https://yardoc.org/
487
487
  [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
488
488
  [PDD]: https://unlicense.org/#unlicensing-contributions
489
- [JSONLD doc]: https://rubydoc.info/github/ruby-rdf/json-ld
490
- [LinkedData doc]: https://rubydoc.info/github/ruby-rdf/linkeddata
491
- [Microdata doc]: https://rubydoc.info/github/ruby-rdf/rdf-microdata
492
- [N3 doc]: https://rubydoc.info/github/ruby-rdf/rdf-n3
493
- [RDFa doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfa
494
- [RDFXML doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfxml
495
- [Turtle doc]: https://rubydoc.info/github/ruby-rdf/rdf-turtle
496
- [SPARQL doc]: https://rubydoc.info/github/ruby-rdf/sparql
489
+ [JSONLD doc]: https://ruby-rdf.github.io/json-ld
490
+ [LinkedData doc]: https://ruby-rdf.github.io/linkeddata
491
+ [Microdata doc]: https://ruby-rdf.github.io/rdf-microdata
492
+ [N3 doc]: https://ruby-rdf.github.io/rdf-n3
493
+ [RDFa doc]: https://ruby-rdf.github.io/rdf-rdfa
494
+ [RDFXML doc]: https://ruby-rdf.github.io/rdf-rdfxml
495
+ [Turtle doc]: https://ruby-rdf.github.io/rdf-turtle
496
+ [SPARQL doc]: https://ruby-rdf.github.io/sparql
497
497
  [RDF 1.0]: https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/
498
498
  [RDF 1.1]: https://www.w3.org/TR/rdf11-concepts/
499
499
  [SPARQL 1.1]: https://www.w3.org/TR/sparql11-query/
500
- [RDF.rb]: https://ruby-rdf.github.com/
501
- [RDF::DO]: https://ruby-rdf.github.com/rdf-do
502
- [RDF::Mongo]: https://ruby-rdf.github.com/rdf-mongo
503
- [RDF::Sesame]: https://ruby-rdf.github.com/rdf-sesame
504
- [RDF::JSON]: https://ruby-rdf.github.com/rdf-json
505
- [RDF::Microdata]: https://ruby-rdf.github.com/rdf-microdata
506
- [RDF::N3]: https://ruby-rdf.github.com/rdf-n3
507
- [RDF::RDFa]: https://ruby-rdf.github.com/rdf-rdfa
508
- [RDF::RDFXML]: https://ruby-rdf.github.com/rdf-rdfxml
509
- [RDF::TriG]: https://ruby-rdf.github.com/rdf-trig
510
- [RDF::TriX]: https://ruby-rdf.github.com/rdf-trix
511
- [RDF::Turtle]: https://ruby-rdf.github.com/rdf-turtle
512
- [RDF::Raptor]: https://ruby-rdf.github.com/rdf-raptor
500
+ [RDF.rb]: https://ruby-rdf.github.io/
501
+ [RDF::DO]: https://ruby-rdf.github.io/rdf-do
502
+ [RDF::Mongo]: https://ruby-rdf.github.io/rdf-mongo
503
+ [RDF::Sesame]: https://ruby-rdf.github.io/rdf-sesame
504
+ [RDF::JSON]: https://ruby-rdf.github.io/rdf-json
505
+ [RDF::Microdata]: https://ruby-rdf.github.io/rdf-microdata
506
+ [RDF::N3]: https://ruby-rdf.github.io/rdf-n3
507
+ [RDF::RDFa]: https://ruby-rdf.github.io/rdf-rdfa
508
+ [RDF::RDFXML]: https://ruby-rdf.github.io/rdf-rdfxml
509
+ [RDF::TriG]: https://ruby-rdf.github.io/rdf-trig
510
+ [RDF::TriX]: https://ruby-rdf.github.io/rdf-trix
511
+ [RDF::Turtle]: https://ruby-rdf.github.io/rdf-turtle
512
+ [RDF::Raptor]: https://ruby-rdf.github.io/rdf-raptor
513
513
  [RDF*]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html
514
- [LinkedData]: https://ruby-rdf.github.com/linkeddata
515
- [JSON::LD]: https://ruby-rdf.github.com/json-ld
514
+ [LinkedData]: https://ruby-rdf.github.io/linkeddata
515
+ [JSON::LD]: https://ruby-rdf.github.io/json-ld
516
516
  [RestClient]: https://rubygems.org/gems/rest-client
517
517
  [RestClient Components]: https://rubygems.org/gems/rest-client-components
518
518
  [Rack::Cache]: https://rtomayko.github.io/rack-cache/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.15
1
+ 3.2.4
@@ -2,9 +2,13 @@ module RDF
2
2
  ##
3
3
  # @since 0.2.0
4
4
  module Countable
5
- autoload :Enumerator, 'rdf/mixin/enumerator'
6
5
  extend RDF::Util::Aliasing::LateBound
7
6
 
7
+ # Extends Enumerator with {Countable}, which is used by {Countable#enum_for}
8
+ class Enumerator < ::Enumerator
9
+ include RDF::Countable
10
+ end
11
+
8
12
  ##
9
13
  # Returns `true` if `self` contains no RDF statements.
10
14
  #
@@ -57,11 +57,23 @@ module RDF
57
57
  # @see RDF::Graph
58
58
  # @see RDF::Repository
59
59
  module Enumerable
60
- autoload :Enumerator, 'rdf/mixin/enumerator'
61
60
  extend RDF::Util::Aliasing::LateBound
62
61
  include ::Enumerable
63
62
  include RDF::Countable # NOTE: must come after ::Enumerable
64
63
 
64
+ # Extends Enumerator with {Queryable} and {Enumerable}, which is used by {Enumerable#each_statement} and {Queryable#enum_for}
65
+ class Enumerator < ::Enumerator
66
+ include RDF::Queryable
67
+ include RDF::Enumerable
68
+
69
+ ##
70
+ # @return [Array]
71
+ # @note Make sure returned arrays are also queryable
72
+ def to_a
73
+ return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
74
+ end
75
+ end
76
+
65
77
  ##
66
78
  # Returns `true` if this enumerable supports the given `feature`.
67
79
  #
@@ -9,9 +9,21 @@ module RDF
9
9
  # @see RDF::Graph
10
10
  # @see RDF::Repository
11
11
  module Queryable
12
- autoload :Enumerator, 'rdf/mixin/enumerator'
13
12
  include ::Enumerable
14
13
 
14
+ # Extends Enumerator with {Queryable} and {Enumerable}, which is used by {Enumerable#each_statement} and {Queryable#enum_for}
15
+ class Enumerator < ::Enumerator
16
+ include RDF::Queryable
17
+ include RDF::Enumerable
18
+
19
+ ##
20
+ # @return [Array]
21
+ # @note Make sure returned arrays are also queryable
22
+ def to_a
23
+ return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
24
+ end
25
+ end
26
+
15
27
  ##
16
28
  # Queries `self` for RDF statements matching the given `pattern`.
17
29
  #
@@ -476,7 +476,7 @@ module RDF
476
476
  # @return [Integer]
477
477
  # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-3C-3D-3E
478
478
  def eql?(other)
479
- to_a.eql? other.to_a # TODO: optimize this
479
+ to_a.eql? Array(other)
480
480
  end
481
481
 
482
482
  ##
@@ -43,6 +43,7 @@ module RDF; class Literal
43
43
  # Can't use simple %f transformation due to special requirements from
44
44
  # N3 tests in representation
45
45
  @string = case
46
+ when @object.nil? then 'NaN'
46
47
  when @object.nan? then 'NaN'
47
48
  when @object.infinite? then @object.to_s[0...-'inity'.length].upcase
48
49
  when @object.zero? then '0.0E0'
@@ -166,12 +166,12 @@ module RDF
166
166
  @object = value.freeze
167
167
  @string = lexical if lexical
168
168
  @string = value if !defined?(@string) && value.is_a?(String)
169
- @string = @string.encode(Encoding::UTF_8).freeze if @string
170
- @object = @string if @string && @object.is_a?(String)
169
+ @string = @string.encode(Encoding::UTF_8).freeze if instance_variable_defined?(:@string)
170
+ @object = @string if instance_variable_defined?(:@string) && @object.is_a?(String)
171
171
  @language = language.to_s.downcase.to_sym if language
172
172
  @datatype = RDF::URI(datatype).freeze if datatype
173
173
  @datatype ||= self.class.const_get(:DATATYPE) if self.class.const_defined?(:DATATYPE)
174
- @datatype ||= @language ? RDF.langString : RDF::URI("http://www.w3.org/2001/XMLSchema#string")
174
+ @datatype ||= instance_variable_defined?(:@language) && @language ? RDF.langString : RDF::URI("http://www.w3.org/2001/XMLSchema#string")
175
175
  end
176
176
 
177
177
  ##
@@ -179,7 +179,7 @@ module RDF
179
179
  #
180
180
  # @return [String]
181
181
  def value
182
- @string || to_s
182
+ instance_variable_defined?(:@string) && @string || to_s
183
183
  end
184
184
 
185
185
  ##
@@ -431,12 +431,10 @@ module RDF
431
431
  end
432
432
 
433
433
  ##
434
- # Returns `true` if the literal has a datatype and the comparison should
435
- # return false instead of raise a type error.
434
+ # Returns `true` if the literals are comperable.
436
435
  #
437
436
  # Used for <=> operator.
438
437
  #
439
- # This behavior is intuited from SPARQL data-r2/expr-equal/eq-2-2
440
438
  # @return [Boolean]
441
439
  def comperable_datatype2?(other)
442
440
  case self
@@ -445,13 +443,9 @@ module RDF
445
443
  when RDF::Literal::Numeric, RDF::Literal::Boolean
446
444
  true
447
445
  else
448
- self.plain? || other.plain? ||
449
- self.language? || other.language? ||
450
- self.datatype == other.datatype
446
+ false
451
447
  end
452
448
  else
453
- self.plain? || other.plain? ||
454
- self.language? || other.language? ||
455
449
  self.datatype == other.datatype
456
450
  end
457
451
  end
@@ -71,6 +71,7 @@ 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
75
  # @return [RDF::Statement]
75
76
  #
76
77
  # @overload initialize(subject, predicate, object, **options)
@@ -83,6 +84,7 @@ module RDF
83
84
  # @option options [RDF::Term] :graph_name (nil)
84
85
  # Note, in RDF 1.1, a graph name MUST be an {Resource}.
85
86
  # @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.
86
88
  # @return [RDF::Statement]
87
89
  def initialize(subject = nil, predicate = nil, object = nil, options = {})
88
90
  if subject.is_a?(Hash)
@@ -209,7 +211,7 @@ module RDF
209
211
  ##
210
212
  # @return [Boolean]
211
213
  def quoted?
212
- false
214
+ !!@options[:quoted]
213
215
  end
214
216
 
215
217
  ##
data/lib/rdf/model/uri.rb CHANGED
@@ -111,6 +111,11 @@ module RDF
111
111
  tag tel turn turns tv urn javascript
112
112
  ).freeze
113
113
 
114
+ # Characters in a PName which must be escaped
115
+ # Note: not all reserved characters need to be escaped in SPARQL/Turtle, but they must be unescaped when encountered
116
+ PN_ESCAPE_CHARS = /[~\.!\$&'\(\)\*\+,;=\/\?\#@%]/.freeze
117
+ PN_ESCAPES = /\\#{Regexp.union(PN_ESCAPE_CHARS, /[\-_]/)}/.freeze
118
+
114
119
  ##
115
120
  # Cache size may be set through {RDF.config} using `uri_cache_size`.
116
121
  #
@@ -621,16 +626,26 @@ module RDF
621
626
  end
622
627
 
623
628
  ##
624
- # Returns a qualified name (QName) for this URI based on available vocabularies, if possible.
629
+ # Returns a qualified name (QName) as a tuple of `[prefix, suffix]` for this URI based on available vocabularies, if possible.
625
630
  #
626
631
  # @example
627
632
  # RDF::URI('http://www.w3.org/2000/01/rdf-schema#').qname #=> [:rdfs, nil]
628
633
  # RDF::URI('http://www.w3.org/2000/01/rdf-schema#label').qname #=> [:rdfs, :label]
629
634
  # RDF::RDFS.label.qname #=> [:rdfs, :label]
630
- #
631
- # @return [Array(Symbol, Symbol)] or `nil` if no QName found
632
- def qname
633
- if self.to_s =~ %r([:/#]([^:/#]*)$)
635
+ # RDF::Vocab::DC.title.qname(
636
+ # prefixes: {dcterms: 'http://purl.org/dc/terms/'}) #=> [:dcterms, :title]
637
+ #
638
+ # @note within this software, the term QName is used to describe the tuple of prefix and suffix for a given IRI, where the prefix identifies some defined vocabulary. This somewhat contrasts with the notion of a [Qualified Name](https://www.w3.org/TR/2006/REC-xml-names11-20060816/#ns-qualnames) from XML, which are a subset of Prefixed Names.
639
+ #
640
+ # @param [Hash{Symbol => String}] prefixes
641
+ # Explicit set of prefixes to look for matches, defaults to loaded vocabularies.
642
+ # @return [Array(Symbol, Symbol)] or `nil` if no QName found. The suffix component will not have [reserved characters](https://www.w3.org/TR/turtle/#reserved) escaped.
643
+ def qname(prefixes: nil)
644
+ if prefixes
645
+ prefixes.each do |prefix, uri|
646
+ return [prefix, self.to_s[uri.length..-1].to_sym] if self.start_with?(uri)
647
+ end
648
+ elsif self.to_s =~ %r([:/#]([^:/#]*)$)
634
649
  local_name = $1
635
650
  vocab_uri = local_name.empty? ? self.to_s : self.to_s[0...-(local_name.length)]
636
651
  Vocabulary.each do |vocab|
@@ -653,11 +668,25 @@ module RDF
653
668
  end
654
669
 
655
670
  ##
656
- # Returns a string version of the QName or the full IRI
671
+ # Returns a Prefixed Name (PName) or the full IRI with any [reserved characters](https://www.w3.org/TR/turtle/#reserved) in the suffix escaped.
672
+ #
673
+ # @example Using a custom prefix for creating a PNname.
674
+ # RDF::URI('http://purl.org/dc/terms/creator').
675
+ # pname(prefixes: {dcterms: 'http://purl.org/dc/terms/'})
676
+ # #=> "dcterms:creator"
657
677
  #
678
+ # @param [Hash{Symbol => String}] prefixes
679
+ # Explicit set of prefixes to look for matches, defaults to loaded vocabularies.
658
680
  # @return [String] or `nil`
659
- def pname
660
- (q = self.qname) ? q.join(":") : to_s
681
+ # @see #qname
682
+ # @see https://www.w3.org/TR/rdf-sparql-query/#prefNames
683
+ def pname(prefixes: nil)
684
+ q = self.qname(prefixes: prefixes)
685
+ return self.to_s unless q
686
+ prefix, suffix = q
687
+ suffix = suffix.to_s.gsub(PN_ESCAPE_CHARS) {|c| "\\#{c}"} if
688
+ suffix.to_s.match?(PN_ESCAPE_CHARS)
689
+ [prefix, suffix].join(":")
661
690
  end
662
691
 
663
692
  ##
data/lib/rdf/nquads.rb CHANGED
@@ -69,9 +69,9 @@ module RDF
69
69
 
70
70
  begin
71
71
  unless blank? || read_comment
72
- subject = read_uriref || read_node || read_embTriple || fail_subject
72
+ subject = read_uriref || read_node || read_quotedTriple || fail_subject
73
73
  predicate = read_uriref(intern: true) || fail_predicate
74
- object = read_uriref || read_node || read_literal || read_embTriple || fail_object
74
+ object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
75
75
  graph_name = read_uriref || read_node
76
76
  if validate? && !read_eos
77
77
  log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
@@ -213,7 +213,7 @@ module RDF::NTriples
213
213
  begin
214
214
  read_statement
215
215
  rescue RDF::ReaderError
216
- value = read_uriref || read_node || read_literal || read_embTriple
216
+ value = read_uriref || read_node || read_literal || read_quotedTriple
217
217
  log_recover
218
218
  value
219
219
  end
@@ -229,9 +229,9 @@ module RDF::NTriples
229
229
 
230
230
  begin
231
231
  unless blank? || read_comment
232
- subject = read_uriref || read_node || read_embTriple || fail_subject
232
+ subject = read_uriref || read_node || read_quotedTriple || fail_subject
233
233
  predicate = read_uriref(intern: true) || fail_predicate
234
- object = read_uriref || read_node || read_literal || read_embTriple || fail_object
234
+ object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
235
235
 
236
236
  if validate? && !read_eos
237
237
  log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
@@ -247,15 +247,15 @@ module RDF::NTriples
247
247
 
248
248
  ##
249
249
  # @return [RDF::Statement]
250
- def read_embTriple
250
+ def read_quotedTriple
251
251
  if @options[:rdfstar] && match(ST_START)
252
- subject = read_uriref || read_node || read_embTriple || fail_subject
252
+ subject = read_uriref || read_node || read_quotedTriple || fail_subject
253
253
  predicate = read_uriref(intern: true) || fail_predicate
254
- object = read_uriref || read_node || read_literal || read_embTriple || fail_object
254
+ object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
255
255
  if !match(ST_END)
256
256
  log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
257
257
  end
258
- RDF::Statement.new(subject, predicate, object)
258
+ RDF::Statement.new(subject, predicate, object, quoted: true)
259
259
  end
260
260
  end
261
261
 
@@ -227,7 +227,7 @@ module RDF::NTriples
227
227
  # @param [RDF::Statement] statement
228
228
  # @param [Hash{Symbol => Object}] options ({})
229
229
  # @return [String]
230
- def format_embTriple(statement, **options)
230
+ def format_quotedTriple(statement, **options)
231
231
  "<<%s %s %s>>" % statement.to_a.map { |value| format_term(value, **options) }
232
232
  end
233
233
  ##
data/lib/rdf/reader.rb CHANGED
@@ -647,7 +647,7 @@ module RDF
647
647
  ##
648
648
  # @return [String]
649
649
  def readline
650
- @line = @line_rest || @input.readline
650
+ @line = instance_variable_defined?(:@line_rest) && @line_rest || @input.readline
651
651
  @line, @line_rest = @line.split("\r", 2)
652
652
  @line = String.new if @line.nil? # not frozen
653
653
  @line.chomp!