Class: I2X::XMLDetector
Overview
XMLDetector
Detect changes in XML files (uses XPath).
Instance Attribute Summary
Attributes inherited from Detector
#agent, #content, #identifier, #objects, #payloads, #templates
Instance Method Summary collapse
-
#detect(object) ⇒ Object
Detect the changes.
Methods inherited from Detector
Constructor Details
This class inherits a constructor from I2X::Detector
Instance Method Details
#detect(object) ⇒ Object
Detect the changes
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/i2x/xmldetector.rb', line 19 def detect object begin if object[:uri] == '' then @doc = Nokogiri::XML(object[:content]) else @doc = Nokogiri::XML(open(object[:uri])) end @doc.remove_namespaces! @doc.xpath(object[:query]).each do |element| element.xpath(object[:cache]).each do |c| @cache = Cashier.verify c.content, object, c.content, object[:seed] end ## # If not on cache, add to payload for processing # if @cache[:status] == 100 then # add row data to payload from selectors (key => key, value => column name) payload = Hash.new JSON.parse(object[:selectors]).each do |selector| selector.each do |k,v| element.xpath(v).each do |el| payload[k] = el.content end end end # add payload object to payloads list @payloads.push payload end end end rescue Exception => e end |