Class: Afterlife::Stage

Inherits:
Struct
  • Object
show all
Defined in:
lib/afterlife/stage.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket

Returns:

  • (Object)

    the current value of bucket



4
5
6
# File 'lib/afterlife/stage.rb', line 4

def bucket
  @bucket
end

#cdn_urlObject

Returns the value of attribute cdn_url

Returns:

  • (Object)

    the current value of cdn_url



4
5
6
# File 'lib/afterlife/stage.rb', line 4

def cdn_url
  @cdn_url
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/afterlife/stage.rb', line 4

def name
  @name
end

#regionObject

Returns the value of attribute region

Returns:

  • (Object)

    the current value of region



4
5
6
# File 'lib/afterlife/stage.rb', line 4

def region
  @region
end

#registryObject

Returns the value of attribute registry

Returns:

  • (Object)

    the current value of registry



4
5
6
# File 'lib/afterlife/stage.rb', line 4

def registry
  @registry
end

Class Method Details

.build(name = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/afterlife/stage.rb', line 12

def self.build(name = nil)
  Stage.new(
    name: ENV.fetch('AFTERLIFE_STAGE', name),
    bucket: ENV.fetch('AWS_BUCKET', nil),
    region: ENV.fetch('AWS_REGION'),
    cdn_url: ENV.fetch('AWS_BUCKET', nil),
    registry: ENV.fetch('AFTERLIFE_DEPLOY_REGISTRY', nil),
  )
end

.find(stage) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/afterlife/stage.rb', line 22

def self.find(stage)
  return build(stage) unless Afterlife.config.file_exist?

  unless Afterlife.config.stages.key?(stage.to_sym)
    fail Error, "invalid stage '#{stage}'. Possible values: #{Afterlife.config.stages.keys.map(&:to_s)}"
  end

  Afterlife.config.stages[stage.to_sym]
end

Instance Method Details

#profileObject



32
33
34
# File 'lib/afterlife/stage.rb', line 32

def profile
  @profile ||= Afterlife::Config::Provider::CLOUD_PROFILES[name.to_sym]
end