class MacSetup::HomebrewRunner
Public Class Methods
install_brew(formula)
click to toggle source
# File lib/mac_setup/homebrew_runner.rb, line 17 def self.install_brew(formula) Shell.run("brew install #{formula}") end
install_cask(cask)
click to toggle source
# File lib/mac_setup/homebrew_runner.rb, line 21 def self.install_cask(cask) Shell.run("brew cask install #{cask}") end
print_args(opts)
click to toggle source
# File lib/mac_setup/homebrew_runner.rb, line 39 def self.print_args(opts) args = opts["args"] return unless args "args: [#{quote_args(args.sort)}]" end
quote_args(args)
click to toggle source
# File lib/mac_setup/homebrew_runner.rb, line 47 def self.quote_args(args) args.map { |arg| %("#{arg}") }.join(", ") end
run(config, _status)
click to toggle source
# File lib/mac_setup/homebrew_runner.rb, line 5 def self.run(config, _status) MacSetup.log("Installing Homebrew brews and casks") do Tempfile.create("Brewfile") do |brewfile| write_brewfile(config, brewfile) File.chmod(0644, brewfile) brewfile.rewind Shell.raw("brew bundle install --file=#{brewfile.path}") end end end
write_brewfile(config, brewfile)
click to toggle source
# File lib/mac_setup/homebrew_runner.rb, line 25 def self.write_brewfile(config, brewfile) taps = config.taps.map { |parts| %(tap #{quote_args(parts)}) } brews = config.brews.map do |name, opts| [%(brew "#{name}"), print_args(opts)].compact.join(", ") end casks = (config.fonts + config.casks + config.quicklook).map do |name| %(cask "#{name}") end brewfile.write((taps + brews + casks).join("\n")) end