Class: Spandx::Ruby::Gateway

Inherits:
Core::Gateway show all
Defined in:
lib/spandx/ruby/gateway.rb

Instance Method Summary collapse

Methods included from Core::Registerable

#all, #inherited, #registry

Constructor Details

#initialize(http: Spandx.http) ⇒ Gateway



7
8
9
# File 'lib/spandx/ruby/gateway.rb', line 7

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

Instance Method Details

#eachObject



11
12
13
14
15
16
17
18
# File 'lib/spandx/ruby/gateway.rb', line 11

def each
  response = http.get('https://index.rubygems.org/versions')
  return unless http.ok?(response)

  parse_each_from(StringIO.new(response.body)) do |item|
    yield item
  end
end

#licenses(name, version) ⇒ Object



24
25
26
# File 'lib/spandx/ruby/gateway.rb', line 24

def licenses(name, version)
  details_on(name, version)['licenses'] || []
end

#licenses_for(dependency) ⇒ Object



20
21
22
# File 'lib/spandx/ruby/gateway.rb', line 20

def licenses_for(dependency)
  licenses(dependency.name, dependency.version)
end

#matches?(dependency) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/spandx/ruby/gateway.rb', line 28

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