From dd0c08c79b93c67a567dae9e2be25cc16cf78174 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 17 Jun 2024 11:46:38 -0300 Subject: [PATCH] Fix Rack version to work across multiple released versions Rack deprecated `Rack.version` and the associated constant `Rack::VERSION` in v3, to be removed in v3.1. We were getting the deprecation warnings on our test suite: ./judoscale-ruby/judoscale-rack/lib/judoscale/rack.rb:14: warning: Rack.version is deprecated and will be removed in Rack 3.1! ./gems/rack-3.0.11/lib/rack/version.rb:25: warning: constant Rack::VERSION is deprecated Running on the latest v3.1 version caused them to break: ./judoscale-ruby/judoscale-rack/lib/judoscale/rack.rb:14:in `': undefined method `version' for module Rack (NoMethodError) framework_version: ::Rack.version ^^^^^^^^ Deprecation: https://github.com/rack/rack/commit/856934f8252d414378e9c17a56573db50c5784a5#diff-75f019921d551ec3df0214212140eeda19369f014b93b77a9c92cfa64ec04c16 Removal: https://github.com/rack/rack/commit/a5762cf60af474b89b555ff8d151be5a021701f8#diff-75f019921d551ec3df0214212140eeda19369f014b93b77a9c92cfa64ec04c16 Reintroducing `Rack::VERSION` constant: (which we don't use -- unreleased as of now) https://github.com/rack/rack/commit/4cfad114a1f3e5e3b657210ebf1252ca9b16ce9d --- judoscale-rack/lib/judoscale/rack.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/judoscale-rack/lib/judoscale/rack.rb b/judoscale-rack/lib/judoscale/rack.rb index f583355a..33f55485 100644 --- a/judoscale-rack/lib/judoscale/rack.rb +++ b/judoscale-rack/lib/judoscale/rack.rb @@ -11,5 +11,6 @@ Judoscale.add_adapter :"judoscale-rack", { adapter_version: Judoscale::VERSION, - framework_version: ::Rack.version + # Rack deprecated `version` in v3, removed in v3.1. + framework_version: ::Rack.respond_to?(:release) ? ::Rack.release : ::Rack.version }, metrics_collector: Judoscale::WebMetricsCollector