Sha256: bb2f249c2ecdda728995f3a4982b7e57b9ff0725afcb1d631ee7dac3fb1d255d

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

require_relative 'configuration'
require_relative 'wordpress/export'
require_relative 'converters/contentful_model_to_json'
require_relative 'converters/markup_converter'

class Migrator
  attr_reader :exporter, :settings, :converter, :markup_converter

  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

  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wordpress-exporter-0.2.0 lib/migrator.rb
wordpress-exporter-0.1.0 lib/migrator.rb
wordpress-exporter-0.0.2 lib/migrator.rb
wordpress-exporter-0.0.1 lib/migrator.rb