Skip to content

Commit e0b67d7

Browse files
committed
Finish 3.3.2
2 parents 2b31abd + 2586399 commit e0b67d7

33 files changed

+335
-165
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
ruby: ['3.0', 3.1, 3.2, ruby-head, jruby]
28+
ruby: ['3.0', 3.1, 3.2, 3.3, ruby-head, jruby]
2929
steps:
3030
- name: Clone repository
3131
uses: actions/checkout@v3
@@ -39,7 +39,7 @@ jobs:
3939
run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
4040
- name: Coveralls GitHub Action
4141
uses: coverallsapp/github-action@v2
42-
if: "matrix.ruby == '3.0'"
42+
if: "matrix.ruby == '3.3'"
4343
with:
4444
github-token: ${{ secrets.GITHUB_TOKEN }}
4545
wintests:
@@ -48,12 +48,12 @@ jobs:
4848
runs-on: windows-latest
4949
env:
5050
CI: true
51-
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' || matrix.ruby == '3.1' }}
51+
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
5252
strategy:
5353
fail-fast: false
5454
matrix:
5555
ruby:
56-
- 3.1
56+
- 3.2
5757
steps:
5858
- name: Clone repository
5959
uses: actions/checkout@v3

CHANGES.md

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

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,15 @@ A separate [SPARQL][SPARQL doc] gem builds on basic BGP support to provide full
265265
foaf[:name] #=> RDF::URI("http://xmlns.com/foaf/0.1/name")
266266
foaf['mbox'] #=> RDF::URI("http://xmlns.com/foaf/0.1/mbox")
267267

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+
268274
## RDF 1.2
269275

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.
271277
[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`.
272278

273279
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)
394400
* {RDF::RDFV} - RDF Vocabulary (RDFV)
395401
* {RDF::XSD} - XML Schema (XSD)
396402

403+
## Change Log
404+
405+
See [Release Notes on GitHub](https://github.com/ruby-rdf/rdf/releases)
397406

398407
## Dependencies
399408

@@ -498,6 +507,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
498507
[SPARQL doc]: https://ruby-rdf.github.io/sparql
499508
[RDF 1.0]: https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/
500509
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts/
510+
[RDF-star]: https://www.w3.org/2021/12/rdf-star.html
501511
[RDF 1.2]: https://www.w3.org/TR/rdf12-concepts/
502512
[SPARQL 1.1]: https://www.w3.org/TR/sparql11-query/
503513
[RDF.rb]: https://ruby-rdf.github.io/

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1
1+
3.3.2

etc/n-triples.ebnf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ ntriplesDoc ::= triple? (EOL triple)* EOL?
22
triple ::= subject predicate object '.'
33
subject ::= IRIREF | BLANK_NODE_LABEL | quotedTriple
44
predicate ::= IRIREF
5-
object ::= IRIREF | BLANK_NODE_LABEL | literal | quotedTriple
5+
object ::= IRIREF | BLANK_NODE_LABEL | literal | tripleTerm | quotedTriple
66
literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANG_DIR )?
7+
tripleTerm ::= '<<' subject predicate object '>>'
78
quotedTriple ::= '<<' subject predicate object '>>'
89

910
@terminals

lib/rdf/mixin/enumerable.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def to_a
8383
# * `: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`.
8484
# * `: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.
8585
# * `: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.
8788
# * `:base_direction` supports RDF 1.2 directional language-tagged strings.
8889
#
8990
# @param [Symbol, #to_sym] feature

lib/rdf/mixin/queryable.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def query_execute(query, **options, &block)
146146
#
147147
# Patterns may also have embedded patterns as either a subject or object, recursively.
148148
#
149+
# Patterns with a variable `graph_name` do not match the default graph.
150+
#
149151
# When matching, match an embedded pattern against embedded statements, recursively. (see {RDF::Query::Pattern#eql?})
150152
#
151153
# @param [RDF::Query::Pattern] pattern

lib/rdf/mixin/writable.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ def insert_graph(graph)
127127
def insert_statements(statements)
128128
each = statements.respond_to?(:each_statement) ? :each_statement : :each
129129
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))
131132
raise ArgumentError, "Writable does not support quoted triples"
132133
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)
134135
raise ArgumentError, "Writable does not support directional languaged-tagged strings"
135136
end
136137
insert_statement(statement)

lib/rdf/model/dataset.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def isolation_level
104104
# @private
105105
# @see RDF::Enumerable#supports?
106106
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)
108109
super
109110
end
110111

