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
- .new ⇒ BacktraceFormatter constructor Internal use only
Instance Attribute Summary
- #exclusion_patterns rw Internal use only
- #full_backtrace=(value) rw Internal use only
- #full_backtrace? ⇒ Boolean rw Internal use only
- #inclusion_patterns rw Internal use only
Instance Method Summary
- #backtrace_line(line) Internal use only
- #exclude?(line) ⇒ Boolean Internal use only
- #filter_gem(gem_name) Internal use only
- #format_backtrace(backtrace, options = {}) Internal use only
- #matches?(patterns, line) ⇒ Boolean private Internal use only
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)
# 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
# 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, ={}) return [] unless backtrace return backtrace if [: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)
# File 'rspec-core/lib/rspec/core/backtrace_formatter.rb', line 60
def matches?(patterns, line) patterns.any? { |p| line =~ p } end