From 9cb1eabc8838edcc1a8ac5f5c9c86ac3b10d4ee8 Mon Sep 17 00:00:00 2001 From: Graham Paye Date: Wed, 29 Aug 2018 13:31:30 -0700 Subject: [PATCH] warn on EOL ruby version (#110) --- CHANGELOG.md | 6 ++++- README.md | 9 +++++++ lib/signet/version.rb | 63 ++++++++++++++++++++++++++++++++++++++++++- signet.gemspec | 2 ++ 4 files changed, 78 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e185e7e..4b6c4ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -## 0.9.0 (2018-08-16) +## 0.9.1 (2018-08-29) +* Warn on EOL ruby versions. +* Fix DateTime normalization. + +## 0.9.0 (2018-08-20) * Add RemoteServerError class for 5xx level errors. * Allow to_json to be called with arguments * Expires_in now sets and reflects current expires_at value diff --git a/README.md b/README.md index 43ea177..05c41b5 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,12 @@ client.fetch_access_token! `gem install signet` Be sure `https://rubygems.org` is in your gem sources. + +## Supported Ruby Versions +This library is currently supported on Ruby 1.9+. +However, Ruby 2.4 or later is strongly recommended, as earlier releases have +reached or are nearing end-of-life. After March 31, 2019, Google will provide +official support only for Ruby versions that are considered current and +supported by Ruby Core (that is, Ruby versions that are either in normal +maintenance or in security maintenance). +See https://www.ruby-lang.org/en/downloads/branches/ for further details. diff --git a/lib/signet/version.rb b/lib/signet/version.rb index 6ed1c07..c01c968 100644 --- a/lib/signet/version.rb +++ b/lib/signet/version.rb @@ -18,10 +18,71 @@ module Signet module VERSION MAJOR = 0 MINOR = 9 - TINY = 0 + TINY = 1 PRE = nil STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') + + # On March 31, 2019, set supported version to 2.4 and recommended to 2.6. + # Thereafter, follow the MRI support schedule: supported means non-EOL, + # and recommended means in normal (rather than security) maintenance. + # See https://www.ruby-lang.org/en/downloads/branches/ + ## + # Minimum "supported" Ruby version (non-EOL) + # @private + # + SUPPORTED_VERSION_THRESHOLD = '1.9'.freeze + ## + # Minimum "recommended" Ruby version (normal maintenance) + # @private + # + RECOMMENDED_VERSION_THRESHOLD = '2.4'.freeze + ## + # Check Ruby version and emit a warning if it is old + # @private + # + def self.warn_on_old_ruby_version + return if ENV['GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS'] + cur_version = Gem::Version.new RUBY_VERSION + if cur_version < Gem::Version.new(SUPPORTED_VERSION_THRESHOLD) + warn_unsupported_ruby cur_version, RECOMMENDED_VERSION_THRESHOLD + elsif cur_version < Gem::Version.new(RECOMMENDED_VERSION_THRESHOLD) + warn_nonrecommended_ruby cur_version, RECOMMENDED_VERSION_THRESHOLD + end + rescue ArgumentError + 'Unable to determine current Ruby version.' + end + + ## + # Print a warning for an EOL version of Ruby + # @private + # + def self.warn_unsupported_ruby cur_version, recommended_version + "WARNING: You are running Ruby #{cur_version}, which has reached" + + " end-of-life and is no longer supported by Ruby Core.\n" + + 'Signet works best on supported versions of' + + ' Ruby. It is strongly recommended that you upgrade to Ruby' + + " #{recommended_version} or later. \n" + + 'See https://www.ruby-lang.org/en/downloads/branches/ for more' + + " info on the Ruby maintenance schedule.\n" + + 'To suppress this message, set the' + + ' GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS environment variable.' + end + + ## + # Print a warning for a supported but nearing EOL version of Ruby + # @private + # + def self.warn_nonrecommended_ruby cur_version, recommended_version + "WARNING: You are running Ruby #{cur_version}, which is nearing" + + " end-of-life.\n" + + 'Signet works best on supported versions of' + + " Ruby. Consider upgrading to Ruby #{recommended_version} or later.\n" + + 'See https://www.ruby-lang.org/en/downloads/branches/ for more' + + " info on the Ruby maintenance schedule.\n" + + 'To suppress this message, set the' + + ' GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS environment variable.' + end end end end diff --git a/signet.gemspec b/signet.gemspec index dc8c98a..2139322 100644 --- a/signet.gemspec +++ b/signet.gemspec @@ -35,4 +35,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'launchy', '~> 2.4' s.add_development_dependency 'kramdown', '~> 1.5' s.add_development_dependency 'simplecov', '~> 0.9' + + s.post_install_message = Signet::VERSION::warn_on_old_ruby_version end