Class: RubyJard::PathFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_jard/path_filter.rb

Overview

Check whether a particular path should be passed when debugging. Filtering is based on path classification (from PathClassifier), program’s current filter mode, and filter included, excluded.

Constant Summary collapse

FILTERS =
[
  FILTER_SOURCE_TREE = :source_tree,
  FILTER_APPLICATION = :application,
  FILTER_GEMS = :gems,
  FILTER_EVERYTHING = :everything
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config: nil, path_classifier: nil) ⇒ PathFilter

Returns a new instance of PathFilter.



15
16
17
18
# File 'lib/ruby_jard/path_filter.rb', line 15

def initialize(config: nil, path_classifier: nil)
  @config = config || RubyJard.config
  @path_classifier = path_classifier || RubyJard::PathClassifier.new
end

Instance Method Details

#match?(path) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ruby_jard/path_filter.rb', line 20

def match?(path)
  case @config.filter
  when FILTER_EVERYTHING
    match_everything?(path)
  when FILTER_GEMS
    match_gems?(path)
  when FILTER_APPLICATION
    match_application?(path)
  when FILTER_SOURCE_TREE
    match_source_tree?(path)
  end
end