Class: MyExternalNode

Inherits:
ExternalNode show all
Defined in:
ext/regexp_nodes/regexp_nodes.rb

Overview

Logic for local hacks that don’t fit neatly into the autoloading model can happen as we initialize a subclass

Instance Attribute Summary

Attributes inherited from ExternalNode

#classes, #hostname, #parameters

Instance Method Summary collapse

Methods inherited from ExternalNode

#match_classes, #match_parameters, #matched_in_patternfile?, #parse_argv, #to_yaml

Constructor Details

#initialize(hostname, classdir = 'classes/', parameterdir = 'parameters/') ⇒ MyExternalNode

Returns a new instance of MyExternalNode.



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'ext/regexp_nodes/regexp_nodes.rb', line 191

def initialize(hostname, classdir = 'classes/', parameterdir = 'parameters/')

  super

  # Set "hostclass" parameter based on hostname,
  # stripped of leading environment prefix and numeric suffix
  if @hostname =~ /^(\w*?)-?(\D+)(\d{2,3})$/
    match = Regexp.last_match

    hostclass = match[2]
    $LOG.debug("matched hostclass #{hostclass}")
    @parameters[ "hostclass" ] = hostclass
  else
    $LOG.debug("hostclass couldn't figure out class from #{@hostname}")
  end
end