Module: Contentful::DatabaseImporter
- Defined in:
- lib/contentful/database_importer.rb,
lib/contentful/database_importer/config.rb,
lib/contentful/database_importer/support.rb,
lib/contentful/database_importer/version.rb,
lib/contentful/database_importer/resource.rb,
lib/contentful/database_importer/json_generator.rb,
lib/contentful/database_importer/id_generator/base.rb,
lib/contentful/database_importer/resource_coercions.rb,
lib/contentful/database_importer/resource_class_methods.rb,
lib/contentful/database_importer/resource_relationships.rb,
lib/contentful/database_importer/resource_bootstrap_methods.rb,
lib/contentful/database_importer/id_generator/contentful_like.rb,
lib/contentful/database_importer/resource_field_class_methods.rb,
lib/contentful/database_importer/resource_bootstrap_class_methods.rb
Overview
Defined Under Namespace
Modules: IdGenerator, JsonGenerator, Resource, ResourceBootstrapClassMethods, ResourceBootstrapMethods, ResourceClassMethods, ResourceCoercions, ResourceFieldClassMethods, ResourceRelationships, Support
Classes: Config
Constant Summary
collapse
- VERSION =
'0.6.0'.freeze
Class Method Summary
collapse
Class Method Details
.bootstrap_create_space!(file) ⇒ Object
47
48
49
50
51
52
53
54
55
|
# 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) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# 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 ⇒ Object
15
16
17
|
# File 'lib/contentful/database_importer.rb', line 15
def self.config
@config ||= Config.new
end
|
.database ⇒ Object
25
26
27
28
29
30
|
# 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_file! ⇒ Object
40
41
42
43
44
45
|
# 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! ⇒ Object
69
70
71
72
|
# 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| ... } ⇒ Object
19
20
21
22
23
|
# 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! ⇒ Object
74
75
76
77
|
# 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
|