Class: Rhea::Command
- Inherits:
-
Object
- Object
- Rhea::Command
- Defined in:
- lib/rhea/command.rb
Constant Summary collapse
- KEY_PREFIX =
'rhea-'
- IMAGE_EXPRESSION_SEPARATOR =
'____'
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#image ⇒ Object
Returns the value of attribute image.
-
#process_count ⇒ Object
Returns the value of attribute process_count.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(expression:, image: nil, process_count: nil, created_at: nil) ⇒ Command
constructor
A new instance of Command.
- #key ⇒ Object
Constructor Details
#initialize(expression:, image: nil, process_count: nil, created_at: nil) ⇒ Command
Returns a new instance of Command.
8 9 10 11 12 13 |
# 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 |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/rhea/command.rb', line 3 def created_at @created_at end |
#expression ⇒ Object
Returns the value of attribute expression.
3 4 5 |
# File 'lib/rhea/command.rb', line 3 def expression @expression end |
#image ⇒ Object
Returns the value of attribute image.
3 4 5 |
# File 'lib/rhea/command.rb', line 3 def image @image end |
#process_count ⇒ Object
Returns the value of attribute process_count.
3 4 5 |
# File 'lib/rhea/command.rb', line 3 def process_count @process_count end |
Instance Method Details
#attributes ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/rhea/command.rb', line 15 def attributes { expression: expression, image: image, process_count: process_count, created_at: created_at } end |
#key ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# 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 |