Class: CovLoupe::Presenters::BaseCoveragePresenter

Inherits:
Object
  • Object
show all
Includes:
PayloadCaching
Defined in:
lib/cov_loupe/presenters/base_coverage_presenter.rb

Overview

Shared presenter behavior for single-file coverage payloads.

Subclasses must implement #build_payload, which calls a CoverageModel method (e.g., :summary_for, :raw_for) for the given file path. The base class enriches the payload with staleness status from model.staleness_for.

Direct Known Subclasses

CoveragePayloadPresenter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PayloadCaching

#absolute_payload, #relativized_payload

Constructor Details

#initialize(model:, path:) ⇒ BaseCoveragePresenter

Returns a new instance of BaseCoveragePresenter.



17
18
19
20
# File 'lib/cov_loupe/presenters/base_coverage_presenter.rb', line 17

def initialize(model:, path:)
  @model = model
  @path = path
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



15
16
17
# File 'lib/cov_loupe/presenters/base_coverage_presenter.rb', line 15

def model
  @model
end

#pathObject (readonly)

Returns the value of attribute path.



15
16
17
# File 'lib/cov_loupe/presenters/base_coverage_presenter.rb', line 15

def path
  @path
end

Instance Method Details

#relative_pathObject

Returns the relativized file path used in CLI output.



28
29
30
# File 'lib/cov_loupe/presenters/base_coverage_presenter.rb', line 28

def relative_path
  relativized_payload['file']
end

#staleObject

Returns the cached stale status for the file.



23
24
25
# File 'lib/cov_loupe/presenters/base_coverage_presenter.rb', line 23

def stale
  absolute_payload['stale']
end