Skip to content

Commit

Permalink
Re-figure File.open_file handling of the file scheme.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Oct 8, 2024
1 parent 71f70d5 commit 884e3ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/rdf/util/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def http_adapter(use_net_http = false)
# @yieldreturn [Object] returned from open_file
# @raise [IOError] if not found
def self.open_file(filename_or_url, proxy: nil, headers: {}, verify_none: false, **options, &block)
filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
remote_document = nil

if filename_or_url.to_s.match?(/^https?/)
Expand Down
11 changes: 11 additions & 0 deletions spec/util_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@
expect(r).to be_a(RDF::Reader)
end

it "yields a file scheme" do
path = fixture_path("test.nt")
path = Gem.win_platform? ? "file:/#{path}" : "file:#{path}"
r = RDF::Util::File.open_file(path) do |f|
expect(f).to respond_to(:read)
opened.opened
RDF::Reader.new
end
expect(r).to be_a(RDF::Reader)
end

it "raises IOError on missing local file" do
expect {RDF::Util::File.open_file(fixture_path("not-here"))}.to raise_error IOError
opened.opened
Expand Down

0 comments on commit 884e3ef

Please sign in to comment.