Skip to content

Commit

Permalink
Merge pull request #32 from telebugs/middleware-to-base-middleware
Browse files Browse the repository at this point in the history
Telebugs::Middleware -> Telebugs::BaseMiddleware
  • Loading branch information
kyrylo authored Jul 31, 2024
2 parents 7e5717e + f25e731 commit 48e851d
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/telebugs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/telebugs/middleware/gem_root_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/telebugs/middleware/ignore_environments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/telebugs/middleware/root_directory_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/test_middleware.rb → test/test_base_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class TestIgnoreMiddleware < Telebugs::Middleware
class TestIgnoreMiddleware < Telebugs::BaseMiddleware
def call(report)
report.ignored = true
end
Expand Down

0 comments on commit 48e851d

Please sign in to comment.