module UpdateHints
Constants
- VERSION
Public Class Methods
version_check(gem_name, present_version_str, destination = $stderr)
click to toggle source
Checks whether rubygems.org has a new version of this specific gem and prints how an update can be obtained if need be. Note: it swallows ANY exception to prevent network-related errors when for some reason the method is run while the app is offline
# File lib/update_hints.rb, line 14 def self.version_check(gem_name, present_version_str, destination = $stderr) begin version_check_without_exception_capture(gem_name, present_version_str, destination) rescue Exception end end
Private Class Methods
version_check_without_exception_capture(gem_name, present_version_str, destination)
click to toggle source
# File lib/update_hints.rb, line 23 def self.version_check_without_exception_capture(gem_name, present_version_str, destination) # Gem::Version was known to throw when a frozen string is passed to the constructor, see # https://github.com/rubygems/rubygems/commit/48f1d869510dcd325d6566df7d0147a086905380 int_present = Gem::Version.new(present_version_str.dup) int_avail = Checker.new(gem_name).get_latest if int_avail > int_present destination << "Your version of #{gem_name} is probably out of date\n" destination << "(the current version is #{int_avail}, but you have #{present_version_str}).\n" destination << "Please consider updating (run `gem update #{gem_name}`)\n" end end