Skip to content

Commit

Permalink
Finish 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 29, 2021
2 parents 95d9fcf + 978870c commit 9a7adc2
Show file tree
Hide file tree
Showing 25 changed files with 138 additions and 199 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ jobs:
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
runs-on: ubuntu-latest
env:
CI: true
ALLOW_FAILURES: false # ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
strategy:
fail-fast: false
matrix:
ruby:
- 2.4
- 2.5
- 2.6
- 2.7
- 3.0
- 3.1
- ruby-head
- jruby
steps:
Expand All @@ -44,5 +42,9 @@ jobs:
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Run tests
run: bundle exec rspec spec || $ALLOW_FAILURES

run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v1.1.2
if: "matrix.ruby == '3.0'"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ group :test do
gem "rake"
gem "equivalent-xml"
gem 'fasterer'
gem 'simplecov', '~> 0.16', platforms: :mri
gem 'coveralls', '~> 0.8', platforms: :mri
gem 'simplecov', '~> 0.21', platforms: :mri
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
end
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,16 +398,16 @@ from BNode identity (i.e., they each entail the other)

## Dependencies

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

## Installation

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

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

## Download

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.15
3.2.0
14 changes: 7 additions & 7 deletions etc/n-triples-star.ebnf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[1] ntriplesDoc ::= triple? (EOL triple)* EOL?
[2] triple ::= subject predicate object '.'
[3] subject ::= IRIREF | BLANK_NODE_LABEL | embTriple
[4] predicate ::= IRIREF
[5] object ::= IRIREF | BLANK_NODE_LABEL | literal | embTriple
[6] literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)?
[7] embTriple ::= '<<' subject predicate object '>>'
[1] ntriplesDoc ::= triple? (EOL triple)* EOL?
[2] triple ::= subject predicate object '.'
[3] subject ::= IRIREF | BLANK_NODE_LABEL | quotedTriple
[4] predicate ::= IRIREF
[5] object ::= IRIREF | BLANK_NODE_LABEL | literal | quotedTriple
[6] literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)?
[7] quotedTriple ::= '<<' subject predicate object '>>'
18 changes: 6 additions & 12 deletions lib/rdf/model/literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,20 @@ def initialize(value, language: nil, datatype: nil, lexical: nil, validate: fals
@object = value.freeze
@string = lexical if lexical
@string = value if !defined?(@string) && value.is_a?(String)
@string = @string.encode(Encoding::UTF_8).freeze if @string
@object = @string if @string && @object.is_a?(String)
@string = @string.encode(Encoding::UTF_8).freeze if instance_variable_defined?(:@string)
@object = @string if instance_variable_defined?(:@string) && @object.is_a?(String)
@language = language.to_s.downcase.to_sym if language
@datatype = RDF::URI(datatype).freeze if datatype
@datatype ||= self.class.const_get(:DATATYPE) if self.class.const_defined?(:DATATYPE)
@datatype ||= @language ? RDF.langString : RDF::URI("http://www.w3.org/2001/XMLSchema#string")
@datatype ||= instance_variable_defined?(:@language) && @language ? RDF.langString : RDF::URI("http://www.w3.org/2001/XMLSchema#string")
end

##
# Returns the value as a string.
#
# @return [String]
def value
@string || to_s
instance_variable_defined?(:@string) && @string || to_s
end

##
Expand Down Expand Up @@ -431,12 +431,10 @@ def comperable_datatype?(other)
end

##
# Returns `true` if the literal has a datatype and the comparison should
# return false instead of raise a type error.
# Returns `true` if the literals are comperable.
#
# Used for <=> operator.
#
# This behavior is intuited from SPARQL data-r2/expr-equal/eq-2-2
# @return [Boolean]
def comperable_datatype2?(other)
case self
Expand All @@ -445,13 +443,9 @@ def comperable_datatype2?(other)
when RDF::Literal::Numeric, RDF::Literal::Boolean
true
else
self.plain? || other.plain? ||
self.language? || other.language? ||
self.datatype == other.datatype
false
end
else
self.plain? || other.plain? ||
self.language? || other.language? ||
self.datatype == other.datatype
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/rdf/model/literal/double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def canonicalize!
# Can't use simple %f transformation due to special requirements from
# N3 tests in representation
@string = case
when @object.nil? then 'NaN'
when @object.nan? then 'NaN'
when @object.infinite? then @object.to_s[0...-'inity'.length].upcase
when @object.zero? then '0.0E0'
Expand Down
18 changes: 13 additions & 5 deletions lib/rdf/model/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,22 @@ def parent
end

##
# Returns a qualified name (QName) for this URI based on available vocabularies, if possible.
# Returns a qualified name (QName) as a tuple of `[prefix, suffix]` for this URI based on available vocabularies, if possible.
#
# @example
# RDF::URI('http://www.w3.org/2000/01/rdf-schema#').qname #=> [:rdfs, nil]
# RDF::URI('http://www.w3.org/2000/01/rdf-schema#label').qname #=> [:rdfs, :label]
# RDF::RDFS.label.qname #=> [:rdfs, :label]
#
# @param [Hash{Symbol => String}] prefixes
# Explicit set of prefixes to look for matches, defaults to loaded vocabularies.
# @return [Array(Symbol, Symbol)] or `nil` if no QName found
def qname
if self.to_s =~ %r([:/#]([^:/#]*)$)
def qname(prefixes: nil)
if prefixes
prefixes.each do |prefix, uri|
return [prefix, self.to_s[uri.length..-1].to_sym] if self.start_with?(uri)
end
elsif self.to_s =~ %r([:/#]([^:/#]*)$)
local_name = $1
vocab_uri = local_name.empty? ? self.to_s : self.to_s[0...-(local_name.length)]
Vocabulary.each do |vocab|
Expand All @@ -655,9 +661,11 @@ def qname
##
# Returns a string version of the QName or the full IRI
#
# @param [Hash{Symbol => String}] prefixes
# Explicit set of prefixes to look for matches, defaults to loaded vocabularies.
# @return [String] or `nil`
def pname
(q = self.qname) ? q.join(":") : to_s
def pname(prefixes: nil)
(q = self.qname(prefixes: prefixes)) ? q.join(":") : to_s
end

##
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf/nquads.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def read_triple

begin
unless blank? || read_comment
subject = read_uriref || read_node || read_embTriple || fail_subject
subject = read_uriref || read_node || read_quotedTriple || fail_subject
predicate = read_uriref(intern: true) || fail_predicate
object = read_uriref || read_node || read_literal || read_embTriple || fail_object
object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
graph_name = read_uriref || read_node
if validate? && !read_eos
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
Expand Down
12 changes: 6 additions & 6 deletions lib/rdf/ntriples/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def read_value
begin
read_statement
rescue RDF::ReaderError
value = read_uriref || read_node || read_literal || read_embTriple
value = read_uriref || read_node || read_literal || read_quotedTriple
log_recover
value
end
Expand All @@ -229,9 +229,9 @@ def read_triple

begin
unless blank? || read_comment
subject = read_uriref || read_node || read_embTriple || fail_subject
subject = read_uriref || read_node || read_quotedTriple || fail_subject
predicate = read_uriref(intern: true) || fail_predicate
object = read_uriref || read_node || read_literal || read_embTriple || fail_object
object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object

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

##
# @return [RDF::Statement]
def read_embTriple
def read_quotedTriple
if @options[:rdfstar] && match(ST_START)
subject = read_uriref || read_node || read_embTriple || fail_subject
subject = read_uriref || read_node || read_quotedTriple || fail_subject
predicate = read_uriref(intern: true) || fail_predicate
object = read_uriref || read_node || read_literal || read_embTriple || fail_object
object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
if !match(ST_END)
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/ntriples/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def format_statement(statement, **options)
# @param [RDF::Statement] statement
# @param [Hash{Symbol => Object}] options ({})
# @return [String]
def format_embTriple(statement, **options)
def format_quotedTriple(statement, **options)
"<<%s %s %s>>" % statement.to_a.map { |value| format_term(value, **options) }
end
##
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def current_line
##
# @return [String]
def readline
@line = @line_rest || @input.readline
@line = instance_variable_defined?(:@line_rest) && @line_rest || @input.readline
@line, @line_rest = @line.split("\r", 2)
@line = String.new if @line.nil? # not frozen
@line.chomp!
Expand Down

0 comments on commit 9a7adc2

Please sign in to comment.