Class: Snapshot::UpdateChecker
- Inherits:
-
Object
- Object
- Snapshot::UpdateChecker
- Defined in:
- lib/snapshot/update_checker.rb
Overview
Verifies, the user runs the latest version of this gem
Class Method Summary collapse
-
.current_version ⇒ Object
The currently used version of this gem.
-
.update_available? ⇒ Boolean
Is a new official release available (this does not include pre-releases).
-
.verify_latest_version ⇒ Object
This method will check if the latest version is installed and show a warning if that’s not the case.
Class Method Details
.current_version ⇒ Object
The currently used version of this gem
36 37 38 |
# File 'lib/snapshot/update_checker.rb', line 36 def self.current_version Snapshot::VERSION end |
.update_available? ⇒ Boolean
Is a new official release available (this does not include pre-releases)
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/snapshot/update_checker.rb', line 22 def self.update_available? begin latest = fetch_latest if latest and Gem::Version.new(latest) > Gem::Version.new(current_version) return true end rescue Exception => ex Helper.log.debug(ex) Helper.log.error("Could not check if 'snapshot' is up to date.") end return false end |
.verify_latest_version ⇒ Object
This method will check if the latest version is installed and show a warning if that’s not the case
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/snapshot/update_checker.rb', line 7 def self.verify_latest_version if self.update_available? v = fetch_latest puts '#######################################################################'.green puts "# Snapshot #{v} is available.".green puts "# It is recommended to use the latest version.".green puts "# Update using '(sudo) gem update snapshot'.".green puts "# To see what's new, open https://github.com/KrauseFx/snapshot/releases.".green puts '#######################################################################'.green return true end false end |