Class: Dependabot::Python::PipCompileFileMatcher

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/pip_compile_file_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(requirements_in_files) ⇒ PipCompileFileMatcher

Returns a new instance of PipCompileFileMatcher.



10
11
12
# File 'lib/dependabot/python/pip_compile_file_matcher.rb', line 10

def initialize(requirements_in_files)
  @requirements_in_files = requirements_in_files
end

Instance Method Details

#lockfile_for_pip_compile_file?(file) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
# File 'lib/dependabot/python/pip_compile_file_matcher.rb', line 15

def lockfile_for_pip_compile_file?(file)
  return false unless requirements_in_files.any?

  name = file.name
  return false unless name.end_with?(".txt")

  return true if file.content&.match?(output_file_regex(name))

  !!manifest_for_lockfile_name(name)
end

#manifest_for_pip_compile_lockfile(file) ⇒ Object



27
28
29
30
31
# File 'lib/dependabot/python/pip_compile_file_matcher.rb', line 27

def manifest_for_pip_compile_lockfile(file)
  return nil unless lockfile_for_pip_compile_file?(file)

  manifest_for_lockfile_name(file.name) || requirements_in_files.first
end