Sha256: 5b91d4169db5366928ab123e6d801bc7a7de32b1b2d350c9e951a9ec803a88cf

Contents?: true

Size: 1019 Bytes

Versions: 40

Compression:

Stored size: 1019 Bytes

Contents

require 'dply/logger'
module Dply
  class ReleaseHelper

    include Logger

    def current_release_dir
      current_dir = "current"
      return if not File.symlink? current_dir
      name = File.basename (File.readlink current_dir)
      "releases/#{name}"
    end

    def prune_releases(keep: 5)
      releases = all_releases
      releases.reject! { |x| x == current_release_dir }
      old_releases = releases[keep..-1]
      return if not old_releases
      old_releases.each do |d|
        logger.info "deleting old release #{File.basename d}"
        FileUtils.rm_rf d
      end
    end
    
    def all_releases
      Dir["releases/*"].sort! { |x, y| File.mtime(y) <=> File.mtime(x) }
    end 

    def parse(name)
      arr = name.split("-")
      deployed = File.exist? "releases/#{name}/.deployed"
      release = {
        revision: arr[0] || "NA",
        project: arr[1] || "NA",
        branch: arr[2] || "NA",
        timestamp: arr[3] || "NA",
        deployed: deployed
      }
    end

  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
dply-0.3.15 lib/dply/release_helper.rb
dply-0.3.14 lib/dply/release_helper.rb
dply-0.3.13 lib/dply/release_helper.rb
dply-0.3.12 lib/dply/release_helper.rb
dply-0.3.11 lib/dply/release_helper.rb
dply-0.3.10 lib/dply/release_helper.rb
dply-0.3.9 lib/dply/release_helper.rb
dply-0.3.8 lib/dply/release_helper.rb
dply-0.3.7 lib/dply/release_helper.rb
dply-0.3.6 lib/dply/release_helper.rb
dply-0.3.5 lib/dply/release_helper.rb
dply-0.3.4 lib/dply/release_helper.rb
dply-0.3.3 lib/dply/release_helper.rb
dply-0.3.2 lib/dply/release_helper.rb
dply-0.3.1 lib/dply/release_helper.rb
dply-0.3.0 lib/dply/release_helper.rb
dply-0.2.19 lib/dply/release_helper.rb
dply-0.2.18 lib/dply/release_helper.rb
dply-0.2.17 lib/dply/release_helper.rb
dply-0.2.16 lib/dply/release_helper.rb