Class: ComfortableMexicanSofa::Fixture::File::Exporter
- Defined in:
- lib/comfortable_mexican_sofa/fixture/file.rb
Instance Attribute Summary
Attributes inherited from Exporter
Instance Method Summary collapse
Methods inherited from Exporter
Constructor Details
This class inherits a constructor from ComfortableMexicanSofa::Fixture::Exporter
Instance Method Details
#export! ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/comfortable_mexican_sofa/fixture/file.rb', line 42 def export! prepare_folder!(self.path) self.site.files.each do |file| file_path = File.join(self.path, file.file_file_name) # writing attributes open(::File.join(self.path, "_#{file.file_file_name}.yml"), 'w') do |f| f.write({ 'label' => file.label, 'description' => file.description, 'categories' => file.categories.map{|c| c.label} }.to_yaml) end # writing content data_path = file.file.[:storage] == :filesystem ? file.file.path : file.file.url open(::File.join(self.path, ::File.basename(file_path)), 'w') do |f| f.write(open(data_path)) end ComfortableMexicanSofa.logger.warn("[FIXTURES] Exported File \t #{file.file_file_name}") end end |