summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-10-15 11:37:41 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-10-15 11:37:41 -0500
commit9e3e39896f9c682782fcc00bd27f81e2a284b2bb (patch)
tree61c7b754b0dad4feac32b4c799da8676f1d88a2d
parentfea177f61df71121c6f9422a74b093e42c504388 (diff)
downloadbundler-seg-digest-loading.tar.gz
Load digest subclasses in a thread-safe mannerseg-digest-loading
-rw-r--r--lib/bundler/compact_index_client/cache.rb4
-rw-r--r--lib/bundler/compact_index_client/updater.rb2
-rw-r--r--lib/bundler/definition.rb2
-rw-r--r--lib/bundler/plugin/api/source.rb4
-rw-r--r--lib/bundler/runtime.rb2
-rw-r--r--lib/bundler/source/git.rb4
-rw-r--r--lib/bundler/source/rubygems/remote.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/runner.rb4
-rw-r--r--spec/bundler/plugin/api/source_spec.rb2
-rw-r--r--spec/bundler/source/rubygems/remote_spec.rb2
-rw-r--r--spec/commands/clean_spec.rb6
-rw-r--r--spec/plugins/source/example_spec.rb2
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/artifice/compact_index.rb2
14 files changed, 20 insertions, 20 deletions
diff --git a/lib/bundler/compact_index_client/cache.rb b/lib/bundler/compact_index_client/cache.rb
index 264e31716d..029e53c30d 100644
--- a/lib/bundler/compact_index_client/cache.rb
+++ b/lib/bundler/compact_index_client/cache.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "digest/md5"
+require "digest"
module Bundler
class CompactIndexClient
@@ -69,7 +69,7 @@ module Bundler
def info_path(name)
name = name.to_s
if name =~ /[^a-z0-9_-]/
- name += "-#{Digest::MD5.hexdigest(name).downcase}"
+ name += "-#{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 e80574e3ba..19dc3a6228 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))
+ Digest(:MD5).hexdigest(IO.read(path))
end
end
end
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 4b9a781c82..f4022da04e 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require "bundler/lockfile_parser"
-require "digest/sha1"
+require "digest"
require "set"
module Bundler
diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb
index aadd65e65e..b27f919253 100644
--- a/lib/bundler/plugin/api/source.rb
+++ b/lib/bundler/plugin/api/source.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require "uri"
-require "digest/sha1"
+require "digest"
module Bundler
module Plugin
@@ -272,7 +272,7 @@ module Bundler
end
def uri_hash
- Digest::SHA1.hexdigest(uri)
+ Digest(:SHA1).hexdigest(uri)
end
# Note: Do not override if you don't know what you are doing.
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index c94effd3a8..d86fa51372 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "digest/sha1"
+require "digest"
module Bundler
class Runtime
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index 97bc1724a0..d9f658d8bb 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -2,7 +2,7 @@
require "bundler/vendored_fileutils"
require "uri"
-require "digest/sha1"
+require "digest"
module Bundler
class Source
@@ -284,7 +284,7 @@ module Bundler
# If there is no URI scheme, assume it is an ssh/git URI
input = uri
end
- Digest::SHA1.hexdigest(input)
+ 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 67f4f373db..9ee1a53eea 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 = Digest(:MD5).hexdigest(uri_parts.compact.join("."))
uri_parts[-1] = uri_digest
uri_parts.compact.join(".")
diff --git a/lib/bundler/vendor/thor/lib/thor/runner.rb b/lib/bundler/vendor/thor/lib/thor/runner.rb
index 65ae422d7f..b110b8d478 100644
--- a/lib/bundler/vendor/thor/lib/thor/runner.rb
+++ b/lib/bundler/vendor/thor/lib/thor/runner.rb
@@ -3,7 +3,7 @@ require "bundler/vendor/thor/lib/thor/group"
require "bundler/vendor/thor/lib/thor/core_ext/io_binary_read"
require "yaml"
-require "digest/md5"
+require "digest"
require "pathname"
class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
@@ -90,7 +90,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
end
thor_yaml[as] = {
- :filename => Digest::MD5.hexdigest(name + as),
+ :filename => Digest(:MD5).hexdigest(name + as),
:location => location,
:namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base)
}
diff --git a/spec/bundler/plugin/api/source_spec.rb b/spec/bundler/plugin/api/source_spec.rb
index 0118ff3d19..2c50ff56a4 100644
--- a/spec/bundler/plugin/api/source_spec.rb
+++ b/spec/bundler/plugin/api/source_spec.rb
@@ -36,7 +36,7 @@ RSpec.describe Bundler::Plugin::API::Source do
context "install_path" do
let(:uri) { "uri://to/a/repository-name" }
- let(:hash) { Digest::SHA1.hexdigest(uri) }
+ let(:hash) { Digest(:SHA1).hexdigest(uri) }
let(:install_path) { Pathname.new "/bundler/install/path" }
before do
diff --git a/spec/bundler/source/rubygems/remote_spec.rb b/spec/bundler/source/rubygems/remote_spec.rb
index 1aa008f3bb..9a7ab42128 100644
--- a/spec/bundler/source/rubygems/remote_spec.rb
+++ b/spec/bundler/source/rubygems/remote_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do
end
before do
- allow(Digest::MD5).to receive(:hexdigest).with(duck_type(:to_s)) {|string| "MD5HEX(#{string})" }
+ allow(Digest(:MD5)).to receive(:hexdigest).with(duck_type(:to_s)) {|string| "MD5HEX(#{string})" }
end
let(:uri_no_auth) { URI("https://gems.example.com") }
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 8113ae8c25..d0df6d30d7 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -141,7 +141,7 @@ RSpec.describe "bundle clean" do
bundle :clean
- digest = Digest::SHA1.hexdigest(git_path.to_s)
+ digest = Digest(:SHA1).hexdigest(git_path.to_s)
cache_path = Bundler::VERSION.start_with?("1.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}")
expect(cache_path).to exist
end
@@ -175,7 +175,7 @@ RSpec.describe "bundle clean" do
expect(vendored_gems("gems/rack-1.0.0")).to exist
expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).not_to exist
- digest = Digest::SHA1.hexdigest(git_path.to_s)
+ digest = Digest(:SHA1).hexdigest(git_path.to_s)
expect(vendored_gems("cache/bundler/git/foo-#{digest}")).not_to exist
expect(vendored_gems("specifications/rack-1.0.0.gemspec")).to exist
@@ -254,7 +254,7 @@ RSpec.describe "bundle clean" do
expect(out).to include("")
expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).to exist
- digest = Digest::SHA1.hexdigest(git_path.to_s)
+ digest = Digest(:SHA1).hexdigest(git_path.to_s)
expect(vendored_gems("cache/bundler/git/foo-#{digest}")).to_not exist
end
diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb
index fdeec0b634..0dbd9a2a0f 100644
--- a/spec/plugins/source/example_spec.rb
+++ b/spec/plugins/source/example_spec.rb
@@ -142,7 +142,7 @@ RSpec.describe "real source plugins" do
end
describe "bundle cache/package" do
- let(:uri_hash) { Digest::SHA1.hexdigest(lib_path("a-path-gem-1.0").to_s) }
+ let(:uri_hash) { Digest(:SHA1).hexdigest(lib_path("a-path-gem-1.0").to_s) }
it "copies repository to vendor cache and uses it" do
bundle "install"
bundle :cache, forgotten_command_line_options([:all, :cache_all] => true)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index bff034688c..419b5449a3 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -6,7 +6,7 @@ $:.unshift File.expand_path("../../lib", __FILE__)
require "bundler/psyched_yaml"
require "bundler/vendored_fileutils"
require "uri"
-require "digest/sha1"
+require "digest"
require File.expand_path("../support/path.rb", __FILE__)
begin
diff --git a/spec/support/artifice/compact_index.rb b/spec/support/artifice/compact_index.rb
index 64f7dc903a..434307576f 100644
--- a/spec/support/artifice/compact_index.rb
+++ b/spec/support/artifice/compact_index.rb
@@ -15,7 +15,7 @@ class CompactIndexAPI < Endpoint
def etag_response
response_body = yield
- checksum = Digest::MD5.hexdigest(response_body)
+ checksum = Digest(:MD5).hexdigest(response_body)
return if not_modified?(checksum)
headers "ETag" => quote(checksum)
headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60"