diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-12-27 08:56:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-27 08:56:00 +0900 |
commit | 9736cb890bb80924e7d1f3189232bfe60519bd29 (patch) | |
tree | 14a239c4cdbf38a34161d6287b627c6542294232 /lib/bundler/shared_helpers.rb | |
parent | 1f877fa238a839dcb77fb88158ea912a43cbf564 (diff) | |
download | ruby-9736cb890bb80924e7d1f3189232bfe60519bd29.tar.gz |
Check if `Kernel#untaint` is defined instead of version comparison
Probably `RUBY_VERSION` seems overwritten somewhere in the tests.
Diffstat (limited to 'lib/bundler/shared_helpers.rb')
-rw-r--r-- | lib/bundler/shared_helpers.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index e48010232a..a9de1625aa 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -13,13 +13,13 @@ module Bundler def root gemfile = find_gemfile raise GemfileNotFound, "Could not locate Gemfile" unless gemfile - Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent + Pathname.new(gemfile).tap{|x| x.untaint if Kernel.method_defined?(:untaint) }.expand_path.parent end def default_gemfile gemfile = find_gemfile raise GemfileNotFound, "Could not locate Gemfile" unless gemfile - Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path + Pathname.new(gemfile).tap{|x| x.untaint if Kernel.method_defined?(:untaint) }.expand_path end def default_lockfile @@ -28,7 +28,7 @@ module Bundler case gemfile.basename.to_s when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked")) else Pathname.new("#{gemfile}.lock") - end.tap{|x| x.untaint if RUBY_VERSION < "2.7" } + end.tap{|x| x.untaint if Kernel.method_defined?(:untaint) } end def default_bundle_dir @@ -100,7 +100,7 @@ module Bundler # # @see {Bundler::PermissionError} def filesystem_access(path, action = :write, &block) - yield(path.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }) + yield(path.dup.tap{|x| x.untaint if Kernel.method_defined?(:untaint) }) rescue Errno::EACCES raise PermissionError.new(path, action) rescue Errno::EAGAIN @@ -236,7 +236,7 @@ module Bundler def search_up(*names) previous = nil - current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" } + current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if Kernel.method_defined?(:untaint) } until !File.directory?(current) || current == previous if ENV["BUNDLER_SPEC_RUN"] |