Skip to content

Commit 6fbad2e

Browse files
authored
Document and check for unsupported Ruby versions (googleapis#1988)
1 parent 0eb3766 commit 6fbad2e

31 files changed

Lines changed: 318 additions & 18 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,14 @@ $ gem install google-cloud-video_intelligence
788788

789789
## Supported Ruby Versions
790790

791-
google-cloud-ruby is supported on Ruby 2.0+.
791+
These libraries are currently supported on Ruby 2.0+.
792+
793+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
794+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
795+
official support only for Ruby versions that are considered current and
796+
supported by Ruby Core (that is, Ruby versions that are either in normal
797+
maintenance or in security maintenance).
798+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
792799

793800
## Versioning
794801

gcloud/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ end
3535

3636
This library is supported on Ruby 2.0+.
3737

38+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
39+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
40+
official support only for Ruby versions that are considered current and
41+
supported by Ruby Core (that is, Ruby versions that are either in normal
42+
maintenance or in security maintenance).
43+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
44+
3845
## Versioning
3946

4047
This library follows [Semantic Versioning](http://semver.org/).

google-cloud-bigquery/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ end
5151

5252
This library is supported on Ruby 2.0+.
5353

54+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
55+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
56+
official support only for Ruby versions that are considered current and
57+
supported by Ruby Core (that is, Ruby versions that are either in normal
58+
maintenance or in security maintenance).
59+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
60+
5461
## Versioning
5562

5663
This library follows [Semantic Versioning](http://semver.org/).

google-cloud-bigtable/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ steps:
2020
$ gem install google-cloud-bigtable
2121
```
2222

23+
### Supported Ruby Versions
24+
25+
This library is supported on Ruby 2.0+.
26+
27+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
28+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
29+
official support only for Ruby versions that are considered current and
30+
supported by Ruby Core (that is, Ruby versions that are either in normal
31+
maintenance or in security maintenance).
32+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
33+
2334
### Next Steps
2435
- Read the [Client Library Documentation][] for Cloud Bigtable API
2536
to see other available methods on the client.

google-cloud-container/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ zone = "us-central1-a"
3131
response = cluster_manager_client.list_clusters(project_id_2, zone)
3232
```
3333

34+
### Supported Ruby Versions
35+
36+
This library is supported on Ruby 2.0+.
37+
38+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
39+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
40+
official support only for Ruby versions that are considered current and
41+
supported by Ruby Core (that is, Ruby versions that are either in normal
42+
maintenance or in security maintenance).
43+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
44+
3445
### Next Steps
3546
- Read the [Client Library Documentation][] for Google Container Engine API
3647
to see other available methods on the client.

google-cloud-core/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ This library contains shared types, such as error classes, for the google-cloud
66

77
## Supported Ruby Versions
88

9-
This library is supported on Ruby 2.0+.
9+
This library is currently supported on Ruby 2.0+.
10+
11+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
12+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
13+
official support only for Ruby versions that are considered current and
14+
supported by Ruby Core (that is, Ruby versions that are either in normal
15+
maintenance or in security maintenance).
16+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
1017

1118
## Versioning
1219

google-cloud-core/lib/google/cloud.rb

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,81 @@ def self.configure
9696

9797
@config
9898
end
99+
100+
##
101+
# Initialize toplevel configuration
102+
# @private
103+
#
104+
def self.init_configuration
105+
configure do |config|
106+
default_project = Google::Cloud::Config.deferred do
107+
ENV["GOOGLE_CLOUD_PROJECT"] || ENV["GCLOUD_PROJECT"]
108+
end
109+
default_creds = Google::Cloud::Config.deferred do
110+
Google::Cloud::Config.credentials_from_env \
111+
"GOOGLE_CLOUD_CREDENTIALS", "GOOGLE_CLOUD_CREDENTIALS_JSON",
112+
"GOOGLE_CLOUD_KEYFILE", "GOOGLE_CLOUD_KEYFILE_JSON",
113+
"GCLOUD_KEYFILE", "GCLOUD_KEYFILE_JSON"
114+
end
115+
116+
config.add_field! :project_id, default_project,
117+
match: String, allow_nil: true
118+
config.add_alias! :project, :project_id
119+
config.add_field! :credentials, default_creds, match: Object
120+
config.add_alias! :keyfile, :credentials
121+
end
122+
end
123+
124+
# In June, 2018, set supported version to 2.3 and recommended to 2.4.
125+
# Thereafter, follow the MRI support schedule: supported means non-EOL,
126+
# and recommended means in normal (rather than security) maintenance.
127+
# See https://www.ruby-lang.org/en/downloads/branches/
128+
129+
##
130+
# Minimum "supported" Ruby version (non-EOL)
131+
# @private
132+
#
133+
SUPPORTED_VERSION_THRESHOLD = "2.0".freeze
134+
135+
##
136+
# Minimum "recommended" Ruby version (normal maintenance)
137+
# @private
138+
#
139+
RECOMMENDED_VERSION_THRESHOLD = "2.3".freeze
140+
141+
##
142+
# Check Ruby version and emit a warning if it is old
143+
# @private
144+
#
145+
def self.warn_on_old_ruby_version \
146+
supported_version: SUPPORTED_VERSION_THRESHOLD,
147+
recommended_version: RECOMMENDED_VERSION_THRESHOLD
148+
cur_version = Gem::Version.new RUBY_VERSION
149+
if cur_version < Gem::Version.new(supported_version)
150+
warn "WARNING: You are running Ruby #{cur_version}, which has reached" \
151+
" end-of-life and is no longer supported by Ruby Core."
152+
warn "It is strongly recommended that you upgrade to Ruby" \
153+
" #{recommended_version} or later."
154+
warn "See https://www.ruby-lang.org/en/downloads/branches/ for more" \
155+
" info on the Ruby maintenance schedule."
156+
elsif cur_version < Gem::Version.new(recommended_version)
157+
warn "WARNING: You are running Ruby #{cur_version}, which is nearing" \
158+
" end-of-life."
159+
warn "Consider upgrading to Ruby #{recommended_version} or later."
160+
warn "See https://www.ruby-lang.org/en/downloads/branches/ for more" \
161+
" info on the Ruby maintenance schedule."
162+
end
163+
rescue ArgumentError
164+
warn "Unable to determine current Ruby version."
165+
end
99166
end
100167
end
101168

102169
# Set the default top-level configuration
103-
Google::Cloud.configure do |config|
104-
default_project = Google::Cloud::Config.deferred do
105-
ENV["GOOGLE_CLOUD_PROJECT"] || ENV["GCLOUD_PROJECT"]
106-
end
107-
default_creds = Google::Cloud::Config.deferred do
108-
Google::Cloud::Config.credentials_from_env \
109-
"GOOGLE_CLOUD_CREDENTIALS", "GOOGLE_CLOUD_CREDENTIALS_JSON",
110-
"GOOGLE_CLOUD_KEYFILE", "GOOGLE_CLOUD_KEYFILE_JSON",
111-
"GCLOUD_KEYFILE", "GCLOUD_KEYFILE_JSON"
112-
end
170+
Google::Cloud.init_configuration
113171

114-
config.add_field! :project_id, default_project, match: String, allow_nil: true
115-
config.add_alias! :project, :project_id
116-
config.add_field! :credentials, default_creds, match: Object
117-
config.add_alias! :keyfile, :credentials
118-
end
172+
# Emit a warning if current Ruby is at or nearing end-of-life
173+
Google::Cloud.warn_on_old_ruby_version
119174

120175
# Auto-load all Google Cloud service gems.
121176
Gem.find_files("google-cloud-*.rb").each do |google_cloud_service|

google-cloud-dataproc/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ cluster_controller_client.list_clusters(project_id_2, region).each_page do |page
4242
end
4343
```
4444

45+
### Supported Ruby Versions
46+
47+
This library is supported on Ruby 2.0+.
48+
49+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
50+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
51+
official support only for Ruby versions that are considered current and
52+
supported by Ruby Core (that is, Ruby versions that are either in normal
53+
maintenance or in security maintenance).
54+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
55+
4556
### Next Steps
4657
- Read the [Client Library Documentation][] for Google Cloud Dataproc API
4758
to see other available methods on the client.

google-cloud-datastore/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ tasks = datastore.run query
5151

5252
This library is supported on Ruby 2.0+.
5353

54+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
55+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
56+
official support only for Ruby versions that are considered current and
57+
supported by Ruby Core (that is, Ruby versions that are either in normal
58+
maintenance or in security maintenance).
59+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
60+
5461
## Versioning
5562

5663
This library follows [Semantic Versioning](http://semver.org/).

google-cloud-debugger/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ for a list of possible configuration options.
226226

227227
This library is supported on Ruby 2.2 or later.
228228

229+
However, Ruby 2.3 or later is strongly recommended, as earlier releases have
230+
reached or are nearing end-of-life. After June 1, 2018, Google will provide
231+
official support only for Ruby versions that are considered current and
232+
supported by Ruby Core (that is, Ruby versions that are either in normal
233+
maintenance or in security maintenance).
234+
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
235+
229236
This library follows [Semantic Versioning](http://semver.org/). It is currently
230237
in major version zero (0.y.z), which means that anything may change at any time
231238
and the public API should not be considered stable.

0 commit comments

Comments
 (0)