10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/occams/seeds/file/exporter.rb', line 10
def export!
prepare_folder!(path)
site.files.each do |file|
file_path = File.join(path, file.attachment.filename.to_s)
::File.write(::File.join(path, "_#{file.attachment.filename}.yml"), {
'label' => file.label,
'description' => file.description,
'categories' => file.categories.map(&:label)
}.to_yaml)
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}"
Occams.logger.warn(message)
next
end
message = "[CMS SEEDS] Exported File \t #{file.attachment.filename}"
Occams.logger.info(message)
end
end
|