class Specinfra::Command::Darwin::Base::Package

Public Class Methods

brew_cask_list() click to toggle source
# File lib/specinfra/command/darwin/base/package.rb, line 45
def brew_cask_list
  # Since `brew cask list` is slow, directly check Caskroom directory
  "ls -1 /opt/homebrew-cask/Caskroom/"
end
brew_list() click to toggle source
# File lib/specinfra/command/darwin/base/package.rb, line 40
def brew_list
  # Since `brew list` is slow, directly check Cellar directory
  'ls -1 "$(brew --prefix)/Cellar/"'
end
check_is_installed(package, version=nil) click to toggle source
# File lib/specinfra/command/darwin/base/package.rb, line 3
def check_is_installed(package, version=nil)
  escaped_package = escape(File.basename(package))
  if version
    cmd = %Q[brew info #{escaped_package} | grep -E "^$(brew --prefix)/Cellar/#{escaped_package}/#{escape(version)}"]
  else
    cmd = "#{brew_list} | grep -E '^#{escaped_package}$'"
  end
  cmd
end
check_is_installed_by_homebrew(package, version=nil)
Alias for: check_is_installed
check_is_installed_by_homebrew_cask(package, version=nil) click to toggle source
# File lib/specinfra/command/darwin/base/package.rb, line 15
def check_is_installed_by_homebrew_cask(package, version=nil)
  escaped_package = escape(File.basename(package))
  if version
    cmd = "brew cask info #{escaped_package} | grep -E '^/opt/homebrew-cask/Caskroom/#{escaped_package}/#{escape(version)}'"
  else
    cmd = "#{brew_cask_list} | grep -E '^#{escaped_package}$'"
  end
  cmd
end
check_is_installed_by_pkgutil(package, version=nil) click to toggle source
# File lib/specinfra/command/darwin/base/package.rb, line 25
def check_is_installed_by_pkgutil(package, version=nil)
  cmd = "pkgutil --pkg-info #{package}"
  cmd = "#{cmd} | grep '^version: #{escape(version)}'" if version
  cmd
end
get_version(package, opts=nil) click to toggle source
# File lib/specinfra/command/darwin/base/package.rb, line 36
def get_version(package, opts=nil)
  %Q[ls -1 "$(brew --prefix)/Cellar/#{package}/" | tail -1]
end
install(package, version=nil, option='') click to toggle source
# File lib/specinfra/command/darwin/base/package.rb, line 31
def install(package, version=nil, option='')
  # Homebrew doesn't support to install specific version.
  cmd = "brew install #{option} '#{package}'"
end