Skip to content

Commit 9a7adc2

Browse files
committed
Finish 3.2.0
2 parents 95d9fcf + 978870c commit 9a7adc2

25 files changed

+138
-199
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@ jobs:
2121
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
2222
runs-on: ubuntu-latest
2323
env:
24-
CI: true
25-
ALLOW_FAILURES: false # ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
24+
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
2625
strategy:
2726
fail-fast: false
2827
matrix:
2928
ruby:
30-
- 2.4
31-
- 2.5
3229
- 2.6
3330
- 2.7
3431
- 3.0
32+
- 3.1
3533
- ruby-head
3634
- jruby
3735
steps:
@@ -44,5 +42,9 @@ jobs:
4442
- name: Install dependencies
4543
run: bundle install --jobs 4 --retry 3
4644
- name: Run tests
47-
run: bundle exec rspec spec || $ALLOW_FAILURES
48-
45+
run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
46+
- name: Coveralls GitHub Action
47+
uses: coverallsapp/[email protected]
48+
if: "matrix.ruby == '3.0'"
49+
with:
50+
github-token: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ group :test do
3131
gem "rake"
3232
gem "equivalent-xml"
3333
gem 'fasterer'
34-
gem 'simplecov', '~> 0.16', platforms: :mri
35-
gem 'coveralls', '~> 0.8', platforms: :mri
34+
gem 'simplecov', '~> 0.21', platforms: :mri
35+
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
3636
end

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,16 @@ from BNode identity (i.e., they each entail the other)
398398

399399
## Dependencies
400400

