diff options
-rw-r--r-- | lib/bundler/compact_index_client/cache.rb | 4 | ||||
-rw-r--r-- | lib/bundler/compact_index_client/updater.rb | 2 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 1 | ||||
-rw-r--r-- | lib/bundler/plugin/api/source.rb | 3 | ||||
-rw-r--r-- | lib/bundler/rubygems_gem_installer.rb | 2 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 2 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 5 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 3 | ||||
-rw-r--r-- | lib/bundler/source/rubygems/remote.rb | 2 |
9 files changed, 11 insertions, 13 deletions
diff --git a/lib/bundler/compact_index_client/cache.rb b/lib/bundler/compact_index_client/cache.rb index 029e53c30d..f6105d3bb3 100644 --- a/lib/bundler/compact_index_client/cache.rb +++ b/lib/bundler/compact_index_client/cache.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "digest" - module Bundler class CompactIndexClient class Cache @@ -69,7 +67,7 @@ module Bundler def info_path(name) name = name.to_s if name =~ /[^a-z0-9_-]/ - name += "-#{Digest(:MD5).hexdigest(name).downcase}" + name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}" info_roots.last.join(name) else info_roots.first.join(name) diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb index 19dc3a6228..91ca653e8d 100644 --- a/lib/bundler/compact_index_client/updater.rb +++ b/lib/bundler/compact_index_client/updater.rb @@ -104,7 +104,7 @@ module Bundler # because we need to preserve \n line endings on windows when calculating # the checksum SharedHelpers.filesystem_access(path, :read) do - Digest(:MD5).hexdigest(IO.read(path)) + SharedHelpers.digest(:MD5).hexdigest(IO.read(path)) end end end diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 5ae0f2e793..0ef920638b 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "bundler/lockfile_parser" -require "digest" require "set" module Bundler diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb index b27f919253..586477efb5 100644 --- a/lib/bundler/plugin/api/source.rb +++ b/lib/bundler/plugin/api/source.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "uri" -require "digest" module Bundler module Plugin @@ -272,7 +271,7 @@ module Bundler end def uri_hash - Digest(:SHA1).hexdigest(uri) + SharedHelpers.digest(:SHA1).hexdigest(uri) end # Note: Do not override if you don't know what you are doing. diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb index 6737c937b8..2b7fa8e0f6 100644 --- a/lib/bundler/rubygems_gem_installer.rb +++ b/lib/bundler/rubygems_gem_installer.rb @@ -48,7 +48,7 @@ module Bundler return true unless source = @package.instance_variable_get(:@gem) return true unless source.respond_to?(:with_read_io) digest = source.with_read_io do |io| - digest = Digest(:SHA256).new + digest = SharedHelpers.digest(:SHA256).new digest << io.read(16_384) until io.eof? io.rewind send(checksum_type(checksum), digest) diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index d86fa51372..f27597b854 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "digest" - module Bundler class Runtime include SharedHelpers diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index a18966b324..45185209f1 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -218,6 +218,11 @@ module Bundler end end + def digest(name) + require "digest" + Digest(name) + end + private def validate_bundle_path diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index d9f658d8bb..a1a59ddce5 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -2,7 +2,6 @@ require "bundler/vendored_fileutils" require "uri" -require "digest" module Bundler class Source @@ -284,7 +283,7 @@ module Bundler # If there is no URI scheme, assume it is an ssh/git URI input = uri end - Digest(:SHA1).hexdigest(input) + SharedHelpers.digest(:SHA1).hexdigest(input) end def cached_revision diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb index 9ee1a53eea..e73baaa992 100644 --- a/lib/bundler/source/rubygems/remote.rb +++ b/lib/bundler/source/rubygems/remote.rb @@ -26,7 +26,7 @@ module Bundler cache_uri = original_uri || uri uri_parts = [cache_uri.host, cache_uri.user, cache_uri.port, cache_uri.path] - uri_digest = Digest(:MD5).hexdigest(uri_parts.compact.join(".")) + uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.compact.join(".")) uri_parts[-1] = uri_digest uri_parts.compact.join(".") |