Module: BinInstall::Brew

Defined in:
lib/bin_install/brew.rb,
lib/bin_install/brew/cask.rb,
lib/bin_install/brew/package.rb,
lib/bin_install/brew/service.rb

Defined Under Namespace

Modules: Cask, Package, Service

Constant Summary collapse

INSTALL =
'/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'.freeze

Class Method Summary collapse

Class Method Details

.askObject



29
30
31
32
33
34
# File 'lib/bin_install/brew.rb', line 29

def self.ask
  return if installed?

  print 'Would you like to install Homebrew? [Y/n]: '
  install if Shell.default_yes?(gets.chomp)
end

.ask!Object



36
37
38
39
# File 'lib/bin_install/brew.rb', line 36

def self.ask!
  print 'Would you like to install Homebrew? [Y/n]: '
  install! if Shell.default_yes?(gets.chomp)
end

.installObject



19
20
21
22
# File 'lib/bin_install/brew.rb', line 19

def self.install
  puts 'Installing Homebrew...'.white
  system(INSTALL)
end

.install!Object



24
25
26
27
# File 'lib/bin_install/brew.rb', line 24

def self.install!
  puts 'Installing Homebrew...'.white
  BinInstall.system!(INSTALL)
end

.installed?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/bin_install/brew.rb', line 53

def self.installed?
  Shell.executable_exists?('brew')
end

.require!Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/bin_install/brew.rb', line 8

def self.require!
  if installed?
    update!
  else
    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

.updateObject



41
42
43
44
45
# File 'lib/bin_install/brew.rb', line 41

def self.update
  puts 'Updating Homebrew...'.white
  system('brew update')
  Cask.tap
end

.update!Object



47
48
49
50
51
# File 'lib/bin_install/brew.rb', line 47

def self.update!
  puts 'Updating Homebrew...'.white
  BinInstall.system!('brew update')
  Cask.tap!
end