Sha256: 0a6061074b511ff30abc47111b9ee675e7bdd22bfbcffa2aabcc809da460a421

Contents?: true

Size: 1.11 KB

Versions: 38

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Decidim
  module ZipStream
    module Writer
      def add_user_data_to_zip_stream(out, user_data)
        user_data.each do |element|
          filename_file = element.last.filename(element.first.parameterize)

          out.put_next_entry(filename_file)
          if element.last.read.presence
            out.write element.last.read
          else
            out.write "No data"
          end
        end
      end

      def add_attachments_to_zip_stream(out, export_attachments)
        export_attachments.each do |attachment_block|
          next if attachment_block.last.nil?

          folder_name = attachment_block.first.parameterize
          attachment_block.last.each do |attachment|
            next unless attachment.attached?

            blobs = attachment.is_a?(ActiveStorage::Attached::One) ? [attachment.blob] : attachment.blobs
            blobs.each do |blob|
              out.put_next_entry("#{folder_name}/#{blob.filename}")
              blob.open do |f|
                out << f.read
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/services/decidim/zip_stream/writer.rb
decidim-core-0.27.8 app/services/decidim/zip_stream/writer.rb
decidim-core-0.29.0.rc2 app/services/decidim/zip_stream/writer.rb
decidim-core-0.29.0.rc1 app/services/decidim/zip_stream/writer.rb
decidim-core-0.28.2 app/services/decidim/zip_stream/writer.rb
decidim-core-0.27.7 app/services/decidim/zip_stream/writer.rb
decidim-core-0.28.1 app/services/decidim/zip_stream/writer.rb
decidim-core-0.27.6 app/services/decidim/zip_stream/writer.rb
decidim-core-0.26.10 app/services/decidim/zip_stream/writer.rb
decidim-core-0.26.9 app/services/decidim/zip_stream/writer.rb
decidim-core-0.28.0 app/services/decidim/zip_stream/writer.rb
decidim-core-0.27.5 app/services/decidim/zip_stream/writer.rb
decidim-core-0.28.0.rc5 app/services/decidim/zip_stream/writer.rb
decidim-core-0.28.0.rc4 app/services/decidim/zip_stream/writer.rb
decidim-core-0.26.8 app/services/decidim/zip_stream/writer.rb
decidim-core-0.27.4 app/services/decidim/zip_stream/writer.rb
decidim-core-0.27.3 app/services/decidim/zip_stream/writer.rb
decidim-core-0.26.7 app/services/decidim/zip_stream/writer.rb
decidim-core-0.26.5 app/services/decidim/zip_stream/writer.rb
decidim-core-0.27.2 app/services/decidim/zip_stream/writer.rb