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.



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

def match
  @match
end

Class Method Details

.descriptor_errors(m) ⇒ Object



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

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)



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

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



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

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

#validate(output) ⇒ Object



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

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