Sha256: d0433313396401b55ff58ad7326c95b9fa95db6ec09172fae477d197de089f8f

Contents?: true

Size: 869 Bytes

Versions: 17

Compression:

Stored size: 869 Bytes

Contents

module ActiveList

  module Exporters

    class CsvExporter < AbstractExporter

      def file_extension
        "csv"
      end

      def mime_type
        Mime::CSV
      end

      def send_data_code
        record = "r"
        code  = generator.select_data_code(paginate: false)
        code << "data = ::CSV.generate do |csv|\n"
        code << "  csv << [#{columns_to_array(:header).join(', ')}]\n"
        code << "  for #{record} in #{generator.records_variable_name}\n"
        code << "    csv << [#{columns_to_array(:body, record: record).join(', ')}]\n"
        code << "  end\n"
        code << "end\n"
        code << "send_data(data, type: #{self.mime_type.to_s.inspect}, disposition: 'inline', filename: #{table.model.name}.model_name.human.gsub(/[^a-z0-9]/i, '_') + '.#{self.file_extension}')\n"
        return code.c
      end

    end

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
active_list-6.5.1 lib/active_list/exporters/csv_exporter.rb
active_list-6.5.0 lib/active_list/exporters/csv_exporter.rb
active_list-6.4.2 lib/active_list/exporters/csv_exporter.rb
active_list-6.4.1 lib/active_list/exporters/csv_exporter.rb
active_list-6.4.0 lib/active_list/exporters/csv_exporter.rb
active_list-6.3.1 lib/active_list/exporters/csv_exporter.rb
active_list-6.3.0 lib/active_list/exporters/csv_exporter.rb
active_list-6.2.4 lib/active_list/exporters/csv_exporter.rb
active_list-6.2.3 lib/active_list/exporters/csv_exporter.rb
active_list-6.2.1 lib/active_list/exporters/csv_exporter.rb
active_list-6.2.0 lib/active_list/exporters/csv_exporter.rb
active_list-6.1.5 lib/active_list/exporters/csv_exporter.rb
active_list-6.1.4 lib/active_list/exporters/csv_exporter.rb
active_list-6.1.3 lib/active_list/exporters/csv_exporter.rb
active_list-6.1.2 lib/active_list/exporters/csv_exporter.rb
active_list-6.1.1 lib/active_list/exporters/csv_exporter.rb
active_list-6.1.0 lib/active_list/exporters/csv_exporter.rb