Class: Dependabot::Python::UpdateChecker::IndexFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/python/update_checker/index_finder.rb

Constant Summary collapse

PYPI_BASE_URL =
"https://pypi.python.org/simple/"
ENVIRONMENT_VARIABLE_REGEX =
/\$\{.+\}/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(dependency_files:, credentials:) ⇒ IndexFinder

Returns a new instance of IndexFinder.



14
15
16
17
# File 'lib/dependabot/python/update_checker/index_finder.rb', line 14

def initialize(dependency_files:, credentials:)
  @dependency_files = dependency_files
  @credentials      = credentials
end

Instance Method Details

#index_urlsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dependabot/python/update_checker/index_finder.rb', line 19

def index_urls
  extra_index_urls =
    config_variable_index_urls[:extra] +
    pipfile_index_urls[:extra] +
    requirement_file_index_urls[:extra] +
    pip_conf_index_urls[:extra] +
    pyproject_index_urls[:extra]

  extra_index_urls = extra_index_urls.map do |url|
    clean_check_and_remove_environment_variables(url)
  end

  # URL encode any `@` characters within registry URL creds.
  # TODO: The test that fails if the `map` here is removed is likely a
  # bug in Ruby's URI parser, and should be fixed there.
  [main_index_url, *extra_index_urls].map do |url|
    url.rpartition("@").tap { |a| a.first.gsub!("@", "%40") }.join
  end.uniq
end