Class: Route500Check::OnlyPublicBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/route_500_check/only_public_builder.rb

Constant Summary collapse

DEFAULT_EXCLUDE_PREFIXES =
%w[
  /admin
  /api
  /internal
  /rails
  /assets
  /health
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ OnlyPublicBuilder

======================

DSL 用(既存仕様そのまま)



17
18
19
# File 'lib/route_500_check/only_public_builder.rb', line 17

def initialize
  @prefixes = []
end

Class Method Details

.filter(paths, prefixes = nil) ⇒ Object

======================

実行用(Runner から利用)



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/route_500_check/only_public_builder.rb', line 32

def self.filter(paths, prefixes = nil)
  effective_prefixes =
    if prefixes && !prefixes.empty?
      prefixes
    else
      DEFAULT_EXCLUDE_PREFIXES
    end

  paths.reject do |path|
    effective_prefixes.any? { |prefix| path.start_with?(prefix) }
  end
end

Instance Method Details

#exclude_prefix(prefix) ⇒ Object



21
22
23
# File 'lib/route_500_check/only_public_builder.rb', line 21

def exclude_prefix(prefix)
  @prefixes << prefix
end

#prefixes ⇒ Object



25
26
27
# File 'lib/route_500_check/only_public_builder.rb', line 25

def prefixes
  @prefixes
end