Class: SpecGuard::RSpec::AnnotationLookup::Index
- Inherits:
-
Struct
- Object
- Struct
- SpecGuard::RSpec::AnnotationLookup::Index
- 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
The values are the INTENT TO SHIP or nil — the verdict already applied —
rather than a Finding, because the two paths that build this index reach
a verdict by different routes (the local Scanner for the LINES, or the
port's report for the verdicts) and only agree on the answer. Storing the answer is what
keeps #intent_for from having to know which one ran.
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. Hence key? rather than a truthy
test: a line whose own annotation was rejected answers nil, and must not
fall through to the comment above it.
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
-
#inheritable ⇒ Object
Returns the value of attribute inheritable.
-
#own ⇒ Object
Returns the value of attribute own.
Instance Method Summary collapse
Instance Attribute Details
#inheritable ⇒ Object
Returns the value of attribute inheritable
137 138 139 |
# File 'lib/specguard/rspec/annotation_lookup.rb', line 137 def inheritable @inheritable end |
#own ⇒ Object
Returns the value of attribute own
137 138 139 |
# File 'lib/specguard/rspec/annotation_lookup.rb', line 137 def own @own end |
Instance Method Details
#intent_for(line) ⇒ Hash?
139 140 141 142 143 |
# File 'lib/specguard/rspec/annotation_lookup.rb', line 139 def intent_for(line) return own[line] if own.key?(line) inheritable[line - 1] end |