Class: Dependabot::Bundler::FileUpdater::RubyRequirementSetter
- Inherits:
-
Object
- Object
- Dependabot::Bundler::FileUpdater::RubyRequirementSetter
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/bundler/file_updater/ruby_requirement_setter.rb
Defined Under Namespace
Classes: GemfileRewriter
Constant Summary collapse
- RUBY_VERSIONS =
%w( 1.8.7 1.9.3 2.0.0 2.1.10 2.2.10 2.3.8 2.4.10 2.5.9 2.6.10 2.7.8 3.0.7 3.1.7 3.2.11 3.3.11 3.4.9 4.0.5 ).freeze
- LANGUAGE =
"ruby"
Instance Attribute Summary collapse
-
#gemspec ⇒ Object
readonly
Returns the value of attribute gemspec.
Instance Method Summary collapse
-
#initialize(gemspec:) ⇒ RubyRequirementSetter
constructor
A new instance of RubyRequirementSetter.
- #rewrite(content) ⇒ Object
Constructor Details
#initialize(gemspec:) ⇒ RubyRequirementSetter
Returns a new instance of RubyRequirementSetter.
28 29 30 |
# File 'lib/dependabot/bundler/file_updater/ruby_requirement_setter.rb', line 28 def initialize(gemspec:) @gemspec = gemspec end |
Instance Attribute Details
#gemspec ⇒ Object (readonly)
Returns the value of attribute gemspec.
25 26 27 |
# File 'lib/dependabot/bundler/file_updater/ruby_requirement_setter.rb', line 25 def gemspec @gemspec end |
Instance Method Details
#rewrite(content) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dependabot/bundler/file_updater/ruby_requirement_setter.rb', line 33 def rewrite(content) return content unless gemspec_declares_ruby_requirement? buffer = Parser::Source::Buffer.new("(gemfile_content)") buffer.source = content ast = Prism::Translation::ParserCurrent.new.parse(buffer) if declares_ruby_version?(ast) GemfileRewriter.new( ruby_version: ruby_version ).rewrite(buffer, ast) else "ruby '#{ruby_version}'\n" + content end end |