Sha256: 379d80d5c4262f8fc1068e5a25fba4dc4718b7988514ab50311adae5f428f92d
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
module ComfortableMexicanSofa::Fixture::Category class Importer < ComfortableMexicanSofa::Fixture::Importer def import! { 'files' => 'Comfy::Cms::File', 'pages' => 'Comfy::Cms::Page', 'snippets' => 'Comfy::Cms::Snippet' }.each do |file, type| if File.exists?(attrs_path = File.join(path, "#{file}.yml")) categories = get_attributes(attrs_path) [categories].flatten.each do |label| self.site.categories.find_or_create_by(:label => label, :categorized_type => type) end end end end end class Exporter < ComfortableMexicanSofa::Fixture::Exporter def export! prepare_folder!(self.path) { 'files' => 'Comfy::Cms::File', 'pages' => 'Comfy::Cms::Page', 'snippets' => 'Comfy::Cms::Snippet' }.each do |file, type| if (categories = self.site.categories.of_type(type)).present? open(File.join(self.path, "#{file}.yml"), 'w') do |f| f.write(categories.map{|c| c.label}.to_yaml) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems