Class: SpecGuard::RSpec::AnnotationLookup::Index

Inherits:
Struct
  • Object
show all
Defined in:
lib/specguard/rspec/annotation_lookup.rb

Overview

One file's annotations, split by who is allowed to claim them.

own          every annotation, by the line it was written on
inheritable  only those in the comment form, by that same line

A line's own annotation always wins: the trailing form is written on the example, so when a file somehow carries both it is the more specific of the two, and a malformed trailing annotation is not quietly backfilled from the comment above it — that would attach an intent its author had already stopped meaning.

line - 1 is 0 for an example on line 1, and #build_index is what guarantees that reads back as "no annotation": line 0 is never a key, because the only Finding produced there is the KIND_READ sentinel.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inheritableObject

Returns the value of attribute inheritable

Returns:

  • (Object)

    the current value of inheritable



129
130
131
# File 'lib/specguard/rspec/annotation_lookup.rb', line 129

def inheritable
  @inheritable
end

#ownObject

Returns the value of attribute own

Returns:

  • (Object)

    the current value of own



129
130
131
# File 'lib/specguard/rspec/annotation_lookup.rb', line 129

def own
  @own
end

Instance Method Details

#finding_for(line) ⇒ Finding?

Returns:



131
132
133
# File 'lib/specguard/rspec/annotation_lookup.rb', line 131

def finding_for(line)
  own[line] || inheritable[line - 1]
end