Class: EmergeCLI::Utils::VersionCheck
- Inherits:
-
Object
- Object
- EmergeCLI::Utils::VersionCheck
- Defined in:
- lib/utils/version_check.rb
Instance Method Summary collapse
- #check_version ⇒ Object
-
#initialize(network: EmergeCLI::Network.new) ⇒ VersionCheck
constructor
A new instance of VersionCheck.
Constructor Details
#initialize(network: EmergeCLI::Network.new) ⇒ VersionCheck
Returns a new instance of VersionCheck.
6 7 8 |
# File 'lib/utils/version_check.rb', line 6 def initialize(network: EmergeCLI::Network.new) @network = network end |
Instance Method Details
#check_version ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/utils/version_check.rb', line 10 def check_version Sync do response = @network.get( path: 'https://rubygems.org/api/v1/gems/emerge.json', headers: {} ) latest_version = JSON.parse(response.read).fetch('version') current_version = EmergeCLI::VERSION if Gem::Version.new(latest_version) > Gem::Version.new(current_version) Logger.warn "A new version of emerge-cli is available (#{latest_version})" Logger.warn "You are currently using version #{current_version}" Logger.warn "To update, run: gem update emerge\n" end end rescue KeyError Logger.error 'Failed to parse version from RubyGems API response' rescue StandardError => e Logger.error "Failed to check for updates: #{e.}" end |