Class: Dependabot::FileFetchers::Ruby::Bundler::RequireRelativeFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/file_fetchers/ruby/bundler/require_relative_finder.rb

Overview

Finds the paths of any files included using ‘require_relative` in the passed file.

Instance Method Summary collapse

Constructor Details

#initialize(file:) ⇒ RequireRelativeFinder

Returns a new instance of RequireRelativeFinder.



15
16
17
# File 'lib/dependabot/file_fetchers/ruby/bundler/require_relative_finder.rb', line 15

def initialize(file:)
  @file = file
end

Instance Method Details

#require_relative_pathsObject



19
20
21
22
23
24
# File 'lib/dependabot/file_fetchers/ruby/bundler/require_relative_finder.rb', line 19

def require_relative_paths
  ast = Parser::CurrentRuby.parse(file.content)
  find_require_relative_paths(ast)
rescue Parser::SyntaxError
  raise Dependabot::DependencyFileNotParseable, file.path
end