diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 8111d46..a74c597 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rails-version: ['5.2.5', '6.0.3.6', '6.1.3.1', '7.0.5', 'main'] + rails-version: ['5.2.8.1', '6.0.3.7', '6.1.7.6', '7.0.8', '7.1.2', 'main'] ruby-version: ['2.7', '3.0', '3.1', '3.2'] exclude: - rails-version: '5.2.5' diff --git a/CHANGELOG.md b/CHANGELOG.md index f67038c..0b2d775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ * Added Ruby 3.0, 3.1, 3.2 to the test matrix. -* Added Rails 6.1.x and 7.0.x to the build matrix. +* Added Rails 6.1.x, 7.0.x, 7.1.x to the build matrix. * Dropped support for Rails 4. Going forward we're targetting Rails 5.x (and 6.x). Rails 5 deprecates a few configuration options that we need access to. If you still need support for Rails 4.x, version 1.2.2 of route_downcaser should work just fine. diff --git a/README.rdoc b/README.rdoc index 9692cb8..c797579 100644 --- a/README.rdoc +++ b/README.rdoc @@ -6,7 +6,7 @@ This gem hooks into the Rack middleware of Rails. This way all paths are downcas == Requirements -This gem is tested with 5.2.x, 6.0.x, 6.1.x. It reportedly also works with Sinatra, although I do not use Sinatra myself. Sinatra test-cases will be most welcome. +This gem is tested with 5.2.x, 6.0.x, 6.1.x., 7.x. It reportedly also works with Sinatra, although I do not use Sinatra myself. Sinatra test-cases will be most welcome. It has previously worked - and I presume still works - in Rails 5.0.x and 5.1.x. diff --git a/test.rb b/test.rb new file mode 100644 index 0000000..792f384 --- /dev/null +++ b/test.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true + +gem "activesupport" +# require 'active_support/all' +require "route_downcaser" +require "route_downcaser/downcase_route_middleware" +require "route_downcaser/original_downcase_route_middleware" + +require "benchmark" + +class FakeApp + def call(env) + end +end + +ITERATIONS = 1_000_000 + +app = FakeApp.new +original_downcaser = RouteDowncaser::OriginalDowncaseRouteMiddleware.new(app) +optimized_downcaser = RouteDowncaser::DowncaseRouteMiddleware.new(app) + +Benchmark.bmbm do |bm| + # bm.report("Original with small env") do + # ITERATIONS.times do + # env = { + # "PATH_INFO" => "/Here/Or/There", + # "REQUEST_URI" => "/Here/Or/There", + # "REQUEST_METHOD" => "GET", + # } + # original_downcaser.call(env) + # end + # end + bm.report("Original") do + ITERATIONS.times do + env = { + "PATH_INFO" => "/Here/Or/There", + "REQUEST_URI" => "/Here/Or/There", + "REQUEST_METHOD" => "GET", + "GATEWAY_INTERFACE" => "GATEWAY_INTERFACE", + "HTTP_ACCEPT" => "HTTP_ACCEPT", + "HTTP_ACCEPT_CHARSET" => "HTTP_ACCEPT_CHARSET", + "HTTP_ACCEPT_ENCODING" => "HTTP_ACCEPT_ENCODING", + "HTTP_ACCEPT_LANGUAGE" => "HTTP_ACCEPT_LANGUAGE", + "HTTP_CACHE_CONTROL" => "HTTP_CACHE_CONTROL", + "HTTP_CONNECTION" => "HTTP_CONNECTION", + "HTTP_COOKIE" => "HTTP_COOKIE", + "HTTP_HOST" => "HTTP_HOST", + "HTTP_KEEP_ALIVE" => "HTTP_KEEP_ALIVE", + "HTTP_REFERER" => "HTTP_REFERER", + "HTTP_USER_AGENT" => "HTTP_USER_AGENT", + "QUERY_STRING" => "QUERY_STRING", + "REMOTE_ADDR" => "REMOTE_ADDR", + "REMOTE_HOST" => "REMOTE_HOST", + "REMOTE_USER" => "REMOTE_USER", + "SERVER_NAME" => "SERVER_NAME", + "SERVER_PORT" => "SERVER_PORT", + "SERVER_PROTOCOL" => "SERVER_PROTOCOL", + "SERVER_SOFTWARE" => "SERVER_SOFTWARE" + } + original_downcaser.call(env) + end + end + # bm.report("Optimized with small env") do + # ITERATIONS.times do + # env = { + # "PATH_INFO" => "/Here/Or/There", + # "REQUEST_URI" => "/Here/Or/There", + # "REQUEST_METHOD" => "GET", + # } + # optimized_downcaser.call(env) + # end + # end + bm.report("Optimized") do + ITERATIONS.times do + env = { + "PATH_INFO" => "/Here/Or/There", + "REQUEST_URI" => "/Here/Or/There", + "REQUEST_METHOD" => "GET", + "GATEWAY_INTERFACE" => "GATEWAY_INTERFACE", + "HTTP_ACCEPT" => "HTTP_ACCEPT", + "HTTP_ACCEPT_CHARSET" => "HTTP_ACCEPT_CHARSET", + "HTTP_ACCEPT_ENCODING" => "HTTP_ACCEPT_ENCODING", + "HTTP_ACCEPT_LANGUAGE" => "HTTP_ACCEPT_LANGUAGE", + "HTTP_CACHE_CONTROL" => "HTTP_CACHE_CONTROL", + "HTTP_CONNECTION" => "HTTP_CONNECTION", + "HTTP_COOKIE" => "HTTP_COOKIE", + "HTTP_HOST" => "HTTP_HOST", + "HTTP_KEEP_ALIVE" => "HTTP_KEEP_ALIVE", + "HTTP_REFERER" => "HTTP_REFERER", + "HTTP_USER_AGENT" => "HTTP_USER_AGENT", + "QUERY_STRING" => "QUERY_STRING", + "REMOTE_ADDR" => "REMOTE_ADDR", + "REMOTE_HOST" => "REMOTE_HOST", + "REMOTE_USER" => "REMOTE_USER", + "SERVER_NAME" => "SERVER_NAME", + "SERVER_PORT" => "SERVER_PORT", + "SERVER_PROTOCOL" => "SERVER_PROTOCOL", + "SERVER_SOFTWARE" => "SERVER_SOFTWARE" + } + optimized_downcaser.call(env) + end + end +end