Sha256: 2b911f72718e403210cfbb8a7e6634cac44ed54e1e1bf41b830bcea9e59daa9b

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

# Extends the default Updater class to allow updating to the latest gem versions.
# Does this by using GemfileEditor to relax the Gemfile requirements before
# `find_updatable_gems` and `apply_updates` are called.
module BundleUpdateInteractive
  module Latest
    class Updater < BundleUpdateInteractive::Updater
      def initialize(editor: GemfileEditor.new, **kwargs)
        super(**kwargs)
        @modified_gemfile = false
        @editor = editor
      end

      def apply_updates(*, **)
        result = editor.with_relaxed_gemfile { super }
        @modified_gemfile = editor.shift_gemfile
        BundlerCommands.lock
        result
      end

      def modified_gemfile?
        @modified_gemfile
      end

      private

      attr_reader :editor

      def find_updatable_gems
        editor.with_relaxed_gemfile { super }
      end

      # Overrides the default Updater implementation.
      # When updating the latest gems, by definition nothing is withheld, so we can skip this.
      def find_withheld_gems(**)
        {}
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bundle_update_interactive-0.11.0 lib/bundle_update_interactive/latest/updater.rb
bundle_update_interactive-0.10.0 lib/bundle_update_interactive/latest/updater.rb
bundle_update_interactive-0.9.1 lib/bundle_update_interactive/latest/updater.rb
bundle_update_interactive-0.9.0 lib/bundle_update_interactive/latest/updater.rb
bundle_update_interactive-0.8.1 lib/bundle_update_interactive/latest/updater.rb
bundle_update_interactive-0.8.0 lib/bundle_update_interactive/latest/updater.rb