Class: LicenseFinder::PipPackage
- Inherits:
-
Package
- Object
- Package
- LicenseFinder::PipPackage
show all
- 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
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(name, version, spec, options = {}) ⇒ PipPackage
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/license_finder/packages/pip_package.rb', line 28
def initialize(name, version, spec, options = {})
super(
name,
version,
options.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
20
21
22
23
24
25
26
|
# File 'lib/license_finder/packages/pip_package.rb', line 10
def self.license_names_from_spec(spec)
license_names = spec['license'].to_s.strip.split(' or ')
has_unrecognized_license = false
license_names.each do |license_name|
license = License.find_by_name(license_name.strip)
has_unrecognized_license ||= license.unrecognized_matcher?
end
return license_names if !license_names.empty? && !has_unrecognized_license
spec
.fetch('classifiers', [])
.select { |c| c =~ LICENSE_FORMAT }
.map { |c| c.gsub(LICENSE_FORMAT, '\1') }
end
|
Instance Method Details
#package_manager ⇒ Object
42
43
44
|
# File 'lib/license_finder/packages/pip_package.rb', line 42
def package_manager
'Pip'
end
|
#package_url ⇒ Object
46
47
48
|
# File 'lib/license_finder/packages/pip_package.rb', line 46
def package_url
"https://pypi.org/project/#{CGI.escape(name)}/#{CGI.escape(version)}/"
end
|