Class: ComfortableMexicanSofa::Fixture::Layout::Exporter

Inherits:
Exporter
  • Object
show all
Defined in:
lib/comfortable_mexican_sofa/fixture/layout.rb

Instance Attribute Summary

Attributes inherited from Exporter

#from, #path, #site, #to

Instance Method Summary collapse

Methods inherited from Exporter

#initialize, #prepare_folder!

Constructor Details

This class inherits a constructor from ComfortableMexicanSofa::Fixture::Exporter

Instance Method Details

#export!Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/comfortable_mexican_sofa/fixture/layout.rb', line 66

def export!
  prepare_folder!(self.path)
  
  self.site.layouts.each do |layout|
    layout_path = File.join(path, layout.ancestors.reverse.collect{|l| l.identifier}, layout.identifier)
    FileUtils.mkdir_p(layout_path)
    
    # writing attributes
    open(File.join(layout_path, 'attributes.yml'), 'w') do |f|
      f.write({
        'label'       => layout.label,
        'app_layout'  => layout.app_layout,
        'position'    => layout.position
      }.to_yaml)
    end
    open(File.join(layout_path, 'content.html'), 'w') do |f|
      f.write(layout.content)
    end
    open(File.join(layout_path, 'stylesheet.css'), 'w') do |f|
      f.write(layout.css)
    end
    open(File.join(layout_path, 'javascript.js'), 'w') do |f|
      f.write(layout.js)
    end
    
    ComfortableMexicanSofa.logger.info("[FIXTURES] Exported Layout \t #{layout.identifier}")
  end
end