data_transformation 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,3 +1,19 @@
1
+ ## Installing the Transformer ##
2
+ Add it as a hook to your existing rake tasks in Rakefile
3
+
4
+ Rake::Task['db:schema:load'].enhance do
5
+ Rake::Task['db:transform:load'].invoke
6
+ end
7
+
8
+ Rake::Task['db:schema:dump'].enhance do
9
+ Rake::Task['db:transform:dump'].invoke
10
+ end
11
+
12
+ Rake::Task['db:migrate'].enhance do
13
+ Rake::Task['db:transform'].invoke
14
+ end
15
+
16
+
1
17
  ## Using the Transformer ##
2
18
 
3
19
  It's just like migrating, moreso than you probably originally thought.
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_path = "lib"
22
22
 
23
- s.add_dependency "activerecord", "~> 3.0.0"
24
- s.add_development_dependency "bundler", "~> 1.0.0"
25
- s.add_development_dependency "rspec", "~> 2.5.0"
26
- s.add_development_dependency "generator_spec", "~> 0.8.2"
23
+ s.add_dependency "activerecord"
24
+ s.add_development_dependency "bundler"
25
+ s.add_development_dependency "rspec"
26
+ s.add_development_dependency "generator_spec"
27
27
  s.add_development_dependency "sqlite3"
28
28
  end
@@ -1,10 +1,10 @@
1
1
  module DataTransformation
2
- class Schema < DataTransformation::Transformation
3
- def self.define(info={})
4
- unless info[:version].blank?
5
- initialize_schema_migrations_table
6
- assume_migrated_upto_version(info[:version], DataTransformation::Transformer.migrations_path)
7
- end
8
- end
9
- end
2
+ class Schema < DataTransformation::Transformation
3
+ def self.define(info={})
4
+ unless info[:version].blank?
5
+ initialize_schema_migrations_table
6
+ ActiveRecord::Base.connection.assume_migrated_upto_version(info[:version], DataTransformation::Transformer.migrations_path)
7
+ end
8
+ end
9
+ end
10
10
  end
@@ -1,9 +1,9 @@
1
1
  require 'active_record/migration'
2
2
 
3
3
  module DataTransformation
4
- class Transformation < ActiveRecord::Migration
5
- def transform(direction)
6
- migrate(direction)
7
- end
8
- end
4
+ class Transformation < ActiveRecord::Migration
5
+ def transform(direction)
6
+ migrate(direction)
7
+ end
8
+ end
9
9
  end
@@ -1,36 +1,36 @@
1
1
  require 'active_record/migration'
2
2
 
3
3
  module DataTransformation
4
- class Transformer < ActiveRecord::Migrator
5
- class << self
6
- def transform(transforms_path, target_version=nil)
7
- migrate(transforms_path, target_version)
8
- end
4
+ class Transformer < ActiveRecord::Migrator
5
+ class << self
6
+ def transform(transforms_path, target_version=nil)
7
+ migrate(transforms_path, target_version)
8
+ end
9
9
 
10
- def migrations_paths
11
- @migrations_paths ||= ['db/transforms']
12
- Array.wrap(@migrations_paths)
13
- end
14
-
15
- def migrations_path
16
- migrations_paths.first
17
- end
10
+ def migrations_paths
11
+ @migrations_paths ||= ['db/transforms']
12
+ Array.wrap(@migrations_paths)
13
+ end
18
14
 
19
- def down
20
- raise "Unimplemented as a Transformation"
21
- end
15
+ def migrations_path
16
+ migrations_paths.first
17
+ end
22
18
 
23
- def forward
24
- raise "Unimplemented as a Transformation"
25
- end
19
+ def down
20
+ raise "Unimplemented as a Transformation"
21
+ end
26
22
 
27
- def rollback
28
- raise "Unimplemented as a Transformation"
29
- end
23
+ def forward
24
+ raise "Unimplemented as a Transformation"
25
+ end
30
26
 
31
- def schema_migrations_table_name
32
- ActiveRecord::Base.table_name_prefix + "schema_transforms" + ActiveRecord::Base.table_name_suffix
33
- end
34
- end
35
- end
27
+ def rollback
28
+ raise "Unimplemented as a Transformation"
29
+ end
30
+
31
+ def schema_migrations_table_name
32
+ ActiveRecord::Base.table_name_prefix + "schema_transforms" + ActiveRecord::Base.table_name_suffix
33
+ end
34
+ end
35
+ end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module DataTransformations
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -4,9 +4,9 @@ require "data_transformation/transformation"
4
4
  require "data_transformation/schema"
5
5
 
6
6
  module DataTransformation
7
- class Railtie < Rails::Railtie
8
- rake_tasks do
9
- load 'tasks/data_transformations.rake'
10
- end
11
- end
7
+ class Railtie < Rails::Railtie
8
+ rake_tasks do
9
+ load 'tasks/data_transformations.rake'
10
+ end
11
+ end
12
12
  end
@@ -1,4 +1,4 @@
1
1
  class <%= migration_class_name %> < DataTransformation::Transformation
2
- def self.up
3
- end
2
+ def self.up
3
+ end
4
4
  end
@@ -37,42 +37,42 @@ end
37
37
  desc "Undoes the hack in Active Record for the migrations"
