Sha256: f813f173183055d89ea823c06e902dbbd00f1dd88dd67655f0e73837f9bdd73c
Contents?: true
Size: 537 Bytes
Versions: 4
Compression:
Stored size: 537 Bytes
Contents
require 'rexml/document' # Discovers values in the format <key>value, which may occur in XML/HTML. # XML attribute values are already handled using the basic ValueDiscoverer, # since they match the `key="value"` format that it handles. class Carwash::XmlValueDiscoverer < Struct.new(:key) def discover(line) line.scan(%r{[^/]#{key}>(?:([^<]+)|<!\[CDATA\[(.*?)\]\])}i) .map(&:compact) .flatten(1) .map { |val| unescape_value(val) } end def unescape_value(value) REXML::Text::unnormalize(value) end end
Version data entries
4 entries across 4 versions & 1 rubygems