From f25e73106ef4254253e30bac653fe87a339ec2c2 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Wed, 31 Jul 2024 09:37:32 +0300 Subject: [PATCH] Telebugs::Middleware -> Telebugs::BaseMiddleware This is instantly recognizable as something that you can inherit from --- lib/telebugs.rb | 2 +- lib/telebugs/{middleware.rb => base_middleware.rb} | 2 +- lib/telebugs/middleware/gem_root_filter.rb | 2 +- lib/telebugs/middleware/ignore_environments.rb | 2 +- lib/telebugs/middleware/root_directory_filter.rb | 2 +- test/{test_middleware.rb => test_base_middleware.rb} | 6 +++--- test/test_config.rb | 2 +- test/test_reporter.rb | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) rename lib/telebugs/{middleware.rb => base_middleware.rb} (94%) rename test/{test_middleware.rb => test_base_middleware.rb} (52%) diff --git a/lib/telebugs.rb b/lib/telebugs.rb index 2360a95..9ed3a6f 100644 --- a/lib/telebugs.rb +++ b/lib/telebugs.rb @@ -15,7 +15,7 @@ require_relative "telebugs/backtrace" require_relative "telebugs/file_cache" require_relative "telebugs/code_hunk" -require_relative "telebugs/middleware" +require_relative "telebugs/base_middleware" require_relative "telebugs/middleware_stack" require_relative "telebugs/truncator" diff --git a/lib/telebugs/middleware.rb b/lib/telebugs/base_middleware.rb similarity index 94% rename from lib/telebugs/middleware.rb rename to lib/telebugs/base_middleware.rb index cc1438a..f904270 100644 --- a/lib/telebugs/middleware.rb +++ b/lib/telebugs/base_middleware.rb @@ -3,7 +3,7 @@ module Telebugs # Represents a middleware that can be used to filter out errors. # You must inherit from this class and implement the #call method. - class Middleware + class BaseMiddleware DEFAULT_WEIGHT = 0 def weight diff --git a/lib/telebugs/middleware/gem_root_filter.rb b/lib/telebugs/middleware/gem_root_filter.rb index c5f3fe9..2cf6191 100644 --- a/lib/telebugs/middleware/gem_root_filter.rb +++ b/lib/telebugs/middleware/gem_root_filter.rb @@ -4,7 +4,7 @@ module Telebugs class Middleware # GemRootFilter is a middleware that filters out the root path of the gems. # It replaces the root path with the gem name and version. - class GemRootFilter < Telebugs::Middleware + class GemRootFilter < Telebugs::BaseMiddleware def initialize @gem_paths = Gem.path.map { |path| /\A#{Regexp.escape(path)}\/gems\// } end diff --git a/lib/telebugs/middleware/ignore_environments.rb b/lib/telebugs/middleware/ignore_environments.rb index 62c1012..2da9cb7 100644 --- a/lib/telebugs/middleware/ignore_environments.rb +++ b/lib/telebugs/middleware/ignore_environments.rb @@ -2,7 +2,7 @@ module Telebugs class Middleware - class IgnoreEnvironments < Telebugs::Middleware + class IgnoreEnvironments < Telebugs::BaseMiddleware def initialize(current_env, ignore_envs) @current_env = current_env @ignore_envs = ignore_envs diff --git a/lib/telebugs/middleware/root_directory_filter.rb b/lib/telebugs/middleware/root_directory_filter.rb index b0cc502..bad918d 100644 --- a/lib/telebugs/middleware/root_directory_filter.rb +++ b/lib/telebugs/middleware/root_directory_filter.rb @@ -3,7 +3,7 @@ module Telebugs class Middleware # Filters out the root directory from the backtrace paths. - class RootDirectoryFilter < Telebugs::Middleware + class RootDirectoryFilter < Telebugs::BaseMiddleware def initialize(root_directory) @root_directory = root_directory end diff --git a/test/test_middleware.rb b/test/test_base_middleware.rb similarity index 52% rename from test/test_middleware.rb rename to test/test_base_middleware.rb index 4617a0f..c437a16 100644 --- a/test/test_middleware.rb +++ b/test/test_base_middleware.rb @@ -2,14 +2,14 @@ require "test_helper" -class TestMiddleware < Minitest::Test +class TestBaseMiddleware < Minitest::Test def test_call assert_raises(NotImplementedError) do - Telebugs::Middleware.new.call(nil) + Telebugs::BaseMiddleware.new.call(nil) end end def test_weight - assert_equal 0, Telebugs::Middleware.new.weight + assert_equal 0, Telebugs::BaseMiddleware.new.weight end end diff --git a/test/test_config.rb b/test/test_config.rb index b5de3f6..839e03f 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -37,7 +37,7 @@ def test_root_directory_overwrite_root_directory_filter_middleware end def test_middleware - middleware_class = Class.new(Telebugs::Middleware) + middleware_class = Class.new(Telebugs::BaseMiddleware) Telebugs.configure do |c| c.middleware.use middleware_class.new diff --git a/test/test_reporter.rb b/test/test_reporter.rb index b55fa96..fdf0037 100644 --- a/test/test_reporter.rb +++ b/test/test_reporter.rb @@ -2,7 +2,7 @@ require "test_helper" -class TestIgnoreMiddleware < Telebugs::Middleware +class TestIgnoreMiddleware < Telebugs::BaseMiddleware def call(report) report.ignored = true end