lib/arii/agent.rb in arii-1.5 vs lib/arii/agent.rb in arii-1.6

- old
+ new

@@ -25,45 +25,45 @@ # def execute @checkup = {} case @publisher - when 'sql' - begin - @d = ARII::SQLDetector.new(self) - rescue Exception => e - @response = {:status => 400, :error => e} - ARII::Config.log.error(self.class.name) { "#{e}" } - end - when 'csv' - begin - @d = ARII::CSVDetector.new(self) - rescue Exception => e - @response = {:status => 400, :error => e} - ARII::Config.log.error(self.class.name) { "#{e}" } - end - when 'excel' - begin - @d = ARII::ExcelDetector.new(self) - rescue Exception => e - @response = {:status => 400, :error => e} - ARII::Config.log.error(self.class.name) { "#{e}" } - end - when 'xml' - begin - @d = ARII::XMLDetector.new(self) - rescue Exception => e - @response = {:status => 400, :error => e} - ARII::Config.log.error(self.class.name) { "#{e}" } - end - when 'json' - begin - @d = ARII::JSONDetector.new(self) - rescue Exception => e - @response = {:status => 400, :error => e} - ARII::Config.log.error(self.class.name) { "#{e}" } - end + when 'sql' + begin + @d = ARII::SQLDetector.new(self) + rescue Exception => e + @response = {:status => 400, :error => e} + ARII::Config.log.error(self.class.name) { "#{e}" } + end + when 'csv' + begin + @d = ARII::CSVDetector.new(self) + rescue Exception => e + @response = {:status => 400, :error => e} + ARII::Config.log.error(self.class.name) { "#{e}" } + end + when 'excel' + begin + @d = ARII::ExcelDetector.new(self) + rescue Exception => e + @response = {:status => 400, :error => e} + ARII::Config.log.error(self.class.name) { "#{e}" } + end + when 'xml' + begin + @d = ARII::XMLDetector.new(self) + rescue Exception => e + @response = {:status => 400, :error => e} + ARII::Config.log.error(self.class.name) { "#{e}" } + end + when 'json' + begin + @d = ARII::JSONDetector.new(self) + rescue Exception => e + @response = {:status => 400, :error => e} + ARII::Config.log.error(self.class.name) { "#{e}" } + end end # Start checkup begin @@ -104,15 +104,17 @@ begin checkup[:templates].each do |template| ARII::Config.log.info(self.class.name) { "Delivering to #{template} template." } checkup[:payload].each do |payload| ARII::Config.log.debug(self.class.name) { "Processing #{payload}." } - response = RestClient.post "#{ARII::Config.host}postman/deliver/#{template}.js", payload + + response = RestClient::Request.execute(:method => 'post', :url => "#{ARII::Config.host}postman/deliver/#{template}.js", :payload => payload ,:verify_ssl => OpenSSL::SSL::VERIFY_NONE ) + case response.code - when 200 - ARII::Config.log.debug(self.class.name) { "Delivered to #{template}." } - else - ARII::Config.log.warn(self.class.name) { "unable to deliver \"#{payload}\" to \"#{template}\"" } + when 200 + ARII::Config.log.debug(self.class.name) { "Delivered to #{template}." } + else + ARII::Config.log.warn(self.class.name) { "unable to deliver \"#{payload}\" to \"#{template}\"" } end end end rescue Exception => e ARII::Config.log.error(self.class.name) { "Processing error: #{e}" }