module Contentful::DatabaseImporter
Database Importer Tool
Constants
- VERSION
Public Class Methods
bootstrap_create_space!(file)
click to toggle source
# File lib/contentful/database_importer.rb, line 47 def self.bootstrap_create_space!(file) Contentful::Bootstrap::CommandRunner.new.create_space( config.space_name, locale: config.locale, json_template: file.path ) ensure file.unlink end
bootstrap_update_space!(file)
click to toggle source
# File lib/contentful/database_importer.rb, line 57 def self.bootstrap_update_space!(file) Contentful::Bootstrap::CommandRunner.new.update_space( config.space_id, environment: config.environment, locale: config.locale, json_template: file.path, skip_content_types: config.skip_content_types ) ensure file.unlink end
config()
click to toggle source
# File lib/contentful/database_importer.rb, line 15 def self.config @config ||= Config.new end
database()
click to toggle source
# File lib/contentful/database_importer.rb, line 25 def self.database error = 'Database Configuration not found' raise error if config.database_connection.nil? @database ||= ::Sequel.connect(config.database_connection) end
generate_json()
click to toggle source
# File lib/contentful/database_importer.rb, line 32 def self.generate_json JsonGenerator.generate_json end
generate_json!()
click to toggle source
# File lib/contentful/database_importer.rb, line 36 def self.generate_json! JsonGenerator.generate_json! end
generate_json_file!()
click to toggle source
# File lib/contentful/database_importer.rb, line 40 def self.generate_json_file! file = Tempfile.new("import_#{config.space_name}") file.write(generate_json!) file.close file end
run!()
click to toggle source
# File lib/contentful/database_importer.rb, line 69 def self.run! raise 'Configuration is incomplete' unless config.complete_for_run? bootstrap_create_space!(generate_json_file!) end
setup() { |config| ... }
click to toggle source
# File lib/contentful/database_importer.rb, line 19 def self.setup yield config if block_given? raise 'Configuration is incomplete' unless config.complete? end
update_space!()
click to toggle source
# File lib/contentful/database_importer.rb, line 74 def self.update_space! raise 'Configuration is incomplete' unless config.complete_for_update? bootstrap_update_space!(generate_json_file!) end