Class: Spandx::Php::PackagistGateway

Inherits:
Core::Gateway show all
Defined in:
lib/spandx/php/packagist_gateway.rb

Instance Attribute Summary

Attributes inherited from Core::Gateway

#http

Instance Method Summary collapse

Methods inherited from Core::Gateway

#initialize

Methods included from Core::Registerable

#all, #each, #inherited, #registry

Constructor Details

This class inherits a constructor from Spandx::Core::Gateway

Instance Method Details

#licenses_for(dependency) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/spandx/php/packagist_gateway.rb', line 10

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

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

#matches?(dependency) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/spandx/php/packagist_gateway.rb', line 6

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