Sha256: b15ab9c2a98b7fcae9516213109390022b14612b960f59155e6b9d66a37ce796

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 Bytes

Contents

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

class Homebrew < Config

  def config
    Config.new.global['homebrew']
  end

  def packages
    config['packages']
  end

  def brewfile
    return File.join(Config.new.workspace_directory, 'Brewfile')
  end

  def brewfile_out(packages)
    output = ''
    packages.each do |type, package_array|
      package_array.each do |package|
        output << "#{type} '#{package}'\n"
      end
    end
    return output
  end

  def bundle
    system("brew tap Homebrew/bundle")
    puts "Updating Brewfile"

    File.open(brewfile, "w+") {
      |file| file.write(brewfile_out(packages))
    }

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

  def exec
    bundle
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
myosx-0.2.6 lib/myosx/homebrew.rb
myosx-0.2.5 lib/myosx/homebrew.rb
myosx-0.2.4 lib/myosx/homebrew.rb