lib/arii/jsondetector.rb in arii-1.2.1 vs lib/arii/jsondetector.rb in arii-1.2.2

- old
+ new

@@ -15,41 +15,41 @@ ## # == Detect the changes # def detect object - ARII::Config.log.info(self.class.name) {"Monitoring #{object[:uri]}"} unless object[:uri].nil? + ARII::Config.log.info(self.class.name) { "Monitoring #{object[:uri]}" } unless object[:uri].nil? begin if object[:uri] == '' then @doc = object[:content] else url = RestClient.get object[:uri] @doc = url.to_str end - JsonPath.on(@doc,object[:query]).each do |element| + JsonPath.on(@doc, object[:query]).each do |element| JsonPath.on(element, object[:cache]).each do |c| @response = Cashier.verify c, object, c, object[:seed] end - # Process ARII cache response - @cache = JSON.parse(@response, {:symbolize_names => true}) - unless @cache[:templates].nil? then + # Process ARII cache response + @cache = JSON.parse(@response, {:symbolize_names => true}) + unless @cache[:templates].nil? then @cache[:templates].each do |t| @templates.push t end end ## # If not on cache, add to payload for processing # if @cache[:cache][:status] == 100 then - ARII::Config.log.info(self.class.name) {"Not on cache, generating payload"} + ARII::Config.log.info(self.class.name) { "Not on cache, generating payload" } # add row data to payload from selectors (key => key, value => column name) payload = Hash.new object[:selectors].each do |selector| - selector.each do |k,v| + selector.each do |k, v| JsonPath.on(element, v).each do |el| payload[k] = el end end end @@ -57,10 +57,10 @@ @payloads.push payload end end rescue Exception => e - ARII::Config.log.error(self.class.name) {"Loading error: #{e}"} + ARII::Config.log.error(self.class.name) { "Loading error: #{e}" } end @cache[:templates] end end end \ No newline at end of file