Class: LicenseFinder::PipPackage
- Defined in:
- lib/license_finder/package_managers/pip_package.rb
Constant Summary collapse
- LICENSE_FORMAT =
/^License.*::\s*(.*)$/
Instance Attribute Summary
Attributes inherited from Package
#children, #description, #groups, #homepage, #install_path, #license_names_from_spec, #logger, #manual_approval, #name, #parents, #summary, #version
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, version, install_path, spec, options = {}) ⇒ PipPackage
constructor
A new instance of PipPackage.
Methods inherited from Package
#activations, #approved?, #approved_manually!, #approved_manually?, #decide_on_license, #license_files, license_names_from_standard_spec, #licenses, #licenses_from_spec, #licensing, #missing?, #whitelisted!, #whitelisted?
Constructor Details
#initialize(name, version, install_path, spec, options = {}) ⇒ PipPackage
Returns a new instance of PipPackage.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/license_finder/package_managers/pip_package.rb', line 16 def initialize(name, version, install_path, spec, ={}) super( name, version, .merge( summary: spec["summary"], description: spec["description"], homepage: spec["home_page"], spec_licenses: self.class.license_names_from_spec(spec), install_path: install_path ) ) end |
Class Method Details
.license_names_from_spec(spec) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/license_finder/package_managers/pip_package.rb', line 5 def self.license_names_from_spec(spec) license = spec["license"] return [license] if license && license != "UNKNOWN" spec .fetch("classifiers", []) .select { |c| c =~ LICENSE_FORMAT } .map { |c| c.gsub(LICENSE_FORMAT, '\1') } end |