Class: Menagerie::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/menagerie/collection.rb

Overview

Connection object that contains releases

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Collection

Returns a new instance of Collection.



8
9
10
11
12
13
# File 'lib/menagerie/collection.rb', line 8

def initialize(params = {})
  params = Cymbal.symbolize(params || {})
  @paths = default_paths.merge(params[:paths] || {})
  @options = default_options.merge(params[:options] || {})
  @logger = Menagerie.get_logger(@options[:verbosity])
end

Instance Method Details

#add_release(artifacts) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/menagerie/collection.rb', line 28

def add_release(artifacts)
  rotate
  Release.new(
    artifacts: Cymbal.symbolize(artifacts),
    paths: @paths,
    logger: @logger
  )
  reap if @options[:reap]
  link_latest
end

#orphansObject



21
22
23
24
25
26
# File 'lib/menagerie/collection.rb', line 21

def orphans
  keepers = releases.map(&:artifacts).flatten.map(&:path).uniq
  Dir.glob("#{@paths[:artifacts]}/*/*").sort.reject do |artifact|
    keepers.include? artifact
  end
end

#releasesObject



15
16
17
18
19
# File 'lib/menagerie/collection.rb', line 15

def releases
  Dir.glob("#{@paths[:releases]}/*").sort.map do |x|
    Release.new path: x, paths: @paths, logger: @logger
  end.sort
end