class Dependabot::FileUpdaters::Base

Attributes

credentials[R]
dependencies[R]
dependency_files[R]
options[R]
repo_contents_path[R]

Public Class Methods

new(dependencies:, dependency_files:, repo_contents_path: nil, credentials:, options: {}) click to toggle source
# File lib/dependabot/file_updaters/base.rb, line 13
def initialize(dependencies:, dependency_files:, repo_contents_path: nil,
               credentials:, options: {})
  @dependencies = dependencies
  @dependency_files = dependency_files
  @repo_contents_path = repo_contents_path
  @credentials = credentials
  @options = options

  check_required_files
end
updated_files_regex() click to toggle source
# File lib/dependabot/file_updaters/base.rb, line 9
def self.updated_files_regex
  raise NotImplementedError
end

Public Instance Methods

updated_dependency_files() click to toggle source
# File lib/dependabot/file_updaters/base.rb, line 24
def updated_dependency_files
  raise NotImplementedError
end

Private Instance Methods

check_required_files() click to toggle source
# File lib/dependabot/file_updaters/base.rb, line 30
def check_required_files
  raise NotImplementedError
end
file_changed?(file) click to toggle source
# File lib/dependabot/file_updaters/base.rb, line 38
def file_changed?(file)
  dependencies.any? { |dep| requirement_changed?(file, dep) }
end
get_original_file(filename) click to toggle source
# File lib/dependabot/file_updaters/base.rb, line 34
def get_original_file(filename)
  dependency_files.find { |f| f.name == filename }
end
requirement_changed?(file, dependency) click to toggle source
# File lib/dependabot/file_updaters/base.rb, line 42
def requirement_changed?(file, dependency)
  changed_requirements =
    dependency.requirements - dependency.previous_requirements

  changed_requirements.any? { |f| f[:file] == file.name }
end
updated_file(file:, content:) click to toggle source
# File lib/dependabot/file_updaters/base.rb, line 49
def updated_file(file:, content:)
  updated_file = file.dup
  updated_file.content = content
  updated_file
end