Sha256: d2147dc6e32f5f66359b320acb2ab01147382c0aa7d1301226565c0d4b809dba

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

module ActiveScripts
  module Packages
    class Homebrew < ActiveScripts::Packages::Base

      # INFO: ActiveScripts::Packages::Homebrew contains code that
      #   execute the Homebrew package.

      private

      def install
        if package_installed?(command: "brew")
          notify_package_exists!
        else
          case $operating_system
          when :macosx
            execute_command!('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
            execute_command!("brew tap homebrew/dupes")
            say_ok("   Installation complete!")
          when :linux
            execute_command!('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"')
            execute_command!("cat #{addendum_path!('linuxbrew.txt')} >> ~/.bashrc")
            execute_command!("source ~/.bashrc")
            execute_command!("brew tap homebrew/dupes")
            say_ok("   Installation complete!")
          else
            notify_package_unavailable!
          end
        end
      end

      def upgrade
        execute_command!("brew update --all")
        output = execute_command!("brew doctor")
        say_warning("   [!] #{output.squish}") unless option_dry_run? || package_output?(output, includes: "Your system is ready to brew.")
        say_ok("   Upgrade complete!")
      end

      def uninstall
        if package_installed?(command: "brew")
          execute_command('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"')
          say_ok("   Uninstallation complete!")
        else
          notify_package_missing!
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_scripts-0.1.0 lib/active_scripts/packages/homebrew.rb