Class: AeEasy::Qa::ValidateScraper

Inherits:
Object
  • Object
show all
Defined in:
lib/ae_easy/qa/validate_internal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scraper_name, collections, rules, outputs, thresholds, data) ⇒ ValidateScraper

Returns a new instance of ValidateScraper.



41
42
43
44
45
46
47
48
49
# 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

Instance Attribute Details

#collectionsObject (readonly)

Returns the value of attribute collections.



39
40
41
# File 'lib/ae_easy/qa/validate_internal.rb', line 39

def collections
  @collections
end

#dataObject (readonly)

Returns the value of attribute data.



39
40
41
# File 'lib/ae_easy/qa/validate_internal.rb', line 39

def data
  @data
end

#optionsObject (readonly)

Returns the value of attribute options.



39
40
41
# File 'lib/ae_easy/qa/validate_internal.rb', line 39

def options
  @options
end

#outputsObject (readonly)

Returns the value of attribute outputs.



39
40
41
# File 'lib/ae_easy/qa/validate_internal.rb', line 39

def outputs
  @outputs
end

#rulesObject (readonly)

Returns the value of attribute rules.



39
40
41
# File 'lib/ae_easy/qa/validate_internal.rb', line 39

def rules
  @rules
end

#scraper_nameObject (readonly)

Returns the value of attribute scraper_name.



39
40
41
# File 'lib/ae_easy/qa/validate_internal.rb', line 39

def scraper_name
  @scraper_name
end

Instance Method Details

#runObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 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