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



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/resources/package.rb', line 136

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.to_s,
    installed: true,
    version: pkg.installed.version.to_s,
    type: 'brew',
  }
end