Skip to content

Instantly share code, notes, and snippets.

@kirichkov
Created August 7, 2014 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kirichkov/2278e783bd6ff7e7ff70 to your computer and use it in GitHub Desktop.
Save kirichkov/2278e783bd6ff7e7ff70 to your computer and use it in GitHub Desktop.
Comfortable Mexican Sofa v 1.12 fixture export workaround
# Add this content at the very end of config/initializers/comfortable_mexican_sofa.rb
# Monkey patch the fixture exporter
module ComfortableMexicanSofa::Fixture::File
class Exporter < ComfortableMexicanSofa::Fixture::Exporter
def export!
prepare_folder!(self.path)
self.site.files.each do |file|
file_path = File.join(self.path, file.file_file_name)
block = file.block
# 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},
'block' => block.present? ? block.identifier : nil
}.to_yaml)
end
# writing content
data_path = file.file.options[:storage] == :filesystem ?
file.file.path :
file.file.url
unless ::File.exists?(data_path)
ComfortableMexicanSofa.logger.warn("[FIXTURES] No physical File \t #{file.file_file_name}")
next
end
open(::File.join(self.path, ::File.basename(file_path)), 'wb') do |f|
open(data_path) { |src| f.write(src.read) }
end
ComfortableMexicanSofa.logger.info("[FIXTURES] Exported File \t #{file.file_file_name}")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment