Skip to content

Commit

Permalink
Finish 3.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Jul 5, 2024
2 parents 2b31abd + 2586399 commit e0b67d7
Show file tree
Hide file tree
Showing 33 changed files with 335 additions and 165 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['3.0', 3.1, 3.2, ruby-head, jruby]
ruby: ['3.0', 3.1, 3.2, 3.3, ruby-head, jruby]
steps:
- name: Clone repository
uses: actions/checkout@v3
Expand All @@ -39,7 +39,7 @@ jobs:
run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
if: "matrix.ruby == '3.0'"
if: "matrix.ruby == '3.3'"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
wintests:
Expand All @@ -48,12 +48,12 @@ jobs:
runs-on: windows-latest
env:
CI: true
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' || matrix.ruby == '3.1' }}
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
strategy:
fail-fast: false
matrix:
ruby:
- 3.1
- 3.2
steps:
- name: Clone repository
uses: actions/checkout@v3
Expand Down
92 changes: 0 additions & 92 deletions CHANGES.md

This file was deleted.

12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,15 @@ A separate [SPARQL][SPARQL doc] gem builds on basic BGP support to provide full
foaf[:name] #=> RDF::URI("http://xmlns.com/foaf/0.1/name")
foaf['mbox'] #=> RDF::URI("http://xmlns.com/foaf/0.1/mbox")

## RDF-star CG

[RDF.rb][] includes provisional support for [RDF-star][] with an N-Triples/N-Quads syntax for quoted triples in the _subject_ or _object_ position.

Support for RDF-star quoted triples is now deprecated, use RDF 1.2 triple terms instead.

## RDF 1.2

[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.
[RDF.rb][] includes provisional support for [RDF 1.2][] with an N-Triples/N-Quads syntax for triple terms in the _object_ position.
[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`.

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`.
Expand Down Expand Up @@ -394,6 +400,9 @@ from BNode identity (i.e., they each entail the other)
* {RDF::RDFV} - RDF Vocabulary (RDFV)
* {RDF::XSD} - XML Schema (XSD)

## Change Log

See [Release Notes on GitHub](https://github.com/ruby-rdf/rdf/releases)

## Dependencies

Expand Down Expand Up @@ -498,6 +507,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
[SPARQL doc]: https://ruby-rdf.github.io/sparql
[RDF 1.0]: https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts/
[RDF-star]: https://www.w3.org/2021/12/rdf-star.html
[RDF 1.2]: https://www.w3.org/TR/rdf12-concepts/
[SPARQL 1.1]: https://www.w3.org/TR/sparql11-query/
[RDF.rb]: https://ruby-rdf.github.io/
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.1
3.3.2
3 changes: 2 additions & 1 deletion etc/n-triples.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ ntriplesDoc ::= triple? (EOL triple)* EOL?
triple ::= subject predicate object '.'
subject ::= IRIREF | BLANK_NODE_LABEL | quotedTriple
predicate ::= IRIREF
object ::= IRIREF | BLANK_NODE_LABEL | literal | quotedTriple
object ::= IRIREF | BLANK_NODE_LABEL | literal | tripleTerm | quotedTriple
literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANG_DIR )?
tripleTerm ::= '<<' subject predicate object '>>'
quotedTriple ::= '<<' subject predicate object '>>'

@terminals
Expand Down
3 changes: 2 additions & 1 deletion lib/rdf/mixin/enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def to_a
# * `: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`.
# * `: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.
# * `: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.
# * `:quoted_triples` supports RDF 1.2 quoted triples.
# * `:rdf_full` supports RDF 1.2 Full profile, including support for embedded Triple Terms.
# * `:quoted_triples` supports RDF-star quoted triples.
# * `:base_direction` supports RDF 1.2 directional language-tagged strings.
#
# @param [Symbol, #to_sym] feature
Expand Down
2 changes: 2 additions & 0 deletions lib/rdf/mixin/queryable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def query_execute(query, **options, &block)
#
# Patterns may also have embedded patterns as either a subject or object, recursively.
#
# Patterns with a variable `graph_name` do not match the default graph.
#
# When matching, match an embedded pattern against embedded statements, recursively. (see {RDF::Query::Pattern#eql?})
#
# @param [RDF::Query::Pattern] pattern
Expand Down
5 changes: 3 additions & 2 deletions lib/rdf/mixin/writable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ def insert_graph(graph)
def insert_statements(statements)
each = statements.respond_to?(:each_statement) ? :each_statement : :each
statements.__send__(each) do |statement|
if statement.embedded? && respond_to?(:supports?) && !supports?(:quoted_triples)
# FIXME: quoted triples are now deprecated
if statement.embedded? && respond_to?(:supports?) && !(supports?(:quoted_triples) || supports?(:rdf_full))
raise ArgumentError, "Writable does not support quoted triples"
end
if statement.object && statement.object.literal? && statement.object.direction? && !supports?(:base_direction)
if statement.object && statement.object.literal? && statement.object.direction? && respond_to?(:supports?) && !supports?(:base_direction)
raise ArgumentError, "Writable does not support directional languaged-tagged strings"
end
insert_statement(statement)
Expand Down
3 changes: 2 additions & 1 deletion lib/rdf/model/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def isolation_level
# @private
# @see RDF::Enumerable#supports?
def supports?(feature)
return true if %i(graph_name quoted_triples).include?(feature)
# FIXME: quoted triples are now deprecated
return true if %i(graph_name quoted_triples rdf_full).include?(feature)
super
end

Expand Down
5 changes: 3 additions & 2 deletions lib/rdf/model/graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,9 @@ def query_pattern(pattern, **options, &block)
# @private
# @see RDF::Mutable#insert
def insert_statement(statement)
if statement.embedded? && !@data.supports?(:quoted_triples)
raise ArgumentError, "Graph does not support quoted triples"
# FIXME: quoted triples are now deprecated
if statement.embedded? && !(@data.supports?(:quoted_triples) || @data.supports?(:rdf_full))
raise ArgumentError, "Graph does not support the RDF Full profile"
end
if statement.object && statement.object.literal? && statement.object.direction? && !@data.supports?(:base_direction)
raise ArgumentError, "Graph does not support directional languaged-tagged strings"
Expand Down
12 changes: 11 additions & 1 deletion lib/rdf/model/literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def initialize(value, language: nil, datatype: nil, direction: nil, lexical: nil
@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
@direction = direction.to_s.downcase.to_sym if direction
@direction = direction.to_s.to_sym if direction
@datatype = RDF::URI(datatype).freeze if datatype
@datatype ||= self.class.const_get(:DATATYPE) if self.class.const_defined?(:DATATYPE)
@datatype ||= if instance_variable_defined?(:@language) && @language &&
Expand Down Expand Up @@ -451,6 +451,16 @@ def valid?
false
end

##
# Returns `true` if this is a language-tagged literal in the English
# language.
#
# @return [Boolean] `true` or `false`
# @since 3.3.2
def english?
/\Aen(?:-[A-Za-z]{2})?\z/ === language.to_s
end

##
# Validates the value using {RDF::Value#valid?}, raising an error if the value is
# invalid.
Expand Down
13 changes: 11 additions & 2 deletions lib/rdf/model/statement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def self.from(statement, graph_name: nil, **options)
# @option options [RDF::Term] :graph_name (nil)
# Note, in RDF 1.1, a graph name MUST be an {Resource}.
# @option options [Boolean] :inferred used as a marker to record that this statement was inferred based on semantic relationships (T-Box).
# @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.
# @option options [Boolean] :tripleTerm used as a marker to record that this statement appears as the object of another RDF::Statement.
# @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).
# @return [RDF::Statement]
#
# @overload initialize(subject, predicate, object, **options)
Expand All @@ -84,7 +85,8 @@ def self.from(statement, graph_name: nil, **options)
# @option options [RDF::Term] :graph_name (nil)
# Note, in RDF 1.1, a graph name MUST be an {Resource}.
# @option options [Boolean] :inferred used as a marker to record that this statement was inferred based on semantic relationships (T-Box).
# @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.
# @option options [Boolean] :tripleTerm used as a marker to record that this statement appears as the object of another RDF::Statement.
# @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).
# @return [RDF::Statement]
def initialize(subject = nil, predicate = nil, object = nil, options = {})
if subject.is_a?(Hash)
Expand Down Expand Up @@ -211,6 +213,13 @@ def asserted?

##
# @return [Boolean]
def tripleTerm?
!!@options[:tripleTerm]
end

##
# @return [Boolean]
# @deprecated Quoted triples are now deprecated
def quoted?
!!@options[:quoted]
end
Expand Down
27 changes: 14 additions & 13 deletions lib/rdf/model/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ class URI
IUSERINFO = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|:)*").freeze
IAUTHORITY = Regexp.compile("(?:#{IUSERINFO}@)?#{IHOST}(?::#{PORT})?").freeze

IRELATIVE_PART = Regexp.compile("(?:(?://#{IAUTHORITY}(?:#{IPATH_ABEMPTY}))|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_NOSCHEME})|(?:#{IPATH_EMPTY}))").freeze
IRELATIVE_REF = Regexp.compile("^#{IRELATIVE_PART}(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
IRELATIVE_PART = Regexp.compile("//#{IAUTHORITY}(?:#{IPATH_ABEMPTY})|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_NOSCHEME})|(?:#{IPATH_EMPTY})").freeze
IRELATIVE_REF = Regexp.compile("^(?:#{IRELATIVE_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze

IHIER_PART = Regexp.compile("(?:(?://#{IAUTHORITY}#{IPATH_ABEMPTY})|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_ROOTLESS})|(?:#{IPATH_EMPTY}))").freeze
IHIER_PART = Regexp.compile("//#{IAUTHORITY}(?:#{IPATH_ABEMPTY})|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_ROOTLESS})|(?:#{IPATH_EMPTY})").freeze
IRI = Regexp.compile("^#{SCHEME}:(?:#{IHIER_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze

# Split an IRI into it's component parts
Expand Down Expand Up @@ -1240,17 +1240,18 @@ def query_values(return_type=Hash)
query.to_s.split('&').
inject(return_type == Hash ? {} : []) do |memo,kv|
k,v = kv.to_s.split('=', 2)
next if k.to_s.empty?
k = CGI.unescape(k)
v = CGI.unescape(v) if v
if return_type == Hash
case memo[k]
when nil then memo[k] = v
when Array then memo[k] << v
else memo[k] = [memo[k], v]
unless k.to_s.empty?
k = CGI.unescape(k)
v = CGI.unescape(v) if v
if return_type == Hash
case memo[k]
when nil then memo[k] = v
when Array then memo[k] << v
else memo[k] = [memo[k], v]
end
else
memo << [k, v].compact
end
else
memo << [k, v].compact
end
memo
end
Expand Down
9 changes: 5 additions & 4 deletions lib/rdf/model/value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,20 @@ def validate!
alias_method :validate, :validate!

##
# Returns `true` if this Value starts with the given `string`.
# Returns `true` if this Value starts with any of the given strings.
#
# @example
# RDF::URI('http://example.org/').start_with?('http') #=> true
# RDF::Node('_:foo').start_with?('_:bar') #=> false
# RDF::Litera('Apple').start_with?('Orange') #=> false
# RDF::Litera('Apple').start_with?('Orange', 'Apple') #=> true
#
# @param [String, #to_s] string
# @param [Array<#to_s>] *args Any number of strings to check against.
# @return [Boolean] `true` or `false`
# @see String#start_with?
# @since 0.3.0
def start_with?(string)
to_s.start_with?(string.to_s)
def start_with?(*args)
to_s.start_with?(*args.map(&:to_s))
end
alias_method :starts_with?, :start_with?

Expand Down
3 changes: 2 additions & 1 deletion lib/rdf/nquads.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ def read_triple

begin
unless blank? || read_comment
# FIXME: quoted triples are now deprecated
subject = read_uriref || read_node || read_quotedTriple || fail_subject
predicate = read_uriref(intern: true) || fail_predicate
object = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
object = read_uriref || read_node || read_literal || read_tripleTerm || 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
6 changes: 5 additions & 1 deletion lib/rdf/ntriples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ module RDF
#
# <https://rubygems.org/gems/rdf> <http://purl.org/dc/terms/title> "rdf" .
#
# ## Quoted Triples
# ## Triple terms
#
# Supports statements as resources using `<<(s p o)>>`.

# ## Quoted Triples (Deprecated)
#
# Supports statements as resources using `<<s p o>>`.
#
Expand Down
Loading

0 comments on commit e0b67d7

Please sign in to comment.