Class: Bulkrax::CsvTemplate::FileValidator
- Inherits:
-
Object
- Object
- Bulkrax::CsvTemplate::FileValidator
- Defined in:
- app/services/bulkrax/csv_template/file_validator.rb
Overview
Validates file references in CSV against zip archive contents
Instance Attribute Summary collapse
-
#csv_data ⇒ Object
readonly
Returns the value of attribute csv_data.
-
#zip_file ⇒ Object
readonly
Returns the value of attribute zip_file.
Instance Method Summary collapse
- #count_references ⇒ Object
- #found_files_count ⇒ Object
-
#initialize(csv_data, zip_file = nil, admin_set_id = nil) ⇒ FileValidator
constructor
A new instance of FileValidator.
- #missing_files ⇒ Object
- #possible_missing_files? ⇒ Boolean
- #zip_included? ⇒ Boolean
Constructor Details
#initialize(csv_data, zip_file = nil, admin_set_id = nil) ⇒ FileValidator
Returns a new instance of FileValidator.
10 11 12 13 14 |
# File 'app/services/bulkrax/csv_template/file_validator.rb', line 10 def initialize(csv_data, zip_file = nil, admin_set_id = nil) @csv_data = csv_data @zip_file = zip_file @admin_set_id = admin_set_id end |
Instance Attribute Details
#csv_data ⇒ Object (readonly)
Returns the value of attribute csv_data.
8 9 10 |
# File 'app/services/bulkrax/csv_template/file_validator.rb', line 8 def csv_data @csv_data end |
#zip_file ⇒ Object (readonly)
Returns the value of attribute zip_file.
8 9 10 |
# File 'app/services/bulkrax/csv_template/file_validator.rb', line 8 def zip_file @zip_file end |
Instance Method Details
#count_references ⇒ Object
16 17 18 |
# File 'app/services/bulkrax/csv_template/file_validator.rb', line 16 def count_references @csv_data.count { |item| item[:file].present? } end |
#found_files_count ⇒ Object
26 27 28 29 30 |
# File 'app/services/bulkrax/csv_template/file_validator.rb', line 26 def found_files_count return 0 unless @zip_file (referenced_files & zip_file_list).count end |
#missing_files ⇒ Object
20 21 22 23 24 |
# File 'app/services/bulkrax/csv_template/file_validator.rb', line 20 def missing_files return [] unless @zip_file referenced_files - zip_file_list end |
#possible_missing_files? ⇒ Boolean
36 37 38 39 40 41 |
# File 'app/services/bulkrax/csv_template/file_validator.rb', line 36 def possible_missing_files? return false unless referenced_files.any? return true if @zip_file.blank? false end |
#zip_included? ⇒ Boolean
32 33 34 |
# File 'app/services/bulkrax/csv_template/file_validator.rb', line 32 def zip_included? @zip_file.present? end |