Class: RSpec::Signal::Backtrace::Reduced

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/signal/backtrace/reducer.rb

Overview

The result of reducing one backtrace.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entries:, total:, omitted:, fallback: false) ⇒ Reduced

Returns a new instance of Reduced.



35
36
37
38
39
40
# File 'lib/rspec/signal/backtrace/reducer.rb', line 35

def initialize(entries:, total:, omitted:, fallback: false)
  @entries  = entries
  @total    = total
  @omitted  = omitted
  @fallback = fallback
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



33
34
35
# File 'lib/rspec/signal/backtrace/reducer.rb', line 33

def entries
  @entries
end

#fallbackObject (readonly)

Returns the value of attribute fallback.



33
34
35
# File 'lib/rspec/signal/backtrace/reducer.rb', line 33

def fallback
  @fallback
end

#omittedObject (readonly)

Returns the value of attribute omitted.



33
34
35
# File 'lib/rspec/signal/backtrace/reducer.rb', line 33

def omitted
  @omitted
end

#totalObject (readonly)

Returns the value of attribute total.



33
34
35
# File 'lib/rspec/signal/backtrace/reducer.rb', line 33

def total
  @total
end

Instance Method Details

#culpritObject

The frame that best identifies where this blew up: the innermost frame that is not test-runner plumbing.



68
69
70
# File 'lib/rspec/signal/backtrace/reducer.rb', line 68

def culprit
  frames.first
end

#empty?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/rspec/signal/backtrace/reducer.rb', line 58

def empty?
  frames.empty?
end

#fallback?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/rspec/signal/backtrace/reducer.rb', line 54

def fallback?
  @fallback
end

#framesObject



42
43
44
# File 'lib/rspec/signal/backtrace/reducer.rb', line 42

def frames
  entries.select(&:frame?)
end

#kept_countObject



50
51
52
# File 'lib/rspec/signal/backtrace/reducer.rb', line 50

def kept_count
  frames.size
end

#omitted_countObject



62
63
64
# File 'lib/rspec/signal/backtrace/reducer.rb', line 62

def omitted_count
  omitted.values.sum
end

#primary_locationObject

The innermost first-party frame — what the agent should open first.



73
74
75
# File 'lib/rspec/signal/backtrace/reducer.rb', line 73

def primary_location
  project_frames.first
end

#project_framesObject



46
47
48
# File 'lib/rspec/signal/backtrace/reducer.rb', line 46

def project_frames
  frames.select(&:project?)
end

#to_aObject



77
78
79
# File 'lib/rspec/signal/backtrace/reducer.rb', line 77

def to_a
  entries.map(&:to_s)
end