Class: Dependabot::Bundler::FileUpdater::GitPinReplacer
- Inherits:
-
Object
- Object
- Dependabot::Bundler::FileUpdater::GitPinReplacer
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/bundler/file_updater/git_pin_replacer.rb
Defined Under Namespace
Classes: Rewriter
Instance Attribute Summary collapse
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#new_pin ⇒ Object
readonly
Returns the value of attribute new_pin.
Instance Method Summary collapse
-
#initialize(dependency:, new_pin:) ⇒ GitPinReplacer
constructor
A new instance of GitPinReplacer.
- #rewrite(content) ⇒ Object
Constructor Details
#initialize(dependency:, new_pin:) ⇒ GitPinReplacer
Returns a new instance of GitPinReplacer.
22 23 24 25 |
# File 'lib/dependabot/bundler/file_updater/git_pin_replacer.rb', line 22 def initialize(dependency:, new_pin:) @dependency = T.let(dependency, Dependabot::Dependency) @new_pin = T.let(new_pin, String) end |
Instance Attribute Details
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
16 17 18 |
# File 'lib/dependabot/bundler/file_updater/git_pin_replacer.rb', line 16 def dependency @dependency end |
#new_pin ⇒ Object (readonly)
Returns the value of attribute new_pin.
19 20 21 |
# File 'lib/dependabot/bundler/file_updater/git_pin_replacer.rb', line 19 def new_pin @new_pin end |
Instance Method Details
#rewrite(content) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/dependabot/bundler/file_updater/git_pin_replacer.rb', line 28 def rewrite(content) buffer = Parser::Source::Buffer.new("(gemfile_content)") buffer.source = content ast = Prism::Translation::ParserCurrent.new.parse(buffer) Rewriter .new(dependency: dependency, new_pin: new_pin) .rewrite(buffer, ast) end |