Class: Kamal::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/kamal/tags.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**tags) ⇒ Tags

Returns a new instance of Tags.



25
26
27
# File 'lib/kamal/tags.rb', line 25

def initialize(**tags)
  @tags = tags.compact
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/kamal/tags.rb', line 4

def config
  @config
end

#tagsObject (readonly)

Returns the value of attribute tags.



4
5
6
# File 'lib/kamal/tags.rb', line 4

def tags
  @tags
end

Class Method Details

.default_tags(config) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/kamal/tags.rb', line 11

def default_tags(config)
  { recorded_at: Time.now.utc.iso8601,
    performer: Kamal::Git.email.presence || `whoami`.chomp,
    destination: config.destination,
    version: config.version,
    service_version: service_version(config),
    service: config.service }
end

.from_config(config, **extra) ⇒ Object



7
8
9
# File 'lib/kamal/tags.rb', line 7

def from_config(config, **extra)
  new(**default_tags(config), **extra)
end

.service_version(config) ⇒ Object



20
21
22
# File 'lib/kamal/tags.rb', line 20

def service_version(config)
  [ config.service, config.abbreviated_version ].compact.join("@")
end

Instance Method Details

#envObject



29
30
31
# File 'lib/kamal/tags.rb', line 29

def env
  tags.transform_keys { |detail| "KAMAL_#{detail.upcase}" }
end

#except(*tags) ⇒ Object



37
38
39
# File 'lib/kamal/tags.rb', line 37

def except(*tags)
  self.class.new(**self.tags.except(*tags))
end

#to_sObject



33
34
35
# File 'lib/kamal/tags.rb', line 33

def to_s
  tags.values.map { |value| "[#{value}]" }.join(" ")
end