Class: Dependabot::Bundler::UpdateChecker::RequirementsUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/bundler/update_checker/requirements_updater.rb

Defined Under Namespace

Classes: UnfixableRequirement

Constant Summary collapse

ALLOWED_UPDATE_STRATEGIES =
%i(bump_versions bump_versions_if_necessary).freeze

Instance Method Summary collapse

Constructor Details

#initialize(requirements:, update_strategy:, updated_source:, latest_version:, latest_resolvable_version:) ⇒ RequirementsUpdater

Returns a new instance of RequirementsUpdater.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dependabot/bundler/update_checker/requirements_updater.rb', line 14

def initialize(requirements:, update_strategy:, updated_source:,
               latest_version:, latest_resolvable_version:)
  @requirements = requirements
  @latest_version = Gem::Version.new(latest_version) if latest_version
  @updated_source = updated_source
  @update_strategy = update_strategy

  check_update_strategy

  return unless latest_resolvable_version

  @latest_resolvable_version =
    Gem::Version.new(latest_resolvable_version)
end

Instance Method Details

#updated_requirementsObject


29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dependabot/bundler/update_checker/requirements_updater.rb', line 29

def updated_requirements
  requirements.map do |req|
    if req[:file].match?(/\.gemspec/)
      update_gemspec_requirement(req)
    else
      # If a requirement doesn't come from a gemspec, it must be from
      # a Gemfile.
      update_gemfile_requirement(req)
    end
  end
end