Skip to content

Commit fa05795

Browse files
committed
Finish 3.3.0
2 parents 4765724 + c2bcdc1 commit fa05795

36 files changed

+368
-161
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
ruby: [2.6, 2.7, '3.0', 3.1, 3.2, ruby-head, jruby]
28+
ruby: ['3.0', 3.1, 3.2, ruby-head, jruby]
2929
steps:
3030
- name: Clone repository
3131
uses: actions/checkout@v3

Gemfile

Lines changed: 1 addition & 1 deletion
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.21', platforms: :mri
34+
gem 'simplecov', '~> 0.22', platforms: :mri
3535
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
3636
end

README.md

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,28 @@ This is a pure-Ruby library for working with [Resource Description Framework
1414

1515
1. [Features](#features)
1616
2. [Differences between RDF 1.0 and RDF 1.1](#differences-between-rdf-1-0-and-rdf-1-1)
17-
3. [Tutorials](#tutorials)
18-
4. [Command Line](#command-line)
19-
5. [Examples](#examples)
20-
6. [Reader/Writer convenience methods](#reader/writer-convenience-methods)
21-
7. [RDF* (RDFStar)](#rdf*-(rdfstar))
22-
8. [Documentation](#documentation)
23-
9. [Dependencies](#dependencies)
24-
10. [Installation](#installation)
25-
11. [Download](#download)
26-
12. [Resources](#resources)
27-
13. [Mailing List](#mailing-list)
28-
14. [Authors](#authors)
29-
15. [Contributors](#contributors)
30-
16. [Contributing](#contributing)
31-
17. [License](#license)
17+
3. [Differences between RDF 1.1 and RDF 1.2](#differences-between-rdf-1-1-and-rdf-1-2)
18+
4. [Tutorials](#tutorials)
19+
5. [Command Line](#command-line)
20+
6. [Examples](#examples)
21+
7. [Reader/Writer convenience methods](#reader/writer-convenience-methods)
22+
8. [RDF 1.2](#rdf\_12)
23+
9. [Documentation](#documentation)
24+
10. [Dependencies](#dependencies)
25+
11. [Installation](#installation)
26+
12. [Download](#download)
27+
13. [Resources](#resources)
28+
14. [Mailing List](#mailing-list)
29+
15. [Authors](#authors)
30+
16. [Contributors](#contributors)
31+
17. [Contributing](#contributing)
32+
18. [License](#license)
3233

3334
## Features
3435

3536
* 100% pure Ruby with minimal dependencies and no bloat.
3637
* Fully compatible with [RDF 1.1][] specifications.
38+
* Provisional support for [RDF 1.2][] specifications.
3739
* 100% free and unencumbered [public domain](https://unlicense.org/) software.
3840
* Provides a clean, well-designed RDF object model and related APIs.
3941
* Supports parsing and serializing [N-Triples][] and [N-Quads][] out of the box, with more
@@ -45,11 +47,10 @@ This is a pure-Ruby library for working with [Resource Description Framework
4547
not modify any of Ruby's core classes or standard library.
4648
* Based entirely on Ruby's autoloading, meaning that you can generally make
4749
use of any one part of the library without needing to load up the rest.
48-
* Compatible with Ruby Ruby >= 2.4, Rubinius and JRuby 9.0+.
49-
* Note, changes in mapping hashes to keyword arguments for Ruby 2.7+ may require that arguments be passed more explicitly, especially when the first argument is a Hash and there are optional keyword arguments. In this case, Hash argument may need to be explicitly included within `{}` and the optional keyword arguments may need to be specified using `**{}` if there are no keyword arguments.
50+
* Compatible with Ruby Ruby >= 3.0, Rubinius and JRuby 9.0+.
51+
* Note, changes in mapping hashes to keyword arguments for Ruby 3+ may require that arguments be passed more explicitly, especially when the first argument is a Hash and there are optional keyword arguments. In this case, Hash argument may need to be explicitly included within `{}` and the optional keyword arguments may need to be specified using `**{}` if there are no keyword arguments.
5052
* Performs auto-detection of input to select appropriate Reader class if one
5153
cannot be determined from file characteristics.
52-
* Provisional support for [RDF*][].
5354

5455
### HTTP requests
5556

@@ -102,6 +103,10 @@ the 1.1 release of RDF.rb:
102103

103104
Notably, {RDF::Queryable#query} and {RDF::Query#execute} are now completely symmetric; this allows an implementation of {RDF::Queryable} to optimize queries using implementation-specific logic, allowing for substantial performance improvements when executing BGP queries.
104105

106+
## Differences between RDF 1.1 and RDF 1.2
107+
* {RDF::Literal} has an optional `direction` property for directional language-tagged strings.
108+
* Removes support for legacy `text/plain` (as an alias for `application/n-triples`) and `text/x-nquads` (as an alias for `application/n-quads`)
109+
105110
## Tutorials
106111

107112
* [Getting data from the Semantic Web using Ruby and RDF.rb](https://semanticweb.org/wiki/Getting_data_from_the_Semantic_Web_%28Ruby%29)
@@ -260,23 +265,24 @@ A separate [SPARQL][SPARQL doc] gem builds on basic BGP support to provide full
260265
foaf[:name] #=> RDF::URI("http://xmlns.com/foaf/0.1/name")
261266
foaf['mbox'] #=> RDF::URI("http://xmlns.com/foaf/0.1/mbox")
262267

263-
## RDF* (RDFStar)
268+
## RDF 1.2
264269

265-
[RDF.rb][] includes provisional support for [RDF*][] with an N-Triples/N-Quads syntax extension that uses inline statements in the _subject_ or _object_ position.
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.
271+
[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`.
266272

267273
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`.
268274

269275
**Note: This feature is subject to change or elimination as the standards process progresses.**
270276

271-
### Serializing a Graph containing embedded statements
277+
### Serializing a Graph containing quoted triples
272278

273279
require 'rdf/ntriples'
274280
statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
275281
graph = RDF::Graph.new << [statement, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
276282
graph.dump(:ntriples, validate: false)
277283
# => '<<<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
278284

279-
### Reading a Graph containing embedded statements
285+
### Reading a Graph containing quoted triples
280286

281287
By default, the N-Triples reader will reject a document containing a subject resource.
282288

@@ -286,13 +292,6 @@ By default, the N-Triples reader will reject a document containing a subject res
286292
end
287293
# => RDF::ReaderError
288294

289-
Readers support a boolean valued `rdfstar` option.
290-
291-
graph = RDF::Graph.new do |graph|
292-
RDF::NTriples::Reader.new(nt, rdfstar: true) {|reader| graph << reader}
293-
end
294-
graph.count #=> 1
295-
296295
## Documentation
297296

298297
<https://ruby-rdf.github.io/rdf>
@@ -398,16 +397,17 @@ from BNode identity (i.e., they each entail the other)
398397

399398
## Dependencies
400399

401-
* [Ruby](https://ruby-lang.org/) (>= 2.6)
400+
* [Ruby](https://ruby-lang.org/) (>= 3.0)
402401
* [LinkHeader][] (>= 0.0.8)
402+
* [bcp47_spec][] ( ~> 0.2)
403403
* 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.6+
410+
% [sudo] gem install rdf # Ruby 3+
411411

412412
## Download
413413

@@ -481,8 +481,10 @@ This is free and unencumbered public domain software. For more information,
481481
see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
482482

483483
[RDF]: https://www.w3.org/RDF/
484-
[N-Triples]: https://www.w3.org/TR/n-triples/
485-
[N-Quads]: https://www.w3.org/TR/n-quads/
484+
[LinkHeader]: https://github.com/asplake/link_header
485+
[bcp47_spec]: https://github.com/dadah89/bcp47_spec
486+
[N-Triples]: https://www.w3.org/TR/rdf-n-triples/
487+
[N-Quads]: https://www.w3.org/TR/rdf-n-quads/
486488
[YARD]: https://yardoc.org/
487489
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
488490
[PDD]: https://unlicense.org/#unlicensing-contributions
@@ -496,6 +498,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
496498
[SPARQL doc]: https://ruby-rdf.github.io/sparql
497499
[RDF 1.0]: https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/
498500
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts/
501+
[RDF 1.2]: https://www.w3.org/TR/rdf12-concepts/
499502
[SPARQL 1.1]: https://www.w3.org/TR/sparql11-query/
500503
[RDF.rb]: https://ruby-rdf.github.io/
501504
[RDF::DO]: https://ruby-rdf.github.io/rdf-do
@@ -510,7 +513,6 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
510513
[RDF::TriX]: https://ruby-rdf.github.io/rdf-trix
511514
[RDF::Turtle]: https://ruby-rdf.github.io/rdf-turtle
512515
[RDF::Raptor]: https://ruby-rdf.github.io/rdf-raptor
513-
[RDF*]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html
514516
[LinkedData]: https://ruby-rdf.github.io/linkeddata
515517
[JSON::LD]: https://ruby-rdf.github.io/json-ld
516518
[RestClient]: https://rubygems.org/gems/rest-client

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.11
1+
3.3.0

etc/n-triples-star.ebnf

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

etc/n-triples.ebnf

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
1-
[1] ntriplesDoc ::= triple? (EOL triple)* EOL?
2-
[2] triple ::= subject predicate object '.'
3-
[3] subject ::= IRIREF | BLANK_NODE_LABEL
4-
[4] predicate ::= IRIREF
5-
[5] object ::= IRIREF | BLANK_NODE_LABEL | literal
6-
[6] literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)?
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 | LANG_DIR )?
7+
quotedTriple ::= '<<' subject predicate object '>>'
8+
9+
@terminals
10+
11+
IRIREF ::= '<' ([^#x00-#x20<>"{}|^`\] | UCHAR)* '>'
12+
BLANK_NODE_LABEL ::= '_:' ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
13+
LANG_DIR ::= "@" [a-zA-Z]+ ( "-" [a-zA-Z0-9]+ )* ('--' [a-zA-Z]+)?`
14+
STRING_LITERAL_QUOTE ::= '"' ( [^#x22#x5C#xA#xD] | ECHAR | UCHAR )* '"'
15+
UCHAR ::= ( "\u" HEX HEX HEX HEX )
16+
| ( "\U" HEX HEX HEX HEX HEX HEX HEX HEX )
17+
ECHAR ::= ("\" [tbnrf"'])
18+
PN_CHARS_BASE ::= ([A-Z]
19+
| [a-z]
20+
| [#x00C0-#x00D6]
21+
| [#x00D8-#x00F6]
22+
| [#x00F8-#x02FF]
23+
| [#x0370-#x037D]
24+
| [#x037F-#x1FFF]
25+
| [#x200C-#x200D]
26+
| [#x2070-#x218F]
27+
| [#x2C00-#x2FEF]
28+
| [#x3001-#xD7FF]
29+
| [#xF900-#xFDCF]
30+
| [#xFDF0-#xFFFD]
31+
| [#x10000-#xEFFFF])
32+
PN_CHARS_U ::= PN_CHARS_BASE | '_'
33+
PN_CHARS ::= (PN_CHARS_U
34+
| "-"
35+
| [0-9]
36+
| #x00B7
37+
| [#x0300-#x036F]
38+
| [#x203F-#x2040])
39+
HEX ::= ([0-9] | [A-F] | [a-f])
40+
EOL ::= [#xD#xA]+

lib/rdf/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module RDF
6060
# RDF::CLI::Option.new(
6161
# symbol: :canonicalize,
6262
# on: ["--canonicalize"],
63-
# description: "Canonicalize input/output.") {true},
63+
# description: "Canonicalize URI/literal forms.") {true},
6464
# RDF::CLI::Option.new(
6565
# symbol: :uri,
6666
# on: ["--uri STRING"],

lib/rdf/mixin/enumerable.rb

Lines changed: 23 additions & 2 deletions
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-
# * `:rdfstar` supports RDF* where statements may be subjects or objects of other statements.
86+
# * `:quoted_triples` supports RDF 1.2 quoted triples.
87+
# * `:base_direction` supports RDF 1.2 directional language-tagged strings.
8788
#
8889
# @param [Symbol, #to_sym] feature
8990
# @return [Boolean]
@@ -720,13 +721,33 @@ def enum_graph
720721
end
721722
alias_method :enum_graphs, :enum_graph
722723

724+
##
725+
# Enumerates each statement using its canonical representation.
726+
#
727+
# @note This is updated by `RDF::Normalize` to also canonicalize blank nodes.
728+
#
729+
# @return [RDF::Enumerable]
730+
def canonicalize
731+
this = self
732+
Enumerable::Enumerator.new do |yielder|
733+
this.send(:each_statement) {|y| yielder << y.canonicalize}
734+
end
735+
end
736+
737+
##
738+
# Mutating canonicalization not supported
739+
#
740+
# @raise NotImplementedError
741+
def canonicalize!
742+
raise NotImplementedError, "Canonicalizing enumerables not supported"
743+
end
744+
723745
##
724746
# Returns all RDF statements in `self` as an array.
725747
#
726748
# Mixes in `RDF::Enumerable` into the returned object.
727749
#
728750
# @return [Array]
729-
# @since 0.2.0
730751
def to_a
731752
super.extend(RDF::Enumerable)
732753
end

lib/rdf/mixin/queryable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def query_execute(query, **options, &block)
140140
# method in order to provide for storage-specific optimized triple
141141
# pattern matching.
142142
#
143-
# ## RDFStar (RDF*)
143+
# ## RDF-star
144144
#
145145
# Statements may have embedded statements as either a subject or object, recursively.
146146
#

lib/rdf/mixin/writable.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +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?(:rdfstar)
131-
raise ArgumentError, "Wriable does not support embedded statements"
130+
if statement.embedded? && respond_to?(:supports?) && !supports?(:quoted_triples)
131+
raise ArgumentError, "Writable does not support quoted triples"
132+
end
133+
if statement.object && statement.object.literal? && statement.object.direction? && !supports?(:base_direction)
134+
raise ArgumentError, "Writable does not support directional languaged-tagged strings"
132135
end
133136
insert_statement(statement)
134137
end

lib/rdf/model/dataset.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def isolation_level
104104
# @private
105105
# @see RDF::Enumerable#supports?
106106
def supports?(feature)
107-
return true if %i(graph_name rdfstar).include?(feature)
107+
return true if %i(graph_name quoted_triples).include?(feature)
108108
super
109109
end
110110

lib/rdf/model/graph.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,11 @@ def query_pattern(pattern, **options, &block)
305305
# @private
306306
# @see RDF::Mutable#insert
307307
def insert_statement(statement)
308-
if statement.embedded? && !@data.supports?(:rdfstar)
309-
raise ArgumentError, "Graph does not support embedded statements"
308+
if statement.embedded? && !@data.supports?(:quoted_triples)
309+
raise ArgumentError, "Graph does not support quoted triples"
310+
end
311+
if statement.object && statement.object.literal? && statement.object.direction? && !@data.supports?(:base_direction)
312+
raise ArgumentError, "Graph does not support directional languaged-tagged strings"
310313
end
311314
statement = statement.dup
312315
statement.graph_name = graph_name

0 commit comments

Comments
 (0)