Class: LicenseFinder::Pip
Class Method Summary
collapse
Instance Method Summary
collapse
#active?, command_exists?, #current_packages_with_relations, #detected_package_path, installed?, takes_priority_over
Constructor Details
#initialize(options = {}) ⇒ Pip
Returns a new instance of Pip.
6
7
8
9
|
# File 'lib/license_finder/package_managers/pip.rb', line 6
def initialize(options = {})
super
@requirements_path = options[:pip_requirements_path] || Pathname('requirements.txt')
end
|
Class Method Details
.package_management_command ⇒ Object
24
25
26
|
# File 'lib/license_finder/package_managers/pip.rb', line 24
def self.package_management_command
'pip'
end
|
.prepare_command ⇒ Object
28
29
30
|
# File 'lib/license_finder/package_managers/pip.rb', line 28
def self.prepare_command
'pip install'
end
|
Instance Method Details
#current_packages ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/license_finder/package_managers/pip.rb', line 11
def current_packages
pip_output.map do |name, version, children, location|
PipPackage.new(
name,
version,
pypi_def(name, version),
logger: logger,
children: children,
install_path: Pathname(location).join(name)
)
end
end
|
#possible_package_paths ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/license_finder/package_managers/pip.rb', line 40
def possible_package_paths
if project_path.nil?
[@requirements_path]
else
[project_path.join(@requirements_path)]
end
end
|
#prepare ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/license_finder/package_managers/pip.rb', line 32
def prepare
prep_cmd = "#{Pip.prepare_command} -r #{@requirements_path}"
_stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(prep_cmd) }
return if status.success?
log_errors stderr
raise "Prepare command '#{prep_cmd}' failed" unless @prepare_no_fail
end
|