Sha256: 6fd92d37a2958aa6be609ba4aabc012ae10fd48c632d8d57b0d5bd7eed6b14d1
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
module ComfortableMexicanSofa::Fixture::Category class Importer < ComfortableMexicanSofa::Fixture::Importer def import! { 'files' => 'Cms::File', 'pages' => 'Cms::Page', 'snippets' => '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_and_categorized_type(label, type) end end end end end class Exporter < ComfortableMexicanSofa::Fixture::Exporter def export! prepare_folder!(self.path) { 'files' => 'Cms::File', 'pages' => 'Cms::Page', 'snippets' => '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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
comfortable_mexican_sofa-1.8.5 | lib/comfortable_mexican_sofa/fixture/category.rb |
comfortable_mexican_sofa-1.8.4 | lib/comfortable_mexican_sofa/fixture/category.rb |