class Contentful::Exporter::Drupal::Vocabulary
Attributes
config[R]
exporter[R]
Public Class Methods
new(exporter, config)
click to toggle source
# File lib/drupal/vocabulary.rb, line 8 def initialize(exporter, config) @exporter, @config = exporter, config end
Public Instance Methods
save_vocabularies_as_json()
click to toggle source
# File lib/drupal/vocabulary.rb, line 12 def save_vocabularies_as_json exporter.create_directory("#{config.entries_dir}/vocabulary") config.db[:taxonomy_vocabulary].each do |vocabulary_row| extract_data(vocabulary_row) end end
Private Instance Methods
extract_data(vocabulary_row)
click to toggle source
# File lib/drupal/vocabulary.rb, line 21 def extract_data(vocabulary_row) puts "Saving vocabulary - id: #{vocabulary_row[:vid]}" db_object = map_fields(vocabulary_row) exporter.write_json_to_file("#{config.entries_dir}/vocabulary/#{db_object[:id]}.json", db_object) end
id(vocabulary_id)
click to toggle source
# File lib/drupal/vocabulary.rb, line 35 def id(vocabulary_id) "vocabulary_#{vocabulary_id}" end
map_fields(row, result = {})
click to toggle source
# File lib/drupal/vocabulary.rb, line 27 def map_fields(row, result = {}) result[:id] = id(row[:vid]) result[:name] = row[:name] result[:description] = row[:description] result[:machine_name] = row[:machine_name] result end