Class: TraceViz::Collectors::Filters::IncludeGemsFilter

Inherits:
BaseFilter
  • Object
show all
Defined in:
lib/trace_viz/collectors/filters/include_gems_filter.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  app_running: true,
  gems: [],
}.freeze

Instance Method Summary collapse

Methods included from Helpers::ConfigHelper

#config, #fetch_general_config

Constructor Details

#initialize(**options) ⇒ IncludeGemsFilter

Returns a new instance of IncludeGemsFilter.



14
15
16
17
18
19
20
21
22
# File 'lib/trace_viz/collectors/filters/include_gems_filter.rb', line 14

def initialize(**options)
  super()
  @include_app = options.fetch(:app_running, DEFAULT_OPTIONS[:app_running])
  @app_path = options[:app_path] || detect_app_path
  @app_path.freeze
  @included_gems = options.fetch(:gems, DEFAULT_OPTIONS[:gems]).map do |gem_name|
    ::Gem.loaded_specs[gem_name]&.full_gem_path
  end.compact.freeze
end

Instance Method Details

#apply?(trace_data) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/trace_viz/collectors/filters/include_gems_filter.rb', line 24

def apply?(trace_data)
  app_path_included?(trace_data.path) || included_gem?(trace_data.path)
end