Skip to content

Commit

Permalink
Finish 3.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Apr 15, 2023
2 parents 9dcc68b + bc385ee commit 105d295
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 45 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby:
- 2.6
- 2.7
- "3.0"
- 3.1
- ruby-head
- jruby
ruby: [2.6, 2.7, '3.0', 3.1, 3.2, ruby-head, jruby]
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -54,15 +48,15 @@ jobs:
runs-on: windows-latest
env:
CI: true
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' || matrix.ruby == '3.1' }}
strategy:
fail-fast: false
matrix:
ruby:
- 3.1
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Update gh-pages with docs
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.9
3.2.10
2 changes: 1 addition & 1 deletion lib/rdf/mixin/mutable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def immutable?
def load(url, graph_name: nil, **options)
raise TypeError.new("#{self} is immutable") if immutable?

Reader.open(url, base_uri: url, **options) do |reader|
Reader.open(url, **options.merge(base_uri: url)) do |reader|
if graph_name
statements = []
reader.each_statement do |statement|
Expand Down
22 changes: 12 additions & 10 deletions lib/rdf/ntriples/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,18 @@ def self.escape_unicode(u, encoding)
# @see http://www.w3.org/TR/n-triples/
def self.escape_ascii(u, encoding)
case (u = u.ord)
when (0x00..0x07) then escape_utf16(u)
when (0x0A) then "\\n"
when (0x0D) then "\\r"
when (0x0E..0x1F) then escape_utf16(u)
when (0x22) then "\\\""
when (0x5C) then "\\\\"
when (0x7F) then escape_utf16(u)
when (0x00..0x7F) then u.chr
else
raise ArgumentError.new("expected an ASCII character in (0x00..0x7F), but got 0x#{u.to_s(16)}")
when (0x08) then "\\b"
when (0x09) then "\\t"
when (0x0A) then "\\n"
when (0x0C) then "\\f"
when (0x0D) then "\\r"
when (0x22) then "\\\""
when (0x5C) then "\\\\"
when (0x00..0x1F) then escape_utf16(u)
when (0x7F) then escape_utf16(u)
when (0x20..0x7E) then u.chr
else
raise ArgumentError.new("expected an ASCII character in (0x00..0x7F), but got 0x#{u.to_s(16)}")
end
end

Expand Down
8 changes: 7 additions & 1 deletion lib/rdf/util/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def []=(key, value)
id = value.__id__
@cache[key] = id
@index[id] = key
ObjectSpace.define_finalizer(value, proc {|id| @cache.delete(@index.delete(id))})
ObjectSpace.define_finalizer(value, finalizer_proc)
end
value
end
Expand All @@ -100,6 +100,12 @@ def delete(key)
@cache.delete(key)
@index.delete(id) if id
end

private

def finalizer_proc
proc { |id| @cache.delete(@index.delete(id)) }
end
end # ObjectSpaceCache

##
Expand Down
10 changes: 5 additions & 5 deletions lib/rdf/util/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ def log_debug(*args, level: :debug, **options, &block)
end

##
# @overload log_depth(options, &block)
# @overload log_depth(depth: 1, **options, &block)
# Increase depth around a method invocation
# @param [Integer] :depth Additional recursion depth
# @param [Hash{Symbol}] options (@options || {})
# @option options [Integer] :depth Additional recursion depth
# @option options [Logger, #<<] :logger
# @yield
# Yields with no arguments
Expand All @@ -194,8 +194,8 @@ def log_debug(*args, level: :debug, **options, &block)
# @overload log_depth
# # Return the current log depth
# @return [Integer]
def log_depth(**options, &block)
self.logger(**options).log_depth(&block)
def log_depth(depth: 1, **options, &block)
self.logger(**options).log_depth(depth: depth, &block)
end

private
Expand Down Expand Up @@ -244,7 +244,7 @@ def log_statistics
end

##
# @overload log_depth(options, &block)
# @overload log_depth(depth: 1, **options, &block)
# Increase depth around a method invocation
# @param [Integer] depth (1) recursion depth
# @param [Hash{Symbol}] options (@options || {})
Expand Down
6 changes: 3 additions & 3 deletions rdf.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'rdf-vocab', '~> 3.2'
gem.add_development_dependency 'rdf-xsd', '~> 3.2', '>= 3.2.1'
gem.add_development_dependency 'rest-client', '~> 2.1'
gem.add_development_dependency 'rspec', '~> 3.10'
gem.add_development_dependency 'rspec', '~> 3.12'
gem.add_development_dependency 'rspec-its', '~> 1.3'
gem.add_development_dependency 'webmock', '~> 3.14'
gem.add_development_dependency 'webmock', '~> 3.18'
gem.add_development_dependency 'yard', '~> 0.9'
gem.add_development_dependency 'faraday', '~> 1.8'
gem.add_development_dependency 'faraday', '~> 1.10'
gem.add_development_dependency 'faraday_middleware', '~> 1.2'

