Class: Contrast::Agent::Assess::Policy::Propagator::Substitution

Inherits:
Object
  • Object
show all
Includes:
Components::Interface
Defined in:
lib/contrast/agent/assess/policy/propagator/substitution.rb

Overview

This class is specifically for String#(g)sub propagation

Disclaimer: there may be a better way, but we’re in a ‘get it work’ state. hopefully, we’ll be in a ‘get it right’ state soon.

Constant Summary collapse

CAPTURE_GROUP_REGEXP =
/\\[[:digit:]]/.cs__freeze
CAPTURE_NAME_REGEXP =
/\\k<[[:alpha:]]/.cs__freeze

Class Method Summary collapse

Methods included from Components::Interface

included

Class Method Details

.gsub_tagger(patcher, preshift, ret, block) ⇒ Object

gsub is hard. there are four versions of this method 1) pattern, replacement (my fav) 2) pattern, hash (not bad) 3) pattern, block (are you kidding me?) 4) pattern (plz no)

In addition, it requires things from $~ & $1-9, which are method scoped. Rather than fight that, we’ll call gsub from C land using a CUSTOM patch.



34
35
36
# File 'lib/contrast/agent/assess/policy/propagator/substitution.rb', line 34

def gsub_tagger patcher, preshift, ret, block
  substitution_tagger(patcher, preshift, ret, !block.nil?)
end

.sub_tagger(patcher, preshift, ret, block) ⇒ Object



38
39
40
# File 'lib/contrast/agent/assess/policy/propagator/substitution.rb', line 38

def sub_tagger patcher, preshift, ret, block
  substitution_tagger(patcher, preshift, ret, !block.nil?, false)
end