Skip to content

Commit 28c9831

Browse files
committed
Finish 3.2.4
2 parents ad71b66 + c0805e0 commit 28c9831

32 files changed

+1255
-1096
lines changed

.github/workflows/generate-docs.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build & deploy documentation
2+
on:
3+
push:
4+
branches:
5+
- master
6+
workflow_dispatch:
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
name: Update gh-pages with docs
11+
steps:
12+
- name: Clone repository
13+
uses: actions/checkout@v2
14+
- name: Set up Ruby
15+
uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: "3.1"
18+
- name: Install required gem dependencies
19+
run: gem install yard --no-document
20+
- name: Build YARD Ruby Documentation
21+
run: yardoc
22+
- name: Deploy
23+
uses: peaceiris/actions-gh-pages@v3
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
publish_dir: ./doc/yard
27+
publish_branch: gh-pages

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Release 2.0.0
5555

5656
* Enumerables vs. Enumerators
5757

58-
- `RDF::Queryable#query` and `RDF::Query#execute` not return an enumerable, which may be an enumerator. Most internal uses return an Array now, which aides performance for small result sets, but potentially causes problems for large result sets. Implementations may still return an Enumerator, and Enumerators may be passed as arguments.
58+
- `RDF::Queryable#query` and `RDF::Query#execute` did not return an enumerable, which may be an enumerator. Most internal uses return an Array now, which aides performance for small result sets, but potentially causes problems for large result sets. Implementations may still return an Enumerator, and Enumerators may be passed as arguments.
5959
- `RDF::Enumerable#statements`, `#quads`, `#triples`, `#subjects`, `#predicates`, `#objects`, and `#contexts` now return an array rather than an Enumerator.
6060

6161
* The following vocabularies are deprecated and have been moved to the rdf-vocab gem.

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This is a pure-Ruby library for working with [Resource Description Framework
44
(RDF)][RDF] data.
55

6-
* <https://ruby-rdf.github.com/rdf>
6+
* <https://ruby-rdf.github.io/rdf>
77

