Class: Cask

Inherits:
Object
  • Object
show all
Defined in:
lib/brew-cask-commands.rb

Defined Under Namespace

Modules: Scopes

Instance Method Summary collapse

Instance Method Details

#installed?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/brew-cask-commands.rb', line 4

def installed?
    destination_path.exist?
end

#installed_versionObject



12
13
14
15
16
17
# File 'lib/brew-cask-commands.rb', line 12

def installed_version
    # returns latest installed version if possible
    Pathname.glob(caskroom_path.join('*')).map(&:basename).sort{|x,y|
        Gem::Version.new(x) <=> Gem::Version.new(y) # throws exception if invalid version is provided ...
    }.last rescue nil # ... return nil in this case
end

#installed_version?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/brew-cask-commands.rb', line 8

def installed_version?
    !installed_version.nil?
end

#update_available?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/brew-cask-commands.rb', line 19

def update_available?
    Gem::Version.correct?(version) && # we have something to compare against in Cask file ...
        installed_version? && # ... we can determine current installed version ...
        Gem::Version.new(installed_version) < Gem::Version.new(version) # ... compare
end