Sha256: 6b975a3240c55333e570d61ef887f2bcf153a00c37f523bce4c1fa2c8decc623

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module BinInstall
  module Brew
    module Package
      def self.install(package)
        system("brew install #{package}")
      end

      def self.install!(package)
        BinInstall.system!("brew install #{package}")
      end

      def self.upgrade(package)
        if latest_version?(package)
          puts "#{package} is already the latest version. Skipping.".blue
        else
          system("brew upgrade #{package}")
        end
      end

      def self.upgrade!(package)
        if latest_version?(package)
          puts "#{package} is already the latest version. Skipping.".blue
        else
          BinInstall.system!("brew upgrade #{package}")
        end
      end

      def self.install_or_upgrade(package)
        if installed?(package)
          upgrade(package)
        else
          install(package)
        end
      end

      def self.install_or_upgrade!(package)
        if installed?(package)
          upgrade!(package)
        else
          install!(package)
        end
      end

      def self.installed?(package)
        system("brew list --versions #{package}")
      end

      def self.latest_version?(package)
        system("brew outdated #{package}")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bin_install-0.0.10 lib/bin_install/brew/package.rb
bin_install-0.0.9 lib/bin_install/brew/package.rb