Class: Inspec::Resources::Brew

Inherits:
PkgManagement show all
Defined in:
lib/resources/package.rb

Overview

MacOS / Darwin implementation

Instance Attribute Summary

Attributes inherited from PkgManagement

#inspec

Instance Method Summary collapse

Methods inherited from PkgManagement

#initialize

Constructor Details

This class inherits a constructor from Inspec::Resources::PkgManagement

Instance Method Details

#info(package_name) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/resources/package.rb', line 140

def info(package_name)
  cmd = inspec.command("brew info --json=v1 #{package_name}")
  return nil if cmd.exit_status.to_i != 0
  # parse data
  pkg = JSON.parse(cmd.stdout)[0]
  {
    name: pkg['name'],
    installed: true,
    version: pkg['installed'][0]['version'],
    type: 'brew',
  }
rescue JSON::ParserError => _e
  return nil
end