Class: ComfortableMexicanSofa::Fixture::Page::Exporter
- Defined in:
- lib/comfortable_mexican_sofa/fixture/page.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
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/comfortable_mexican_sofa/fixture/page.rb', line 99 def export! prepare_folder!(self.path) self.site.pages.each do |page| page.slug = 'index' if page.slug.blank? page_path = File.join(path, page.ancestors.reverse.collect{|p| p.slug.blank?? 'index' : p.slug}, page.slug) FileUtils.mkdir_p(page_path) open(File.join(page_path, 'attributes.yml'), 'w') do |f| f.write({ 'label' => page.label, 'layout' => page.layout.try(:identifier), 'parent' => page.parent && (page.parent.slug.present?? page.parent.slug : 'index'), 'target_page' => page.target_page.try(:full_path), 'categories' => page.categories.map{|c| c.label}, 'is_published' => page.is_published, 'position' => page.position }.to_yaml) end page.blocks_attributes.each do |block| open(File.join(page_path, "#{block[:identifier]}.html"), 'w') do |f| f.write(block[:content]) end end ComfortableMexicanSofa.logger.info("[FIXTURES] Exported Page \t #{page.full_path}") end end |