Sha256: 23b60f4f81b6f1b9c40a01f010a640b4a4a4a768e70207557a615798e204e6ac

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    module Import
      module Readers
        autoload :Base, "decidim/admin/import/readers/base"
        autoload :CSV, "decidim/admin/import/readers/csv"
        autoload :JSON, "decidim/admin/import/readers/json"
        autoload :XLSX, "decidim/admin/import/readers/xlsx"

        # Accepted mime types
        # keys: are used for dynamic help text on admin form.
        # values: are used to validate the file format of imported document.
        ACCEPTED_MIME_TYPES = {
          json: Readers::JSON::MIME_TYPE,
          csv: Readers::CSV::MIME_TYPE,
          xlsx: Readers::XLSX::MIME_TYPE
        }.freeze

        def self.all
          [
            Readers::CSV,
            Readers::JSON,
            Readers::XLSX
          ]
        end

        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
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-admin-0.25.2 lib/decidim/admin/import/readers.rb
decidim-admin-0.25.1 lib/decidim/admin/import/readers.rb
decidim-admin-0.25.0 lib/decidim/admin/import/readers.rb
decidim-admin-0.25.0.rc4 lib/decidim/admin/import/readers.rb
decidim-admin-0.25.0.rc3 lib/decidim/admin/import/readers.rb
decidim-admin-0.25.0.rc2 lib/decidim/admin/import/readers.rb
decidim-admin-0.25.0.rc1 lib/decidim/admin/import/readers.rb