Class: Dependabot::Bundler::FileUpdater::GitPinReplacer

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/bundler/file_updater/git_pin_replacer.rb

Defined Under Namespace

Classes: Rewriter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, new_pin:) ⇒ GitPinReplacer

Returns a new instance of GitPinReplacer.


12
13
14
15
# File 'lib/dependabot/bundler/file_updater/git_pin_replacer.rb', line 12

def initialize(dependency:, new_pin:)
  @dependency = dependency
  @new_pin = new_pin
end

Instance Attribute Details

#dependencyObject (readonly)

Returns the value of attribute dependency


10
11
12
# File 'lib/dependabot/bundler/file_updater/git_pin_replacer.rb', line 10

def dependency
  @dependency
end

#new_pinObject (readonly)

Returns the value of attribute new_pin


10
11
12
# File 'lib/dependabot/bundler/file_updater/git_pin_replacer.rb', line 10

def new_pin
  @new_pin
end

Instance Method Details

#rewrite(content) ⇒ Object


17
18
19
20
21
22
23
24
25
# File 'lib/dependabot/bundler/file_updater/git_pin_replacer.rb', line 17

def rewrite(content)
  buffer = Parser::Source::Buffer.new("(gemfile_content)")
  buffer.source = content
  ast = Parser::CurrentRuby.new.parse(buffer)

  Rewriter.
    new(dependency: dependency, new_pin: new_pin).
    rewrite(buffer, ast)
end