lib/bin_install/brew.rb in bin_install-0.0.6 vs lib/bin_install/brew.rb in bin_install-0.0.9
- old
+ new
@@ -1,75 +1,56 @@
+require 'bin_install/brew/cask'
+require 'bin_install/brew/package'
+require 'bin_install/brew/service'
+
module BinInstall
module Brew
def self.require!
if installed?
update!
else
- abort('Homebrew is required! Visit https://brew.sh/ to install.'.red)
+ puts 'Homebrew is required.'.red
+ puts 'Visit https://brew.sh/ for more information.'
+ ask!
+ abort('Can not continue without Homebrew.'.red) unless installed?
end
end
- def self.update
- puts 'Updating Homebrew...'.white
- system('brew update')
- system('brew tap caskroom/cask')
+ def self.install
+ puts 'Installing Homebrew...'.white
+ system('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
end
- def self.update!
- puts 'Updating Homebrew...'.white
- BinInstall.system!('brew update')
- BinInstall.system!('brew tap caskroom/cask')
+ def self.install!
+ puts 'Installing Homebrew...'.white
+ BinInstall.system!('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
end
- def self.install(package)
- system("brew install #{package}")
- end
+ def self.ask
+ return if installed?
- def self.install!(package)
- BinInstall.system!("brew install #{package}")
+ print 'Would you like to install Homebrew? [Y/n]: '
+ install if Shell.default_yes?(gets.chomp)
end
- def self.upgrade(package)
- if package_latest_version?(package)
- puts "#{package} is already the latest version. Skipping.".blue
- else
- system("brew upgrade #{package}")
- end
+ def self.ask!
+ print 'Would you like to install Homebrew? [Y/n]: '
+ install! if Shell.default_yes?(gets.chomp)
end
- def self.upgrade!(package)
- if package_latest_version?(package)
- puts "#{package} is already the latest version. Skipping.".blue
- else
- BinInstall.system!("brew upgrade #{package}")
- end
+ def self.update
+ puts 'Updating Homebrew...'.white
+ system('brew update')
+ Cask.tap
end
- def self.install_or_upgrade(package)
- if package_installed?(package)
- upgrade(package)
- else
- install(package)
- end
+ def self.update!
+ puts 'Updating Homebrew...'.white
+ BinInstall.system!('brew update')
+ Cask.tap!
end
- def self.install_or_upgrade!(package)
- if package_installed?(package)
- upgrade!(package)
- else
- install!(package)
- end
- end
-
def self.installed?
- system('brew --version')
- end
-
- def self.package_installed?(package)
- system("brew list --versions #{package}")
- end
-
- def self.package_latest_version?(package)
- system("brew outdated #{package}")
+ Shell.executable_exists?('brew')
end
end
end