Class: Textus::Application::Read::Freshness::Impl
- Inherits:
-
Object
- Object
- Textus::Application::Read::Freshness::Impl
- Defined in:
- lib/textus/application/read/freshness.rb
Instance Method Summary collapse
- #call(prefix: nil, zone: nil) ⇒ Object
-
#initialize(ctx:, caps:, evaluator: Textus::Domain::Freshness::Evaluator) ⇒ Impl
constructor
A new instance of Impl.
-
#soonest_due(prefix: nil, zone: nil) ⇒ Object
Returns the soonest ‘next_due_at` across all entries with a refresh policy, as an ISO-8601 string, or nil if none.
Constructor Details
#initialize(ctx:, caps:, evaluator: Textus::Domain::Freshness::Evaluator) ⇒ Impl
Returns a new instance of Impl.
16 17 18 19 20 21 22 |
# File 'lib/textus/application/read/freshness.rb', line 16 def initialize(ctx:, caps:, evaluator: Textus::Domain::Freshness::Evaluator) @ctx = ctx @manifest = caps.manifest @file_store = caps.file_store @evaluator = evaluator @cache = {} end |
Instance Method Details
#call(prefix: nil, zone: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/textus/application/read/freshness.rb', line 36 def call(prefix: nil, zone: nil) rows = [] @manifest.data.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 |
#soonest_due(prefix: nil, zone: nil) ⇒ Object
Returns the soonest ‘next_due_at` across all entries with a refresh policy, as an ISO-8601 string, or nil if none.
26 27 28 29 30 31 32 33 34 |
# File 'lib/textus/application/read/freshness.rb', line 26 def soonest_due(prefix: nil, zone: nil) times = call(prefix: prefix, zone: zone) .map { |r| r[:next_due_at] } .compact .map { |t| Time.parse(t) } return nil if times.empty? times.min.utc.iso8601 end |