Sha256: 6eadb0071e5da0b7c91ab8e09cde33834c0be095e02511498ca70f86c7e245f6

Contents?: true

Size: 837 Bytes

Versions: 1

Compression:

Stored size: 837 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
    $global_config['homebrew']
  end

  def packages
    config['packages']
  end

  def brewfile
    return File.join($workspace, '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

1 entries across 1 versions & 1 rubygems

Version Path
myosx-0.2.2 lib/myosx/homebrew.rb