Class: Lemans::Clobber
- Inherits:
-
Object
- Object
- Lemans::Clobber
- Defined in:
- lib/lemans/clobber.rb
Overview
Deletes run directories based on the provided filters.
Constant Summary collapse
- TRIAL_DIR =
/\A(?<task>.+)__[A-Za-z0-9]{7}\z/
Instance Method Summary collapse
-
#call ⇒ Object
Deletes everything it can, says what it could not, and returns what it actually removed — the caller's "deleted N" must not count survivors.
-
#initialize(runs_dir:, tasks: [], ttl_sec: nil, invalid: false) ⇒ Clobber
constructor
A new instance of Clobber.
- #matches ⇒ Object
Constructor Details
#initialize(runs_dir:, tasks: [], ttl_sec: nil, invalid: false) ⇒ Clobber
Returns a new instance of Clobber.
12 13 14 15 16 17 |
# File 'lib/lemans/clobber.rb', line 12 def initialize(runs_dir:, tasks: [], ttl_sec: nil, invalid: false) @runs_dir = Pathname(runs_dir) @tasks = Array(tasks) @ttl_sec = ttl_sec @invalid = invalid end |
Instance Method Details
#call ⇒ Object
Deletes everything it can, says what it could not, and returns what it actually removed — the caller's "deleted N" must not count survivors.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lemans/clobber.rb', line 25 def call deleted = matches.select do |entry| FileUtils.remove_entry(entry.to_s) true rescue SystemCallError => e warn "lemans: could not delete #{entry}: #{e.}" false end prune_emptied_parents(deleted) deleted end |
#matches ⇒ Object
19 20 21 |
# File 'lib/lemans/clobber.rb', line 19 def matches @matches ||= select_matches end |