class Rhea::Command

Constants

IMAGE_EXPRESSION_SEPARATOR
KEY_PREFIX

Attributes

created_at[RW]
expression[RW]
image[RW]
process_count[RW]

Public Class Methods

new(expression:, image: nil, process_count: nil, created_at: nil) click to toggle source
# File lib/rhea/command.rb, line 8
def initialize(expression:, image: nil, process_count: nil, created_at: nil)
  self.expression = expression
  self.image = image || Rhea.configuration.default_image
  self.process_count = process_count
  self.created_at = created_at
end

Public Instance Methods

attributes() click to toggle source
# File lib/rhea/command.rb, line 15
def attributes
  {
    expression: expression,
    image: image,
    process_count: process_count,
    created_at: created_at
  }
end
key() click to toggle source
# File lib/rhea/command.rb, line 24
def key
  command_hash = Digest::MD5.hexdigest("#{image}#{expression}")[0..3]
  command_for_host = expression.downcase.gsub(/[^-a-z0-9]+/i, '-').squeeze('-')
  key = "#{KEY_PREFIX}#{command_hash}-#{command_for_host}"
  max_host_name_length = 62
  key = key[0,max_host_name_length]
  # The key can't end with a '-'
  key.gsub!(/\-+$/, '')
  key
end