Sha256: ec6794c8e95160e11454724338fd89005741f290cd99be463c6fa4e773f6b7aa
Contents?: true
Size: 764 Bytes
Versions: 1
Compression:
Stored size: 764 Bytes
Contents
class KuberKit::Tools::BuildDirCleaner include KuberKit::Import[ "shell.bash_commands", ] KEEP_DIRS_COUNT = 10 Contract KuberKit::Shell::AbstractShell, KeywordArgs[parent_dir: String] => Any def call(shell, parent_dir:) dirs_to_delete = get_ancient_builds_dirs(shell, parent_dir: parent_dir) dirs_to_delete.each do |dir| bash_commands.rm_rf(shell, dir) end end private def get_ancient_builds_dirs(shell, parent_dir:) all_dirs = shell.list_dirs("#{parent_dir}/*") all_dirs.each do |dir| puts bash_commands.ctime(shell, f).inspect end skip_dirs = all_dirs .sort_by{ |f| bash_commands.ctime(shell, f) } .reverse[0...KEEP_DIRS_COUNT] all_dirs - skip_dirs end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kuber_kit-0.9.4 | lib/kuber_kit/tools/build_dir_cleaner.rb |