Module: BlackStack::Deployer::MatchModule

Included in:
Match
Defined in:
lib/blackstack-deployer.rb

Overview

define attributes and methods of a command’s match

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#matchObject

Returns the value of attribute match.



436
437
438
# File 'lib/blackstack-deployer.rb', line 436

def match
  @match
end

Class Method Details

.descriptor_errors(m) ⇒ Object



438
439
440
441
442
443
444
# File 'lib/blackstack-deployer.rb', line 438

def self.descriptor_errors(m)
  errors = []
  # validate the match is a regular expresion
  errors << "The match is not a regex" unless m.is_a?(Regexp)
  # 
  errors.uniq
end

Instance Method Details

#initialize(h) ⇒ Object

def self.descriptor_error(h)



446
447
448
449
450
# File 'lib/blackstack-deployer.rb', line 446

def initialize(h)
  errors = BlackStack::Deployer::MatchModule.descriptor_errors(h)
  raise "The node descriptor is not valid: #{errors.uniq.join(".\n")}" if errors.length > 0
  self.match = h
end

#to_hashObject



452
453
454
455
456
# File 'lib/blackstack-deployer.rb', line 452

def to_hash
  h = {}
  h[:match] = self.match
  h
end

#validate(output) ⇒ Object



458
459
460
461
462
# File 'lib/blackstack-deployer.rb', line 458

def validate(output)
  errors = []
  errors << "The output of the command does not match the regular expression #{self.match.inspect}" unless output.match(self.match)
  errors
end