Sha256: 7b8707376d7834e1db888d478747a41f01cc3e7a97b70d441294485ed75f4e0f
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module ComfortableMediaSurfer::Seeds::File class Exporter < ComfortableMediaSurfer::Seeds::Exporter def initialize(from, to = from) super self.path = ::File.join(ComfortableMediaSurfer.config.seeds_path, to, 'files/') end def export! prepare_folder!(path) site.files.each do |file| file_path = File.join(path, file.attachment.filename.to_s) # writing attributes ::File.write(::File.join(path, "_#{file.attachment.filename}.yml"), { 'label' => file.label, 'description' => file.description, 'categories' => file.categories.map(&:label) }.to_yaml) # writing content begin ::File.binwrite(::File.join(path, ::File.basename(file_path)), file.attachment.download) rescue Errno::ENOENT, OpenURI::HTTPError message = "[CMS SEEDS] No physical File \t #{file.attachment.filename}" ComfortableMediaSurfer.logger.warn(message) next end message = "[CMS SEEDS] Exported File \t #{file.attachment.filename}" ComfortableMediaSurfer.logger.info(message) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems