summaryrefslogtreecommitdiff
path: root/lib/bundler/installer.rb
diff options
context:
space:
mode:
authorfotanus@gmail.com <Felipe Tanus>2015-05-17 12:55:25 -0300
committerfotanus@gmail.com <Felipe Tanus>2015-05-17 12:55:25 -0300
commitcd7b52e9ea04ec90705878cc96035b30501237ba (patch)
tree3f26f6def7968a065065b7144ecb83d4d9d4ab22 /lib/bundler/installer.rb
parent9eef958bf531e723aa84f2334708aa3dc3feabb0 (diff)
downloadbundler-cd7b52e9ea04ec90705878cc96035b30501237ba.tar.gz
Extract two methods from Installer#run
Code climate points it as complexity 384. This build should fail because the master build is failing. I ran the specs against ruby 2.2.2 only, so don't merge without pass on travis.
Diffstat (limited to 'lib/bundler/installer.rb')
-rw-r--r--lib/bundler/installer.rb63
1 files changed, 34 insertions, 29 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index d0a7dc4fda..54e2cb2588 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -63,40 +63,14 @@ module Bundler
return
end
- if Bundler.default_lockfile.exist? && !options["update"]
- local = Bundler.ui.silence do
- begin
- tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
- true unless tmpdef.new_platform? || tmpdef.missing_specs.any?
- rescue BundlerError
- end
- end
- end
-
- # Since we are installing, we can resolve the definition
- # using remote specs
- unless local
- options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
- end
-
- force = options["force"]
-
- # the order that the resolver provides is significant, since
- # dependencies might actually affect the installation of a gem.
- # that said, it's a rare situation (other than rake), and parallel
- # installation is just SO MUCH FASTER. so we let people opt in.
- jobs = [Bundler.settings[:jobs].to_i-1, 1].max
- if jobs > 1 && can_install_in_parallel?
- require 'bundler/installer/parallel_installer'
- install_in_parallel jobs, options[:standalone], force
- else
- install_sequentially options[:standalone], force
- end
+ resolve_if_need(options)
+ install(options)
lock unless Bundler.settings[:frozen]
generate_standalone(options[:standalone]) if options[:standalone]
end
+
def install_gem_from_spec(spec, standalone = false, worker = 0, force = false)
# Fetch the build settings, if there are any
settings = Bundler.settings["build.#{spec.name}"]
@@ -206,6 +180,21 @@ module Bundler
private
+ # the order that the resolver provides is significant, since
+ # dependencies might actually affect the installation of a gem.
+ # that said, it's a rare situation (other than rake), and parallel
+ # installation is just SO MUCH FASTER. so we let people opt in.
+ def install(options)
+ force = options["force"]
+ jobs = [Bundler.settings[:jobs].to_i-1, 1].max
+ if jobs > 1 && can_install_in_parallel?
+ require 'bundler/installer/parallel_installer'
+ install_in_parallel jobs, options[:standalone], force
+ else
+ install_sequentially options[:standalone], force
+ end
+ end
+
def can_install_in_parallel?
if Bundler.rubygems.provides?(">= 2.1.0")
true
@@ -290,5 +279,21 @@ module Bundler
"because of an invalid symlink. Remove the symlink so the directory can be created."
end
+ def resolve_if_need(options)
+ if Bundler.default_lockfile.exist? && !options["update"]
+ local = Bundler.ui.silence do
+ begin
+ tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
+ true unless tmpdef.new_platform? || tmpdef.missing_specs.any?
+ rescue BundlerError
+ end
+ end
+ end
+
+ unless local
+ options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
+ end
+ end
+
end
end