legacy_migrations 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +0 -3
- data/VERSION +1 -5
- data/legacy_migrations.gemspec +8 -8
- data/lib/legacy_migrations.rb +11 -63
- metadata +7 -14
data/README
CHANGED
data/VERSION
CHANGED
data/legacy_migrations.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{legacy_migrations}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bernie Telles"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-30}
|
13
13
|
s.description = %q{Rails plugin for transferring or updating data between two db structures.}
|
14
14
|
s.email = %q{bernardo.telles@dms.myflorida.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -47,21 +47,21 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.homepage = %q{http://github.com/btelles/legacy_migrations}
|
48
48
|
s.rdoc_options = ["--charset=UTF-8"]
|
49
49
|
s.require_paths = ["lib"]
|
50
|
-
s.rubygems_version = %q{1.3.
|
50
|
+
s.rubygems_version = %q{1.3.6}
|
51
51
|
s.summary = %q{Rails plugin for transferring or updating data between two db structures.}
|
52
52
|
s.test_files = [
|
53
|
-
"spec/
|
54
|
-
"spec/
|
53
|
+
"spec/lib/transformations_spec.rb",
|
54
|
+
"spec/db/schema.rb",
|
55
55
|
"spec/models.rb",
|
56
|
-
"spec/
|
57
|
-
"spec/
|
56
|
+
"spec/legacy_migrations_spec.rb",
|
57
|
+
"spec/spec_helper.rb"
|
58
58
|
]
|
59
59
|
|
60
60
|
if s.respond_to? :specification_version then
|
61
61
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
62
62
|
s.specification_version = 3
|
63
63
|
|
64
|
-
if Gem::Version.new(Gem::
|
64
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
65
65
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
66
66
|
else
|
67
67
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
data/lib/legacy_migrations.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'legacy_migrations/transformations'
|
2
2
|
require 'legacy_migrations/future_storage'
|
3
3
|
require 'legacy_migrations/squirrel'
|
4
|
-
require 'legacy_migrations/source_iterators'
|
5
|
-
require 'legacy_migrations/row_matchers'
|
6
4
|
module LegacyMigrations
|
7
5
|
|
8
6
|
# Define a source and destination table to transfer data
|
@@ -14,31 +12,27 @@ module LegacyMigrations
|
|
14
12
|
# This is useful when you're trying to find faulty data in the source
|
15
13
|
# table, and don't want to run the entire dataset.
|
16
14
|
# * <tt>:validate</tt> - Default = true. Use ActiveRecord validations
|
17
|
-
# when saving
|
15
|
+
# when saving destination data.
|
18
16
|
# * <tt>:source_type</tt> - Default = :active_record. Sets the source
|
19
17
|
# destination type.
|
20
18
|
# Options:
|
21
|
-
# _:
|
19
|
+
# _:active_record_: Assumes the From option is a class that inherits
|
22
20
|
# from ActiveRecord::Base, then iterates through each record of From
|
23
21
|
# table by using *From*.all.each...
|
24
22
|
# _:other_: Assumes the From option is an iterable 'collection' whose
|
25
|
-
# elements/items can respond to all
|
23
|
+
# elements/items can respond to all columns speficied in the given block.
|
26
24
|
# * <tt>:store_as</tt> - Stores the generated destination record as a key
|
27
|
-
# that is retrievable in other transformations
|
28
|
-
# source object must respond to the method <tt>id</tt> which returns
|
29
|
-
# a value that is unique for all rows within the table (usually
|
30
|
-
# this is just a primary key).
|
25
|
+
# that is retrievable in other transformations
|
31
26
|
#
|
32
27
|
# _Example_
|
33
|
-
# <tt>
|
34
|
-
# transfer_from Mammal, :to => Species, :store_as => 'new_animal' do
|
35
|
-
# match_same_name_attributes
|
36
|
-
# end
|
37
28
|
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
29
|
+
# transfer_from Mammal, :to => Species, :store_as => 'new_animal' do
|
30
|
+
# match_same_name_attributes
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# transfer_from Person, :to => Animal do
|
34
|
+
# stored 'new_animal', :to => :species
|
35
|
+
# end
|
42
36
|
#
|
43
37
|
def transfer_from(from_table, *args, &block)
|
44
38
|
|
@@ -55,52 +49,6 @@ module LegacyMigrations
|
|
55
49
|
@status_report
|
56
50
|
end
|
57
51
|
|
58
|
-
# Define a source and destination table with which to update data
|
59
|
-
#
|
60
|
-
# This method accepts all of the same options as <tt>transfer_from</tt>.
|
61
|
-
#
|
62
|
-
# In addition, you'll need to use a series of columns that match data
|
63
|
-
# from the source to the destination. For example, if your source and
|
64
|
-
# destination data have a social security number, then you'd use the
|
65
|
-
# social security number to match records from the two rows. The following
|
66
|
-
# is how you would do that.
|
67
|
-
#
|
68
|
-
# <tt>
|
69
|
-
# update_from SourceTable, :to => DestinationTable do
|
70
|
-
# based_on do
|
71
|
-
# ssn == from.social_security_number
|
72
|
-
# end
|
73
|
-
#
|
74
|
-
# from :last_name, :to => :last_name
|
75
|
-
# end
|
76
|
-
# </tt>
|
77
|
-
#
|
78
|
-
# Note that when using the 'based_on' method, the left-hannd item always
|
79
|
-
# corresponds to a column method on the destination table.
|
80
|
-
#
|
81
|
-
# The methods available in the based_on block correspond to the well-known
|
82
|
-
# squirrel plugin's syntax. Here's a quick review of the possible operators:
|
83
|
-
#
|
84
|
-
# Handles comparisons in the query. This class is analagous to the columns in the database.
|
85
|
-
# When comparing the Condition to a value, the operators are used as follows:
|
86
|
-
# * ==, === : Straight-up Equals. Can also be used as the "IN" operator if the operand is an Array.
|
87
|
-
# Additionally, when the oprand is +nil+, the comparison is correctly generates as "IS NULL"."
|
88
|
-
# * =~ : The LIKE and REGEXP operators. If the operand is a String, it will generate a LIKE
|
89
|
-
# comparison. If it is a Regexp, the REGEXP operator will be used. NOTE: MySQL regular expressions
|
90
|
-
# are NOT the same as Ruby regular expressions. Also NOTE: No wildcards are inserted into the LIKE
|
91
|
-
# comparison, so you may add them where you wish.
|
92
|
-
# * <=> : Performs a BETWEEN comparison, as long as the operand responds to both #first and #last,
|
93
|
-
# which both Ranges and Arrays do.
|
94
|
-
# * > : A simple greater-than comparison.
|
95
|
-
# * >= : Greater-than or equal-to.
|
96
|
-
# * < : A simple less-than comparison.
|
97
|
-
# * <= : Less-than or equal-to.
|
98
|
-
# * contains? : Like =~, except automatically surrounds the operand in %s, which =~ does not do.
|
99
|
-
# * nil? : Works exactly like "column == nil", but in a nicer syntax, which is what Squirrel is all about.
|
100
|
-
#
|
101
|
-
# ==== Options
|
102
|
-
#
|
103
|
-
#
|
104
52
|
def update_from(from_table, *args, &block)
|
105
53
|
|
106
54
|
configure_transfer(from_table, *args) { yield }
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legacy_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 31
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Bernie Telles
|
@@ -15,18 +14,16 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-05-30 00:00:00 -04:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rspec
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
27
|
segments:
|
31
28
|
- 1
|
32
29
|
- 2
|
@@ -80,33 +77,29 @@ rdoc_options:
|
|
80
77
|
require_paths:
|
81
78
|
- lib
|
82
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
80
|
requirements:
|
85
81
|
- - ">="
|
86
82
|
- !ruby/object:Gem::Version
|
87
|
-
hash: 3
|
88
83
|
segments:
|
89
84
|
- 0
|
90
85
|
version: "0"
|
91
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
87
|
requirements:
|
94
88
|
- - ">="
|
95
89
|
- !ruby/object:Gem::Version
|
96
|
-
hash: 3
|
97
90
|
segments:
|
98
91
|
- 0
|
99
92
|
version: "0"
|
100
93
|
requirements: []
|
101
94
|
|
102
95
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.3.
|
96
|
+
rubygems_version: 1.3.6
|
104
97
|
signing_key:
|
105
98
|
specification_version: 3
|
106
99
|
summary: Rails plugin for transferring or updating data between two db structures.
|
107
100
|
test_files:
|
108
|
-
- spec/legacy_migrations_spec.rb
|
109
101
|
- spec/lib/transformations_spec.rb
|
102
|
+
- spec/db/schema.rb
|
110
103
|
- spec/models.rb
|
104
|
+
- spec/legacy_migrations_spec.rb
|
111
105
|
- spec/spec_helper.rb
|
112
|
-
- spec/db/schema.rb
|