Class: Spandx::Php::PackagistGateway
- Inherits:
-
Core::Gateway
- Object
- Core::Gateway
- Spandx::Php::PackagistGateway
- Defined in:
- lib/spandx/php/packagist_gateway.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
Instance Method Summary collapse
-
#initialize(http: Spandx.http) ⇒ PackagistGateway
constructor
A new instance of PackagistGateway.
- #licenses_for(dependency) ⇒ Object
- #matches?(dependency) ⇒ Boolean
Methods included from Core::Registerable
#all, #each, #inherited, #registry
Constructor Details
#initialize(http: Spandx.http) ⇒ PackagistGateway
Returns a new instance of PackagistGateway.
8 9 10 |
# File 'lib/spandx/php/packagist_gateway.rb', line 8 def initialize(http: Spandx.http) @http = http end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
6 7 8 |
# File 'lib/spandx/php/packagist_gateway.rb', line 6 def http @http end |
Instance Method Details
#licenses_for(dependency) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/spandx/php/packagist_gateway.rb', line 16 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
12 13 14 |
# File 'lib/spandx/php/packagist_gateway.rb', line 12 def matches?(dependency) dependency.package_manager == :composer end |