Class: Dependabot::Swift::FileUpdater::ManifestUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/swift/file_updater/manifest_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(content, old_requirements:, new_requirements:) ⇒ ManifestUpdater

Returns a new instance of ManifestUpdater.



11
12
13
14
15
# File 'lib/dependabot/swift/file_updater/manifest_updater.rb', line 11

def initialize(content, old_requirements:, new_requirements:)
  @content = content
  @old_requirements = old_requirements
  @new_requirements = new_requirements
end

Instance Method Details

#updated_manifest_contentObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dependabot/swift/file_updater/manifest_updater.rb', line 17

def updated_manifest_content
  updated_content = content

  old_requirements.zip(new_requirements).each do |old, new|
    updated_content = RequirementReplacer.new(
      content: updated_content,
      declaration: old[:metadata][:declaration_string],
      old_requirement: old[:metadata][:requirement_string],
      new_requirement: new[:metadata][:requirement_string]
    ).updated_content
  end

  updated_content
end