summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2024-11-20 13:18:26 +0100
committergit <svn-admin@ruby-lang.org>2024-11-25 18:14:31 +0000
commite7bb505130936590782385b7d62528f20709217b (patch)
tree7f1ead1a6cde30d2342fddf72613470ac5849d70
parentc215e95572d0e4f2b682634fd7ed8c8418e07eb1 (diff)
[rubygems/rubygems] Make installer code more clear
I always found the `resolve_if_necessary` method pretty confusing because by reading it, it suggests that resolution always happens, and the point is whether that needs to be local or remote. This commit tries to make that more clear. https://github.com/rubygems/rubygems/commit/93d6861ee8
-rw-r--r--lib/bundler/definition.rb19
-rw-r--r--lib/bundler/installer.rb16
2 files changed, 20 insertions, 15 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 405fb67ea4..037f414a32 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -176,6 +176,25 @@ module Bundler
resolve
end
+ #
+ # Setup sources according to the given options and the state of the
+ # definition.
+ #
+ # @return [Boolean] Whether fetching remote information will be necessary or not
+ #
+ def setup_domain!(options)
+ prefer_local! if options[:"prefer-local"]
+
+ if options[:local] || no_install_needed?
+ Bundler.settings.set_command_option(:jobs, 1) if no_install_needed? # to avoid the overhead of Bundler::Worker
+ with_cache!
+ false
+ else
+ remotely!
+ true
+ end
+ end
+
def resolve_with_cache!
with_cache!
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 48dc14ebf4..e60201e52c 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -77,7 +77,7 @@ module Bundler
return
end
- if resolve_if_needed(options)
+ if @definition.setup_domain!(options)
ensure_specs_are_compatible!
Bundler.load_plugins(@definition)
end
@@ -222,20 +222,6 @@ module Bundler
end
end
- # returns whether or not a re-resolve was needed
- def resolve_if_needed(options)
- @definition.prefer_local! if options[:"prefer-local"]
-
- if options[:local] || @definition.no_install_needed?
- Bundler.settings.set_command_option(:jobs, 1) if @definition.no_install_needed? # to avoid the overhead of Bundler::Worker
- @definition.with_cache!
- false
- else
- @definition.remotely!
- true
- end
- end
-
def lock
@definition.lock
end