Skip to content

Commit aabc989

Browse files
committed
Suppress URI.open warning in Ruby 2.7
This PR suppresses the follwoing warning in Ruby 2.7 ```console % ruby -v ruby 2.7.0dev (2019-09-14T09:21:37Z master 39c37acf86) [x86_64-darwin17] % bundle exec thor spec (snip) /Users/koic/src/github.com/erikhuda/thor/lib/ty ./Users/koic/src/github.com/erikhuda/thor/lib/thor/actions/file_manipulation.rb:89: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly ``` cf ruby/ruby@05aac90.
1 parent edb975f commit aabc989

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/thor/actions/file_manipulation.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ def get(source, *args, &block)
8080
config = args.last.is_a?(Hash) ? args.pop : {}
8181
destination = args.first
8282

83-
if source =~ %r{^https?\://}
83+
render = if source =~ %r{^https?\://}
8484
require "open-uri"
85+
URI.send(:open, source) { |input| input.binmode.read }
8586
else
8687
source = File.expand_path(find_in_source_paths(source.to_s))
88+
open(source) { |input| input.binmode.read }
8789
end
8890

89-
render = open(source) { |input| input.binmode.read }
90-
9191
destination ||= if block_given?
9292
block.arity == 1 ? yield(render) : yield
9393
else

0 commit comments

Comments
 (0)