Class: Dependabot::Elm::UpdateChecker::RequirementsUpdater

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

Constant Summary collapse

RANGE_REQUIREMENT_REGEX =
/(\d+\.\d+\.\d+) <= v < (\d+\.\d+\.\d+)/
SINGLE_VERSION_REGEX =
/\A(\d+\.\d+\.\d+)\z/

Instance Method Summary collapse

Constructor Details

#initialize(requirements:, latest_resolvable_version:) ⇒ RequirementsUpdater

Returns a new instance of RequirementsUpdater.



16
17
18
19
20
21
22
23
24
# File 'lib/dependabot/elm/update_checker/requirements_updater.rb', line 16

def initialize(requirements:, latest_resolvable_version:)
  @requirements = requirements

  return unless latest_resolvable_version
  return unless version_class.correct?(latest_resolvable_version)

  @latest_resolvable_version =
    version_class.new(latest_resolvable_version)
end

Instance Method Details

#updated_requirementsObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dependabot/elm/update_checker/requirements_updater.rb', line 26

def updated_requirements
  return requirements unless latest_resolvable_version

  requirements.map do |req|
    updated_req_string = update_requirement(
      req[:requirement],
      latest_resolvable_version
    )

    req.merge(requirement: updated_req_string)
  end
end