Skip to content

Commit 105d295

Browse files
committed
Finish 3.2.10
2 parents 9dcc68b + bc385ee commit 105d295

File tree

11 files changed

+129
-45
lines changed

11 files changed

+129
-45
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,10 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
ruby:
29-
- 2.6
30-
- 2.7
31-
- "3.0"
32-
- 3.1
33-
- ruby-head
34-
- jruby
28+
ruby: [2.6, 2.7, '3.0', 3.1, 3.2, ruby-head, jruby]
3529
steps:
3630
- name: Clone repository
37-
uses: actions/checkout@v2
31+
uses: actions/checkout@v3
3832
- name: Set up Ruby
3933
uses: ruby/setup-ruby@v1
4034
with:
@@ -54,15 +48,15 @@ jobs:
5448
runs-on: windows-latest
5549
env:
5650
CI: true
57-
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
51+
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' || matrix.ruby == '3.1' }}
5852
strategy:
5953
fail-fast: false
6054
matrix:
6155
ruby:
6256
- 3.1
6357
steps:
6458
- name: Clone repository
65-
uses: actions/checkout@v2
59+
uses: actions/checkout@v3
6660
- name: Set up Ruby
6761
uses: ruby/setup-ruby@v1
6862
with:

.github/workflows/generate-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Update gh-pages with docs
1111
steps:
1212
- name: Clone repository
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414
- name: Set up Ruby
1515
uses: ruby/setup-ruby@v1
1616
with:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.9
1+
3.2.10

lib/rdf/mixin/mutable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def immutable?
4141
def load(url, graph_name: nil, **options)
4242
raise TypeError.new("#{self} is immutable") if immutable?
4343

44-
Reader.open(url, base_uri: url, **options) do |reader|
44+
Reader.open(url, **options.merge(base_uri: url)) do |reader|
4545
if graph_name
4646
statements = []
4747
reader.each_statement do |statement|

lib/rdf/ntriples/writer.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,18 @@ def self.escape_unicode(u, encoding)
125125
# @see http://www.w3.org/TR/n-triples/
126126
def self.escape_ascii(u, encoding)
127127
case (u = u.ord)
128-
when (0x00..0x07) then escape_utf16(u)
129-
when (0x0A) then "\\n"
130-
when (0x0D) then "\\r"
131-
when (0x0E..0x1F) then escape_utf16(u)
132-
when (0x22) then "\\\""
133-
when (0x5C) then "\\\\"
134-
when (0x7F) then escape_utf16(u)
135-
when (0x00..0x7F) then u.chr
136-
else
137-
raise ArgumentError.new("expected an ASCII character in (0x00..0x7F), but got 0x#{u.to_s(16)}")
128+
when (0x08) then "\\b"
129+
when (0x09) then "\\t"
130+
when (0x0A) then "\\n"
131+
when (0x0C) then "\\f"
132+
when (0x0D) then "\\r"
133+
when (0x22) then "\\\""
134+
when (0x5C) then "\\\\"
135+
when (0x00..0x1F) then escape_utf16(u)
136+
when (0x7F) then escape_utf16(u)
137+
when (0x20..0x7E) then u.chr
138+
else
139+
raise ArgumentError.new("expected an ASCII character in (0x00..0x7F), but got 0x#{u.to_s(16)}")
138140
end
139141
end
140142

lib/rdf/util/cache.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def []=(key, value)
8585
id = value.__id__
8686
@cache[key] = id
8787
@index[id] = key
88-
ObjectSpace.define_finalizer(value, proc {|id| @cache.delete(@index.delete(id))})
88+
ObjectSpace.define_finalizer(value, finalizer_proc)
8989
end
9090
value
9191
end
@@ -100,6 +100,12 @@ def delete(key)
100100
@cache.delete(key)
101101
@index.delete(id) if id
102102
end
103+
104+
private
105+
106+
def finalizer_proc
107+
proc { |id| @cache.delete(@index.delete(id)) }
108+
end
103109
end # ObjectSpaceCache
104110

105111
##

lib/rdf/util/logger.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ def log_debug(*args, level: :debug, **options, &block)
181181
end
182182

