Class: KamalBackup::CommandSpec
- Inherits:
-
Object
- Object
- KamalBackup::CommandSpec
- Defined in:
- lib/kamal_backup/command.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #display(redactor) ⇒ Object
-
#initialize(argv:, env: {}, host: nil) ⇒ CommandSpec
constructor
A new instance of CommandSpec.
Constructor Details
#initialize(argv:, env: {}, host: nil) ⇒ CommandSpec
Returns a new instance of CommandSpec.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kamal_backup/command.rb', line 13 def initialize(argv:, env: {}, host: nil) @argv = Array(argv).compact.map(&:to_s) @host = host.to_s unless host.to_s.empty? @env = env.each_with_object({}) do |(key, value), result| next if value.nil? || value.to_s.empty? result[key.to_s] = value.to_s end raise ArgumentError, 'command argv cannot be empty' if @argv.empty? end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
11 12 13 |
# File 'lib/kamal_backup/command.rb', line 11 def argv @argv end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
11 12 13 |
# File 'lib/kamal_backup/command.rb', line 11 def env @env end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/kamal_backup/command.rb', line 11 def host @host end |
Instance Method Details
#display(redactor) ⇒ Object
25 26 27 28 |
# File 'lib/kamal_backup/command.rb', line 25 def display(redactor) env_prefix = env.keys.sort.map { |key| "#{key}=#{redactor.redact_value(key, env[key])}" } redactor.redact_string((env_prefix + [argv.shelljoin]).join(' ')) end |