Sha256: a10d8e3b98fa3db322cc99227b5afff48ec04ffc17b34d05d2696b93fa2c402d

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

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

class Homebrew

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

  def packages
    config['packages']
  end

  def brewfile
    return File.join(Konfig.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

1 entries across 1 versions & 1 rubygems

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