Class: Wright::Provider::Package::Homebrew

Inherits:
Wright::Provider::Package show all
Defined in:
lib/wright/provider/package/homebrew.rb

Overview

Homebrew package provider. Used as a provider for Resource::Package on OS X systems.

Constant Summary

Constants inherited from Wright::Provider

Wright::Provider::PROVIDER_DIR

Instance Method Summary collapse

Methods inherited from Wright::Provider::Package

#install, #installed?, #remove

Methods inherited from Wright::Provider

#initialize, #updated?

Constructor Details

This class inherits a constructor from Wright::Provider

Instance Method Details

#installed_versionsArray<String>

Returns the installed package versions.

Returns:

  • (Array<String>)

    the installed package versions


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wright/provider/package/homebrew.rb', line 14

def installed_versions
  cmd = 'brew'
  args = ['info', '--json=v1', package_name]
  cmd_stdout, _, cmd_status = Wright::Util.bundler_clean_env do
    Open3.capture3(env, cmd, *args)
  end

  if cmd_status.success?
    JSON[cmd_stdout].first['installed'].map { |v| v['version'] }
  else
    []
  end
end