capitalist-acts-as-importable 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "rails", "3.0.3"
5
+ gem "capybara", ">= 0.4.0"
6
+ gem "sqlite3-ruby", :require => "sqlite3"
7
+ gem "rspec-rails", ">= 2.0.0.beta"
8
+ gem "bundler", "~> 1.0.0"
9
+ gem "jeweler", "~> 1.5.2"
10
+ gem "rcov", ">= 0"
11
+ gem "awesome_print"
12
+ gem "mysql2"
13
+ end
14
+
15
+
16
+ # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
17
+ # gem 'ruby-debug'
18
+ # gem 'ruby-debug19'
data/Gemfile.lock ADDED
@@ -0,0 +1,129 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.3)
6
+ actionpack (= 3.0.3)
7
+ mail (~> 2.2.9)
8
+ actionpack (3.0.3)
9
+ activemodel (= 3.0.3)
10
+ activesupport (= 3.0.3)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.13)
16
+ rack-test (~> 0.5.6)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.3)
19
+ activesupport (= 3.0.3)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4)
22
+ activerecord (3.0.3)
23
+ activemodel (= 3.0.3)
24
+ activesupport (= 3.0.3)
25
+ arel (~> 2.0.2)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.3)
28
+ activemodel (= 3.0.3)
29
+ activesupport (= 3.0.3)
30
+ activesupport (3.0.3)
31
+ arel (2.0.7)
32
+ awesome_print (0.3.1)
33
+ builder (2.1.2)
34
+ capybara (0.4.1.1)
35
+ celerity (>= 0.7.9)
36
+ culerity (>= 0.2.4)
37
+ mime-types (>= 1.16)
38
+ nokogiri (>= 1.3.3)
39
+ rack (>= 1.0.0)
40
+ rack-test (>= 0.5.4)
41
+ selenium-webdriver (>= 0.0.27)
42
+ xpath (~> 0.1.3)
43
+ celerity (0.8.7)
44
+ childprocess (0.1.6)
45
+ ffi (~> 0.6.3)
46
+ culerity (0.2.15)
47
+ diff-lcs (1.1.2)
48
+ erubis (2.6.6)
49
+ abstract (>= 1.0.0)
50
+ ffi (0.6.3)
51
+ rake (>= 0.8.7)
52
+ git (1.2.5)
53
+ i18n (0.5.0)
54
+ jeweler (1.5.2)
55
+ bundler (~> 1.0.0)
56
+ git (>= 1.2.5)
57
+ rake
58
+ json_pure (1.5.1)
59
+ mail (2.2.15)
60
+ activesupport (>= 2.3.6)
61
+ i18n (>= 0.4.0)
62
+ mime-types (~> 1.16)
63
+ treetop (~> 1.4.8)
64
+ mime-types (1.16)
65
+ mysql2 (0.2.6)
66
+ nokogiri (1.4.4)
67
+ polyglot (0.3.1)
68
+ rack (1.2.1)
69
+ rack-mount (0.6.13)
70
+ rack (>= 1.0.0)
71
+ rack-test (0.5.7)
72
+ rack (>= 1.0)
73
+ rails (3.0.3)
74
+ actionmailer (= 3.0.3)
75
+ actionpack (= 3.0.3)
76
+ activerecord (= 3.0.3)
77
+ activeresource (= 3.0.3)
78
+ activesupport (= 3.0.3)
79
+ bundler (~> 1.0)
80
+ railties (= 3.0.3)
81
+ railties (3.0.3)
82
+ actionpack (= 3.0.3)
83
+ activesupport (= 3.0.3)
84
+ rake (>= 0.8.7)
85
+ thor (~> 0.14.4)
86
+ rake (0.8.7)
87
+ rcov (0.9.9)
88
+ rspec (2.4.0)
89
+ rspec-core (~> 2.4.0)
90
+ rspec-expectations (~> 2.4.0)
91
+ rspec-mocks (~> 2.4.0)
92
+ rspec-core (2.4.0)
93
+ rspec-expectations (2.4.0)
94
+ diff-lcs (~> 1.1.2)
95
+ rspec-mocks (2.4.0)
96
+ rspec-rails (2.4.1)
97
+ actionpack (~> 3.0)
98
+ activesupport (~> 3.0)
99
+ railties (~> 3.0)
100
+ rspec (~> 2.4.0)
101
+ rubyzip (0.9.4)
102
+ selenium-webdriver (0.1.2)
103
+ childprocess (~> 0.1.5)
104
+ ffi (~> 0.6.3)
105
+ json_pure
106
+ rubyzip
107
+ sqlite3 (1.3.3)
108
+ sqlite3-ruby (1.3.3)
109
+ sqlite3 (>= 1.3.3)
110
+ thor (0.14.6)
111
+ treetop (1.4.9)
112
+ polyglot (>= 0.3.1)
113
+ tzinfo (0.3.24)
114
+ xpath (0.1.3)
115
+ nokogiri (~> 1.3)
116
+
117
+ PLATFORMS
118
+ ruby
119
+
120
+ DEPENDENCIES
121
+ awesome_print
122
+ bundler (~> 1.0.0)
123
+ capybara (>= 0.4.0)
124
+ jeweler (~> 1.5.2)
125
+ mysql2
126
+ rails (= 3.0.3)
127
+ rcov
128
+ rspec-rails (>= 2.0.0.beta)
129
+ sqlite3-ruby
data/README.textile ADDED
@@ -0,0 +1,8 @@
1
+ h1. Acts as Importable
2
+
3
+ This gem is from Tim Riley's old plugin for Rails. I've updated it to use with Rails 3. It taste's good with my "model_mill":https://rubygems.org/gems/model_mill/ gem.
4
+
5
+ See "Importing Legacy Data in Rails":http://openmonkey.com/articles/2009/05/importing-legacy-data-in-rails for an introduction and documentation.
6
+
7
+ Copyright (c) 2009 Tim Riley, released under the MIT license
8
+ Some bits Copyright (c) 2011 Joe Martinez, released under the same
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "capitalist-acts-as-importable"
16
+ gem.homepage = "http://github.com/capitalist/acts-as-importable"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Helps transfer records from one database to another}
19
+ gem.description = %Q{Allows you to connect to a second database and systematically transfer those records}
20
+ gem.email = "joe@joemartinez.name"
21
+ gem.authors = ["Tim Riley", "Joe Martinez"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "Acts As Importable #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{capitalist-acts-as-importable}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Tim Riley", "Joe Martinez"]
12
+ s.date = %q{2011-01-26}
13
+ s.description = %q{Allows you to connect to a second database and systematically transfer those records}
14
+ s.email = %q{joe@joemartinez.name}
15
+ s.extra_rdoc_files = [
16
+ "README.textile"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "README.textile",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "capitalist-acts-as-importable.gemspec",
25
+ "init.rb",
26
+ "lib/acts_as_importable.rb",
27
+ "lib/core_extensions.rb",
28
+ "spec/acts_as_importable_spec.rb",
29
+ "spec/database.yml",
30
+ "spec/schema.rb",
31
+ "spec/spec.opts",
32
+ "spec/spec_helper.rb",
33
+ "tasks/acts_as_importable_tasks.rake"
34
+ ]
35
+ s.homepage = %q{http://github.com/capitalist/acts-as-importable}
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.7}
39
+ s.summary = %q{Helps transfer records from one database to another}
40
+ s.test_files = [
41
+ "spec/acts_as_importable_spec.rb",
42
+ "spec/schema.rb",
43
+ "spec/spec_helper.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<rails>, ["= 3.0.3"])
52
+ s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
53
+ s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
54
+ s.add_development_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
55
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
57
+ s.add_development_dependency(%q<rcov>, [">= 0"])
58
+ s.add_development_dependency(%q<awesome_print>, [">= 0"])
59
+ s.add_development_dependency(%q<mysql2>, [">= 0"])
60
+ else
61
+ s.add_dependency(%q<rails>, ["= 3.0.3"])
62
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
63
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
64
+ s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ s.add_dependency(%q<awesome_print>, [">= 0"])
69
+ s.add_dependency(%q<mysql2>, [">= 0"])
70
+ end
71
+ else
72
+ s.add_dependency(%q<rails>, ["= 3.0.3"])
73
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
74
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
75
+ s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
76
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
77
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
78
+ s.add_dependency(%q<rcov>, [">= 0"])
79
+ s.add_dependency(%q<awesome_print>, [">= 0"])
80
+ s.add_dependency(%q<mysql2>, [">= 0"])
81
+ end
82
+ end
83
+
data/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ $:.unshift "#{File.dirname(__FILE__)}/lib"
2
+ require 'core_extensions'
3
+ require 'acts_as_importable'
4
+ ActiveRecord::Base.class_eval { include Acts::Importable }
@@ -0,0 +1,77 @@
1
+ module Acts
2
+ module Importable
3
+
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ end
7
+
8
+ module ClassMethods
9
+
10
+ def acts_as_importable(options = {})
11
+ # Store the import target class with the legacy class
12
+ write_inheritable_attribute :importable_to, options[:to]
13
+
14
+ # Don't extend or include twice. This will allow acts_as_importable to be called multiple times.
15
+ # eg. once in a parent class and once again in the child class, where it can override some options.
16
+ extend AMC::Acts::Importable::SingletonMethods unless self.methods.include?('import') && self.methods.include?('import_all')
17
+ include AMC::Acts::Importable::InstanceMethods unless self.included_modules.include?(AMC::Acts::Importable::InstanceMethods)
18
+ end
19
+
20
+ end # ClassMethods
21
+
22
+ module SingletonMethods
23
+ def import(id)
24
+ find(id).import
25
+ end
26
+
27
+ def import_all
28
+ all.each do |legacy_model|
29
+ legacy_model.import
30
+ end
31
+ end
32
+
33
+ # This requires a numeric primary key for the legacy tables
34
+ def import_all_in_batches
35
+ each do |legacy_model|
36
+ legacy_model.import
37
+ end
38
+ end
39
+
40
+ def lookup(id)
41
+ lookup_class = read_inheritable_attribute(:importable_to) || "#{self.to_s.split('::').last}"
42
+ lookups[id] ||= Kernel.const_get(lookup_class).first(:conditions => {:legacy_id => id, :legacy_class => self.to_s}).try(:id__)
43
+ end
44
+
45
+ def flush_lookups!
46
+ @lookups = {}
47
+ end
48
+
49
+ private
50
+
51
+ def lookups
52
+ @lookups ||= {}
53
+ end
54
+
55
+ end # SingletonMethods
56
+
57
+ module InstanceMethods
58
+
59
+ def import
60
+ returning to_model do |new_model|
61
+ if new_model
62
+ new_model.legacy_id = self.id if new_model.respond_to?(:"legacy_id=")
63
+ new_model.legacy_class = self.class.to_s if new_model.respond_to?(:"legacy_class=")
64
+
65
+ if !new_model.save
66
+ p new_model.errors
67
+ # TODO log an error that the model failed to save
68
+ # TODO remove the raise once we're out of the development cycle
69
+ raise
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end # InstanceMethods
75
+
76
+ end
77
+ end
@@ -0,0 +1,17 @@
1
+ # See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/212639
2
+ # And http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/210633 for alternative [:id] notation
3
+ class ActiveRecord::Base
4
+ alias_method :id__, :id if method_defined? :id
5
+ end
6
+
7
+ # From http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord
8
+ class <<ActiveRecord::Base
9
+ def each(limit=1000)
10
+ rows = find(:all, :conditions => ["#{primary_key} > ?", 0], :limit => limit)
11
+ while rows.any?
12
+ rows.each { |record| yield record }
13
+ rows = find(:all, :conditions => ["#{primary_key} > ?", rows.last.id], :limit => limit)
14
+ end
15
+ self
16
+ end
17
+ end
@@ -0,0 +1,117 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe AMC::Acts::Importable do
4
+
5
+ it "should include instance methods" do
6
+ Legacy::Thing.new.should be_kind_of(AMC::Acts::Importable::InstanceMethods)
7
+ end
8
+
9
+ it "should extend singleton methods" do
10
+ Legacy::Thing.should be_kind_of(AMC::Acts::Importable::SingletonMethods)
11
+ end
12
+
13
+ describe "importing from an instance of a single model" do
14
+ before(:each) do
15
+ @legacy_thing = create_legacy_thing
16
+ end
17
+
18
+ it "should build the new model using the legacy model's to_model method" do
19
+ @legacy_thing.should_receive(:to_model)
20
+ @legacy_thing.import
21
+ end
22
+
23
+ it "should assign the legacy model's ID to the legacy_id attribute in the new model" do
24
+ new_model = @legacy_thing.import
25
+ new_model.legacy_id.should == @legacy_thing.id
26
+ end
27
+
28
+ it "should assign the legacy model's class name to the legacy_class attribute of the new model" do
29
+ new_model = @legacy_thing.import
30
+ new_model.legacy_class.should == @legacy_thing.class.to_s
31
+ end
32
+
33
+ it "should save the new model" do
34
+ new_model = @legacy_thing.import
35
+ new_model.should_not be_new_record
36
+ end
37
+ end
38
+
39
+ describe "importing a single model" do
40
+ before(:each) do
41
+ @legacy_thing = mock(Legacy::Thing, :import => nil)
42
+ Legacy::Thing.stub!(:find).and_return(@legacy_thing)
43
+ end
44
+
45
+ it "should find the legacy model" do
46
+ Legacy::Thing.should_receive(:find).with(123)
47
+ Legacy::Thing.import(123)
48
+ end
49
+
50
+ it "should import the legacy model" do
51
+ @legacy_thing.should_receive(:import)
52
+ Legacy::Thing.import(123)
53
+ end
54
+ end
55
+
56
+ describe "importing all models" do
57
+ before(:each) do
58
+ @legacy_thing_1 = mock(Legacy::Thing, :import => nil)
59
+ @legacy_thing_2 = mock(Legacy::Thing, :import => nil)
60
+ Legacy::Thing.stub!(:all).and_return([@legacy_thing_1, @legacy_thing_2])
61
+ end
62
+
63
+ it "should find all legacy models" do
64
+ Legacy::Thing.should_receive(:all)
65
+ Legacy::Thing.import_all
66
+ end
67
+
68
+ it "should import each of the legacy models" do
69
+ @legacy_thing_1.should_receive(:import)
70
+ @legacy_thing_2.should_receive(:import)
71
+ Legacy::Thing.import_all
72
+ end
73
+ end
74
+
75
+ describe "looking up legcy IDs for already imported models" do
76
+ before(:all) do
77
+ @legacy_thing = create_legacy_thing
78
+ @imported_thing = @legacy_thing.import
79
+ end
80
+
81
+ before(:each) do
82
+ Legacy::Thing.flush_lookups!
83
+ end
84
+
85
+ it "should attempt to find the imported model by legacy_id" do
86
+ Thing.should_receive(:first).with(:conditions => {:legacy_id => 123, :legacy_class => 'Legacy::Thing'})
87
+ Legacy::Thing.lookup(123)
88
+ end
89
+
90
+ it "should return the ID of the imported model with a matching legacy_id" do
91
+ Legacy::Thing.lookup(@legacy_thing.id).should == @imported_thing.id
92
+ end
93
+
94
+ it "should memoize the mapping from the legacy_id to the imported model's ID" do
95
+ Thing.should_receive(:first).and_return(@imported_thing)
96
+ Legacy::Thing.lookup(@legacy_thing.id).inspect
97
+ Thing.should_not_receive(:find_by_legacy_id)
98
+ Legacy::Thing.lookup(@legacy_thing.id).inspect
99
+ end
100
+ end
101
+
102
+ describe "looking up legacy IDs for already imported models when importing to a model with a different class name to the legacy model" do
103
+ before(:all) do
104
+ @other_legacy_thing = create_other_legacy_thing
105
+ end
106
+
107
+ before(:each) do
108
+ Legacy::Thing.flush_lookups!
109
+ end
110
+
111
+ it "should attempt to find the imported model with the specified class name by legacy_id" do
112
+ Thing.should_receive(:first).with(:conditions => {:legacy_id => 123, :legacy_class => 'Legacy::OtherThing'})
113
+ Legacy::OtherThing.lookup(123)
114
+ end
115
+ end
116
+
117
+ end
data/spec/database.yml ADDED
@@ -0,0 +1,21 @@
1
+ sqlite:
2
+ :adapter: sqlite
3
+ :dbfile: acts_as_importable_plugin.sqlite.db
4
+ sqlite3mem:
5
+ :adapter: sqlite3
6
+ :dbfile: ":memory:"
7
+ sqlite3:
8
+ :adapter: sqlite3
9
+ :dbfile: acts_as_importable_plugin.sqlite3.db
10
+ postgresql:
11
+ :adapter: postgresql
12
+ :username: postgres
13
+ :password: postgres
14
+ :database: acts_as_importable_plugin_test
15
+ :min_messages: ERROR
16
+ mysql:
17
+ :adapter: mysql
18
+ :host: localhost
19
+ :username: rails
20
+ :password:
21
+ :database: acts_as_importable_plugin_test
data/spec/schema.rb ADDED
@@ -0,0 +1,13 @@
1
+ ActiveRecord::Schema.define(:version => 0) do
2
+ create_table :legacy_things, :force => true do |t|
3
+ t.string :legacy_name
4
+ t.string :legacy_description
5
+ end
6
+
7
+ create_table :things, :force => true do |t|
8
+ t.string :name
9
+ t.string :description
10
+ t.integer :legacy_id
11
+ t.string :legacy_class
12
+ end
13
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,50 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
3
+
4
+ require 'rubygems'
5
+ require 'active_record'
6
+ require File.dirname(__FILE__) + '/../init.rb'
7
+
8
+ require 'spec'
9
+
10
+ config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
11
+ ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
12
+ ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite3mem'])
13
+
14
+ ActiveRecord::Migration.verbose = false
15
+ load(File.dirname(__FILE__) + "/schema.rb")
16
+
17
+ class Thing < ActiveRecord::Base
18
+ end
19
+
20
+ module Legacy
21
+ class Thing < ActiveRecord::Base
22
+ set_table_name 'legacy_things'
23
+
24
+ acts_as_importable
25
+
26
+ def to_model
27
+ ::Thing.new do |t|
28
+ t.name = self.legacy_name
29
+ t.description = self.legacy_description
30
+ end
31
+ end
32
+ end
33
+
34
+ class OtherThing < Thing
35
+ set_table_name 'legacy_things'
36
+
37
+ acts_as_importable :to => 'Thing'
38
+ end
39
+ end
40
+
41
+ Spec::Runner.configure do |config|
42
+
43
+ def create_legacy_thing(attrs = {})
44
+ Legacy::Thing.create({:legacy_name => 'Grandfather Clock', :legacy_description => 'Tick tock'}.merge(attrs))
45
+ end
46
+
47
+ def create_other_legacy_thing(attrs = {})
48
+ Legacy::OtherThing.create({:legacy_name => 'Grandfather Clock', :legacy_description => 'Tick tock'}.merge(attrs))
49
+ end
50
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :acts_as_importable do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capitalist-acts-as-importable
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Tim Riley
14
+ - Joe Martinez
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-01-26 00:00:00 -05:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ type: :development
24
+ prerelease: false
25
+ name: rails
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - "="
30
+ - !ruby/object:Gem::Version
31
+ hash: 1
32
+ segments:
33
+ - 3
34
+ - 0
35
+ - 3
36
+ version: 3.0.3
37
+ requirement: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ type: :development
40
+ prerelease: false
41
+ name: capybara
42
+ version_requirements: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 15
48
+ segments:
49
+ - 0
50
+ - 4
51
+ - 0
52
+ version: 0.4.0
53
+ requirement: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ type: :development
56
+ prerelease: false
57
+ name: sqlite3-ruby
58
+ version_requirements: &id003 !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirement: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ type: :development
70
+ prerelease: false
71
+ name: rspec-rails
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 31098209
78
+ segments:
79
+ - 2
80
+ - 0
81
+ - 0
82
+ - beta
83
+ version: 2.0.0.beta
84
+ requirement: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ type: :development
87
+ prerelease: false
88
+ name: bundler
89
+ version_requirements: &id005 !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ hash: 23
95
+ segments:
96
+ - 1
97
+ - 0
98
+ - 0
99
+ version: 1.0.0
100
+ requirement: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ type: :development
103
+ prerelease: false
104
+ name: jeweler
105
+ version_requirements: &id006 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ hash: 7
111
+ segments:
112
+ - 1
113
+ - 5
114
+ - 2
115
+ version: 1.5.2
116
+ requirement: *id006
117
+ - !ruby/object:Gem::Dependency
118
+ type: :development
119
+ prerelease: false
120
+ name: rcov
121
+ version_requirements: &id007 !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ requirement: *id007
131
+ - !ruby/object:Gem::Dependency
132
+ type: :development
133
+ prerelease: false
134
+ name: awesome_print
135
+ version_requirements: &id008 !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ requirement: *id008
145
+ - !ruby/object:Gem::Dependency
146
+ type: :development
147
+ prerelease: false
148
+ name: mysql2
149
+ version_requirements: &id009 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
157
+ version: "0"
158
+ requirement: *id009
159
+ description: Allows you to connect to a second database and systematically transfer those records
160
+ email: joe@joemartinez.name
161
+ executables: []
162
+
163
+ extensions: []
164
+
165
+ extra_rdoc_files:
166
+ - README.textile
167
+ files:
168
+ - Gemfile
169
+ - Gemfile.lock
170
+ - README.textile
171
+ - Rakefile
172
+ - VERSION
173
+ - capitalist-acts-as-importable.gemspec
174
+ - init.rb
175
+ - lib/acts_as_importable.rb
176
+ - lib/core_extensions.rb
177
+ - spec/acts_as_importable_spec.rb
178
+ - spec/database.yml
179
+ - spec/schema.rb
180
+ - spec/spec.opts
181
+ - spec/spec_helper.rb
182
+ - tasks/acts_as_importable_tasks.rake
183
+ has_rdoc: true
184
+ homepage: http://github.com/capitalist/acts-as-importable
185
+ licenses:
186
+ - MIT
187
+ post_install_message:
188
+ rdoc_options: []
189
+
190
+ require_paths:
191
+ - lib
192
+ required_ruby_version: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ hash: 3
198
+ segments:
199
+ - 0
200
+ version: "0"
201
+ required_rubygems_version: !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ hash: 3
207
+ segments:
208
+ - 0
209
+ version: "0"
210
+ requirements: []
211
+
212
+ rubyforge_project:
213
+ rubygems_version: 1.3.7
214
+ signing_key:
215
+ specification_version: 3
216
+ summary: Helps transfer records from one database to another
217
+ test_files:
218
+ - spec/acts_as_importable_spec.rb
219
+ - spec/schema.rb
220
+ - spec/spec_helper.rb