Class: StorageRoomExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/storage_room_exporter.rb

Constant Summary collapse

PAGE_SIZE =
100

Instance Method Summary collapse

Instance Method Details

#export_collectionsObject



11
12
13
14
15
16
17
# File 'lib/storage_room_exporter.rb', line 11

def export_collections
  puts 'Exporting collections:'
  collections.each do |collection|
    puts collection['name']
    save_to_file(COLLECTIONS_DATA_DIR, collection['entry_type'], format_json(collection))
  end
end

#export_entriesObject



19
20
21
22
23
24
25
26
27
# File 'lib/storage_room_exporter.rb', line 19

def export_entries
  collections.each do |collection|
    puts "Exporting entries for: #{collection['name']}"
    entries(collection).each do |entry|
      entry_id = File.basename(entry['@url'])
      save_to_file("#{ENTRIES_DATA_DIR}/#{collection['entry_type'].downcase}", "#{entry_id}", format_json(entry))
    end
  end
end

#mapping_collections_input_typesObject



29
30
31
32
33
34
# File 'lib/storage_room_exporter.rb', line 29

def mapping_collections_input_types
  read_collection_data do |collection_attributes, fields, file_path|
    translate_fields(fields)
    File.open(file_path, 'w') { |file| file.write(format_json(collection_attributes)) }
  end
end