Sha256: bc0575232796897078e15be184a64d0a1b0370bf279527146c3fc18cd9cfd901
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