Sha256: f42a2ddcc75921ef8dae9005364e5c21d8b0ba35fe79836f2356287cb5e01136

Contents?: true

Size: 1014 Bytes

Versions: 16

Compression:

Stored size: 1014 Bytes

Contents

class Specinfra::Command::Darwin::Base::Package < Specinfra::Command::Base::Package
  class << self
    def check_is_installed(package, version=nil)
      escaped_package = escape(package)
      if version
        cmd = "/usr/local/bin/brew info #{escaped_package} | grep -E '^\/usr\/local\/Cellar\/#{escaped_package}\/#{escape(version)}'"
      else
        cmd = "/usr/local/bin/brew list -1 | grep -E '^#{escaped_package}$'"
      end
      cmd
    end

    alias :check_is_installed_by_homebrew :check_is_installed

    def check_is_installed_by_pkgutil(package, version=nil)
      cmd = "pkgutil --pkg-info #{package}"
      cmd = "#{cmd} | grep '^version: #{escape(version)}'" if version
      cmd
    end

    def install(package, version=nil, option='')
      # Homebrew doesn't support to install specific version.
      cmd = "brew install #{option} '#{package}'"
    end

    def get_version(package, opts=nil)
      "basename $(brew info #{package} | grep '\*$' | awk '{print $1}')"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
specinfra-2.10.0 lib/specinfra/command/darwin/base/package.rb
specinfra-2.9.3 lib/specinfra/command/darwin/base/package.rb
specinfra-2.9.2 lib/specinfra/command/darwin/base/package.rb
specinfra-2.9.1 lib/specinfra/command/darwin/base/package.rb
specinfra-2.9.0 lib/specinfra/command/darwin/base/package.rb
specinfra-2.8.0 lib/specinfra/command/darwin/base/package.rb
specinfra-2.7.0 lib/specinfra/command/darwin/base/package.rb
specinfra-2.6.0 lib/specinfra/command/darwin/base/package.rb
specinfra-2.5.0 lib/specinfra/command/darwin/base/package.rb
specinfra-2.4.5 lib/specinfra/command/darwin/base/package.rb
specinfra-2.4.4 lib/specinfra/command/darwin/base/package.rb
specinfra-2.4.3 lib/specinfra/command/darwin/base/package.rb
specinfra-2.4.2 lib/specinfra/command/darwin/base/package.rb
specinfra-2.4.1 lib/specinfra/command/darwin/base/package.rb
specinfra-2.4.0 lib/specinfra/command/darwin/base/package.rb
specinfra-2.3.2 lib/specinfra/command/darwin/base/package.rb