Class: Migrator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Migrator

Returns a new instance of Migrator.



9
10
11
12
13
14
# File 'lib/migrator.rb', line 9

def initialize(settings)
  @settings = Contentful::Configuration.new(settings)
  @exporter = Contentful::Exporter::Wordpress::Export.new(@settings)
  @converter = Contentful::Converter::ContentfulModelToJson.new(@settings)
  @markup_converter = Contentful::Converter::MarkupConverter.new(@settings)
end

Instance Attribute Details

#converterObject (readonly)

Returns the value of attribute converter.



7
8
9
# File 'lib/migrator.rb', line 7

def converter
  @converter
end

#exporterObject (readonly)

Returns the value of attribute exporter.



7
8
9
# File 'lib/migrator.rb', line 7

def exporter
  @exporter
end

#markup_converterObject (readonly)

Returns the value of attribute markup_converter.



7
8
9
# File 'lib/migrator.rb', line 7

def markup_converter
  @markup_converter
end

#settingsObject (readonly)

Returns the value of attribute settings.



7
8
9
# File 'lib/migrator.rb', line 7

def settings
  @settings
end

Instance Method Details

#run(action, opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/migrator.rb', line 16

def run(action, opts = {})
  case action.to_s
    when '--extract-to-json'
      exporter.export_blog
      omit_flag = opts[:omit_content_model].present?
      converter.create_content_type_json(omit_flag) unless omit_flag
    when '--convert-content-model-to-json'
      converter.convert_to_import_form
    when '--create-contentful-model-from-json'
      converter.create_content_type_json
    when '--convert-markup'
      markup_converter.convert_markup_to_markdown
  end
end