Class: LicenseFinder::PipPackage
- Defined in:
- lib/license_finder/packages/pip_package.rb
Constant Summary collapse
- LICENSE_FORMAT =
/^License.*::\s*(.*)$/.freeze
- 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, #log_activation, #missing?, #notice_files, #whitelisted!, #whitelisted?
Constructor Details
#initialize(name, version, spec, options = {}) ⇒ PipPackage
Returns a new instance of PipPackage.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/license_finder/packages/pip_package.rb', line 21 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
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/license_finder/packages/pip_package.rb', line 10 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
35 36 37 |
# File 'lib/license_finder/packages/pip_package.rb', line 35 def package_manager 'Pip' end |