Sha256: 0ac2c6db144b35e6e0b4f1cdaa6d72f38394f1e44b024d27cafa5fab567d1e46

Contents?: true

Size: 604 Bytes

Versions: 9

Compression:

Stored size: 604 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Php
    class PackagistGateway < ::Spandx::Core::Gateway
      attr_reader :http

      def initialize(http: Spandx.http)
        @http = http
      end

      def matches?(dependency)
        dependency.package_manager == :composer
      end

      def licenses_for(dependency)
        response = http.get("https://repo.packagist.org/p/#{dependency.name}.json")
        return [] unless http.ok?(response)

        json = JSON.parse(response.body)
        json['packages'][dependency.name][dependency.version]['license']
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spandx-0.13.4 lib/spandx/php/packagist_gateway.rb
spandx-0.13.3 lib/spandx/php/packagist_gateway.rb
spandx-0.13.2 lib/spandx/php/packagist_gateway.rb
spandx-0.13.1 lib/spandx/php/packagist_gateway.rb
spandx-0.13.0 lib/spandx/php/packagist_gateway.rb
spandx-0.12.3 lib/spandx/php/packagist_gateway.rb
spandx-0.12.2 lib/spandx/php/packagist_gateway.rb
spandx-0.12.1 lib/spandx/php/packagist_gateway.rb
spandx-0.12.0 lib/spandx/php/packagist_gateway.rb