Class: Bundler::Interactive::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/interactive/update.rb

Overview

Applies the version selections the user made in the interactive table.

Selections whose target exceeds the Gemfile constraint have their requirement rewritten first (via GemfileEditor); then every selected gem is unlocked and re-resolved through a fresh Bundler definition so the lockfile is updated in one pass.

Instance Method Summary collapse

Constructor Details

#initialize(selections) ⇒ Update

Returns a new instance of Update.



12
13
14
# File 'lib/bundler/interactive/update.rb', line 12

def initialize(selections)
  @selections = Array(selections)
end

Instance Method Details

#update!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bundler/interactive/update.rb', line 16

def update!
  return if selections.empty?

  rewrite_gemfile!
  names = selections.map(&:name)

  Bundler.ui.info("Updating #{names.join(', ')}...")
  definition = Bundler.definition(gems: names)
  definition.resolve_remotely!
  Bundler::Installer.install(Bundler.root, definition)
  definition.lock

  print_summary
end