Class: LicenseFinder::CargoPackage

Inherits:
Package
  • Object
show all
Defined in:
lib/license_finder/packages/cargo_package.rb

Instance Attribute Summary

Attributes inherited from Package

#authors, #children, #description, #groups, #homepage, #install_path, #license_names_from_spec, #logger, #manual_approval, #name, #parents, #summary, #version

Instance Method Summary collapse

Methods inherited from Package

#<=>, #activations, #approved?, #approved_manually!, #approved_manually?, #decide_on_license, #eql?, #hash, #license_files, license_names_from_standard_spec, #licenses, #licenses_from_spec, #licensing, #log_activation, #missing?, #notice_files, #permitted!, #permitted?, #restricted!, #restricted?

Constructor Details

#initialize(crate, options = {}) ⇒ CargoPackage

Returns a new instance of CargoPackage.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/license_finder/packages/cargo_package.rb', line 5

def initialize(crate, options = {})
  crate = crate.reject { |_, v| v.nil? || v == '' }
  children = crate.fetch('dependencies', []).map { |p| p['name'] }
  licenses = crate.fetch('license', '').split('/')
  super(
    crate['name'],
    crate['version'],
    options.merge(
      summary: crate.fetch('description', '').strip,
      spec_licenses: licenses.compact,
      children: children
    )
  )
end

Instance Method Details

#package_managerObject



20
21
22
# File 'lib/license_finder/packages/cargo_package.rb', line 20

def package_manager
  'Cargo'
end

#package_urlObject



24
25
26
# File 'lib/license_finder/packages/cargo_package.rb', line 24

def package_url
  "https://crates.io/crates/#{CGI.escape(name)}/#{CGI.escape(version)}"
end