Class: Dash::Tags
- Inherits:
-
Object
- Object
- Dash::Tags
- Defined in:
- lib/dash/tags.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
- .default_tags(config) ⇒ Object
- .from_config(config, **extra) ⇒ Object
- .service_version(config) ⇒ Object
Instance Method Summary collapse
-
#env ⇒ Object
Both prefixes carry the same value: hooks are operator-written and apps read these at runtime, so the old names stay until 5.0 (zoolutions/dash#118).
- #except(*tags) ⇒ Object
-
#initialize(**tags) ⇒ Tags
constructor
A new instance of Tags.
- #to_s ⇒ Object
Constructor Details
#initialize(**tags) ⇒ Tags
Returns a new instance of Tags.
25 26 27 |
# File 'lib/dash/tags.rb', line 25 def initialize(**) @tags = .compact end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/dash/tags.rb', line 4 def config @config end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
4 5 6 |
# File 'lib/dash/tags.rb', line 4 def @tags end |
Class Method Details
.default_tags(config) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/dash/tags.rb', line 11 def (config) { recorded_at: Time.now.utc.iso8601, performer: Dash::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/dash/tags.rb', line 7 def from_config(config, **extra) new(**(config), **extra) end |
.service_version(config) ⇒ Object
20 21 22 |
# File 'lib/dash/tags.rb', line 20 def service_version(config) [ config.service, config.abbreviated_version ].compact.join("@") end |
Instance Method Details
#env ⇒ Object
Both prefixes carry the same value: hooks are operator-written and apps read these at runtime, so the old names stay until 5.0 (zoolutions/dash#118).
31 32 33 34 35 36 |
# File 'lib/dash/tags.rb', line 31 def env .each_with_object({}) do |(detail, value), env| env["DASH_#{detail.upcase}"] = value env["KAMAL_#{detail.upcase}"] = value end end |
#except(*tags) ⇒ Object
42 43 44 |
# File 'lib/dash/tags.rb', line 42 def except(*) self.class.new(**self..except(*)) end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/dash/tags.rb', line 38 def to_s .values.map { |value| "[#{value}]" }.join(" ") end |