summaryrefslogtreecommitdiff
path: root/lib/rubygems/test_utilities.rb
diff options
context:
space:
mode:
authorOlle Jonsson <olle.jonsson@auctionet.com>2020-04-19 18:06:02 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-06-05 07:32:42 +0900
commitf61ee674d8c5871e8e81b1a7f5884635a0ee9803 (patch)
treeaa956731f75c20eaa39b7366d0428155df685a77 /lib/rubygems/test_utilities.rb
parentdd5b918cbead5fdb641118aa4e4d90e013f90df1 (diff)
[rubygems/rubygems] Prefer start_with? and end_with? over regex.
- In one of the cases, filenames were checked for ending with "gz" - this is changed to check for ending with ".gz" - The change was made to make it even easier to read the code, and to match only from the start of the input (as opposed to start of the line) https://github.com/rubygems/rubygems/commit/aac4290271
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3184
Diffstat (limited to 'lib/rubygems/test_utilities.rb')
-rw-r--r--lib/rubygems/test_utilities.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 0edf3d6a61..0ad167b19a 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -49,7 +49,7 @@ class Gem::FakeFetcher
path = path.to_s
@paths << path
- raise ArgumentError, 'need full URI' unless path =~ %r{^https?://}
+ raise ArgumentError, 'need full URI' unless path.start_with?("https://", "http://")
unless @data.key? path
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
@@ -67,7 +67,7 @@ class Gem::FakeFetcher
if data.respond_to?(:call)
data.call
else
- if path.to_s =~ /gz$/ and not data.nil? and not data.empty?
+ if path.to_s.end_with?(".gz") and not data.nil? and not data.empty?
data = Gem::Util.gunzip data
end
data