Skip to content

Commit

Permalink
Merge pull request #1312 from jeremyf/removing-deprecation-warning
Browse files Browse the repository at this point in the history
Removing warning for open-uri calling Kernel#open
  • Loading branch information
lsegal authored May 3, 2020
2 parents e3e8321 + a8f6c83 commit 21cf1e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/yard/cli/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ def load_gem_data(gemfile)
url = "http://rubygems.org/downloads/#{gemfile}"
log.info "Searching for remote gem file #{url}"
begin
open(url) {|io| expand_and_parse(gemfile, io) }
# Note: In Ruby 2.4.x, URI.open is a private method. After
# 2.5, URI.open behaves much like Kernel#open once you've
# required 'open-uri'
OpenURI.open_uri(url) {|io| expand_and_parse(gemfile, io) }
return true
rescue OpenURI::HTTPError
nil # noop
Expand Down
4 changes: 2 additions & 2 deletions spec/cli/diff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def baz; BAR end
expect(File).to receive(:directory?).with('gem2.gem').and_return(false)
expect(File).to receive(:exist?).with('gem1.gem').and_return(false)
expect(File).to receive(:exist?).with('gem2.gem').and_return(false)
expect(@diff).to receive(:open).with('http://rubygems.org/downloads/gem1.gem')
expect(@diff).to receive(:open).with('http://rubygems.org/downloads/gem2.gem')
expect(OpenURI).to receive(:open_uri).with('http://rubygems.org/downloads/gem1.gem')
expect(OpenURI).to receive(:open_uri).with('http://rubygems.org/downloads/gem2.gem')
allow(FileUtils).to receive(:mkdir_p)
allow(Gem::Package).to receive(:open)
allow(FileUtils).to receive(:rm_rf)
Expand Down

0 comments on commit 21cf1e6

Please sign in to comment.