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

Version Path
eb_deployer-0.6.6 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.5 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.4 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.3 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.2 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.1 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.0 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.0.beta6 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.0.beta5 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.0.beta4 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.0.beta3 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.0.beta2 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.5.2 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.6.0.beta1 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.5.1.beta3 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.5.1.beta2 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.5.1.beta1 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.5.0 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.4.13 lib/eb_deployer/version_cleaner.rb
eb_deployer-0.4.12 lib/eb_deployer/version_cleaner.rb