class AeEasy::Qa::ValidateScraper
Attributes
collections[R]
data[R]
options[R]
outputs[R]
rules[R]
scraper_name[R]
Public Class Methods
new(scraper_name, collections, rules, outputs, thresholds, data)
click to toggle source
# File lib/ae_easy/qa/validate_internal.rb, line 41 def initialize(scraper_name, collections, rules, outputs, thresholds, data) @scraper_name = scraper_name @collections = collections @rules = rules @outputs = outputs @options = {} @data = data options['thresholds'] = thresholds[scraper_name] if thresholds && thresholds[scraper_name] end
Public Instance Methods
run()
click to toggle source
# File lib/ae_easy/qa/validate_internal.rb, line 51 def run begin output_scraper if status_ok? validate_collections if collections && collections.any? else output_response return nil end rescue StandardError => e puts "An error has occurred for the scraper named '#{scraper_name}': #{e}" return nil end end
Private Instance Methods
collection_counts()
click to toggle source
# File lib/ae_easy/qa/validate_internal.rb, line 95 def collection_counts @collection_counts ||= collection_response.parsed_response end
collection_response()
click to toggle source
# File lib/ae_easy/qa/validate_internal.rb, line 99 def collection_response @collection_response || AnswersEngine::Client::ScraperJobOutput.new.collections(scraper_name) end
output_response()
click to toggle source
# File lib/ae_easy/qa/validate_internal.rb, line 87 def output_response if collection_response.parsed_response.nil? puts "collection response is null" else puts collection_response.parsed_response['message'] end end
output_scraper()
click to toggle source
# File lib/ae_easy/qa/validate_internal.rb, line 68 def output_scraper puts "validating scraper: #{scraper_name}" end
status_ok?()
click to toggle source
# File lib/ae_easy/qa/validate_internal.rb, line 72 def status_ok? !collection_response.parsed_response.nil? && collection_response.code == 200 end
validate_collections()
click to toggle source
# File lib/ae_easy/qa/validate_internal.rb, line 76 def validate_collections collections.each do |collection_name| collection = collection_counts.find{|collection_hash| collection_hash['collection'] == collection_name } if collection ValidateCollection.new(scraper_name, collection_name, collection['outputs'], rules, outputs, options.merge({'data' => @data})).run else puts "collection #{collection_name} is missing" end end end