Module: Jerakia::Response::Filter::Strsub

Defined in:
lib/jerakia/response/filter/strsub.rb

Instance Method Summary collapse

Instance Method Details

#do_substr(data) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/jerakia/response/filter/strsub.rb', line 23

def do_substr(data)
  data.gsub!(/%\{([^\}]*)\}/) do |tag|
    Jerakia.log.debug("matched substr #{tag}")
    scopekey = tag.match(/\{([^\}]+)\}/)[1]
    scopekey.gsub!(/^::/,'')
    lookup.scope[scopekey.to_sym]
  end
end

#filter_strsub(opts = {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/jerakia/response/filter/strsub.rb', line 14

def filter_strsub(opts={})
  parse_values do |val|
    if val.is_a?(String)
      do_substr(val)
    end
    val
  end
end