Class: Dependabot::Bundler::FileFetcher::RequireRelativeFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/bundler/file_fetcher/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.



14
15
16
# File 'lib/dependabot/bundler/file_fetcher/require_relative_finder.rb', line 14

def initialize(file:)
  @file = file
end

Instance Method Details

#require_relative_pathsObject



18
19
20
21
22
23
# File 'lib/dependabot/bundler/file_fetcher/require_relative_finder.rb', line 18

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