401-
* [Ruby](https://ruby-lang.org/) (>= 2.2)
401+
* [Ruby](https://ruby-lang.org/) (>= 2.6)
402402
* [LinkHeader][] (>= 0.0.8)
403-
* Soft dependency on [RestClient][] (>= 1.7)
403+
* Soft dependency on [RestClient][] (>= 2.1)
404404

405405
## Installation
406406

407407
The recommended installation method is via [RubyGems](https://rubygems.org/).
408408
To install the latest official release of RDF.rb, do:
409409

410-
% [sudo] gem install rdf # Ruby 2+
410+
% [sudo] gem install rdf # Ruby 2.6+
411411

412412
## Download
413413

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.15
1+
3.2.0

etc/n-triples-star.ebnf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[1] ntriplesDoc ::= triple? (EOL triple)* EOL?
2-
[2] triple ::= subject predicate object '.'
3-
[3] subject ::= IRIREF | BLANK_NODE_LABEL | embTriple
4-
[4] predicate ::= IRIREF
5-
[5] object ::= IRIREF | BLANK_NODE_LABEL | literal | embTriple
6-
[6] literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)?
7-
[7] embTriple ::= '<<' subject predicate object '>>'
1+
[1] ntriplesDoc ::= triple? (EOL triple)* EOL?
2+
[2] triple ::= subject predicate object '.'
3+
[3] subject ::= IRIREF | BLANK_NODE_LABEL | quotedTriple
4+
[4] predicate ::= IRIREF
5+
[5] object ::= IRIREF | BLANK_NODE_LABEL | literal | quotedTriple
6+
[6] literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)?
7+
[7] quotedTriple ::= '<<' subject predicate object '>>'

lib/rdf/model/literal.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,20 @@ def initialize(value, language: nil, datatype: nil, lexical: nil, validate: fals
166166
@object = value.freeze
167167
@string = lexical if lexical
168168
@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)
171171
@language = language.to_s.downcase.to_sym if language
172172
@datatype = RDF::URI(datatype).freeze if datatype
173173
@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")
175175
end
176176

177177
##
178178
# Returns the value as a string.
179179
#
180180
# @return [String]
181181
def value
182-
@string || to_s
182+
instance_variable_defined?(:@string) && @string || to_s
183183
end
184184

185185
##
@@ -431,12 +431,10 @@ def comperable_datatype?(other)
431431
end
432432

433433
##
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.
436435
#
437436
# Used for <=> operator.
438437
#
439-
# This behavior is intuited from SPARQL data-r2/expr-equal/eq-2-2
440438
# @return [Boolean]
441439
def comperable_datatype2?(other)
442440
case self
@@ -445,13 +443,9 @@ def comperable_datatype2?(other)
445443
when RDF::Literal::Numeric, RDF::Literal::Boolean
446444
true
447445
else
448-
self.plain? || other.plain? ||
449-
self.language? || other.language? ||
450-
self.datatype == other.datatype
446+
false
451447
end
452448
else
453-
self.plain? || other.plain? ||
454-
self.language? || other.language? ||
455449
self.datatype == other.datatype
456450
end
457451
end

lib/rdf/model/literal/double.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def canonicalize!
4343
# Can't use simple %f transformation due to special requirements from
4444
# N3 tests in representation
4545
@string = case
46+
when @object.nil? then 'NaN'
4647
when @object.nan? then 'NaN'
4748
when @object.infinite? then @object.to_s[0...-'inity'.length].upcase
4849
when @object.zero? then '0.0E0'

lib/rdf/model/uri.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,22 @@ def parent
621621
end
622622

623623
##
624-
# Returns a qualified name (QName) for this URI based on available vocabularies, if possible.
624+
# Returns a qualified name (QName) as a tuple of `[prefix, suffix]` for this URI based on available vocabularies, if possible.
625625
#
626626
# @example
627627
# RDF::URI('http://www.w3.org/2000/01/rdf-schema#').qname #=> [:rdfs, nil]
628628
# RDF::URI('http://www.w3.org/2000/01/rdf-schema#label').qname #=> [:rdfs, :label]
629629
# RDF::RDFS.label.qname #=> [:rdfs, :label]
630630
#
631+
# @param [Hash{Symbol => String}] prefixes
632+
# Explicit set of prefixes to look for matches, defaults to loaded vocabularies.
631633
# @return [Array(Symbol, Symbol)] or `nil` if no QName found
632-
def qname
633-
if self.to_s =~ %r([:/#]([^:/#]*)$)
634+
def qname(prefixes: nil)
635+
if prefixes
636+
prefixes.each do |prefix, uri|
637+
return [prefix, self.to_s[uri.length..-1].to_sym] if self.start_with?(uri)
638+
end
639+
elsif self.to_s =~ %r([:/#]([^:/#]*)$)
634640
local_name = $1
635641
vocab_uri = local_name.empty? ? self.to_s : self.to_s[0...-(local_name.length)]
636642
Vocabulary.each do |vocab|
@@ -655,9 +661,11 @@ def qname
655661
##
656662
# Returns a string version of the QName or the full IRI
657663
#
664+
# @param [Hash{Symbol => String}] prefixes
665+
# Explicit set of prefixes to look for matches, defaults to loaded vocabularies.
658666
# @return [String] or `nil`
659-
def pname
660-
(q = self.qname) ? q.join(":") : to_s
667+
def pname(prefixes: nil)
668+
(q = self.qname(prefixes: prefixes)) ? q.join(":") : to_s
661669
end
662670

663671
##

lib/rdf/nquads.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ def read_triple
6969

7070
begin
7171
unless blank? || read_comment
72-
subject = read_uriref || read_node || read_embTriple || fail_subject
72+
subject = read_uriref || read_node || read_quotedTriple || fail_subject
7373
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
7575
graph_name = read_uriref || read_node
7676
if validate? && !read_eos
7777
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)

lib/rdf/ntriples/reader.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def read_value
213213
begin
214214
read_statement
215215
rescue RDF::ReaderError
216-
value = read_uriref || read_node || read_literal || read_embTriple
216+
value = read_uriref || read_node || read_literal || read_quotedTriple
217217
log_recover
218218
value
219219
end
@@ -229,9 +229,9 @@ def read_triple
229229

230230
begin
231231
unless blank? || read_comment
232-
subject = read_uriref || read_node || read_embTriple || fail_subject
232+
subject = read_uriref || read_node || read_quotedTriple || fail_subject
233233
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
235235

236236
if validate? && !read_eos
237237
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
@@ -247,11 +247,11 @@ def read_triple
247247

248248
##
249249
# @return [RDF::Statement]
250-
def read_embTriple
250+
def read_quotedTriple
251251
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
253253
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
255255
if !match(ST_END)
256256
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
257257
end

lib/rdf/ntriples/writer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def format_statement(statement, **options)
227227
# @param [RDF::Statement] statement
228228
# @param [Hash{Symbol => Object}] options ({})
229229
# @return [String]
230-
def format_embTriple(statement, **options)
230+
def format_quotedTriple(statement, **options)
231231
"<<%s %s %s>>" % statement.to_a.map { |value| format_term(value, **options) }
232232
end
233233
##

lib/rdf/reader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ def current_line
647647
##
648648
# @return [String]
649649
def readline
650-
@line = @line_rest || @input.readline
650+
@line = instance_variable_defined?(:@line_rest) && @line_rest || @input.readline
651651
@line, @line_rest = @line.split("\r", 2)
652652
@line = String.new if @line.nil? # not frozen
653653
@line.chomp!

0 commit comments

Comments
 (0)