Class: Homebrew

Inherits:
Object
  • Object
show all
Defined in:
lib/myosx/homebrew.rb

Instance Method Summary collapse

Instance Method Details

#brewfileObject



19
20
21
# File 'lib/myosx/homebrew.rb', line 19

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

#brewfile_out(packages) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/myosx/homebrew.rb', line 23

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

#bundleObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/myosx/homebrew.rb', line 33

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

#configObject



11
12
13
# File 'lib/myosx/homebrew.rb', line 11

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

#execObject



45
46
47
# File 'lib/myosx/homebrew.rb', line 45

def exec
  bundle
end

#packagesObject



15
16
17
# File 'lib/myosx/homebrew.rb', line 15

def packages
  config['packages']
end