Class: Tebako::CacheCommand
- Inherits:
-
Thor
- Object
- Thor
- Tebako::CacheCommand
- Defined in:
- lib/tebako/build_commands.rb
Overview
tebako cache inspection and maintenance command group.
Instance Method Summary collapse
- #clean ⇒ Object
- #explain(key) ⇒ Object
- #list ⇒ Object
- #prune ⇒ Object
- #remove(key) ⇒ Object
- #stats ⇒ Object
- #verify ⇒ Object
Instance Method Details
#clean ⇒ Object
228 229 230 231 |
# File 'lib/tebako/build_commands.rb', line 228 def clean catalog.clean render("cleaned" => true) end |
#explain(key) ⇒ Object
199 200 201 202 203 204 |
# File 'lib/tebako/build_commands.rb', line 199 def explain(key) matches = catalog.entries.select { |entry| entry.key == key || "#{entry.type}:#{entry.key}" == key } raise Thor::Error, "Cache artifact not found: #{key}" if matches.empty? render(matches.map(&:to_h)) end |
#list ⇒ Object
179 180 181 |
# File 'lib/tebako/build_commands.rb', line 179 def list render(catalog.entries.map(&:to_h)) end |
#prune ⇒ Object
209 210 211 212 213 214 215 216 217 |
# File 'lib/tebako/build_commands.rb', line 209 def prune raise Thor::Error, "Specify --max-size or --older-than" unless ["max-size"] || ["older-than"] removed = catalog.prune( max_size: parse_size(["max-size"]), older_than: parse_duration(["older-than"]) ) render("removed" => removed.map(&:to_h), "removed_bytes" => removed.sum(&:byte_size)) end |
#remove(key) ⇒ Object
220 221 222 223 224 225 |
# File 'lib/tebako/build_commands.rb', line 220 def remove(key) removed = catalog.remove(key) raise Thor::Error, "Cache artifact not found or currently in use: #{key}" if removed.empty? render("removed" => removed.map(&:to_h)) end |
#stats ⇒ Object
184 185 186 |
# File 'lib/tebako/build_commands.rb', line 184 def stats render(catalog.stats) end |
#verify ⇒ Object
189 190 191 192 193 194 195 196 |
# File 'lib/tebako/build_commands.rb', line 189 def verify invalid = catalog.verify render( "valid" => invalid.empty?, "invalid" => invalid.map(&:to_h) ) raise Thor::Error, "#{invalid.length} corrupt cache artifact(s) found" unless invalid.empty? end |