Class: Textus::Application::Reads::Freshness

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/application/reads/freshness.rb

Overview

Per-entry freshness report. Walks every entry declared in the manifest, consults ‘rules_for(key)` for a refresh rule, and reports the current status. Status is one of :fresh, :stale, :never_refreshed, or :no_policy.

Instance Method Summary collapse

Constructor Details

#initialize(ctx:, manifest:, file_store:, evaluator: Textus::Domain::Freshness::Evaluator) ⇒ Freshness

Returns a new instance of Freshness.



11
12
13
14
15
16
# File 'lib/textus/application/reads/freshness.rb', line 11

def initialize(ctx:, manifest:, file_store:, evaluator: Textus::Domain::Freshness::Evaluator)
  @ctx        = ctx
  @manifest   = manifest
  @file_store = file_store
  @evaluator  = evaluator
end

Instance Method Details

#call(prefix: nil, zone: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/textus/application/reads/freshness.rb', line 18

def call(prefix: nil, zone: nil)
  rows = []
  @manifest.entries.each do |mentry|
    next if prefix && !mentry.key.start_with?(prefix)
    next if zone && mentry.zone != zone

    rows << row_for(mentry)
  end
  rows
end