Class: Spandx::Js::YarnPkg
- Inherits:
-
Core::Gateway
- Object
- Core::Gateway
- Spandx::Js::YarnPkg
- Defined in:
- lib/spandx/js/yarn_pkg.rb
Constant Summary collapse
- DEFAULT_SOURCE =
'https://registry.yarnpkg.com'
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
Instance Method Summary collapse
-
#initialize(http: Spandx.http) ⇒ YarnPkg
constructor
A new instance of YarnPkg.
- #licenses_for(dependency) ⇒ Object
- #matches?(dependency) ⇒ Boolean
- #metadata_for(dependency) ⇒ Object
Methods included from Core::Registerable
#all, #each, #inherited, #registry
Constructor Details
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
7 8 9 |
# File 'lib/spandx/js/yarn_pkg.rb', line 7 def http @http end |
Instance Method Details
#licenses_for(dependency) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/spandx/js/yarn_pkg.rb', line 17 def licenses_for(dependency) = (dependency) return [] if .empty? [['license']].compact end |
#matches?(dependency) ⇒ Boolean
13 14 15 |
# File 'lib/spandx/js/yarn_pkg.rb', line 13 def matches?(dependency) %i[npm yarn].include?(dependency.package_manager) end |
#metadata_for(dependency) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/spandx/js/yarn_pkg.rb', line 25 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 |