class Dependabot::Cargo::MetadataFinder
Constants
- SOURCE_KEYS
Private Instance Methods
crates_listing()
click to toggle source
# File lib/dependabot/cargo/metadata_finder.rb, line 50 def crates_listing return @crates_listing unless @crates_listing.nil? response = Excon.get( "https://crates.io/api/v1/crates/#{dependency.name}", idempotent: true, **SharedHelpers.excon_defaults ) @crates_listing = JSON.parse(response.body) end
find_source_from_crates_listing()
click to toggle source
# File lib/dependabot/cargo/metadata_finder.rb, line 33 def find_source_from_crates_listing potential_source_urls = SOURCE_KEYS. map { |key| crates_listing.dig("crate", key) }. compact source_url = potential_source_urls.find { |url| Source.from_url(url) } Source.from_url(source_url) end
find_source_from_git_url()
click to toggle source
# File lib/dependabot/cargo/metadata_finder.rb, line 43 def find_source_from_git_url info = dependency.requirements.map { |r| r[:source] }.compact.first url = info[:url] || info.fetch("url") Source.from_url(url) end
look_up_source()
click to toggle source
# File lib/dependabot/cargo/metadata_finder.rb, line 15 def look_up_source case new_source_type when "default" then find_source_from_crates_listing when "git" then find_source_from_git_url else raise "Unexpected source type: #{new_source_type}" end end
new_source_type()
click to toggle source
# File lib/dependabot/cargo/metadata_finder.rb, line 23 def new_source_type sources = dependency.requirements.map { |r| r.fetch(:source) }.uniq.compact return "default" if sources.empty? raise "Multiple sources! #{sources.join(', ')}" if sources.count > 1 sources.first[:type] || sources.first.fetch("type") end