mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
align pip resource with info handling
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
10926935e2
commit
55a26cfba7
1 changed files with 12 additions and 9 deletions
|
@ -12,28 +12,31 @@ class PipPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
|
||||
@info = {}
|
||||
@info[:type] = 'pip'
|
||||
|
||||
cmd = vulcano.run_command("pip show #{@package_name}")
|
||||
return nil if cmd.exit_status != 0
|
||||
return @info if cmd.exit_status != 0
|
||||
|
||||
params = SimpleConfig.new(
|
||||
cmd.stdout,
|
||||
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
|
||||
multiple_values: false,
|
||||
).params
|
||||
@cache = {
|
||||
name: params['Name'],
|
||||
installed: true,
|
||||
version: params['Version'],
|
||||
type: 'pip',
|
||||
}
|
||||
@info[:name] = params['Name']
|
||||
@info[:version] = params['Version']
|
||||
@info[:installed] = true
|
||||
@info
|
||||
end
|
||||
|
||||
def installed?
|
||||
!info.nil?
|
||||
info[:installed]
|
||||
end
|
||||
|
||||
def version
|
||||
info.nil? ? nil : info[:version]
|
||||
info[:version]
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
Loading…
Reference in a new issue