123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Core::BacktraceFormatter Private

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: rspec-core/lib/rspec/core/backtrace_formatter.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#exclusion_patterns (rw)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 6

attr_accessor :exclusion_patterns, :inclusion_patterns

#full_backtrace=(value) (rw)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 22

attr_writer :full_backtrace

#full_backtrace?Boolean (rw)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 24

def full_backtrace?
  @full_backtrace || exclusion_patterns.empty?
end

#inclusion_patterns (rw)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 6

attr_accessor :exclusion_patterns, :inclusion_patterns

Instance Method Details

#backtrace_line(line)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 49

def backtrace_line(line)
  Metadata.relative_path(line) unless exclude?(line)
end

#exclude?(line) ⇒ Boolean

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 53

def exclude?(line)
  return false if @full_backtrace
  matches?(exclusion_patterns, line) && !matches?(inclusion_patterns, line)
end

#filter_gem(gem_name)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 28

def filter_gem(gem_name)
  sep = File::SEPARATOR
  exclusion_patterns << /#{sep}#{gem_name}(-[^#{sep}]+)?#{sep}/
end

#format_backtrace(backtrace, options = {})

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 33

def format_backtrace(backtrace, options={})
  return [] unless backtrace
  return backtrace if options[:full_backtrace] || backtrace.empty?

  backtrace.map { |l| backtrace_line(l) }.compact.
    tap do |filtered|
      if filtered.empty?
        filtered.concat backtrace
        filtered << ""
        filtered << "  Showing full backtrace because every line was filtered out."
        filtered << "  See docs for RSpec::Configuration#backtrace_exclusion_patterns and"
        filtered << "  RSpec::Configuration#backtrace_inclusion_patterns for more information."
      end
    end
end

#matches?(patterns, line) ⇒ Boolean (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 60

def matches?(patterns, line)
  patterns.any? { |p| line =~ p }
end