Class: Dependabot::Gradle::UpdateChecker::MultiDependencyUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/gradle/update_checker/multi_dependency_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, credentials:, target_version_details:, ignored_versions:, raise_on_ignored: false) ⇒ MultiDependencyUpdater

Returns a new instance of MultiDependencyUpdater.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dependabot/gradle/update_checker/multi_dependency_updater.rb', line 14

def initialize(dependency:, dependency_files:, credentials:,
               target_version_details:, ignored_versions:,
               raise_on_ignored: false)
  @dependency       = dependency
  @dependency_files = dependency_files
  @credentials      = credentials
  @target_version   = target_version_details&.fetch(:version)
  @source_url       = target_version_details&.fetch(:source_url)
  @ignored_versions = ignored_versions
  @raise_on_ignored = raise_on_ignored
end

Instance Method Details

#update_possible?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dependabot/gradle/update_checker/multi_dependency_updater.rb', line 26

def update_possible?
  return false unless target_version

  @update_possible ||=
    dependencies_to_update.all? do |dep|
      VersionFinder.new(
        dependency: dep,
        dependency_files: dependency_files,
        credentials: credentials,
        ignored_versions: ignored_versions,
        raise_on_ignored: @raise_on_ignored,
        security_advisories: []
      ).versions
                   .map { |v| v.fetch(:version) }
                   .include?(target_version)
    end
end

#updated_dependenciesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/dependabot/gradle/update_checker/multi_dependency_updater.rb', line 44

def updated_dependencies
  raise "Update not possible!" unless update_possible?

  @updated_dependencies ||=
    dependencies_to_update.map do |dep|
      Dependency.new(
        name: dep.name,
        version: target_version.to_s,
        requirements: updated_requirements(dep),
        previous_version: dep.version,
        previous_requirements: dep.requirements,
        package_manager: dep.package_manager
      )
    end
end