Class: Dependabot::FileUpdaters::Ruby::Bundler::GemspecSanitizer::Rewriter
- Inherits:
-
Parser::TreeRewriter
- Object
- Parser::TreeRewriter
- Dependabot::FileUpdaters::Ruby::Bundler::GemspecSanitizer::Rewriter
- Defined in:
- lib/dependabot/file_updaters/ruby/bundler/gemspec_sanitizer.rb
Instance Method Summary collapse
-
#initialize(replacement_version:) ⇒ Rewriter
constructor
A new instance of Rewriter.
- #on_send(node) ⇒ Object
Constructor Details
#initialize(replacement_version:) ⇒ Rewriter
Returns a new instance of Rewriter.
42 43 44 |
# File 'lib/dependabot/file_updaters/ruby/bundler/gemspec_sanitizer.rb', line 42 def initialize(replacement_version:) @replacement_version = replacement_version end |
Instance Method Details
#on_send(node) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/dependabot/file_updaters/ruby/bundler/gemspec_sanitizer.rb', line 46 def on_send(node) # Wrap any `require` or `require_relative` calls in a rescue # block, as we might not have the required files wrap_require(node) if requires_file?(node) # Remove any assignments to a VERSION constant (or similar), as # that constant probably comes from a required file replace_version_assignments(node) # Replace the `s.files= ...` assignment with a blank array, as # occassionally a File.open(..).readlines pattern is used replace_file_assignments(node) # Replace the `s.require_path= ...` assignment, as # occassionally a Dir['lib'] pattern is used replace_require_paths_assignments(node) # Replace any `File.read(...)` calls with a dummy string replace_file_reads(node) # Remove the arguments from any `Find.find(...)` calls remove_find_dot_find_args(node) remove_unnecessary_assignments(node) end |