Class: Spandx::Core::LicensePlugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/spandx/core/license_plugin.rb

Instance Method Summary collapse

Methods inherited from Plugin

enhance

Methods included from Registerable

#all, #each, #inherited, #registry

Constructor Details

#initialize(catalogue: Spdx::Catalogue.default) ⇒ LicensePlugin

Returns a new instance of LicensePlugin.



6
7
8
# File 'lib/spandx/core/license_plugin.rb', line 6

def initialize(catalogue: Spdx::Catalogue.default)
  @guess = Guess.new(catalogue)
end

Instance Method Details

#enhance(dependency) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/spandx/core/license_plugin.rb', line 10

def enhance(dependency)
  package_manager = package_manager_for(dependency)
  return dependency unless known?(package_manager)
  return (dependency) if available_in?(dependency.meta)

  licenses_for(dependency).each do |text|
    dependency.licenses << @guess.license_for(text)
  end
  dependency
end