Class: BundleUpdateInteractive::Updater

Inherits:
Object
  • Object
show all
Defined in:
lib/bundle_update_interactive/updater.rb

Direct Known Subclasses

Latest::Updater

Instance Method Summary collapse

Constructor Details

#initialize(groups: [], only_explicit: false) ⇒ Updater

Returns a new instance of Updater.



5
6
7
8
9
10
# File 'lib/bundle_update_interactive/updater.rb', line 5

def initialize(groups: [], only_explicit: false)
  @only_explicit = only_explicit
  @gemfile = Gemfile.parse
  @current_lockfile = Lockfile.parse
  @candidate_gems = current_lockfile.gems_exclusively_installed_by(gemfile: gemfile, groups: groups) if groups.any?
end

Instance Method Details

#apply_updates(*gem_names) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/bundle_update_interactive/updater.rb', line 19

def apply_updates(*gem_names)
  expanded_names = expand_gems_with_exact_dependencies(*gem_names)
  BundlerCommands.update_gems_conservatively(*expanded_names)

  # Return the gems that were actually updated based on observed changes to the lock file
  updated_gems = build_outdated_gems(File.read("Gemfile.lock"))
  @current_lockfile = Lockfile.parse
  updated_gems
end

#generate_reportObject



12
13
14
15
16
17
# File 'lib/bundle_update_interactive/updater.rb', line 12

def generate_report
  updatable_gems = find_updatable_gems
  withheld_gems = find_withheld_gems(exclude: updatable_gems.keys)

  Report.new(current_lockfile: current_lockfile, updatable_gems: updatable_gems, withheld_gems: withheld_gems)
end

#modified_gemfile?Boolean

Overridden by Latest::Updater subclass

Returns:

  • (Boolean)


30
31
32
# File 'lib/bundle_update_interactive/updater.rb', line 30

def modified_gemfile?
  false
end