Class: Spandx::Js::YarnPkg
Constant Summary
collapse
- DEFAULT_SOURCE =
'https://registry.yarnpkg.com'
Instance Attribute Summary
#http
Instance Method Summary
collapse
#initialize
#all, #each, #inherited, #registry
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)
metadata = metadata_for(dependency)
return [] if metadata.empty?
[metadata['license']].compact
end
|
#matches?(dependency) ⇒ Boolean
8
9
10
|
# File 'lib/spandx/js/yarn_pkg.rb', line 8
def matches?(dependency)
%i[npm yarn].include?(dependency.package_manager)
end
|
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/spandx/js/yarn_pkg.rb', line 20
def metadata_for(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
|