Class: Inspec::Resources::PipPackage
- Inherits:
-
Object
- Object
- Inspec::Resources::PipPackage
- Defined in:
- lib/resources/pip.rb
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(package_name) ⇒ PipPackage
constructor
A new instance of PipPackage.
- #installed? ⇒ Boolean
- #to_s ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(package_name) ⇒ PipPackage
Returns a new instance of PipPackage.
20 21 22 |
# File 'lib/resources/pip.rb', line 20 def initialize(package_name) @package_name = package_name end |
Instance Method Details
#info ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/resources/pip.rb', line 24 def info return @info if defined?(@info) @info = {} @info[:type] = 'pip' cmd = inspec.command("#{pip_cmd} show #{@package_name}") return @info if cmd.exit_status != 0 params = SimpleConfig.new( cmd.stdout, assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/, multiple_values: false, ).params @info[:name] = params['Name'] @info[:version] = params['Version'] @info[:installed] = true @info end |
#installed? ⇒ Boolean
43 44 45 |
# File 'lib/resources/pip.rb', line 43 def installed? info[:installed] == true end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/resources/pip.rb', line 51 def to_s "Pip Package #{@package_name}" end |
#version ⇒ Object
47 48 49 |
# File 'lib/resources/pip.rb', line 47 def version info[:version] end |