Module: Decidim::Admin::Import::Readers
- Defined in:
- decidim-admin/lib/decidim/admin/import/readers.rb,
decidim-admin/lib/decidim/admin/import/readers/csv.rb,
decidim-admin/lib/decidim/admin/import/readers/base.rb,
decidim-admin/lib/decidim/admin/import/readers/json.rb,
decidim-admin/lib/decidim/admin/import/readers/xlsx.rb
Defined Under Namespace
Classes: Base, CSV, JSON, XLSX
Constant Summary
collapse
- ACCEPTED_MIME_TYPES =
Accepted mime types keys: are used for dynamic help text on admin form. values: are used to validate the file format of imported document.
{
csv: Readers::CSV::MIME_TYPE,
json: Readers::JSON::MIME_TYPE,
xlsx: Readers::XLSX::MIME_TYPE
}.freeze
Class Method Summary
collapse
Class Method Details
.search_by_file_extension(extension) ⇒ Object
37
38
39
40
41
|
# File 'decidim-admin/lib/decidim/admin/import/readers.rb', line 37
def self.search_by_file_extension(extension)
return unless ACCEPTED_MIME_TYPES.has_key?(extension.to_sym)
search_by_mime_type(ACCEPTED_MIME_TYPES[extension.to_sym])
end
|
.search_by_mime_type(mime_type) ⇒ Object
29
30
31
32
33
34
35
|
# File 'decidim-admin/lib/decidim/admin/import/readers.rb', line 29
def self.search_by_mime_type(mime_type)
all.each do |reader_klass|
return reader_klass if mime_type == reader_klass::MIME_TYPE
end
nil
end
|