88
[![Gem Version](https://badge.fury.io/rb/rdf.png)](https://badge.fury.io/rb/rdf)
99
[![Build Status](https://github.com/ruby-rdf/rdf/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rdf/actions?query=workflow%3ACI)
@@ -141,11 +141,11 @@ or
141141
### Reading RDF data in the [N-Triples][] format
142142

143143
require 'rdf/ntriples'
144-
graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nt")
144+
graph = RDF::Graph.load("https://ruby-rdf.github.io/rdf/etc/doap.nt")
145145

146146
or
147147

148-
RDF::Reader.open("https://ruby-rdf.github.com/rdf/etc/doap.nt") do |reader|
148+
RDF::Reader.open("https://ruby-rdf.github.io/rdf/etc/doap.nt") do |reader|
149149
reader.each_statement do |statement|
150150
puts statement.inspect
151151
end
@@ -160,13 +160,13 @@ MimeType or file extension, where available.
160160

161161
require 'rdf/nquads'
162162

163-
graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nq", format: :nquads)
163+
graph = RDF::Graph.load("https://ruby-rdf.github.io/rdf/etc/doap.nq", format: :nquads)
164164

165165
A specific sub-type of Reader can also be invoked directly:
166166

167167
require 'rdf/nquads'
168168

169-
RDF::NQuads::Reader.open("https://ruby-rdf.github.com/rdf/etc/doap.nq") do |reader|
169+
RDF::NQuads::Reader.open("https://ruby-rdf.github.io/rdf/etc/doap.nq") do |reader|
170170
reader.each_statement do |statement|
171171
puts statement.inspect
172172
end
@@ -220,7 +220,7 @@ Note that no prefixes are loaded automatically, however they can be provided as
220220

221221
require 'rdf/ntriples'
222222

223-
graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nt")
223+
graph = RDF::Graph.load("https://ruby-rdf.github.io/rdf/etc/doap.nt")
224224
query = RDF::Query.new({
225225
person: {
226226
RDF.type => FOAF.Person,
@@ -295,7 +295,7 @@ Readers support a boolean valued `rdfstar` option.
295295

296296
## Documentation
297297

298-
<https://rubydoc.info/github/ruby-rdf/rdf>
298+
<https://ruby-rdf.github.io/rdf>
299299

300300
### RDF Object Model
301301

@@ -309,7 +309,7 @@ Readers support a boolean valued `rdfstar` option.
309309
* {RDF::Literal::Double}
310310
* {RDF::Literal::Integer}
311311
* {RDF::Literal::Time}
312-
* [RDF::XSD](https://rubydoc.info/github/gkellogg/rdf-xsd) (extension)
312+
* [RDF::XSD](https://ruby-rdf.github.io/rdf-xsd) (extension)
313313
* {RDF::Resource}
314314
* {RDF::Node}
315315
* {RDF::URI}
@@ -371,10 +371,10 @@ from BNode identity (i.e., they each entail the other)
371371
* {RDF::Mutable}
372372
* {RDF::Durable}
373373
* {RDF::Transaction}
374-
* [RDF::AllegroGraph](https://rubydoc.info/github/ruby-rdf/rdf-agraph) (extension)
375-
* [RDF::Mongo](https://rubydoc.info/github/ruby-rdf/rdf-mongo) (extension)
376-
* [RDF::DataObjects](https://rubydoc.info/github/ruby-rdf/rdf-do) (extension)
377-
* [RDF::Sesame](https://rubydoc.info/github/ruby-rdf/rdf-sesame) (extension)
374+
* [RDF::AllegroGraph](https://ruby-rdf.github.io/rdf-agraph) (extension)
375+
* [RDF::Mongo](https://ruby-rdf.github.io/rdf-mongo) (extension)
376+
* [RDF::DataObjects](https://ruby-rdf.github.io/rdf-do) (extension)
377+
* [RDF::Sesame](https://ruby-rdf.github.io/rdf-sesame) (extension)
378378

379379
### RDF Querying
380380

@@ -384,7 +384,7 @@ from BNode identity (i.e., they each entail the other)
384384
* {RDF::Query::Solution}
385385
* {RDF::Query::Solutions}
386386
* {RDF::Query::Variable}
387-
* [SPARQL](https://rubydoc.info/github/ruby-rdf/sparql) (extension)
387+
* [SPARQL](https://ruby-rdf.github.io/sparql) (extension)
388388

389389

390390
### RDF Vocabularies
@@ -422,7 +422,7 @@ follows:
422422

423423
## Resources
424424

425-
* <https://rubydoc.info/github/ruby-rdf/rdf>
425+
* <https://ruby-rdf.github.io/rdf>
426426
* <https://github.com/ruby-rdf/rdf>
427427
* <https://rubygems.org/gems/rdf>
428428
* <https://www.ohloh.net/p/rdf>
@@ -486,33 +486,33 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
486486
[YARD]: https://yardoc.org/
487487
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
488488
[PDD]: https://unlicense.org/#unlicensing-contributions
489-
[JSONLD doc]: https://rubydoc.info/github/ruby-rdf/json-ld
490-
[LinkedData doc]: https://rubydoc.info/github/ruby-rdf/linkeddata
491-
[Microdata doc]: https://rubydoc.info/github/ruby-rdf/rdf-microdata
492-
[N3 doc]: https://rubydoc.info/github/ruby-rdf/rdf-n3
493-
[RDFa doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfa
494-
[RDFXML doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfxml
495-
[Turtle doc]: https://rubydoc.info/github/ruby-rdf/rdf-turtle
496-
[SPARQL doc]: https://rubydoc.info/github/ruby-rdf/sparql
489+
[JSONLD doc]: https://ruby-rdf.github.io/json-ld
490+
[LinkedData doc]: https://ruby-rdf.github.io/linkeddata
491+
[Microdata doc]: https://ruby-rdf.github.io/rdf-microdata
492+
[N3 doc]: https://ruby-rdf.github.io/rdf-n3
493+
[RDFa doc]: https://ruby-rdf.github.io/rdf-rdfa
494+
[RDFXML doc]: https://ruby-rdf.github.io/rdf-rdfxml
495+
[Turtle doc]: https://ruby-rdf.github.io/rdf-turtle
496+
[SPARQL doc]: https://ruby-rdf.github.io/sparql
497497
[RDF 1.0]: https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/
498498
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts/
499499
[SPARQL 1.1]: https://www.w3.org/TR/sparql11-query/
500-
[RDF.rb]: https://ruby-rdf.github.com/
501-
[RDF::DO]: https://ruby-rdf.github.com/rdf-do
502-
[RDF::Mongo]: https://ruby-rdf.github.com/rdf-mongo
503-
[RDF::Sesame]: https://ruby-rdf.github.com/rdf-sesame
504-
[RDF::JSON]: https://ruby-rdf.github.com/rdf-json
505-
[RDF::Microdata]: https://ruby-rdf.github.com/rdf-microdata
506-
[RDF::N3]: https://ruby-rdf.github.com/rdf-n3
507-
[RDF::RDFa]: https://ruby-rdf.github.com/rdf-rdfa
508-
[RDF::RDFXML]: https://ruby-rdf.github.com/rdf-rdfxml
509-
[RDF::TriG]: https://ruby-rdf.github.com/rdf-trig
510-
[RDF::TriX]: https://ruby-rdf.github.com/rdf-trix
511-
[RDF::Turtle]: https://ruby-rdf.github.com/rdf-turtle
512-
[RDF::Raptor]: https://ruby-rdf.github.com/rdf-raptor
500+
[RDF.rb]: https://ruby-rdf.github.io/
501+
[RDF::DO]: https://ruby-rdf.github.io/rdf-do
502+
[RDF::Mongo]: https://ruby-rdf.github.io/rdf-mongo
503+
[RDF::Sesame]: https://ruby-rdf.github.io/rdf-sesame
504+
[RDF::JSON]: https://ruby-rdf.github.io/rdf-json
505+
[RDF::Microdata]: https://ruby-rdf.github.io/rdf-microdata
506+
[RDF::N3]: https://ruby-rdf.github.io/rdf-n3
507+
[RDF::RDFa]: https://ruby-rdf.github.io/rdf-rdfa
508+
[RDF::RDFXML]: https://ruby-rdf.github.io/rdf-rdfxml
509+
[RDF::TriG]: https://ruby-rdf.github.io/rdf-trig
510+
[RDF::TriX]: https://ruby-rdf.github.io/rdf-trix
511+
[RDF::Turtle]: https://ruby-rdf.github.io/rdf-turtle
512+
[RDF::Raptor]: https://ruby-rdf.github.io/rdf-raptor
513513
[RDF*]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html
514-
[LinkedData]: https://ruby-rdf.github.com/linkeddata
515-
[JSON::LD]: https://ruby-rdf.github.com/json-ld
514+
[LinkedData]: https://ruby-rdf.github.io/linkeddata
515+
[JSON::LD]: https://ruby-rdf.github.io/json-ld
516516
[RestClient]: https://rubygems.org/gems/rest-client
517517
[RestClient Components]: https://rubygems.org/gems/rest-client-components
518518
[Rack::Cache]: https://rtomayko.github.io/rack-cache/

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.3
1+
3.2.4

bin/console

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler/setup"
5+
require "rdf"
6+
7+
require "irb"
8+
require 'amazing_print'
9+
IRB.start(__FILE__)

examples/issue433/Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source 'https://rubygems.org'
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
#ruby '2.7.5'
5+
6+
gem 'rdf', path: '../..'
7+
gem 'byebug'
8+
gem 'amazing_print'

examples/issue433/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# rdf-issue
2+
3+
```
4+
bundle install
5+
6+
bundle exec ruby test.rb
7+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Something
2+
module Enumerator
3+
end
4+
end

examples/issue433/test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'rdf'
2+
require 'rdf/mixin/enumerable'
3+
require 'rdf/model/list'
4+
require './something/enumerator'
5+
require 'enumerator'
6+
7+
puts "All OK!"

lib/rdf.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
require 'rdf/version'
88
require 'rdf/extensions'
99

10-
# When loading, issue deprecation warning on forthcoming unsupported versions of Ruby
11-
warn "[DEPRECATION] Ruby 2.4+ required in next version 3.1 of RDF.rb" if RUBY_VERSION < "2.4"
12-
1310
module RDF
1411
# RDF mixins
1512
autoload :Countable, 'rdf/mixin/countable'

lib/rdf/mixin/countable.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ module RDF
22
##
33
# @since 0.2.0
44
module Countable
5-
autoload :Enumerator, 'rdf/mixin/enumerator'
65
extend RDF::Util::Aliasing::LateBound
76

7+
# Extends Enumerator with {Countable}, which is used by {Countable#enum_for}
8+
class Enumerator < ::Enumerator
9+
include RDF::Countable
10+
end
11+
812
##
913
# Returns `true` if `self` contains no RDF statements.
1014
#

lib/rdf/mixin/enumerable.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,23 @@ module RDF
5757
# @see RDF::Graph
5858
# @see RDF::Repository
5959
module Enumerable
60-
autoload :Enumerator, 'rdf/mixin/enumerator'
6160
extend RDF::Util::Aliasing::LateBound
6261
include ::Enumerable
6362
include RDF::Countable # NOTE: must come after ::Enumerable
6463

64+
# Extends Enumerator with {Queryable} and {Enumerable}, which is used by {Enumerable#each_statement} and {Queryable#enum_for}
65+
class Enumerator < ::Enumerator
66+
include RDF::Queryable
67+
include RDF::Enumerable
68+
69+
##
70+
# @return [Array]
71+
# @note Make sure returned arrays are also queryable
72+
def to_a
73+
return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
74+
end
75+
end
76+
6577
##
6678
# Returns `true` if this enumerable supports the given `feature`.
6779
#

lib/rdf/mixin/enumerator.rb

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

lib/rdf/mixin/queryable.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,21 @@ module RDF
99
# @see RDF::Graph
1010
# @see RDF::Repository
1111
module Queryable
12-
autoload :Enumerator, 'rdf/mixin/enumerator'
1312
include ::Enumerable
1413

14+
# Extends Enumerator with {Queryable} and {Enumerable}, which is used by {Enumerable#each_statement} and {Queryable#enum_for}
15+
class Enumerator < ::Enumerator
16+
include RDF::Queryable
17+
include RDF::Enumerable
18+
19+
##
20+
# @return [Array]
21+
# @note Make sure returned arrays are also queryable
22+
def to_a
23+
return super.to_a.extend(RDF::Queryable, RDF::Enumerable)
24+
end
25+
end
26+
1527
##
1628
# Queries `self` for RDF statements matching the given `pattern`.
1729
#

lib/rdf/model/list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def <<(value)
476476
# @return [Integer]
477477
# @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-3C-3D-3E
478478
def eql?(other)
479-
to_a.eql? other.to_a # TODO: optimize this
479+
to_a.eql? Array(other)
480480
end
481481

482482
##

lib/rdf/model/statement.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ 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.
7475
# @return [RDF::Statement]
7576
#
7677
# @overload initialize(subject, predicate, object, **options)
@@ -83,6 +84,7 @@ def self.from(statement, graph_name: nil, **options)
8384
# @option options [RDF::Term] :graph_name (nil)
8485
# Note, in RDF 1.1, a graph name MUST be an {Resource}.
8586
# @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.
8688
# @return [RDF::Statement]
8789
def initialize(subject = nil, predicate = nil, object = nil, options = {})
8890
if subject.is_a?(Hash)
@@ -209,7 +211,7 @@ def asserted?
209211
##
210212
# @return [Boolean]
211213
def quoted?
212-
false
214+
!!@options[:quoted]
213215
end
214216

215217
##

lib/rdf/model/uri.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ class URI
112112
).freeze
113113

114114
# Characters in a PName which must be escaped
115-
PN_ESCAPE_CHARS = /[~\.\-!\$&'\(\)\*\+,;=\/\?\#@%_]/.freeze
116-
PN_ESCAPES = /\\#{PN_ESCAPE_CHARS}/.freeze
115+
# Note: not all reserved characters need to be escaped in SPARQL/Turtle, but they must be unescaped when encountered
116+
PN_ESCAPE_CHARS = /[~\.!\$&'\(\)\*\+,;=\/\?\#@%]/.freeze
117+
PN_ESCAPES = /\\#{Regexp.union(PN_ESCAPE_CHARS, /[\-_]/)}/.freeze
117118

118119
##
119120
# Cache size may be set through {RDF.config} using `uri_cache_size`.

0 commit comments

Comments
 (0)