Class: Zizia::CsvManifestValidator
- Inherits:
-
Object
- Object
- Zizia::CsvManifestValidator
- Defined in:
- app/uploaders/zizia/csv_manifest_validator.rb
Instance Attribute Summary collapse
-
#csv_file ⇒ Object
readonly
Returns the value of attribute csv_file.
- #delimiter ⇒ Object
-
#errors ⇒ Object
readonly
Errors and warnings for the CSV file.
-
#warnings ⇒ Object
readonly
Errors and warnings for the CSV file.
Instance Method Summary collapse
-
#initialize(manifest_uploader) ⇒ CsvManifestValidator
constructor
A new instance of CsvManifestValidator.
-
#record_count ⇒ Object
One record per row.
- #validate ⇒ Object
Constructor Details
#initialize(manifest_uploader) ⇒ CsvManifestValidator
Returns a new instance of CsvManifestValidator.
16 17 18 19 20 |
# File 'app/uploaders/zizia/csv_manifest_validator.rb', line 16 def initialize(manifest_uploader) @csv_file = manifest_uploader.file @errors = [] @warnings = [] end |
Instance Attribute Details
#csv_file ⇒ Object (readonly)
Returns the value of attribute csv_file.
24 25 26 |
# File 'app/uploaders/zizia/csv_manifest_validator.rb', line 24 def csv_file @csv_file end |
#delimiter ⇒ Object
45 46 47 |
# File 'app/uploaders/zizia/csv_manifest_validator.rb', line 45 def delimiter @delimiter ||= default_delimiter end |
#errors ⇒ Object (readonly)
Errors and warnings for the CSV file.
23 24 25 |
# File 'app/uploaders/zizia/csv_manifest_validator.rb', line 23 def errors @errors end |
#warnings ⇒ Object (readonly)
Errors and warnings for the CSV file.
23 24 25 |
# File 'app/uploaders/zizia/csv_manifest_validator.rb', line 23 def warnings @warnings end |
Instance Method Details
#record_count ⇒ Object
One record per row
40 41 42 43 |
# File 'app/uploaders/zizia/csv_manifest_validator.rb', line 40 def record_count return nil unless @rows @rows.size - 1 # Don't include the header row end |
#validate ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/uploaders/zizia/csv_manifest_validator.rb', line 26 def validate parse_csv return unless @rows missing_headers duplicate_headers unrecognized_headers missing_values invalid_license invalid_resource_type invalid_rights_statement end |