Class: Brewmaster::BrewCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/brewmaster/brew_collection.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(names) ⇒ BrewCollection

Returns a new instance of BrewCollection.



3
4
5
6
# File 'lib/brewmaster/brew_collection.rb', line 3

def initialize(names)
  @names = names
  @formulae = names.map {|name| Formula.factory(name)}
end

Class Method Details

.installedObject

anything installed, that’s not in our list anymore def extras

@extras ||= self.class.installed - @formulae

end



39
40
41
42
# File 'lib/brewmaster/brew_collection.rb', line 39

def self.installed
  # `ls #{HOMEBREW_CELLAR}`.split
  Formula.installed
end

.outdatedObject



44
45
46
# File 'lib/brewmaster/brew_collection.rb', line 44

def self.outdated
  Homebrew.outdated_brews
end

Instance Method Details

#install_missingObject



8
9
10
11
12
# File 'lib/brewmaster/brew_collection.rb', line 8

def install_missing
  Homebrew.perform_preinstall_checks

  missing.each {|f| Homebrew.install_formula(f)}
end

#install_updatesObject



14
15
16
17
18
# File 'lib/brewmaster/brew_collection.rb', line 14

def install_updates
  Homebrew.perform_preinstall_checks

  outdated.each {|f| Homebrew.upgrade_formula(f)}
end

#missingObject

anything not installed, excluding the outdated



25
26
27
# File 'lib/brewmaster/brew_collection.rb', line 25

def missing
  @missing ||= @formulae.select {|f| !f.installed?} - self.class.outdated
end

#outdatedObject

anything outdated that we want installed that is not pinned



30
31
32
# File 'lib/brewmaster/brew_collection.rb', line 30

def outdated
  @outdated ||= @formulae & self.class.outdated.select {|f| !f.pinned?}
end