183183
##
184-
# @overload log_depth(options, &block)
184+
# @overload log_depth(depth: 1, **options, &block)
185185
# Increase depth around a method invocation
186+
# @param [Integer] :depth Additional recursion depth
186187
# @param [Hash{Symbol}] options (@options || {})
187-
# @option options [Integer] :depth Additional recursion depth
188188
# @option options [Logger, #<<] :logger
189189
# @yield
190190
# Yields with no arguments
@@ -194,8 +194,8 @@ def log_debug(*args, level: :debug, **options, &block)
194194
# @overload log_depth
195195
# # Return the current log depth
196196
# @return [Integer]
197-
def log_depth(**options, &block)
198-
self.logger(**options).log_depth(&block)
197+
def log_depth(depth: 1, **options, &block)
198+
self.logger(**options).log_depth(depth: depth, &block)
199199
end
200200

201201
private
@@ -244,7 +244,7 @@ def log_statistics
244244
end
245245

246246
##
247-
# @overload log_depth(options, &block)
247+
# @overload log_depth(depth: 1, **options, &block)
248248
# Increase depth around a method invocation
249249
# @param [Integer] depth (1) recursion depth
250250
# @param [Hash{Symbol}] options (@options || {})

rdf.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ Gem::Specification.new do |gem|
3535
gem.add_development_dependency 'rdf-vocab', '~> 3.2'
3636
gem.add_development_dependency 'rdf-xsd', '~> 3.2', '>= 3.2.1'
3737
gem.add_development_dependency 'rest-client', '~> 2.1'
38-
gem.add_development_dependency 'rspec', '~> 3.10'
38+
gem.add_development_dependency 'rspec', '~> 3.12'
3939
gem.add_development_dependency 'rspec-its', '~> 1.3'
40-
gem.add_development_dependency 'webmock', '~> 3.14'
40+
gem.add_development_dependency 'webmock', '~> 3.18'
4141
gem.add_development_dependency 'yard', '~> 0.9'
42-
gem.add_development_dependency 'faraday', '~> 1.8'
42+
gem.add_development_dependency 'faraday', '~> 1.10'
4343
gem.add_development_dependency 'faraday_middleware', '~> 1.2'
4444

4545
gem.post_install_message = nil

spec/ntriples_spec.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@
573573
end
574574
end
575575

