Sha256: 5c1e0357edacfdf0f1f94e1313ffa7ad4fd3402648198e7ba125072408bf6fd1
Contents?: true
Size: 936 Bytes
Versions: 1
Compression:
Stored size: 936 Bytes
Contents
require 'rubygems' require "dm-core" require 'dm-migrations' require '../lib/cheap_imports' DataMapper.setup(:default, 'sqlite3::memory:') class Cat include DataMapper::Resource property :id, Serial property :name, String property :age, Integer include CheapImports end class Appointment include DataMapper::Resource property :id, Serial property :cat_id, Integer property :starts_at, DateTime include CheapImports imports :legacy_data => { :starts_at => "APPOINTMENT START TIME", :starts_at_format => "%d %b %Y %H:%M", :cat_name => "ANIMAL IDENTIFIER" } end DataMapper.finalize DataMapper.auto_migrate! data = %{name\tage\nFluffy\t7} Import.import(Cat, data, {}, true) Cat.all.each do |c| puts c.inspect end data = %{ANIMAL IDENTIFIER,APPOINTMENT START TIME\n} data << %{Fluffy,5 Jan 2009 10:30\n} Import.import([Appointment], data) Appointment.all.each do |a| puts a.inspect end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cheap_imports-0.0.4 | examples/cats.rb |