Class: Dependabot::UpdateCheckers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/update_checkers/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, credentials:, ignored_versions: [], requirements_update_strategy: nil) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
18
19
# File 'lib/dependabot/update_checkers/base.rb', line 12

def initialize(dependency:, dependency_files:, credentials:,
               ignored_versions: [], requirements_update_strategy: nil)
  @dependency = dependency
  @dependency_files = dependency_files
  @credentials = credentials
  @requirements_update_strategy = requirements_update_strategy
  @ignored_versions = ignored_versions
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



9
10
11
# File 'lib/dependabot/update_checkers/base.rb', line 9

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



9
10
11
# File 'lib/dependabot/update_checkers/base.rb', line 9

def dependency
  @dependency
end

#dependency_filesObject (readonly)

Returns the value of attribute dependency_files.



9
10
11
# File 'lib/dependabot/update_checkers/base.rb', line 9

def dependency_files
  @dependency_files
end

#ignored_versionsObject (readonly)

Returns the value of attribute ignored_versions.



9
10
11
# File 'lib/dependabot/update_checkers/base.rb', line 9

def ignored_versions
  @ignored_versions
end

#requirements_update_strategyObject (readonly)

Returns the value of attribute requirements_update_strategy.



9
10
11
# File 'lib/dependabot/update_checkers/base.rb', line 9

def requirements_update_strategy
  @requirements_update_strategy
end

Instance Method Details

#can_update?(requirements_to_unlock:) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
# File 'lib/dependabot/update_checkers/base.rb', line 29

def can_update?(requirements_to_unlock:)
  if dependency.appears_in_lockfile?
    version_can_update?(requirements_to_unlock: requirements_to_unlock)
  else
    # TODO: Handle full unlock updates for dependencies without a lockfile
    return false if requirements_to_unlock == :none

    requirements_can_update?
  end
end

#latest_resolvable_versionObject

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/dependabot/update_checkers/base.rb', line 57

def latest_resolvable_version
  raise NotImplementedError
end

#latest_resolvable_version_with_no_unlockObject

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/dependabot/update_checkers/base.rb', line 61

def latest_resolvable_version_with_no_unlock
  raise NotImplementedError
end

#latest_versionObject

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/dependabot/update_checkers/base.rb', line 53

def latest_version
  raise NotImplementedError
end

#requirement_classObject



73
74
75
# File 'lib/dependabot/update_checkers/base.rb', line 73

def requirement_class
  Utils.requirement_class_for_package_manager(dependency.package_manager)
end

#requirements_unlocked_or_can_be?Boolean

For some langauges, the manifest file may be constructed such that Dependabot has no way to update it (e.g., if it fetches its versions from a web API). This method is overridden in those cases.

Returns:

  • (Boolean)


80
81
82
# File 'lib/dependabot/update_checkers/base.rb', line 80

def requirements_unlocked_or_can_be?
  true
end

#up_to_date?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/dependabot/update_checkers/base.rb', line 21

def up_to_date?
  if dependency.appears_in_lockfile?
    version_up_to_date?
  else
    requirements_up_to_date?
  end
end

#updated_dependencies(requirements_to_unlock:) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dependabot/update_checkers/base.rb', line 40

def updated_dependencies(requirements_to_unlock:)
  unless can_update?(requirements_to_unlock: requirements_to_unlock)
    return []
  end

  case requirements_to_unlock&.to_sym
  when :none then [updated_dependency_without_unlock]
  when :own then [updated_dependency_with_own_req_unlock]
  when :all then updated_dependencies_after_full_unlock
  else raise "Unknown unlock level '#{requirements_to_unlock}'"
  end
end

#updated_requirementsObject

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/dependabot/update_checkers/base.rb', line 65

def updated_requirements
  raise NotImplementedError
end

#version_classObject



69
70
71
# File 'lib/dependabot/update_checkers/base.rb', line 69

def version_class
  Utils.version_class_for_package_manager(dependency.package_manager)
end