Sha256: 0afd4ad6b84ff27699e3943c799908770ac3aca96ab073c573e1645c3a9d9985
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
require 'open-uri' module FastlaneCore # Verifies, the user runs the latest version of this gem class UpdateChecker # This method will check if the latest version is installed and show a warning if that's not the case def self.verify_latest_version(gem_name, current_version) return true unless self.update_available?(gem_name, current_version) v = fetch_latest(gem_name) puts '#######################################################################'.green puts "# #{gem_name} #{v} is available. You are on #{current_version}.".green puts "# It is recommended to use the latest version.".green puts "# Update using 'sudo gem update #{gem_name}'.".green puts "# To see what's new, open https://github.com/KrauseFx/#{gem_name}/releases.".green puts '#######################################################################'.green false end # Is a new official release available (this does not include pre-releases) def self.update_available?(gem_name, current_version) begin latest = fetch_latest(gem_name) if latest and Gem::Version.new(latest) > Gem::Version.new(current_version) return true end rescue => ex Helper.log.error("Could not check if '#{gem_name}' is up to date.") end return false end private def self.fetch_latest(gem_name) JSON.parse(open("http://rubygems.org/api/v1/gems/#{gem_name}.json").read)["version"] end end end
Version data entries
4 entries across 4 versions & 1 rubygems