Class: Contrast::Agent::Assess::Policy::Propagator::Next
- Defined in:
- lib/contrast/agent/assess/policy/propagator/next.rb
Overview
Propagation that results in all the tags of the source being applied to the target. In those cases where overflow occurred, the overflow is tagged the same as the character which preceded it. The target’s preexisting tags are shifted to account for this.
Class Method Summary collapse
-
.propagate(propagation_node, preshift, target) ⇒ Object
String has some silly methods like next.
Methods inherited from Base
Class Method Details
.propagate(propagation_node, preshift, target) ⇒ Object
String has some silly methods like next. Basically, this flips a character in a predictable manner
propagation action required by this method.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/contrast/agent/assess/policy/propagator/next.rb', line 23 def propagate propagation_node, preshift, target return unless (properties = Contrast::Agent::Assess::Tracker.properties!(target)) source = find_source(propagation_node.sources[0], preshift) properties.copy_from(source, target, 0, propagation_node.) # this means the char that was shifted overflowed and created new # chars (i.e 'z' "wraps" to create 'aa' ) unless target.length == source.length properties.copy_from(source, target, 0, propagation_node.) first_difference = (0...source.length).find { |i| source[i] != target[i] } || source.length properties.(first_difference).each do |tag| tag.shift_end(target.length - source.length) end end properties. end |