Skip to content

Fix: update google-style to 1.31, fix linting issues #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ source "https://rubygems.org"
gemspec

gem "base64"
gem "google-style", "~> 1.30.1"
gem "google-style", "~> 1.31.0"
gem "minitest", "~> 5.16"
gem "minitest-focus", "~> 1.2"
gem "minitest-rg", "~> 5.2"
Expand Down
2 changes: 1 addition & 1 deletion functions_framework.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ version = ::FunctionsFramework::VERSION
spec.bindir = "bin"
spec.executables = ["functions-framework", "functions-framework-ruby"]

spec.required_ruby_version = ">= 3.0.0"
spec.required_ruby_version = ">= 3.1.0"
spec.add_dependency "cloud_events", ">= 0.7.0", "< 2.a"
spec.add_dependency "puma", ">= 4.3.0", "< 7.a"
spec.add_dependency "rack", ">= 2.1", "< 4.a"
Expand Down
30 changes: 13 additions & 17 deletions lib/functions_framework.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,10 @@ class << self
# end
#
# @param name [String] The function name. Defaults to {DEFAULT_TARGET}.
# @param block [Proc] The function code as a proc.
# @return [self]
#
def http name = DEFAULT_TARGET, &block
global_registry.add_http name, &block
def http(name = DEFAULT_TARGET, &)
global_registry.add_http(name, &)
self
end

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

Expand All @@ -187,16 +185,15 @@ def typed name = DEFAULT_TARGET, request_class: nil, &block
# end
#
# @param name [String] The function name. Defaults to {DEFAULT_TARGET}.
# @param block [Proc] The function code as a proc.
# @return [self]
#
def cloud_event name = DEFAULT_TARGET, &block
global_registry.add_cloud_event name, &block
def cloud_event(name = DEFAULT_TARGET, &)
global_registry.add_cloud_event(name, &)
self
end

##
# Define a server startup task. This is useful for initializing shared
# Define a server startup task as a block. This is useful for initializing shared
# resources that should be accessible across all function invocations in
# this Ruby VM.
#
Expand All @@ -208,11 +205,10 @@ def cloud_event name = DEFAULT_TARGET, &block
# Startup tasks are passed the {FunctionsFramework::Function} identifying
# the function to execute, and have no return value.
#
# @param block [Proc] The startup task
# @return [self]
#
def on_startup &block
global_registry.add_startup_task(&block)
def on_startup(&)
global_registry.add_startup_task(&)
self
end

Expand All @@ -227,7 +223,7 @@ def on_startup &block
# manipulated to configure the server.
# @return [FunctionsFramework::Server]
#
def start target, &block
def start(target, &)
require "functions_framework/server"
if target.is_a? ::FunctionsFramework::Function
function = target
Expand All @@ -236,7 +232,7 @@ def start target, &block
raise ::ArgumentError, "Undefined function: #{target.inspect}" if function.nil?
end
globals = function.populate_globals
server = Server.new function, globals, &block
server = Server.new(function, globals, &)
global_registry.startup_tasks.each do |task|
task.call function, globals: globals, logger: server.config.logger
end
Expand All @@ -255,8 +251,8 @@ def start target, &block
# manipulated to configure the server.
# @return [self]
#
def run target, &block
server = start target, &block
def run(target, &)
server = start(target, &)
server.wait_until_stopped
self
end
Expand Down
4 changes: 4 additions & 0 deletions lib/functions_framework/legacy_event_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def convert_data context, data
%r{^providers/google\.firebase\.analytics/} => "firebase.googleapis.com",
%r{^providers/google\.firebase\.database/} => "firebasedatabase.googleapis.com"
}.freeze
private_constant :LEGACY_TYPE_TO_SERVICE

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

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

# Map Firebase Auth legacy event metadata field names to their equivalent CloudEvent field names.
FIREBASE_AUTH_METADATA_LEGACY_TO_CE = {
"createdAt" => "createTime",
"lastSignedInAt" => "lastSignInTime"
}.freeze
private_constant :FIREBASE_AUTH_METADATA_LEGACY_TO_CE
end
end
4 changes: 2 additions & 2 deletions lib/functions_framework/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ module Testing
#
# @param path [String] File path to load
#
def load_temporary path, &block
def load_temporary(path, &)
path = ::File.expand_path path
Testing.load_for_testing path, &block
Testing.load_for_testing(path, &)
end

##
Expand Down
Loading