module Cfer::Auster::CferHelpers
Constants
- CFIZER_DEFAULT_CAPTURE_REGEXP
Public Class Methods
cfize(text, capture_regexp: nil)
click to toggle source
# File lib/cfer/auster/cfer_helpers.rb, line 26 def self.cfize(text, capture_regexp: nil) raise "'text' must be a string." unless text.is_a?(String) capture_regexp ||= CFIZER_DEFAULT_CAPTURE_REGEXP raise "'capture_regexp' must be a Regexp." unless capture_regexp.is_a?(Regexp) raise "'capture_regexp' must include a 'contents' named 'directive'." \ unless capture_regexp.named_captures.key?("directive") working = [] until working[-2] == "" && working[-1] == "" do if working.empty? working = text.partition(capture_regexp) else working[-1] = working[-1].partition(capture_regexp) working = working.flatten end end cfizer = Cfizer.new Cfizer::Fn.join("", working.map do |token| match = capture_regexp.match(token) if match.nil? token else cfizer.cfize(match["directive"]) end end.reject { |t| t == ""}) end
Public Instance Methods
_exported_name(name)
click to toggle source
# File lib/cfer/auster/cfer_helpers.rb, line 18 def _exported_name(name) "#{parameters[:PlanID]}--#{name}" end
cfize(text, capture_regexp: nil)
click to toggle source
# File lib/cfer/auster/cfer_helpers.rb, line 22 def cfize(text, capture_regexp: nil) CferHelpers.cfize(text, capture_regexp: capture_regexp) end
eval_file(filename)
click to toggle source
# File lib/cfer/auster/cfer_helpers.rb, line 6 def eval_file(filename) instance_eval IO.read(filename), filename end
export(name, value)
click to toggle source
# File lib/cfer/auster/cfer_helpers.rb, line 14 def export(name, value) output name, value, Export: { Name: _exported_name(name) } end
import(name)
click to toggle source
# File lib/cfer/auster/cfer_helpers.rb, line 10 def import(name) { "Fn::ImportValue" => _exported_name(name) } end