Class: Dependabot::Composer::UpdateChecker::RequirementsUpdater

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

Constant Summary collapse

ALIAS_REGEX =
/[a-z0-9\-_\.]*\sas\s+/.freeze
VERSION_REGEX =
/(?:#{ALIAS_REGEX})?[0-9]+(?:\.[a-zA-Z0-9*\-]+)*/.freeze
AND_SEPARATOR =
/(?<=[a-zA-Z0-9*])(?<!\sas)[\s,]+(?![\s,]*[|-]|as)/.freeze
OR_SEPARATOR =
/(?<=[a-zA-Z0-9*])[\s,]*\|\|?\s*/.freeze
SEPARATOR =
/(?:#{AND_SEPARATOR})|(?:#{OR_SEPARATOR})/.freeze
ALLOWED_UPDATE_STRATEGIES =
%i(widen_ranges bump_versions bump_versions_if_necessary).freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of RequirementsUpdater.


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

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

  check_update_strategy

  return unless latest_resolvable_version

  @latest_resolvable_version =
    version_class.new(latest_resolvable_version)
end

Instance Method Details

#updated_requirementsObject


39
40
41
42
43
# File 'lib/dependabot/composer/update_checker/requirements_updater.rb', line 39

def updated_requirements
  return requirements unless latest_resolvable_version

  requirements.map { |req| updated_requirement(req) }
end