Sha256: fc5ca38555ffa11c852213d5dad4131d39f95c5bc145d6eb32464ab655da8f17
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
module Contentful module Exporter module Drupal class Tag attr_reader :exporter, :config def initialize(exporter, config) @exporter, @config = exporter, config end def save_tags_as_json exporter.create_directory("#{config.entries_dir}/tag") config.db[:taxonomy_term_data].each do |tag_row| extract_data(tag_row) end end private def extract_data(tag_row) puts "Saving tag - id: #{tag_row[:tid]}" db_object = map_fields(tag_row) exporter.write_json_to_file("#{config.entries_dir}/tag/#{db_object[:id]}.json", db_object) end def map_fields(row, result = {}) result[:id] = id(row[:tid]) result[:name] = row[:name] result[:description] = row[:description] result[:vocabulary] = vocabulary(row[:vid]) result end def id(tag_id) 'tag_' + tag_id.to_s end def vocabulary(tag_vocabulary_id) vocabulary = tag_vocabulary(tag_vocabulary_id) {type: 'EntryVocabulary', id: "vocabulary_#{vocabulary[:vid]}"} end def tag_vocabulary(tag_vocabulary_id) config.db[:taxonomy_vocabulary].where(vid: tag_vocabulary_id).first end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
drupal-exporter-0.0.1 | lib/drupal/tag.rb |