Class: Spandx::Js::YarnPkg

Inherits:
Core::Gateway show all
Defined in:
lib/spandx/js/yarn_pkg.rb

Constant Summary collapse

DEFAULT_SOURCE =
'https://registry.yarnpkg.com'

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



12
13
14
15
16
17
18
# File 'lib/spandx/js/yarn_pkg.rb', line 12

def licenses_for(dependency)
   = (dependency)

  return [] if .empty?

  [['license']].compact
end

#matches?(dependency) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/spandx/js/yarn_pkg.rb', line 8

def matches?(dependency)
  %i[npm yarn].include?(dependency.package_manager)
end

#metadata_for(dependency) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/spandx/js/yarn_pkg.rb', line 20

def (dependency)
  uri = uri_for(dependency)
  response = http.get(uri, escape: false)

  if http.ok?(response)
    json = Oj.load(response.body)
    json['versions'] ? json['versions'][dependency.version] : json
  else
    {}
  end
end