Class: Occams::Seeds::File::Exporter
- Defined in:
- lib/occams/seeds/file/exporter.rb
Instance Attribute Summary
Attributes inherited from Exporter
Instance Method Summary collapse
- #export! ⇒ Object
-
#initialize(from, to = from) ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
Instance Method Details
#export! ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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..filename.to_s) # writing attributes ::File.write(::File.join(path, "_#{file..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..download) Occams.logger.info("[CMS SEEDS] Exported File \t #{file..filename}") rescue Errno::ENOENT, OpenURI::HTTPError Occams.logger.warn("[CMS SEEDS] No physical File \t #{file..filename}") end end end |