Class: Jets::Thor::VersionCheck
- Inherits:
-
Object
- Object
- Jets::Thor::VersionCheck
- Defined in:
- lib/jets/thor/version_check.rb
Instance Method Summary collapse
- #check! ⇒ Object
- #check_needed? ⇒ Boolean
- #last_check_file ⇒ Object
- #last_checked_time ⇒ Object
- #save_last_checked_time ⇒ Object
Instance Method Details
#check! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jets/thor/version_check.rb', line 6 def check! return unless check_needed? remote_version = Gems.info("jets")["version"] local_version = Gem.loaded_specs["jets"].version return if remote_version.nil? if Gem::Version.new(remote_version) > Gem::Version.new(local_version) puts <<~EOL jets has a newer version available. installed version: #{local_version} latest version: #{remote_version} Please update jets EOL end save_last_checked_time end |
#check_needed? ⇒ Boolean
28 29 30 31 |
# File 'lib/jets/thor/version_check.rb', line 28 def check_needed? check_interval = 24 * 60 * 60 # 24 hours in seconds Time.now - last_checked_time >= check_interval end |
#last_check_file ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/jets/thor/version_check.rb', line 43 def last_check_file # Do not define last_check_file as a LAST_CHECK_FILE constant # On AWS lambda, Jets eager load errors since ENV["HOME"] is nil # Note: Added an extra safeguard in case ENV["HOME"] is nil home = ENV["HOME"] || "/root" File.join(home, ".jets/tmp/last-checked.txt") end |