Skip to content

Commit bbd11d8

Browse files
authored
Fix: update google-style to 1.31, fix linting issues (#224)
* Fix: update google-style to 1.31, fix linting issues * remove doc comments for removed &block parameters
1 parent 5a42d1e commit bbd11d8

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ source "https://rubygems.org"
1717
gemspec
1818

1919
gem "base64"
20-
gem "google-style", "~> 1.30.1"
20+
gem "google-style", "~> 1.31.0"
2121
gem "minitest", "~> 5.16"
2222
gem "minitest-focus", "~> 1.2"
2323
gem "minitest-rg", "~> 5.2"

functions_framework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ version = ::FunctionsFramework::VERSION
4444
spec.bindir = "bin"
4545
spec.executables = ["functions-framework", "functions-framework-ruby"]
4646

47-
spec.required_ruby_version = ">= 3.0.0"
47+
spec.required_ruby_version = ">= 3.1.0"
4848
spec.add_dependency "cloud_events", ">= 0.7.0", "< 2.a"
4949
spec.add_dependency "puma", ">= 4.3.0", "< 7.a"
5050
spec.add_dependency "rack", ">= 2.1", "< 4.a"

lib/functions_framework.rb

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,10 @@ class << self
134134
# end
135135
#
136136
# @param name [String] The function name. Defaults to {DEFAULT_TARGET}.
137-
# @param block [Proc] The function code as a proc.
138137
# @return [self]
139138
#
140-
def http name = DEFAULT_TARGET, &block
141-
global_registry.add_http name, &block
139+
def http(name = DEFAULT_TARGET, &)
140+
global_registry.add_http(name, &)
142141
self
143142
end
144143

@@ -164,11 +163,10 @@ def http name = DEFAULT_TARGET, &block
164163
# @param name [String] The function name. Defaults to {DEFAULT_TARGET}
165164
# @param request_class [#decode_json] An optional class which will be used to
166165
# decode the request if it implements a `decode_json` static method.
167-
# @param block [Proc] The function code as a proc @return [self]
168166
# @return [self]
169167
#
170-
def typed name = DEFAULT_TARGET, request_class: nil, &block
171-
global_registry.add_typed name, request_class: request_class, &block
168+
def typed(name = DEFAULT_TARGET, request_class: nil, &)
169+
global_registry.add_typed(name, request_class: request_class, &)
172170
self
173171
end
174172

@@ -187,16 +185,15 @@ def typed name = DEFAULT_TARGET, request_class: nil, &block
187185
# end
188186
#
189187
# @param name [String] The function name. Defaults to {DEFAULT_TARGET}.
190-
# @param block [Proc] The function code as a proc.
191188
# @return [self]
192189
#
193-
def cloud_event name = DEFAULT_TARGET, &block
194-
global_registry.add_cloud_event name, &block
190+
def cloud_event(name = DEFAULT_TARGET, &)
191+
global_registry.add_cloud_event(name, &)
195192
self
196193
end
197194

198195
##
199-
# Define a server startup task. This is useful for initializing shared
196+
# Define a server startup task as a block. This is useful for initializing shared
200197
# resources that should be accessible across all function invocations in
201198
# this Ruby VM.
202199
#
@@ -208,11 +205,10 @@ def cloud_event name = DEFAULT_TARGET, &block
208205
# Startup tasks are passed the {FunctionsFramework::Function} identifying
209206
# the function to execute, and have no return value.
210207
#
211-
# @param block [Proc] The startup task
212208
# @return [self]
213209
#
214-
def on_startup &block
215-
global_registry.add_startup_task(&block)
210+
def on_startup(&)
211+
global_registry.add_startup_task(&)
216212
self
217213
end
218214

@@ -227,7 +223,7 @@ def on_startup &block
227223
# manipulated to configure the server.
228224
# @return [FunctionsFramework::Server]
229225
#
230-
def start target, &block
226+
def start(target, &)
231227
require "functions_framework/server"
232228
if target.is_a? ::FunctionsFramework::Function
233229
function = target
@@ -236,7 +232,7 @@ def start target, &block
236232
raise ::ArgumentError, "Undefined function: #{target.inspect}" if function.nil?
237233
end
238234
globals = function.populate_globals
239-
server = Server.new function, globals, &block
235+
server = Server.new(function, globals, &)
240236
global_registry.startup_tasks.each do |task|
241237
task.call function, globals: globals, logger: server.config.logger
242238
end
@@ -255,8 +251,8 @@ def start target, &block
255251
# manipulated to configure the server.
256252
# @return [self]
257253
#
258-
def run target, &block
259-
server = start target, &block
254+
def run(target, &)
255+
server = start(target, &)
260256
server.wait_until_stopped
261257
self
262258
end

lib/functions_framework/legacy_event_converter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def convert_data context, data
185185
%r{^providers/google\.firebase\.analytics/} => "firebase.googleapis.com",
186186
%r{^providers/google\.firebase\.database/} => "firebasedatabase.googleapis.com"
187187
}.freeze
188+
private_constant :LEGACY_TYPE_TO_SERVICE
188189

189190
LEGACY_TYPE_TO_CE_TYPE = {
190191
"google.pubsub.topic.publish" => "google.cloud.pubsub.topic.v1.messagePublished",
@@ -206,18 +207,21 @@ def convert_data context, data
206207
"providers/google.firebase.database/eventTypes/ref.delete" => "google.firebase.database.ref.v1.deleted",
207208
"providers/cloud.storage/eventTypes/object.change" => "google.cloud.storage.object.v1.finalized"
208209
}.freeze
210+
private_constant :LEGACY_TYPE_TO_CE_TYPE
209211

210212
CE_SERVICE_TO_RESOURCE_RE = {
211213
"firebase.googleapis.com" => %r{^(projects/[^/]+)/(events/[^/]+)$},
212214
"firebasedatabase.googleapis.com" => %r{^projects/_/(instances/[^/]+)/(refs/.+)$},
213215
"firestore.googleapis.com" => %r{^(projects/[^/]+/databases/\(default\))/(documents/.+)$},
214216
"storage.googleapis.com" => %r{^(projects/[^/]+/buckets/[^/]+)/([^#]+)(?:#.*)?$}
215217
}.freeze
218+
private_constant :CE_SERVICE_TO_RESOURCE_RE
216219

217220
# Map Firebase Auth legacy event metadata field names to their equivalent CloudEvent field names.
218221
FIREBASE_AUTH_METADATA_LEGACY_TO_CE = {
219222
"createdAt" => "createTime",
220223
"lastSignedInAt" => "lastSignInTime"
221224
}.freeze
225+
private_constant :FIREBASE_AUTH_METADATA_LEGACY_TO_CE
222226
end
223227
end

lib/functions_framework/testing.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ module Testing
7070
#
7171
# @param path [String] File path to load
7272
#
73-
def load_temporary path, &block
73+
def load_temporary(path, &)
7474
path = ::File.expand_path path
75-
Testing.load_for_testing path, &block
75+
Testing.load_for_testing(path, &)
7676
end
7777

7878
##

0 commit comments

Comments
 (0)