Skip to content

Commit f1fd5e0

Browse files
authored
chore: Add support for Ruby 4.0 via unbundled gems (#1693)
chore: Rubocop fixes for google-style v1.32.0
1 parent d4e526d commit f1fd5e0

15 files changed

Lines changed: 35 additions & 38 deletions

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
source "https://rubygems.org"
1616

1717
group :development, :test do
18-
gem "google-style", "~> 1.26.1"
18+
gem "benchmark", "~> 0.4"
19+
gem "google-style", "~> 1.32.0"
1920
gem "minitest", "~> 5.16"
2021
gem "minitest-focus", "~> 1.1"
2122
gem "minitest-junit"
23+
gem "ostruct", "~> 0.6.3"
2224
gem "rake", "~> 13.0"
25+
gem "tsort", "~> 0.2.0"
2326
end

eventarc/generic/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ source "https://rubygems.org"
33
gem "sinatra", "~>3.1"
44

55
group :test do
6+
gem "ostruct"
67
gem "rack-test"
78
gem "rest-client"
89
gem "rspec"

eventarc/generic/app.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030

3131
puts "\nHEADERS:"
3232
headers = request.env.select { |k, _v| k.start_with? "HTTP_" }
33-
.collect { |key, val| [key.sub(/^HTTP_/, ""), val] }
34-
.collect { |key, val| "#{key}: #{val}" }
35-
.sort
33+
.collect { |key, val| [key.sub(/^HTTP_/, ""), val] }
34+
.collect { |key, val| "#{key}: #{val}" }
35+
.sort
3636
headers.each do |key, value|
3737
if key != "Authorization"
3838
puts "#{key}: #{value}<br>"

functions/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ source "https://rubygems.org"
1717
gem "functions_framework", "~> 1.4", ">= 1.4.1"
1818

1919
group "test" do
20+
gem "benchmark", "~> 0.4"
21+
gem "cgi", "~> 0.5"
2022
gem "google-apis-kgsearch_v1", "~> 0.13"
2123
gem "google-cloud-bigquery", "~> 1.45"
2224
gem "google-cloud-firestore", "~> 2.13"

functions/helloworld/http/app.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414

1515
# [START functions_helloworld_http]
1616
require "functions_framework"
17-
require "cgi"
17+
require "cgi/escape"
1818
require "json"
1919

2020
FunctionsFramework.http "hello_http" do |request|
2121
# The request parameter is a Rack::Request object.
2222
# See https://www.rubydoc.info/gems/rack/Rack/Request
2323
name = request.params["name"] ||
24-
(request.body.rewind && JSON.parse(request.body.read)["name"] rescue nil) ||
25-
"World"
24+
(request.body.rewind && JSON.parse(request.body.read)["name"]) rescue "World"
2625
# Return the response body as a string.
2726
# You can also return a Rack::Response object, a Rack response array, or
2827
# a hash which will be JSON-encoded into a response.

functions/http/content/app.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
case content_type
2525
# '{"name":"John"}'
2626
when "application/json"
27-
name = (JSON.parse(request.body.read.to_s)["name"] rescue nil)
27+
name = JSON.parse(request.body.read.to_s)["name"] rescue nil
2828
# "John", stored in a Buffer
2929
when "application/octet-stream"
3030
name = request.body.read.to_s # Convert buffer to a string
@@ -33,7 +33,7 @@
3333
name = request.body.read.to_s
3434
# "name=John" in the body of a POST request (not the URL)
3535
when "application/x-www-form-urlencoded"
36-
name = (request.params["name"] rescue nil)
36+
name = request.params["name"] rescue nil
3737
end
3838

3939
name ||= "World"

functions/slack/app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def format_slack_message query, response
9797
{ "title" => name && description ? "#{name}: #{description}" : name,
9898
"title_link" => details.fetch("url", nil),
9999
"text" => details.fetch("articleBody", nil),
100-
"image_url" => result.fetch("image", nil)&.fetch("contentUrl", nil) }
100+
"image_url" => result.dig("image", "contentUrl") }
101101
else
102102
{ "text" => "No results match your query." }
103103
end

media_cdn/dualtoken.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ def base64_encode value
3434
#
3535
# @return [String] the aggregated string
3636
def header_names headers
37-
header_names = []
38-
headers.each do |header|
39-
header_names.append header[:name]
37+
header_names = headers.map do |header|
38+
header[:name]
4039
end
4140
header_names.join ","
4241
end
@@ -49,9 +48,8 @@ def header_names headers
4948
#
5049
# @return [String] the aggregated string
5150
def header_pairs headers
52-
header_pairs = []
53-
headers.each do |header|
54-
header_pairs.append "#{header[:name]}=#{header[:value]}"
51+
header_pairs = headers.map do |header|
52+
"#{header[:name]}=#{header[:value]}"
5553
end
5654
header_pairs.join ","
5755
end
@@ -100,7 +98,6 @@ def sign_token(
10098
headers: nil,
10199
ip_ranges: nil
102100
)
103-
104101
decoded_key = Base64.urlsafe_decode64 base64_key
105102
algo = signature_algorithm.downcase
106103

spanner/database_leader_placement_samples.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def create_database_with_default_leader \
8181

8282
db_admin_client = Google::Cloud::Spanner::Admin::Database.database_admin project_id: project_id
8383

84-
instance_path = \
84+
instance_path =
8585
db_admin_client.instance_path project: project_id, instance: instance_id
8686
statements = [
8787
"CREATE TABLE Singers (

spanner/json_column_type_samples.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
require_relative "./utils"
15+
require_relative "utils"
1616

1717
def add_json_column project_id:, instance_id:, database_id:
1818
# [START spanner_add_json_column]

0 commit comments

Comments
 (0)