Class: Inspec::Resources::PipPackage
- Inherits:
-
Object
- Object
- Inspec::Resources::PipPackage
- Defined in:
- lib/inspec/resources/pip.rb
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(package_name, pip_path = nil) ⇒ PipPackage
constructor
A new instance of PipPackage.
- #installed? ⇒ Boolean
- #resource_id ⇒ Object
- #to_s ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(package_name, pip_path = nil) ⇒ PipPackage
Returns a new instance of PipPackage.
26 27 28 29 30 31 |
# File 'lib/inspec/resources/pip.rb', line 26 def initialize(package_name, pip_path = nil) @package_name = package_name @pip_cmd = pip_path || default_pip_path return skip_resource "pip not found" if @pip_cmd.nil? end |
Instance Method Details
#info ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/inspec/resources/pip.rb', line 33 def info return @info if defined?(@info) @info = {} @info[:type] = "pip" return @info unless cmd_successful? params = SimpleConfig.new( cmd.stdout, assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/, multiple_values: false ).params @info[:name] = params["Name"] @info[:version] = params["Version"] @info[:installed] = true @info end |
#installed? ⇒ Boolean
51 52 53 |
# File 'lib/inspec/resources/pip.rb', line 51 def installed? info[:installed] == true end |
#resource_id ⇒ Object
59 60 61 |
# File 'lib/inspec/resources/pip.rb', line 59 def resource_id @package_name || "pip" end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/inspec/resources/pip.rb', line 63 def to_s "Pip Package #{@package_name}" end |
#version ⇒ Object
55 56 57 |
# File 'lib/inspec/resources/pip.rb', line 55 def version info[:version] end |