paraphraser 0.1.10 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.2.0
@@ -11,7 +11,10 @@ module Paraphraser
11
11
 
12
12
  def convert
13
13
  with_activerecord_stubbed do
14
- migrations.each { |migration| migration.migrate(direction) }
14
+ migrations.each do |migration|
15
+ announce "#{migration.version} : #{migration.name}"
16
+ migration.migrate(direction)
17
+ end
15
18
  end
16
19
  end
17
20
 
@@ -26,26 +29,36 @@ module Paraphraser
26
29
  end
27
30
 
28
31
  def with_activerecord_stubbed(&block)
29
- apply_stubs
32
+ ActiveRecord::Migration.verbose = false
33
+ apply_overrides
30
34
  yield
31
- reset_stubs
32
35
  end
33
36
 
34
- def apply_stubs
35
- connection.class.send(:alias_method, :real_execute, :execute)
36
- connection.instance_eval do
37
- def execute(*args)
38
- p '--', args.first
39
- end
37
+ def apply_overrides
38
+ connection.class.send(:define_method, :execute) do |sql, name = nil, skip_logging = false|
39
+ print "#{sql};\n"
40
+ STDOUT.flush
41
+ end
42
+ connection.class.send(:define_method, :initialize_schema_migrations_table) { }
43
+ connection.class.send(:define_method, :tables) { |*args| [] }
44
+ connection.class.send(:define_method, :index_name_exists?) {|*args| false }
45
+ connection.class.send(:define_method, :rename_column) do |table_name, column_name, new_column_name|
46
+ execute "ALTER TABLE #{quote_table_name(table_name)} RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}"
47
+ end
48
+ connection.class.send(:define_method, :change_column) do |table_name, column_name, type, options = {}|
49
+ execute "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"
50
+ end
51
+ connection.class.send(:define_method, :change_column_default) do |table_name, column_name, default|
52
+ execute "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} SET DEFAULT #{quote(default)}"
40
53
  end
41
54
  end
42
55
 
43
- def reset_stubs
44
- connection.class.send(:alias_method, :execute, :real_execute)
56
+ def announce(text)
57
+ length = [0, 90 - text.length].max
58
+ print "\n-- %s %s\n" % [text, "-" * length]
45
59
  end
46
-
60
+
47
61
  end
48
62
 
49
63
  end
50
64
  end
51
-
@@ -1,7 +1,6 @@
1
1
  namespace :db do
2
2
  desc 'provides a rake task to convert migrations to sql statements for *the dba*.'
3
3
  task :paraphrase => :environment do
4
- p 'paraphrasing'
5
4
  Paraphraser::Convertor.convert
6
5
  end
7
6
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{paraphraser}
8
- s.version = "0.1.10"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Vinay Patel"]
12
- s.date = %q{2010-12-29}
12
+ s.date = %q{2010-12-30}
13
13
  s.description = %q{provides a rake task to convert migrations to sql statements for *the dba*.}
14
14
  s.email = %q{mail@vinayvinay.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 10
9
- version: 0.1.10
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Vinay Patel
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-29 00:00:00 -06:00
17
+ date: 2010-12-30 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- hash: 825956019
88
+ hash: 498993587
89
89
  segments:
90
90
  - 0
91
91
  version: "0"