Class: Hillary::Slug

Inherits:
Object
  • Object
show all
Includes:
Shellable
Defined in:
lib/hillary/slug.rb,
lib/hillary/slug/bucket.rb

Defined Under Namespace

Classes: Bucket

Constant Summary collapse

SlugArchiveError =
Class.new(StandardError)
SlugNotFoundError =
Class.new(StandardError)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shellable

#shell

Constructor Details

#initialize(path, version, options = {}) ⇒ Slug

Returns a new instance of Slug.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/hillary/slug.rb', line 24

def initialize(path, version, options = {})
  @path = path
  @version = version
  @bucket = options[:bucket] || Bucket.new

  @logger = if options[:logger]
    options[:logger]
  else
    Logger.new($stdout).tap do |logger|
      logger.formatter = proc do |severity, time, _, msg|
        "#{time.strftime('%Y-%m-%d %H:%M:%S')} #{severity} - #{msg}\n"
      end
    end
  end
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



11
12
13
# File 'lib/hillary/slug.rb', line 11

def branch
  @branch
end

#versionObject (readonly)

Returns the value of attribute version.



11
12
13
# File 'lib/hillary/slug.rb', line 11

def version
  @version
end

Class Method Details

.build(path = File.expand_path('.'), version = Repo::Version.create!, options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/hillary/slug.rb', line 17

def build(path = File.expand_path('.'), version = Repo::Version.create!, options = {})
  return unless version.sluggable?

  new(path, version, options).tap{|slug| slug.build}
end

Instance Method Details

#buildObject



40
41
42
43
44
45
46
47
48
# File 'lib/hillary/slug.rb', line 40

def build
  if version.master?
    create_slug_if_missing
    copy_slug
  elsif version.dev?
    create_slug
    upload_slug
  end
end

#canonical_nameObject



54
55
56
# File 'lib/hillary/slug.rb', line 54

def canonical_name
  "#{project_name}_slug_#{version.sha}"
end

#nameObject



50
51
52
# File 'lib/hillary/slug.rb', line 50

def name
  "#{project_name}_slug_#{version.name}"
end