Sha256: 7d696adaa0213b8656ceead63dd1c1e6363ff3a14f05b368d095cb384c2c9fc2
Contents?: true
Size: 1.23 KB
Versions: 11
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Spandx module Python class Source attr_reader :name, :uri, :verify_ssl def initialize(source) @name = source['name'] @uri = URI.parse(source['url']) @verify_ssl = source['verify_ssl'] end def host @uri.host end def uri_for(name, version) "https://#{host}/pypi/#{name}/#{version}/json" end def lookup(name, version, http: Spandx.http) response = http.get(uri_for(name, version)) if http.ok?(response) Oj.load(response.body) else {} end end def ==(other) name == other.name && uri.to_s == other.uri.to_s && verify_ssl == other.verify_ssl end def eql(other) self == other end class << self def sources_from(json) meta = json['_meta'] meta['sources'].map do |hash| new(hash) rescue URI::InvalidURIError default end end def default new( 'name' => 'pypi', 'url' => 'https://pypi.org/simple', 'verify_ssl' => true ) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems