Sha256: af59780626c82166ebe4b5e7737ab36044f9b86bc6a7f32592994fc4fa1273d0

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

module ComfortableMexicanSofa::Seeds::Snippet
  class Exporter < ComfortableMexicanSofa::Seeds::Exporter

    def initialize(from, to = from)
      super
      self.path = ::File.join(ComfortableMexicanSofa.config.seeds_path, to, "snippets/")
    end

    def export!
      prepare_folder!(self.path)

      self.site.snippets.each do |snippet|
        attrs = {
          "label"       => snippet.label,
          "categories"  => snippet.categories.map{|c| c.label},
          "position"    => snippet.position
        }.to_yaml

        data = []
        data << {header: "attributes", content: attrs}
        data << {header: "content", content: snippet.content}

        snippet_path = File.join(self.path, "#{snippet.identifier}.html")
        write_file_content(snippet_path, data)

        message = "[CMS SEEDS] Exported Snippet \t #{snippet.identifier}"
        ComfortableMexicanSofa.logger.info(message)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.2 lib/comfortable_mexican_sofa/seeds/snippet/exporter.rb
comfortable_mexican_sofa-2.0.1 lib/comfortable_mexican_sofa/seeds/snippet/exporter.rb
comfortable_mexican_sofa-2.0.0 lib/comfortable_mexican_sofa/seeds/snippet/exporter.rb