Class: BrewCaskTools::Tasks::Outdated

Inherits:
Caskroom
  • Object
show all
Defined in:
lib/bct/tasks/outdated.rb

Overview

Outdated cask task

Instance Method Summary collapse

Methods inherited from Caskroom

#caskroom, #format, #handle, #increment, #progressbar

Constructor Details

#initializeOutdated

Returns a new instance of Outdated.



7
8
9
10
11
12
13
14
15
# File 'lib/bct/tasks/outdated.rb', line 7

def initialize
  super
  progressbar.total = caskroom.casks.length
  progressbar.log "\nLooking for outdated casks..."
  @outdated, @deprecated = compile

  outdated
  deprecated
end

Instance Method Details

#compileObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bct/tasks/outdated.rb', line 17

def compile
  outdated = []
  deprecated = []
  caskroom.enumerate do |cask|
    increment(cask)

    outdated << cask if cask.outdated?
    deprecated << cask if cask.deprecated?
  end
  [outdated, deprecated]
end

#deprecatedObject



41
42
43
44
45
46
47
48
49
# File 'lib/bct/tasks/outdated.rb', line 41

def deprecated
  return if @deprecated.empty?

  @deprecated.map! { |cask| [cask.name] }

  handle(@deprecated, 'deprecated') do |deprecated|
    format(['Package'], deprecated)
  end
end

#outdatedObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bct/tasks/outdated.rb', line 29

def outdated
  return say "\nThere are no outdated casks", :yellow if @outdated.empty?

  @outdated.map! do |cask|
    [cask.name, cask.current, cask.candidate]
  end

  handle(@outdated, 'outdated') do |outdated|
    format(['Package', 'Installed Version', 'New Version'], outdated)
  end
end