576-
context "Writing a Statements" do
576+
context "Writing Statements" do
577577
let(:statements) {[
578578
RDF::Statement(RDF::URI('s'), RDF::URI('p'), RDF::URI('o1')),
579579
RDF::Statement(RDF::URI('s'), RDF::URI('p'), RDF::URI('o2'))
@@ -600,6 +600,10 @@
600600
expect(writer.new.format_literal(RDF::Literal.new('Hello, world!'))).to eq '"Hello, world!"'
601601
end
602602

603+
it "should correctly format string literals" do
604+
expect(writer.new.format_literal(RDF::Literal.new('Hello, world!', datatype: RDF::XSD.string))).to eq '"Hello, world!"'
605+
end
606+
603607
it "should correctly format language-tagged literals" do
604608
expect(writer.new.format_literal(RDF::Literal.new('Hello, world!', language: :en))).to eq '"Hello, world!"@en'
605609
end
@@ -848,11 +852,11 @@
848852
# @see http://www.w3.org/TR/rdf-testcases/#ntrip_strings
849853
it "should correctly escape ASCII characters (#x0-#x7F)" do
850854
(0x00..0x07).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" }
851-
expect(writer.escape(0x08.chr, encoding)).to eq "\b"
852-
expect(writer.escape(0x09.chr, encoding)).to eq "\t"
855+
expect(writer.escape(0x08.chr, encoding)).to eq "\\b"
856+
expect(writer.escape(0x09.chr, encoding)).to eq "\\t"
853857
expect(writer.escape(0x0A.chr, encoding)).to eq "\\n"
854-
expect(writer.escape(0x0B.chr, encoding)).to eq "\v"
855-
expect(writer.escape(0x0C.chr, encoding)).to eq "\f"
858+
expect(writer.escape(0x0B.chr, encoding)).to eq "\\u000B"
859+
expect(writer.escape(0x0C.chr, encoding)).to eq "\\f"
856860
expect(writer.escape(0x0D.chr, encoding)).to eq "\\r"
857861
(0x0E..0x1F).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" }
858862
(0x20..0x21).each { |u| expect(writer.escape(u.chr, encoding)).to eq u.chr }
@@ -910,11 +914,11 @@
910914
# @see http://www.w3.org/TR/rdf-testcases/#ntrip_strings
911915
it "should correctly escape ASCII characters (#x0-#x7F)" do
912916
(0x00..0x07).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" }
913-
expect(writer.escape(0x08.chr, encoding)).to eq "\b"
914-
expect(writer.escape(0x09.chr, encoding)).to eq "\t"
917+
expect(writer.escape(0x08.chr, encoding)).to eq "\\b"
918+
expect(writer.escape(0x09.chr, encoding)).to eq "\\t"
915919
expect(writer.escape(0x0A.chr, encoding)).to eq "\\n"
916-
expect(writer.escape(0x0B.chr, encoding)).to eq "\v"
917-
expect(writer.escape(0x0C.chr, encoding)).to eq "\f"
920+
expect(writer.escape(0x0B.chr, encoding)).to eq "\\u000B"
921+
expect(writer.escape(0x0C.chr, encoding)).to eq "\\f"
918922
expect(writer.escape(0x0D.chr, encoding)).to eq "\\r"
919923
(0x0E..0x1F).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" }
920924
(0x20..0x21).each { |u| expect(writer.escape(u.chr, encoding)).to eq u.chr }

spec/util/cache_spec.rb

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
require_relative '../spec_helper'
2+
3+
describe RDF::Util::Cache do
4+
subject(:cache) do
5+
described_class.new(10)
6+
end
7+
8+
describe '#capacity' do
9+
it 'returns the cache size' do
10+
expect(cache.capacity).to eq 10
11+
end
12+
end
13+
14+
describe '#size' do
15+
it 'returns the cache size' do
16+
cache[:key] = {}
17+
expect(cache.size).to eq 1
18+
end
19+
end
20+
21+
describe '#[]' do
22+
it 'returns the value' do
23+
cache[:key] = {}
24+
expect(cache[:key]).to eq({})
25+
end
26+
end
27+
28+
describe '#[]=' do
29+
context 'when the cache is not full' do
30+
it 'stores the value' do
31+
expect {
32+
cache[:key] = {}
33+
}.to change(cache, :size).by(1)
34+
end
35+
36+
it 'returns the value' do
37+
expect(cache[:key] = {}).to eq({})
38+
end
39+
end
40+
41+
context 'when the cache is full' do
42+
before do
43+
10.times { |i| cache[i] = {} }
44+
end
45+
46+
it 'does not store the value' do
47+
expect {
48+
cache[:key] = {}
49+
}.not_to change(cache, :size)
50+
end
51+
52+
it 'returns the value' do
53+
expect(cache[:key] = {}).to eq({})
54+
end
55+
end
56+
end
57+
58+
context 'when the GC starts' do
59+
before do
60+
100.times { |i| cache[i] = {}; nil }
61+
end
62+
63+
# Sometimes the last reference is not gc
64+
it 'cleans the unused references' do
65+
expect {
66+
GC.start
67+
}.to change(cache, :size).by_at_most(-9)
68+
end
69+
end
70+
71+
describe '#delete' do
72+
before do
73+
cache[:key] = {}
74+
end
75+
76+
it 'delete the value' do
77+
expect { cache.delete(:key) }.to change(cache, :size).to(0)
78+
end
79+
end
80+
end

spec/vocabulary_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@
462462

463463
describe ".imports" do
464464
{
465-
RDF::Vocab::FOAF => [],
466-
RDF::Vocab::WOT => [RDF::RDFS, RDF::OWL]
465+
RDF::Vocab::FOAF => []
467466
}.each do |v, r|
468467
context v.to_uri do
469468
subject {v}
@@ -476,8 +475,7 @@
476475

477476
describe ".imported_from" do
478477
{
479-
RDF::RDFS => [RDF::OWL, RDF::Vocab::WOT],
480-
RDF::OWL => [RDF::Vocab::WOT]
478+
RDF::RDFS => [RDF::OWL],
481479
}.each do |v, r|
482480
context v.to_uri do
483481
subject {v}

0 commit comments

Comments
 (0)