38
38
  task :undo_hack_in_ar do
39
39
  class << ActiveRecord::Migrator
40
- alias_method :schema_migrations_table_name, :original_schema_migrations_table_name
40
+ alias_method :schema_migrations_table_name, :original_schema_migrations_table_name
41
41
  end
42
42
 
43
43
  ActiveRecord::ConnectionAdapters::SchemaStatements.module_eval do
44
- alias_method :initialize_schema_migrations_table, :original_initialize_schema_migrations_table
44
+ alias_method :initialize_schema_migrations_table, :original_initialize_schema_migrations_table
45
45
  end
46
46
  end
47
47
 
48
48
  namespace :db do
49
- desc "Transform the database (options: VERSION=x, VERBOSE=false)."
50
- task :transform => [:environment, :hack_in_ar] do
51
- DataTransformation::Transformation.verbose = ENV['VERBOSE'] ? ENV['VERBOSE'] == "true" : true
52
- DataTransformation::Transformer.transform('db/transforms/', ENV['VERSION'] ? ENV['VERSION'].to_i : nil)
53
- Rake::Task["db:transform:dump"].invoke
54
- end
49
+ desc "Transform the database (options: VERSION=x, VERBOSE=false)."
50
+ task :transform => [:environment, :hack_in_ar] do
51
+ DataTransformation::Transformation.verbose = ENV['VERBOSE'] ? ENV['VERBOSE'] == "true" : true
52
+ DataTransformation::Transformer.transform('db/transforms/', ENV['VERSION'] ? ENV['VERSION'].to_i : nil)
53
+ Rake::Task["db:transform:dump"].invoke
54
+ end
55
55
 
56
- namespace :transform do
57
- desc "Dump the Transform schema."
58
- task :dump => [:environment, :hack_in_ar] do
59
- filename = ENV['SCHEMA'] || "#{Rails.root}/db/transform_schema.rb"
60
- File.open(filename, 'w') do |f|
61
- version = DataTransformation::Transformer::current_version rescue nil
62
- f.puts "DataTransformation::Schema.define(:version => #{version})"
63
- end
64
- Rake::Task['undo_hack_in_ar'].invoke
65
- end
56
+ namespace :transform do
57
+ desc "Dump the Transform schema."
58
+ task :dump => [:environment, :hack_in_ar] do
59
+ filename = ENV['SCHEMA'] || "#{Rails.root}/db/transform_schema.rb"
60
+ File.open(filename, 'w') do |f|
61
+ version = DataTransformation::Transformer::current_version rescue nil
62
+ f.puts "DataTransformation::Schema.define(:version => #{version})"
63
+ end
64
+ Rake::Task['undo_hack_in_ar'].invoke
65
+ end
66
66
 
67
- desc "Load the Transform schema."
68
- task :load => [:environment, :hack_in_ar] do
69
- filename = ENV['SCHEMA'] || "#{Rails.root}/db/transform_schema.rb"
70
- if File.exists?(filename)
71
- load(filename)
72
- else
73
- abort %{#{filename} doesn't exist yet. Run 'rake db:transform' to create it and then try again.}
74
- end
75
- Rake::Task['undo_hack_in_ar'].invoke
76
- end
77
- end
67
+ desc "Load the Transform schema."
68
+ task :load => [:environment, :hack_in_ar] do
69
+ filename = ENV['SCHEMA'] || "#{Rails.root}/db/transform_schema.rb"
70
+ if File.exists?(filename)
71
+ load(filename)
72
+ else
73
+ abort %{#{filename} doesn't exist yet. Run 'rake db:transform' to create it and then try again.}
74
+ end
75
+ Rake::Task['undo_hack_in_ar'].invoke
76
+ end
77
+ end
78
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_transformation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,55 +9,55 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-01 00:00:00.000000000Z
12
+ date: 2011-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &2153431640 !ruby/object:Gem::Requirement
16
+ requirement: &70253803662560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 3.0.0
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153431640
24
+ version_requirements: *70253803662560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &2153463680 !ruby/object:Gem::Requirement
27
+ requirement: &70253803661600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ~>
30
+ - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 1.0.0
32
+ version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2153463680
35
+ version_requirements: *70253803661600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2153463220 !ruby/object:Gem::Requirement
38
+ requirement: &70253803661120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ~>
41
+ - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 2.5.0
43
+ version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153463220
46
+ version_requirements: *70253803661120
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: generator_spec
49
- requirement: &2153462760 !ruby/object:Gem::Requirement
49
+ requirement: &70253803660640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ~>
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.8.2
54
+ version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2153462760
57
+ version_requirements: *70253803660640
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sqlite3
60
- requirement: &2153462380 !ruby/object:Gem::Requirement
60
+ requirement: &70253803659840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2153462380
68
+ version_requirements: *70253803659840
69
69
  description: To keep the necessity of changing data out of migrations, transformations
70
70
  keep track of that
71
71
  email:
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: 1.3.6
115
115
  requirements: []
116
116
  rubyforge_project: data_transformation
117
- rubygems_version: 1.8.6
117
+ rubygems_version: 1.8.10
118
118
  signing_key:
119
119
  specification_version: 3
120
120
  summary: Rails 3 Data Transformations