Skip to content

Commit 2b73d12

Browse files
committed
Finish 3.2.7
2 parents 84063a9 + 8573895 commit 2b73d12

File tree

10 files changed

+120
-11
lines changed

10 files changed

+120
-11
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,31 @@ jobs:
4848
if: "matrix.ruby == '3.0'"
4949
with:
5050
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
wintests:
52+
name: Win64 Ruby ${{ matrix.ruby }}
53+
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
54+
runs-on: windows-latest
55+
env:
56+
CI: true
57+
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
ruby:
62+
- 3.1
63+
steps:
64+
- name: Clone repository
65+
uses: actions/checkout@v2
66+
- name: Set up Ruby
67+
uses: ruby/setup-ruby@v1
68+
with:
69+
ruby-version: ${{ matrix.ruby }}
70+
- name: Install dependencies
71+
run: bundle install --jobs 4 --retry 3
72+
- name: Run tests
73+
run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
74+
- name: Coveralls GitHub Action
75+
uses: coverallsapp/[email protected]
76+
if: "matrix.ruby == '3.0'"
77+
with:
78+
github-token: ${{ secrets.GITHUB_TOKEN }}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.6
1+
3.2.7

lib/rdf/cli.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,8 @@ def self.exec(args, output: $stdout, option_parser: nil, messages: {}, **options
572572
# @param [Hash{Symbol => Object}] options already set
573573
# @return [Array<String>] list of executable commands
574574
# @overload commands(format: :json, **options)
575-
# @param [:json] format (:json)
575+
# Returns commands as JSON, for API usage.
576+
# @param [:json] format
576577
# @param [Hash{Symbol => Object}] options already set
577578
# @return [Array{Object}]
578579
# Returns an array of commands including the command symbol
@@ -593,7 +594,7 @@ def self.commands(format: nil, **options)
593594
# Subset commands based on filter options
594595
cmds = COMMANDS.reject do |k, c|
595596
c.fetch(:filter, {}).any? do |opt, val|
596-
options[opt].to_s != val.to_s
597+
options.merge(format: format)[opt].to_s != val.to_s
597598
end
598599
end
599600

lib/rdf/format.rb

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ module RDF
2323
#
2424
# @example Defining a new RDF serialization format class
2525
# class RDF::NTriples::Format < RDF::Format
26-
# content_type 'application/n-triples', extension: :nt
26+
# content_type 'application/n-triples',
27+
# extension: :nt,
28+
# uri: RDF::URI("http://www.w3.org/ns/formats/N-Triples")
2729
# content_encoding 'utf-8'
2830
#
2931
# reader RDF::NTriples::Reader
@@ -222,6 +224,19 @@ def self.file_extensions
222224
@@file_extensions
223225
end
224226

227+
##
228+
# Returns the unique URI for the format.
229+
#
230+
# @example retrieving a list of supported file format URIs
231+
#
232+
# RDF::Format.uris.keys
233+
#
234+
# @see https://www.w3.org/ns/formats/
235+
# @return [Hash{Symbol => URI}]
236+
def self.uris
237+
@@uris
238+
end
239+
225240
##
226241
# Returns the set of format symbols for available RDF::Reader subclasses.
227242
#
@@ -465,6 +480,7 @@ class << self
465480
# @option options [Array<String>] :aliases (nil)
466481
# @option options [Symbol] :extension (nil)
467482
# @option options [Array<Symbol>] :extensions (nil)
483+
# @option options [URI] :uri (nil)
468484
# @return [void]
469485
#
470486
# @overload content_type
@@ -504,6 +520,10 @@ def self.content_type(type = nil, options = {})
504520
@@content_types[aa] << self unless @@content_types[aa].include?(self)
505521
end
506522
end
523+
# URI identifying this format
524+
if uri = options[:uri]
525+
@@uris[RDF::URI(uri)] = self
526+
end
507527
end
508528
end
509529

@@ -517,7 +537,7 @@ def self.accept_type
517537
end
518538

519539
##
520-
# Retrieves or defines file extensions for this RDF serialization format.
540+
# Retrieves file extensions for this RDF serialization format.
521541
#
522542
# The return is an array where the first element is the cannonical
523543
# file extension for the format and following elements are alias file extensions.
@@ -527,6 +547,17 @@ def self.file_extension
527547
@@file_extensions.map {|ext, formats| ext if formats.include?(self)}.compact
528548
end
529549

550+
##
551+
# Retrieves any format URI defined for this format..
552+
#
553+
# @return [URI]
554+
def self.uri
555+
@@uris.invert[self]
556+
end
557+
class << self
558+
alias_method :to_uri, :uri
559+
end
560+
530561
protected
531562

532563
##
@@ -568,6 +599,7 @@ def self.content_encoding(encoding = nil)
568599
@@readers = {} # @private
569600
@@writers = {} # @private
570601
@@subclasses = [] # @private
602+
@@uris = {} # @private
571603

572604
##
573605
# @private

lib/rdf/model/uri.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class URI
7676
IRI = Regexp.compile("^#{SCHEME}:(?:#{IHIER_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
7777

7878
# Split an IRI into it's component parts
79+
# scheme, authority, path, query, fragment
7980
IRI_PARTS = /^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(\?[^#]*)?(#.*)?$/.freeze
8081

8182
# Remove dot expressions regular expressions
@@ -872,6 +873,12 @@ def parse(value)
872873
parts = {}
873874
if matchdata = IRI_PARTS.match(value)
874875
scheme, authority, path, query, fragment = matchdata[1..-1]
876+
877+
if Gem.win_platform? && scheme && !authority && scheme.match?(/^[a-zA-Z]$/)
878+
# A drive letter, not a scheme
879+
scheme, path = nil, "#{scheme}:#{path}"
880+
end
881+
875882
userinfo, hostport = authority.to_s.split('@', 2)
876883
hostport, userinfo = userinfo, nil unless hostport
877884
user, password = userinfo.to_s.split(':', 2)

lib/rdf/nquads.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ module NQuads
2020
# @see http://www.w3.org/TR/n-quads/
2121
# @since 0.4.0
2222
class Format < RDF::Format
23-
content_type 'application/n-quads', extension: :nq, alias: 'text/x-nquads;q=0.2'
23+
content_type 'application/n-quads',
24+
extension: :nq,
25+
alias: 'text/x-nquads;q=0.2',
26+
uri: RDF::URI("http://www.w3.org/ns/formats/N-Quads")
2427
content_encoding 'utf-8'
2528

2629
reader { RDF::NQuads::Reader }

lib/rdf/ntriples/format.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ module RDF::NTriples
1616
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
1717
# @see http://www.w3.org/TR/n-triples/
1818
class Format < RDF::Format
19-
content_type 'application/n-triples', extension: :nt, alias: 'text/plain;q=0.2'
19+
content_type 'application/n-triples',
20+
extension: :nt,
21+
alias: 'text/plain;q=0.2',
22+
uri: RDF::URI("http://www.w3.org/ns/formats/N-Triples")
2023
content_encoding 'utf-8'
2124

2225
reader { RDF::NTriples::Reader }

spec/format_spec.rb

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
class RDF::Format::FooFormat < RDF::Format
77
content_type 'application/test;q=1',
8-
extension: :test
8+
extension: :test,
9+
uri: "http://example.com/ns/formats/Foo"
910
reader { RDF::NTriples::Reader }
1011
def self.detect(sample)
1112
sample == "foo"
@@ -16,7 +17,8 @@ def self.to_sym; :foo_bar; end
1617
class RDF::Format::BarFormat < RDF::Format
1718
content_type 'application/test',
1819
extension: :test,
19-
alias: 'application/x-test;q=0.1'
20+
alias: 'application/x-test;q=0.1',
21+
uri: "http://example.com/ns/formats/Bar"
2022
reader { RDF::NTriples::Reader }
2123
def self.detect(sample)
2224
sample == "bar"
@@ -129,6 +131,16 @@ def self.to_sym; :foo_bar; end
129131
end
130132
end
131133

134+
describe ".uris" do
135+
it "returns accept-types of available readers with quality" do
136+
expect(RDF::Format.accept_types).to include(*%w(
137+
application/n-triples text/plain;q=0.2
138+
application/n-quads text/x-nquads;q=0.2
139+
application/test application/x-test;q=0.1
140+
))
141+
end
142+
end
143+
132144
describe ".writer_symbols" do
133145
it "returns symbols of available writers" do
134146
%i(ntriples nquads).each do |sym|
@@ -152,6 +164,15 @@ def self.to_sym; :foo_bar; end
152164
end
153165
end
154166

167+
describe ".uris" do
168+
it "matches format classes to URIs" do
169+
RDF::Format.uris.each do |u, c|
170+
expect(u).to be_a(RDF::URI)
171+
expect(c).to respond_to(:content_type)
172+
end
173+
end
174+
end
175+
155176
RDF::Format.each do |format|
156177
context format.name do
157178
subject {format}
@@ -166,6 +187,20 @@ def self.to_sym; :foo_bar; end
166187
end
167188
end
168189

190+
describe RDF::NTriples::Format do
191+
it "has a format URI" do
192+
expect(described_class.uri).to eql RDF::URI('http://www.w3.org/ns/formats/N-Triples')
193+
expect(described_class.to_uri).to eql RDF::URI('http://www.w3.org/ns/formats/N-Triples')
194+
end
195+
end
196+
197+
describe RDF::NQuads::Format do
198+
it "has a format URI" do
199+
expect(described_class.uri).to eql RDF::URI('http://www.w3.org/ns/formats/N-Quads')
200+
expect(described_class.to_uri).to eql RDF::URI('http://www.w3.org/ns/formats/N-Quads')
201+
end
202+
end
203+
169204
context "Examples" do
170205
require 'rdf/ntriples'
171206
subject {RDF::Format}

spec/model_uri_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@
620620
%w(http://foo/bar# /a) => "<http://foo/a>",
621621
%w(http://foo/bar# #a) => "<http://foo/bar#a>",
622622

623-
%w(http://a/bb/ccc/.. g:h) => "<g:h>",
623+
%w(http://a/bb/ccc/.. gg:h) => "<gg:h>",
624624
%w(http://a/bb/ccc/.. g) => "<http://a/bb/ccc/g>",
625625
%w(http://a/bb/ccc/.. ./g) => "<http://a/bb/ccc/g>",
626626
%w(http://a/bb/ccc/.. g/) => "<http://a/bb/ccc/g/>",

spec/ntriples_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@
630630
expect(output.string).to eq "#{stmt_string}\n"
631631
end
632632

633-
it "should dump statements to a file" do
633+
it "should dump statements to a file", skip: ('not windows' if Gem.win_platform?) do
634634
require 'tmpdir' # for Dir.tmpdir
635635
writer.dump(graph, filename = File.join(Dir.tmpdir, "test.nt"))
636636
expect(File.read(filename)).to eq "#{stmt_string}\n"

0 commit comments

Comments
 (0)