Class: Dependabot::Bundler::UpdateChecker::LatestVersionFinder::DependencySource
- Inherits:
-
Object
- Object
- Dependabot::Bundler::UpdateChecker::LatestVersionFinder::DependencySource
- Includes:
- SharedBundlerHelpers
- Defined in:
- lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb
Constant Summary collapse
- RUBYGEMS =
"rubygems"
- PRIVATE_REGISTRY =
"private"
- GIT =
"git"
- OTHER =
"other"
Constants included from SharedBundlerHelpers
SharedBundlerHelpers::GIT_REF_REGEX, SharedBundlerHelpers::GIT_REGEX, SharedBundlerHelpers::PATH_REGEX, SharedBundlerHelpers::RETRYABLE_ERRORS, SharedBundlerHelpers::RETRYABLE_PRIVATE_REGISTRY_ERRORS
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#dependency_files ⇒ Object
readonly
Returns the value of attribute dependency_files.
-
#repo_contents_path ⇒ Object
readonly
Returns the value of attribute repo_contents_path.
Instance Method Summary collapse
- #git? ⇒ Boolean
-
#initialize(dependency:, dependency_files:, credentials:) ⇒ DependencySource
constructor
A new instance of DependencySource.
-
#latest_git_version_details ⇒ Hash{Symbol => String}?
The latest version details for the dependency from a git repo.
-
#versions ⇒ Array<Gem::Version>
The latest version details for the dependency from a registry.
Methods included from SharedBundlerHelpers
#base_directory, #git_source_credentials, #handle_bundler_errors, #in_a_native_bundler_context, #inaccessible_git_dependencies, #jfrog_source, #lockfile, #private_registry_credentials, #relevant_credentials, #retryable_error?, #sanitized_lockfile_body, #using_bundler_2?, #write_temporary_dependency_files
Constructor Details
#initialize(dependency:, dependency_files:, credentials:) ⇒ DependencySource
Returns a new instance of DependencySource.
19 20 21 22 23 24 25 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 19 def initialize(dependency:, dependency_files:, credentials:) @dependency = dependency @dependency_files = dependency_files @credentials = credentials end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
16 17 18 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 16 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
16 17 18 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 16 def dependency @dependency end |
#dependency_files ⇒ Object (readonly)
Returns the value of attribute dependency_files.
16 17 18 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 16 def dependency_files @dependency_files end |
#repo_contents_path ⇒ Object (readonly)
Returns the value of attribute repo_contents_path.
16 17 18 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 16 def repo_contents_path @repo_contents_path end |
Instance Method Details
#git? ⇒ Boolean
72 73 74 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 72 def git? source_type == GIT end |
#latest_git_version_details ⇒ Hash{Symbol => String}?
The latest version details for the dependency from a git repo
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 47 def latest_git_version_details return unless git? source_details = dependency.requirements.map { |r| r.fetch(:source) }. uniq.compact.first SharedHelpers.with_git_configured(credentials: credentials) do in_a_native_bundler_context do |tmp_dir| SharedHelpers.run_helper_subprocess( command: NativeHelpers.helper_path, function: "depencency_source_latest_git_version", args: { dir: tmp_dir, gemfile_name: gemfile.name, dependency_name: dependency.name, credentials: credentials, dependency_source_url: source_details[:url], dependency_source_branch: source_details[:branch] } ) end end.transform_keys(&:to_sym) end |
#versions ⇒ Array<Gem::Version>
The latest version details for the dependency from a registry
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 30 def versions return rubygems_versions if dependency.name == "bundler" return rubygems_versions unless gemfile case source_type when OTHER, GIT [] when PRIVATE_REGISTRY private_registry_versions else rubygems_versions end end |