Class: Dash::Report::History
- Inherits:
-
Object
- Object
- Dash::Report::History
- Defined in:
- lib/dash/report/history.rb
Overview
The saved reports for one destination, newest first.
Everything here is best-effort by design: the directory is the operator's, a report may be half-written by a deploy that was killed mid-flush, and a future dash may write a schema this one does not know. None of that is worth a word on a deploy, so an unreadable file is skipped rather than reported.
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#initialize(directory, destination: nil) ⇒ History
constructor
A new instance of History.
-
#prune(count) ⇒ Object
Keeps the newest
countreports of this destination and deletes the rest. - #recent(count) ⇒ Object
Constructor Details
#initialize(directory, destination: nil) ⇒ History
Returns a new instance of History.
12 13 14 15 |
# File 'lib/dash/report/history.rb', line 12 def initialize(directory, destination: nil) @directory = directory @destination = destination end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
10 11 12 |
# File 'lib/dash/report/history.rb', line 10 def destination @destination end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
10 11 12 |
# File 'lib/dash/report/history.rb', line 10 def directory @directory end |
Instance Method Details
#any? ⇒ Boolean
21 22 23 |
# File 'lib/dash/report/history.rb', line 21 def any? documents.any? end |
#prune(count) ⇒ Object
Keeps the newest count reports of this destination and deletes the rest. Other
destinations are left alone: they have their own budget, and a staging deploy must
not age out production's history.
28 29 30 31 32 33 34 |
# File 'lib/dash/report/history.rb', line 28 def prune(count) entries.drop(count).each do |path, _document| File.delete(path) rescue SystemCallError nil end end |
#recent(count) ⇒ Object
17 18 19 |
# File 'lib/dash/report/history.rb', line 17 def recent(count) documents.first(count) end |