Sha256: 6274e03ad2dd0638073c4ef5b058371d395273418e720ffe702828d52b42233a

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

require_relative 'parallel_importer'
require_relative 'configuration'
require_relative 'converters/contentful_model_to_json'
require_relative 'json_schema_validator'

module Contentful
  module Importer
    class Migrator

      attr_reader :importer, :converter, :config, :json_validator

      def initialize(settings)
        @config = Configuration.new(settings)
        @importer = ParallelImporter.new(@config)
        @converter = ContentfulModelToJson.new(@config)
        @json_validator = JsonSchemaValidator.new(@config)
      end

      def run(action, options = {})
        case action.to_s
          when '--create-contentful-model-from-json'
            converter.create_content_type_json
          when '--import-content-types'
            importer.create_contentful_model(options)
          when '--import'
            importer.import_data(options[:threads])
          when '--convert-content-model-to-json'
            converter.convert_to_import_form
          when '--publish-entries'
            importer.publish_entries_in_threads
          when '--test-credentials'
            importer.test_credentials
          when '--import-assets'
            importer.import_only_assets
          when '--publish-assets'
            importer.publish_assets_in_threads(options[:threads])
          when '--validate-schema'
            json_validator.validate_schemas
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contentful-importer-0.1.1 lib/contentful/importer/migrator.rb
contentful-importer-0.1.0 lib/contentful/importer/migrator.rb