Class: DhEasy::Qa::ValidateCollection

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, collection_name, total_records, rules, outputs, options) ⇒ ValidateCollection

Returns a new instance of ValidateCollection.



115
116
117
118
119
120
121
122
123
# File 'lib/dh_easy/qa/validate_internal.rb', line 115

def initialize(scraper_name, collection_name, total_records, rules, outputs, options)
  @scraper_name = scraper_name
  @collection_name = collection_name
  @total_records = total_records
  @rules = rules
  @outputs = outputs
  @options = options
  @errors = { errored_items: [] }
end

Instance Attribute Details

#collection_nameObject (readonly)

Returns the value of attribute collection_name.



113
114
115
# File 'lib/dh_easy/qa/validate_internal.rb', line 113

def collection_name
  @collection_name
end

#errorsObject (readonly)

Returns the value of attribute errors.



113
114
115
# File 'lib/dh_easy/qa/validate_internal.rb', line 113

def errors
  @errors
end

#optionsObject (readonly)

Returns the value of attribute options.



113
114
115
# File 'lib/dh_easy/qa/validate_internal.rb', line 113

def options
  @options
end

#outputsObject (readonly)

Returns the value of attribute outputs.



113
114
115
# File 'lib/dh_easy/qa/validate_internal.rb', line 113

def outputs
  @outputs
end

#rulesObject (readonly)

Returns the value of attribute rules.



113
114
115
# File 'lib/dh_easy/qa/validate_internal.rb', line 113

def rules
  @rules
end

#scraper_nameObject (readonly)

Returns the value of attribute scraper_name.



113
114
115
# File 'lib/dh_easy/qa/validate_internal.rb', line 113

def scraper_name
  @scraper_name
end

#total_recordsObject (readonly)

Returns the value of attribute total_records.



113
114
115
# File 'lib/dh_easy/qa/validate_internal.rb', line 113

def total_records
  @total_records
end

Instance Method Details

#runObject



125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/dh_easy/qa/validate_internal.rb', line 125

def run
  output_collection
  if most_recent_finished_job
    puts "data count #{data.count}"
    if data.any?
      ValidateGroups.new(data, scraper_name, collection_name, errors).run
      ValidateRules.new(data, errors, rules).run if rules
    end
    SaveOutput.new(data.count, rules, errors, outputs_collection_name, outputs, options).run
  else
    puts "No job with status 'done' available"
  end
end