gem.post_install_message = nil
Expand Down
22 changes: 13 additions & 9 deletions spec/ntriples_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@
end
end

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

it "should correctly format string literals" do
expect(writer.new.format_literal(RDF::Literal.new('Hello, world!', datatype: RDF::XSD.string))).to eq '"Hello, world!"'
end

it "should correctly format language-tagged literals" do
expect(writer.new.format_literal(RDF::Literal.new('Hello, world!', language: :en))).to eq '"Hello, world!"@en'
end
Expand Down Expand Up @@ -848,11 +852,11 @@
# @see http://www.w3.org/TR/rdf-testcases/#ntrip_strings
it "should correctly escape ASCII characters (#x0-#x7F)" do
(0x00..0x07).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" }
expect(writer.escape(0x08.chr, encoding)).to eq "\b"
expect(writer.escape(0x09.chr, encoding)).to eq "\t"
expect(writer.escape(0x08.chr, encoding)).to eq "\\b"
expect(writer.escape(0x09.chr, encoding)).to eq "\\t"
expect(writer.escape(0x0A.chr, encoding)).to eq "\\n"
expect(writer.escape(0x0B.chr, encoding)).to eq "\v"
expect(writer.escape(0x0C.chr, encoding)).to eq "\f"
expect(writer.escape(0x0B.chr, encoding)).to eq "\\u000B"
expect(writer.escape(0x0C.chr, encoding)).to eq "\\f"
expect(writer.escape(0x0D.chr, encoding)).to eq "\\r"
(0x0E..0x1F).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" }
(0x20..0x21).each { |u| expect(writer.escape(u.chr, encoding)).to eq u.chr }
Expand Down Expand Up @@ -910,11 +914,11 @@
# @see http://www.w3.org/TR/rdf-testcases/#ntrip_strings
it "should correctly escape ASCII characters (#x0-#x7F)" do
(0x00..0x07).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" }
expect(writer.escape(0x08.chr, encoding)).to eq "\b"
expect(writer.escape(0x09.chr, encoding)).to eq "\t"
expect(writer.escape(0x08.chr, encoding)).to eq "\\b"
expect(writer.escape(0x09.chr, encoding)).to eq "\\t"
expect(writer.escape(0x0A.chr, encoding)).to eq "\\n"
expect(writer.escape(0x0B.chr, encoding)).to eq "\v"
expect(writer.escape(0x0C.chr, encoding)).to eq "\f"
expect(writer.escape(0x0B.chr, encoding)).to eq "\\u000B"
expect(writer.escape(0x0C.chr, encoding)).to eq "\\f"
expect(writer.escape(0x0D.chr, encoding)).to eq "\\r"
(0x0E..0x1F).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" }
(0x20..0x21).each { |u| expect(writer.escape(u.chr, encoding)).to eq u.chr }
Expand Down
80 changes: 80 additions & 0 deletions spec/util/cache_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
require_relative '../spec_helper'

describe RDF::Util::Cache do
subject(:cache) do
described_class.new(10)
end

describe '#capacity' do
it 'returns the cache size' do
expect(cache.capacity).to eq 10
end
end

describe '#size' do
it 'returns the cache size' do
cache[:key] = {}
expect(cache.size).to eq 1
end
end

describe '#[]' do
it 'returns the value' do
cache[:key] = {}
expect(cache[:key]).to eq({})
end
end

describe '#[]=' do
context 'when the cache is not full' do
it 'stores the value' do
expect {
cache[:key] = {}
}.to change(cache, :size).by(1)
end

it 'returns the value' do
expect(cache[:key] = {}).to eq({})
end
end

context 'when the cache is full' do
before do
10.times { |i| cache[i] = {} }
end

it 'does not store the value' do
expect {
cache[:key] = {}
}.not_to change(cache, :size)
end

it 'returns the value' do
expect(cache[:key] = {}).to eq({})
end
end
end

context 'when the GC starts' do
before do
100.times { |i| cache[i] = {}; nil }
end

# Sometimes the last reference is not gc
it 'cleans the unused references' do
expect {
GC.start
}.to change(cache, :size).by_at_most(-9)
end
end

describe '#delete' do
before do
cache[:key] = {}
end

it 'delete the value' do
expect { cache.delete(:key) }.to change(cache, :size).to(0)
end
end
end
6 changes: 2 additions & 4 deletions spec/vocabulary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@

describe ".imports" do
{
RDF::Vocab::FOAF => [],
RDF::Vocab::WOT => [RDF::RDFS, RDF::OWL]
RDF::Vocab::FOAF => []
}.each do |v, r|
context v.to_uri do
subject {v}
Expand All @@ -476,8 +475,7 @@

describe ".imported_from" do
{
RDF::RDFS => [RDF::OWL, RDF::Vocab::WOT],
RDF::OWL => [RDF::Vocab::WOT]
RDF::RDFS => [RDF::OWL],
}.each do |v, r|
context v.to_uri do
subject {v}
Expand Down

0 comments on commit 105d295

Please sign in to comment.