Sha256: 6a7621f721c5dfbe5e7119d3ba03aeeaef4e26ed20ba2b7e0a79b7ce68a6c181

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

#!/usr/bin/env ruby
#
# Class which configures homebrew and brew bundle
#
require 'yaml'
require 'git'
require_relative 'config'

class Homebrew < Config
  def initialize
    @config = $global_config['homebrew']
  end

  def bundle
    system("brew tap Homebrew/bundle")
    puts "Updating Brewfile"
    packages = @config['packages']
    brew_packages = packages['brew']
    tap_packages = packages['tap']
    cask_packages = packages['cask']

    File.open(File.join($workspace, 'Brewfile'), "w+") do |f|
      brew_packages.each { |p| f.puts "brew '#{p}'" }
      tap_packages.each { |p| f.puts "tap '#{p}'" }
      cask_packages.each { |p| f.puts "cask '#{p}'" }
    end
    brewfile = File.join($workspace, 'Brewfile')

    puts "Installing packages from #{brewfile}"
    system("brew bundle --file=#{brewfile}")
  end

  def exec
    if @config['manage']
      bundle
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
myosx-0.2.1 lib/myosx/homebrew.rb
myosx-0.1.0 lib/myosx/homebrew.rb