Class: Dependabot::Swift::FileUpdater::RequirementReplacer

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

Instance Method Summary collapse

Constructor Details

#initialize(content:, declaration:, old_requirement:, new_requirement:) ⇒ RequirementReplacer

Returns a new instance of RequirementReplacer.



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

def initialize(content:, declaration:, old_requirement:, new_requirement:)
  @content         = content
  @declaration     = declaration
  @old_requirement = old_requirement
  @new_requirement = new_requirement
end

Instance Method Details

#updated_contentObject



17
18
19
20
21
# File 'lib/dependabot/swift/file_updater/requirement_replacer.rb', line 17

def updated_content
  content.gsub(declaration) do |match|
    match.to_s.sub(old_requirement, new_requirement)
  end
end