Class: DhEasy::Qa::ValidateScraper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ValidateScraper.



40
41
42
43
44
45
46
47
# File 'lib/dh_easy/qa/validate_internal.rb', line 40

def initialize(scraper_name, collections, rules, outputs, thresholds)
  @scraper_name = scraper_name
  @collections = collections
  @rules = rules
  @outputs = outputs
  @options = {}
  options['thresholds'] = thresholds[scraper_name] if thresholds && thresholds[scraper_name]
end

Instance Attribute Details

#collectionsObject (readonly)

Returns the value of attribute collections.



38
39
40
# File 'lib/dh_easy/qa/validate_internal.rb', line 38

def collections
  @collections
end

#optionsObject (readonly)

Returns the value of attribute options.



38
39
40
# File 'lib/dh_easy/qa/validate_internal.rb', line 38

def options
  @options
end

#outputsObject (readonly)

Returns the value of attribute outputs.



38
39
40
# File 'lib/dh_easy/qa/validate_internal.rb', line 38

def outputs
  @outputs
end

#rulesObject (readonly)

Returns the value of attribute rules.



38
39
40
# File 'lib/dh_easy/qa/validate_internal.rb', line 38

def rules
  @rules
end

#scraper_nameObject (readonly)

Returns the value of attribute scraper_name.



38
39
40
# File 'lib/dh_easy/qa/validate_internal.rb', line 38

def scraper_name
  @scraper_name
end

Instance Method Details

#runObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dh_easy/qa/validate_internal.rb', line 49

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