Class: LicenseFinder::PipPackage
- Defined in:
- lib/license_finder/package_managers/pip_package.rb
Constant Summary collapse
- LICENSE_FORMAT =
/^License.*::\s*(.*)$/
- INVALID_LICENSES =
["", "UNKNOWN"].to_set
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
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, version, spec, options = {}) ⇒ PipPackage
constructor
A new instance of PipPackage.
- #package_manager ⇒ Object
Methods inherited from Package
#<=>, #activations, #approved?, #approved_manually!, #approved_manually?, #blacklisted!, #blacklisted?, #decide_on_license, #eql?, #hash, #license_files, license_names_from_standard_spec, #licenses, #licenses_from_spec, #licensing, #missing?, #whitelisted!, #whitelisted?
Constructor Details
#initialize(name, version, spec, options = {}) ⇒ PipPackage
Returns a new instance of PipPackage.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/license_finder/package_managers/pip_package.rb', line 17 def initialize(name, version, spec, ={}) super( name, version, .merge( authors: spec["author"], summary: spec["summary"], description: spec["description"], homepage: spec["home_page"], spec_licenses: self.class.license_names_from_spec(spec) ) ) end |
Class Method Details
.license_names_from_spec(spec) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/license_finder/package_managers/pip_package.rb', line 6 def self.license_names_from_spec(spec) license = spec["license"].to_s.strip return [license] unless INVALID_LICENSES.include?(license) spec .fetch("classifiers", []) .select { |c| c =~ LICENSE_FORMAT } .map { |c| c.gsub(LICENSE_FORMAT, '\1') } end |
Instance Method Details
#package_manager ⇒ Object
31 32 33 |
# File 'lib/license_finder/package_managers/pip_package.rb', line 31 def package_manager 'Pip' end |