Class: Dependabot::Bundler::FileFetcher::IncludedPathFinder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/bundler/file_fetcher/included_path_finder.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(file:) ⇒ IncludedPathFinder

Returns a new instance of IncludedPathFinder.



19
20
21
# File 'lib/dependabot/bundler/file_fetcher/included_path_finder.rb', line 19

def initialize(file:)
  @file = file
end

Instance Method Details

#find_included_pathsObject



24
25
26
27
28
29
# File 'lib/dependabot/bundler/file_fetcher/included_path_finder.rb', line 24

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