Module: XMLScrubber

Defined in:
lib/xml_scrubber.rb,
lib/xml_scrubber/version.rb

Constant Summary collapse

DEFAULT_REPLACEMENT =
"[filtered]"
VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.call(xml, *directives) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/xml_scrubber.rb', line 8

def self.call(xml, *directives)
  tree = Nokogiri.XML(xml)
  tree.traverse do |node|
    Array(directives).flatten.each do |directive|
      node.content = DEFAULT_REPLACEMENT if applies_to_node?(directive, node)
    end
  end
  tree.to_s
end