align pip resource with info handling

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2015-09-17 16:54:01 +02:00
parent 10926935e2
commit 55a26cfba7

View file

@ -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