Sha256: 1f634fe5f5f843e9e8cff578a95be90d37aa368d280eae551bd478166d8bdd1d
Contents?: true
Size: 791 Bytes
Versions: 9
Compression:
Stored size: 791 Bytes
Contents
# frozen_string_literal: true module Spandx module Ruby class Gateway < ::Spandx::Core::Gateway # https://guides.rubygems.org/rubygems-org-api-v2/ def initialize(http: Spandx.http) @http = http end def licenses_for(dependency) details_on(dependency.name, dependency.version)['licenses'] || [] end def matches?(dependency) dependency.package_manager == :rubygems end private attr_reader :http 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
9 entries across 9 versions & 1 rubygems