Class: Purview::Parsers::CSV
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from Base
Methods included from Mixins::Logger
#logger, #logger_opts, #logger_type, #with_context_logging
Constructor Details
This class inherits a constructor from Purview::Parsers::Base
Instance Method Details
#parse(data) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/purview/parsers/csv.rb', line 4 def parse(data) with_context_logging("`parse` for: #{table.name}") do [].tap do |result| headers = extract_headers(data) extract_rows(data).each do |row| result << build_result(headers.zip(row)) end end end end |
#validate(data) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/purview/parsers/csv.rb', line 15 def validate(data) with_context_logging("`validate` for: #{table.name}") do missing_columns = missing_columns(data) raise 'Missing one or more columns: "%s"' % missing_columns.join('", "') \ unless missing_columns.empty? true end end |