Class: Dependabot::Hex::UpdateChecker::FilePreparer

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/hex/update_checker/file_preparer.rb

Overview

This class takes a set of dependency files and sanitizes them for use in UpdateCheckers::Elixir::Hex.

Instance Method Summary collapse

Constructor Details

#initialize(dependency_files:, dependency:, unlock_requirement: true, replacement_git_pin: nil, latest_allowable_version: nil) ⇒ FilePreparer

Returns a new instance of FilePreparer.



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dependabot/hex/update_checker/file_preparer.rb', line 30

def initialize(
  dependency_files:,
  dependency:,
  unlock_requirement: true,
  replacement_git_pin: nil,
  latest_allowable_version: nil
)
  @dependency_files = T.let(dependency_files, T::Array[Dependabot::DependencyFile])
  @dependency = T.let(dependency, Dependabot::Dependency)
  @unlock_requirement = T.let(unlock_requirement ? true : false, T::Boolean)
  @replacement_git_pin = T.let(replacement_git_pin, T.nilable(String))
  @latest_allowable_version = T.let(latest_allowable_version, T.nilable(Gem::Version))
end

Instance Method Details

#prepared_dependency_filesObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/dependabot/hex/update_checker/file_preparer.rb', line 45

def prepared_dependency_files
  files = []
  files += mixfiles.map do |file|
    DependencyFile.new(
      name: file.name,
      content: mixfile_content_for_update_check(file),
      directory: file.directory
    )
  end
  files << lockfile if lockfile
  files += support_files
  files
end