Sha256: dc9d083a87ccf79d30a19ecd96a1307b4a32f9b60082258c9887673075f3e65d
Contents?: true
Size: 770 Bytes
Versions: 49
Compression:
Stored size: 770 Bytes
Contents
module EbDeployer class VersionCleaner def initialize(app, number_to_keep) @app = app @number_to_keep = number_to_keep end def clean(version_prefix = "") if @number_to_keep > 0 versions_to_remove = versions_to_clean(version_prefix) @app.remove(versions_to_remove, true) end end private def versions_to_clean(version_prefix = "") all_versions = @app.versions.select do |apv| apv[:version].start_with?(version_prefix) end all_versions.sort! { |x, y| y[:date_updated] <=> x[:date_updated] } versions_to_keep = all_versions.slice!(range_to_keep) all_versions.map { |apv| apv[:version] } end def range_to_keep (0..(@number_to_keep-1)) end end end
Version data entries
49 entries across 49 versions & 1 rubygems