Class: RailsTracepointStack::Filter::GemPath

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_tracepoint_stack/filter/gem_path.rb

Class Method Summary collapse

Class Method Details

.bundled_gem_pathsObject



13
14
15
16
17
18
19
# File 'lib/rails_tracepoint_stack/filter/gem_path.rb', line 13

def self.bundled_gem_paths
  return nil unless defined?(::Bundler)

  ::Bundler.load.specs.map(&:full_gem_path)
rescue
  nil
end

.full_gem_pathObject

Bundler gives the tightest answer, but it is not always there: a plain ruby -e or an irb session against an installed gem has no bundle, and asking Bundler then raises instead of filtering. Falling back to every installed gem is wider than needed and still filters out the code the developer did not write.



9
10
11
# File 'lib/rails_tracepoint_stack/filter/gem_path.rb', line 9

def self.full_gem_path
  @full_gem_path ||= bundled_gem_paths || gem_install_roots
end

.gem_install_rootsObject

Without a bundle there is no resolved list to ask for, but everything installed lives under these roots, which is all the filter needs.



23
24
25
# File 'lib/rails_tracepoint_stack/filter/gem_path.rb', line 23

def self.gem_install_roots
  Gem.path.map { |dir| File.join(dir, "gems") }
end