Class: ARII::Detector
- Inherits:
-
Object
- Object
- ARII::Detector
- Defined in:
- lib/arii/detector.rb
Overview
Detector
Main change detection class, to be inherited by SQL, CSV, JSON and XML detectors (and others to come).
Direct Known Subclasses
CSVDetector, ExcelDetector, JSONDetector, SQLDetector, XMLDetector
Instance Attribute Summary collapse
-
#agent ⇒ Object
Returns the value of attribute agent.
-
#content ⇒ Object
Returns the value of attribute content.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#objects ⇒ Object
Returns the value of attribute objects.
-
#payloads ⇒ Object
Returns the value of attribute payloads.
-
#templates ⇒ Object
Returns the value of attribute templates.
Instance Method Summary collapse
-
#checkup ⇒ Object
Start original source detection process.
-
#initialize(agent) ⇒ Detector
constructor
A new instance of Detector.
Constructor Details
#initialize(agent) ⇒ Detector
Returns a new instance of Detector.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/arii/detector.rb', line 18 def initialize agent begin @agent = agent @payloads = Array.new @objects = Array.new @help = ARII::Helper.new ARII::Config.log.info(self.class.name) { "Started new #{agent.identifier} detector" } rescue Exception => e ARII::Config.log.error(self.class.name) { "#{e}" } end end |
Instance Attribute Details
#agent ⇒ Object
Returns the value of attribute agent.
16 17 18 |
# File 'lib/arii/detector.rb', line 16 def agent @agent end |
#content ⇒ Object
Returns the value of attribute content.
16 17 18 |
# File 'lib/arii/detector.rb', line 16 def content @content end |
#identifier ⇒ Object
Returns the value of attribute identifier.
16 17 18 |
# File 'lib/arii/detector.rb', line 16 def identifier @identifier end |
#objects ⇒ Object
Returns the value of attribute objects.
16 17 18 |
# File 'lib/arii/detector.rb', line 16 def objects @objects end |
#payloads ⇒ Object
Returns the value of attribute payloads.
16 17 18 |
# File 'lib/arii/detector.rb', line 16 def payloads @payloads end |
#templates ⇒ Object
Returns the value of attribute templates.
16 17 18 |
# File 'lib/arii/detector.rb', line 16 def templates @templates end |
Instance Method Details
#checkup ⇒ Object
Start original source detection process
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/arii/detector.rb', line 34 def checkup begin ## # => Process seed data, if available. # unless @agent.seeds.nil? then @agent.seeds.each do |seed| case seed[:publisher] when 'csv' begin @sr = ARII::CSVSeedReader.new(@agent, seed) rescue Exception => e ARII::Config.log.error(self.class.name) { "#{e}" } end when 'sql' begin @sr = ARII::SQLSeedReader.new(@agent, seed) rescue Exception => e ARII::Config.log.error(self.class.name) { "#{e}" } end when 'xml' begin @sr = ARII::XMLSeedReader.new(@agent, seed) rescue Exception => e ARII::Config.log.error(self.class.name) { "#{e}" } end when 'json' begin @sr = ARII::JSONSeedReader.new(@agent, seed) rescue Exception => e ARII::Config.log.error(self.class.name) { "#{e}" } end end begin @reads = @sr.read @reads.each do |read| @objects.push read end rescue Exception => e ARII::Config.log.error(self.class.name) { "#{e}" } end end else ## # no seeds, simply copy agent data object = @help.deep_copy @agent.payload object[:identifier] = @agent.identifier object[:cache] = @agent.cache object[:seed] = object[:identifier] object[:selectors] = @agent.selectors unless self.content.nil? then object[:content] = self.content end @objects.push object end rescue Exception => e @response = {:status => 404, :message => "[ARII][Detector] failed to load doc, #{e}"} ARII::Config.log.error(self.class.name) { "#{e}" } end begin # increase detected events count @templates = Array.new @response = {:payload => @payloads, :templates => @templates, :status => 100} rescue Exception => e @response = {:status => 404, :message => "[ARII][Detector] failed to process queries, #{e}"} ARII::Config.log.error(self.class.name) { "#{e}" } end @response end |