Class: Dependabot::Bundler::FileFetcher

Inherits:
FileFetchers::Base
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/dependabot/bundler/file_fetcher.rb,
lib/dependabot/bundler/file_fetcher/gemspec_finder.rb,
lib/dependabot/bundler/file_fetcher/path_gemspec_finder.rb,
lib/dependabot/bundler/file_fetcher/child_gemfile_finder.rb,
lib/dependabot/bundler/file_fetcher/included_path_finder.rb

Defined Under Namespace

Classes: ChildGemfileFinder, GemspecFinder, IncludedPathFinder, PathGemspecFinder

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.required_files_in?(filenames) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.required_files_in?(filenames)
  return true if filenames.any? { |name| name.match?(%r{^[^/]*\.gemspec$}) }

  filenames.include?("Gemfile") || filenames.include?("gems.rb")
end

.required_files_messageObject



30
31
32
# File 'lib/dependabot/bundler/file_fetcher.rb', line 30

def self.required_files_message
  "Repo must contain either a Gemfile, a gemspec, or a gems.rb."
end

Instance Method Details

#ecosystem_versionsObject



35
36
37
38
39
40
41
# File 'lib/dependabot/bundler/file_fetcher.rb', line 35

def ecosystem_versions
  {
    package_managers: {
      "bundler" => Helpers.detected_bundler_version(lockfile)
    }
  }
end

#fetch_filesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/dependabot/bundler/file_fetcher.rb', line 44

def fetch_files
  fetched_files = T.let([], T::Array[DependencyFile])
  fetched_files << T.must(gemfile) if gemfile
  fetched_files << T.must(lockfile) if gemfile && lockfile
  fetched_files += child_gemfiles
  fetched_files += gemspecs
  fetched_files << T.must(ruby_version_file) if ruby_version_file
  fetched_files << T.must(tool_versions_file) if tool_versions_file
  fetched_files += path_gemspecs
  fetched_files += find_included_files(fetched_files)

  uniq_files(fetched_files)
end