Class: Cask
- Inherits:
-
Object
- Object
- Cask
- Defined in:
- lib/brew-cask-commands.rb
Defined Under Namespace
Modules: Scopes
Instance Method Summary collapse
- #installed? ⇒ Boolean
- #installed_version ⇒ Object
- #installed_version? ⇒ Boolean
- #update_available? ⇒ Boolean
Instance Method Details
#installed? ⇒ Boolean
4 5 6 |
# File 'lib/brew-cask-commands.rb', line 4 def installed? destination_path.exist? end |
#installed_version ⇒ Object
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
8 9 10 |
# File 'lib/brew-cask-commands.rb', line 8 def installed_version? !installed_version.nil? end |
#update_available? ⇒ 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 |