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.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#repo_contents_path ⇒ Object
readonly
Returns the value of attribute repo_contents_path.
Instance Method Summary collapse
- #git? ⇒ Boolean
-
#initialize(dependency:, dependency_files:, credentials:, options:) ⇒ 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, #handle_bundler_errors, #in_a_native_bundler_context, #inaccessible_git_dependencies, #jfrog_source, #private_registry_credentials, #retryable_error?, #sanitized_lockfile_body, #write_temporary_dependency_files
Constructor Details
#initialize(dependency:, dependency_files:, credentials:, options:) ⇒ DependencySource
Returns a new instance of DependencySource.
22 23 24 25 26 27 28 29 30 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 22 def initialize(dependency:, dependency_files:, credentials:, options:) @dependency = dependency @dependency_files = dependency_files @credentials = credentials @options = end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
19 20 21 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 19 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
19 20 21 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 19 def dependency @dependency end |
#dependency_files ⇒ Object (readonly)
Returns the value of attribute dependency_files.
19 20 21 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 19 def dependency_files @dependency_files end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 19 def @options end |
#repo_contents_path ⇒ Object (readonly)
Returns the value of attribute repo_contents_path.
19 20 21 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 19 def repo_contents_path @repo_contents_path end |
Instance Method Details
#git? ⇒ Boolean
77 78 79 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 77 def git? source_type == GIT end |
#latest_git_version_details ⇒ Hash{Symbol => String}?
The latest version details for the dependency from a git repo
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 52 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| NativeHelpers.run_bundler_subprocess( bundler_version: bundler_version, 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
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 35 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 |