Class: Dependabot::Cargo::FileUpdater::WorkspaceManifestUpdater

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/cargo/file_updater/workspace_manifest_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependencies:, manifest:) ⇒ WorkspaceManifestUpdater

Returns a new instance of WorkspaceManifestUpdater.



14
15
16
17
# File 'lib/dependabot/cargo/file_updater/workspace_manifest_updater.rb', line 14

def initialize(dependencies:, manifest:)
  @dependencies = T.let(dependencies, T::Array[Dependabot::Dependency])
  @manifest = T.let(manifest, Dependabot::DependencyFile)
end

Instance Method Details

#updated_manifest_contentObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dependabot/cargo/file_updater/workspace_manifest_updater.rb', line 20

def updated_manifest_content
  workspace_deps = dependencies.select { |dep| workspace_dependency?(dep) }

  return T.must(manifest.content) if workspace_deps.empty?

  T.must(
    workspace_deps.reduce(manifest.content.dup) do |content, dep|
      update_workspace_dependency(T.must(content), dep)
    end
  )
end