Sha256: 9f0ef5e98306a85b8904399ea6d306198e38039414d54deb85bc774647b0741c
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'cymbal' module Menagerie ## # Connection object that contains releases class Collection def initialize(params = nil) params = Cymbal.symbolize(params || {}) @paths = default_paths.merge(params[:paths] || {}) @options = default_options.merge(params[:options] || {}) end def releases Dir.glob("#{@paths[:releases]}/*").map do |x| Release.new path: x end end def create(artifacts) rotate Release.new artifacts: Cymbal.symbolize(artifacts), paths: @paths reap if @options[:reap] link_latest end private def rotate existing = releases.sort.reverse keepers = existing.pop(@options[:retention]) existing.each(&:delete) keepers.each(&:rotate) end def reap end def link_latest FileUtils.rm_f @paths[:latest] FileUtils.ln_sf releases.sort.first.path, @paths[:latest] end def default_paths { artifacts: 'artifacts', releases: 'releases', latest: 'latest' } end def default_options { retention: 5, reap: true } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
menagerie-0.0.3 | lib/menagerie/collection.rb |