= Import

== Install

Add Import to your Gemfile:

    gem 'import', git: 'https://github.com/milabent/import.git', branch: 'master'

Import migrations and execute them:

    rake import_engine:install:migrations
    rake db:migrate

== Prepare

Create your import resource:

    class Import::Resources::User < Import::Resources::Base
        validates :name, presence: true
        import do
          ::User.create(name: name)
        end
    end

Create a plan, e.g. via rails console:

    Plan.create(url: 'http://example.org/users', resource_type: 'Import::Resources::User')

== Run

Run your plans, e.g. via rails console:

    Import::Command::import_all

=== Partial imports

You can add a placeholder to tell the server about the last successful import:

    Plan.create(url: 'http://example.org/users?continue_from=###LAST_SUCCESS###')

This allows the server to reduce the export to latest changes. The placeholder is replaced with an UTC ISO 8610 time like 2015-06-25T13:19:06Z.

To trigger a partial import you have to use continue_import instead of import_all:

    Import::Command::continue_import
= Import

== Install

Add Import to your Gemfile:

    gem 'import', git: 'https://github.com/milabent/import.git', branch: 'master'

Import migrations and execute them:

    rake import_engine:install:migrations
    rake db:migrate

== Prepare

Create your import resource:

    class Import::Resources::User < Import::Resources::Base
        validates :name, presence: true
        import do
          ::User.create(name: name)
        end
    end

Create a plan, e.g. via rails console:

    Plan.create(url: 'http://example.org/users', resource_type: 'Import::Resources::User')

== Run

Run your plans, e.g. via rails console:

    Import::Command::import_all

=== Partial imports

You can add a placeholder to tell the server about the last successful import:

    Plan.create(url: 'http://example.org/users?continue_from=###LAST_SUCCESS###')

This allows the server to reduce the export to latest changes. The placeholder is replaced with an UTC ISO 8610 time like 2015-06-25T13:19:06Z.

To trigger a partial import you have to use continue_import instead of import_all:

    Import::Command::continue_import

= Extend Import::Plan

Sometimes you need additional fields on the plan model. You can add those fields via migration and extend the model like this:

    # yourapp/app/models/import/plan.rb

    require Import::Engine.root.join('app', 'models', 'import', 'plan')

    class Import::Plan < ActiveRecord::Base
      belongs_to :user
      validates :user, :some_string, presence: true
    end

This allows you to use this fields for the import.

Add instructions for how to extend Import::Plan
Add instructions for how to extend Import::Plan
