Class: Dependabot::Elm::UpdateChecker::Elm19VersionResolver
- Inherits:
-
Object
- Object
- Dependabot::Elm::UpdateChecker::Elm19VersionResolver
- Defined in:
- lib/dependabot/elm/update_checker/elm_19_version_resolver.rb
Defined Under Namespace
Classes: UnrecoverableState
Instance Method Summary collapse
-
#initialize(dependency:, dependency_files:) ⇒ Elm19VersionResolver
constructor
A new instance of Elm19VersionResolver.
- #latest_resolvable_version(unlock_requirement:) ⇒ Object
- #updated_dependencies_after_full_unlock ⇒ Object
Constructor Details
#initialize(dependency:, dependency_files:) ⇒ Elm19VersionResolver
Returns a new instance of Elm19VersionResolver.
20 21 22 23 |
# File 'lib/dependabot/elm/update_checker/elm_19_version_resolver.rb', line 20 def initialize(dependency:, dependency_files:) @dependency = dependency @dependency_files = dependency_files end |
Instance Method Details
#latest_resolvable_version(unlock_requirement:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dependabot/elm/update_checker/elm_19_version_resolver.rb', line 25 def latest_resolvable_version(unlock_requirement:) raise "Invalid unlock setting: #{unlock_requirement}" unless %i(none own all).include?(unlock_requirement) # Elm has no lockfile, so we will never create an update PR if # unlock requirements are `none`. Just return the current version. return current_version if unlock_requirement == :none # Otherwise, we gotta check a few conditions to see if bumping # wouldn't also bump other deps in elm.json fetch_latest_resolvable_version(unlock_requirement) end |
#updated_dependencies_after_full_unlock ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dependabot/elm/update_checker/elm_19_version_resolver.rb', line 37 def updated_dependencies_after_full_unlock changed_deps = original_dependency_details.filter_map do |original_dep| new_version = changed_deps.fetch(original_dep.name, nil) next unless new_version old_reqs = original_dep.requirements.map do |req| requirement_class.new(req[:requirement]) end next if old_reqs.all? { |req| req.satisfied_by?(new_version) } new_requirements = RequirementsUpdater.new( requirements: original_dep.requirements, latest_resolvable_version: new_version.to_s ).updated_requirements Dependency.new( name: original_dep.name, version: new_version.to_s, requirements: new_requirements, previous_version: original_dep.version, previous_requirements: original_dep.requirements, package_manager: original_dep.package_manager ) end end |