Sha256: 8f5de3d3dc1d1050d96479c6b645caff54efb78d43ece1ea5e7d35ac56471fc7
Contents?: true
Size: 820 Bytes
Versions: 3
Compression:
Stored size: 820 Bytes
Contents
# frozen_string_literal: true module Spandx module Rubygems class Gateway # https://guides.rubygems.org/rubygems-org-api-v2/ def initialize(http: Spandx.http) @http = http end def licenses_for(name, version) found = index.licenses_for(name: name, version: version) found.any? ? found : details_on(name, version)['licenses'] || [] end private attr_reader :http def index @index ||= OfflineIndex.new(:rubygems) end def details_on(name, version) url = "https://rubygems.org/api/v2/rubygems/#{name}/versions/#{version}.json" response = http.get(url, default: {}) http.ok?(response) ? parse(response.body) : {} end def parse(json) JSON.parse(json) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spandx-0.8.0 | lib/spandx/rubygems/gateway.rb |
spandx-0.7.0 | lib/spandx/rubygems/gateway.rb |
spandx-0.6.0 | lib/spandx/rubygems/gateway.rb |