lib/rdf/model/graph.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,9 @@ def query_pattern(pattern, **options, &block)
305305
# @private
306306
# @see RDF::Mutable#insert
307307
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"
310311
end
311312
if statement.object && statement.object.literal? && statement.object.direction? && !@data.supports?(:base_direction)
312313
raise ArgumentError, "Graph does not support directional languaged-tagged strings"

lib/rdf/model/literal.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def initialize(value, language: nil, datatype: nil, direction: nil, lexical: nil
194194
@string = @string.encode(Encoding::UTF_8).freeze if instance_variable_defined?(:@string)
195195
@object = @string if instance_variable_defined?(:@string) && @object.is_a?(String)
196196
@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
198198
@datatype = RDF::URI(datatype).freeze if datatype
199199
@datatype ||= self.class.const_get(:DATATYPE) if self.class.const_defined?(:DATATYPE)
200200
@datatype ||= if instance_variable_defined?(:@language) && @language &&
@@ -451,6 +451,16 @@ def valid?
451451
false
452452
end
453453

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+
454464
##
455465
# Validates the value using {RDF::Value#valid?}, raising an error if the value is
456466
# invalid.

lib/rdf/model/statement.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def self.from(statement, graph_name: nil, **options)
7171
# @option options [RDF::Term] :graph_name (nil)
7272
# Note, in RDF 1.1, a graph name MUST be an {Resource}.
7373
# @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).
7576
# @return [RDF::Statement]
7677
#
7778
# @overload initialize(subject, predicate, object, **options)
@@ -84,7 +85,8 @@ def self.from(statement, graph_name: nil, **options)
8485
# @option options [RDF::Term] :graph_name (nil)
8586
# Note, in RDF 1.1, a graph name MUST be an {Resource}.
8687
# @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).
8890
# @return [RDF::Statement]
8991
def initialize(subject = nil, predicate = nil, object = nil, options = {})
9092
if subject.is_a?(Hash)
@@ -211,6 +213,13 @@ def asserted?
211213

212214
##
213215
# @return [Boolean]
216+
def tripleTerm?
217+
!!@options[:tripleTerm]
218+
end
219+
220+
##
221+
# @return [Boolean]
222+
# @deprecated Quoted triples are now deprecated
214223
def quoted?
215224
!!@options[:quoted]
216225
end

lib/rdf/model/uri.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ class URI
7070
IUSERINFO = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|:)*").freeze
7171
IAUTHORITY = Regexp.compile("(?:#{IUSERINFO}@)?#{IHOST}(?::#{PORT})?").freeze
7272

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
7575

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
7777
IRI = Regexp.compile("^#{SCHEME}:(?:#{IHIER_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
7878

7979
# Split an IRI into it's component parts
@@ -1240,17 +1240,18 @@ def query_values(return_type=Hash)
12401240
query.to_s.split('&').
12411241
inject(return_type == Hash ? {} : []) do |memo,kv|
12421242
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
12511254
end
1252-
else
1253-
memo << [k, v].compact
12541255
end
12551256
memo
12561257
end

lib/rdf/model/value.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,20 @@ def validate!
197197
alias_method :validate, :validate!
198198

199199
##
200-
# Returns `true` if this Value starts with the given `string`.
200+
# Returns `true` if this Value starts with any of the given strings.
201201
#
202202
# @example
203203
# RDF::URI('http://example.org/').start_with?('http') #=> true
204204
# RDF::Node('_:foo').start_with?('_:bar') #=> false
205205
# RDF::Litera('Apple').start_with?('Orange') #=> false
206+
# RDF::Litera('Apple').start_with?('Orange', 'Apple') #=> true
206207
#
207-
# @param [String, #to_s] string
208+
# @param [Array<#to_s>] *args Any number of strings to check against.
208209
# @return [Boolean] `true` or `false`
209210
# @see String#start_with?
210211
# @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))
213214
end
214215
alias_method :starts_with?, :start_with?
215216

lib/rdf/nquads.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ def read_triple
7171

7272
begin
7373
unless blank? || read_comment
74+
# FIXME: quoted triples are now deprecated
7475
subject = read_uriref || read_node || read_quotedTriple || fail_subject
7576
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
7778
graph_name = read_uriref || read_node
7879
if validate? && !read_eos
7980
log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError)

lib/rdf/ntriples.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ module RDF
1515
#
1616
# <https://rubygems.org/gems/rdf> <http://purl.org/dc/terms/title> "rdf" .
1717
#
18-
# ## Quoted Triples
18+
# ## Triple terms
19+
#
20+
# Supports statements as resources using `<<(s p o)>>`.
21+
22+
# ## Quoted Triples (Deprecated)
1923
#
2024
# Supports statements as resources using `<<s p o>>`.
2125
#

0 commit comments

Comments
 (0)