Module: Importer

Defined in:
lib/importer.rb,
lib/importer/parser.rb,
lib/importer/import.rb,
lib/importer/version.rb,
lib/importer/parser/xml.rb,
lib/importer/parser/csv.rb,
lib/importer/parser/base.rb,
lib/importer/imported_object.rb,
lib/importer/adapters/data_mapper_adapter.rb,
lib/importer/adapters/mongo_mapper_adapter.rb,
lib/importer/adapters/active_record_adapter.rb

Overview

Importer module provides your models with flexible API that makes it easier to import data from external sources.

Usage:

class Product < ActiveRecord::Base
  include Importer
end

Product.import(path_to_xml_or_csv_file)

Check README.rdoc file for more useful information

Author

Michal Szajbe

Copyright

Copyright © 2010 Michal Szajbe

License

check the LICENCE file

Defined Under Namespace

Modules: Adapters, Parser Classes: AdapterError, Import, ImportedObject, ParserNotFoundError

Constant Summary collapse

VERSION =
"0.5.0"

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


31
32
33
34
35
36
37
38
39
40
41
# File 'lib/importer.rb', line 31

def included(base)
  if base.respond_to?(:descends_from_active_record?) && base.descends_from_active_record?
    base.send(:include, Importer::Adapters::ActiveRecordAdapter)
  elsif defined?(MongoMapper) && (base.ancestors.include?(MongoMapper::Document) || base.ancestors.include?(MongoMapper::EmbeddedDocument))
    base.send(:include, Importer::Adapters::MongoMapperAdapter)
  elsif defined?(DataMapper) && (base.ancestors.include?(DataMapper::Resource))
    base.send(:include, Importer::Adapters::DataMapperAdapter)
  else
    raise AdapterError.new("Can't determine adapter for #{base.class} class.")
  end
end