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.



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

def initialize(settings)
  @config = Contentful::Configuration.new(settings)
  @exporter = Contentful::Exporter::Drupal::Export.new(config)
  @converter = Contentful::Converter::ContentfulModelToJson.new(config)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#converterObject (readonly)

Returns the value of attribute converter.



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

def converter
  @converter
end

#exporterObject (readonly)

Returns the value of attribute exporter.



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

def exporter
  @exporter
end

Instance Method Details

#run(action) ⇒ Object



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

def run(action)
  case action.to_s
    when '--extract-to-json'
      exporter.save_data_as_json
    when '--convert-content-model-to-json'
      converter.convert_to_import_form
    when '--create-contentful-model-from-json'
      converter.create_content_type_json
    else
      fail ArgumentError, 'You have entered incorrect action! View README'
  end
end