Class: Dependabot::Python::Package::PackageDetailsFetcher
- Inherits:
-
Object
- Object
- Dependabot::Python::Package::PackageDetailsFetcher
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/python/package/package_details_fetcher.rb
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.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(dependency:, dependency_files:, credentials:) ⇒ PackageDetailsFetcher
constructor
A new instance of PackageDetailsFetcher.
Constructor Details
#initialize(dependency:, dependency_files:, credentials:) ⇒ PackageDetailsFetcher
Returns a new instance of PackageDetailsFetcher.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dependabot/python/package/package_details_fetcher.rb', line 45 def initialize( dependency:, dependency_files:, credentials: ) @dependency = dependency @dependency_files = dependency_files @credentials = credentials @registry_urls = T.let(nil, T.nilable(T::Array[String])) end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
64 65 66 |
# File 'lib/dependabot/python/package/package_details_fetcher.rb', line 64 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
58 59 60 |
# File 'lib/dependabot/python/package/package_details_fetcher.rb', line 58 def dependency @dependency end |
#dependency_files ⇒ Object (readonly)
Returns the value of attribute dependency_files.
61 62 63 |
# File 'lib/dependabot/python/package/package_details_fetcher.rb', line 61 def dependency_files @dependency_files end |
Instance Method Details
#fetch ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/dependabot/python/package/package_details_fetcher.rb', line 67 def fetch package_releases = registry_urls .select { |index_url| validate_index(index_url) } # Ensure only valid URLs .flat_map do |index_url| fetch_from_registry(index_url) || [] # Ensure it always returns an array rescue Excon::Error::Timeout, Excon::Error::Socket raise if MAIN_PYPI_INDEXES.include?(index_url) raise PrivateSourceTimedOut, sanitized_url(index_url) rescue URI::InvalidURIError raise DependencyFileNotResolvable, "Invalid URL: #{sanitized_url(index_url)}" end Dependabot::Package::PackageDetails.new( dependency: dependency, releases: package_releases.reverse ) end |