ridgepole 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -0
  3. data/README.md +21 -21
  4. data/lib/ridgepole.rb +0 -1
  5. data/lib/ridgepole/diff.rb +2 -2
  6. data/lib/ridgepole/dumper.rb +1 -1
  7. data/lib/ridgepole/version.rb +1 -1
  8. data/spec/0_diff/dump_disable_unsigned_spec.rb +1 -1
  9. data/spec/diff/diff_spec.rb +1 -1
  10. data/spec/dump/dump_class_method_spec.rb +1 -1
  11. data/spec/dump/dump_some_tables_spec.rb +2 -2
  12. data/spec/dump/dump_spec.rb +1 -1
  13. data/spec/migrate/migrate_add_column_spec.rb +3 -3
  14. data/spec/migrate/migrate_change_column_spec.rb +3 -3
  15. data/spec/migrate/migrate_change_table_option_spec.rb +2 -2
  16. data/spec/migrate/migrate_create_index_spec.rb +3 -3
  17. data/spec/migrate/migrate_create_table_spec.rb +3 -3
  18. data/spec/migrate/migrate_drop_column_spec.rb +3 -3
  19. data/spec/migrate/migrate_drop_index_spec.rb +3 -3
  20. data/spec/migrate/migrate_drop_table_spec.rb +3 -3
  21. data/spec/migrate/migrate_empty_spec.rb +3 -3
  22. data/spec/migrate/migrate_merge_mode_spec.rb +2 -2
  23. data/spec/migrate/migrate_rename_column_spec.rb +7 -7
  24. data/spec/migrate/migrate_rename_table_spec.rb +5 -5
  25. data/spec/migrate/migrate_same_default_null_spec.rb +4 -4
  26. data/spec/migrate/migrate_same_default_unsigned_spec.rb +4 -4
  27. data/spec/migrate/migrate_same_spec.rb +2 -2
  28. data/spec/migrate/migrate_skip_rename_column_spec.rb +5 -5
  29. data/spec/migrate/migrate_skip_rename_table_spec.rb +3 -3
  30. data/spec/migrate/migrate_with_ignore_tables_spec.rb +5 -5
  31. data/spec/migrate/migrate_with_tables_spec.rb +5 -5
  32. data/spec/spec_helper.rb +1 -0
  33. data/spec/string_ext.rb +0 -10
  34. metadata +3 -3
  35. data/lib/ridgepole/string_ext.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2356f9b779b9119757eb4ef1a164b64e7c300bb3
4
- data.tar.gz: ba5282a5f09799f4c69ab8cf39d810f5731098c0
3
+ metadata.gz: 5cedd9f4e2b3aea9219a4d1af456767e3f5711c1
4
+ data.tar.gz: 23174d2ebecd2aa64c402222557a791b32016eb7
5
5
  SHA512:
6
- metadata.gz: ca299b961a46df66acf0e446f3171efe6f41a8fdf0143f9e3261dac694333721aa7869e3bf4656a2134aad006001ba5d4ad88e0e3e41e9d57c418cd2fa136d14
7
- data.tar.gz: 14fab8ed7d0962d4f3f67a5e2d5363035a2913faed67de36bc86d1592c82905d60e25d0ba47b313ca0b0f736b3faf17ea7dfd29d94293f78d3990ceea7d5e2d3
6
+ metadata.gz: d953e35d399c6ecf1b8df3df9a6c559569826f3eabe58d9909b2a287bbeaef28e1f24c19204c613f45c76f741788243078d64b7115e4f85d9dc0b9ad29f57240
7
+ data.tar.gz: f7200deace1bfc4f5cc293f68c61c1463e2aeb77d40128ae9059a3950c51dd5cdb7ee69c7d5920e51d52fcf5c9d6016a359e0ac66d1119ddd381fbe05ce35caf
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script:
5
+ - bundle install
6
+ - bundle exec rake
data/README.md CHANGED
@@ -6,7 +6,7 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
6
6
  (like Chef/Puppet)
7
7
 
8
8
  [![Gem Version](https://badge.fury.io/rb/ridgepole.png)](http://badge.fury.io/rb/ridgepole)
9
- [![Build Status](https://drone.io/github.com/winebarrel/ridgepole/status.png)](https://drone.io/github.com/winebarrel/ridgepole/latest)
9
+ [![Build Status](https://travis-ci.org/winebarrel/ridgepole.svg?branch=master)](https://travis-ci.org/winebarrel/ridgepole)
10
10
 
11
11
  ## Installation
12
12
 
@@ -100,6 +100,25 @@ Apply `Schemafile`
100
100
  -> 0.0202s
101
101
  ```
102
102
 
103
+ ## Rename
104
+ ```sh
105
+ create_table "articles", force: true do |t|
106
+ t.string "title"
107
+ t.text "desc", renamed_from: "text"
108
+ t.text "author"
109
+ t.datetime "created_at"
110
+ t.datetime "updated_at"
111
+ end
112
+
113
+ create_table "user_comments", force: true, renamed_from: "comments" do |t|
114
+ t.string "commenter"
115
+ t.text "body"
116
+ t.integer "article_id"
117
+ t.datetime "created_at"
118
+ t.datetime "updated_at"
119
+ end
120
+ ```
121
+
103
122
  ## Diff
104
123
  ```sh
105
124
  $ ridgepole --diff file1.schema file2.schema
@@ -117,25 +136,6 @@ $ ridgepole --diff config.yml file1.schema
117
136
  remove_column("articles", "author")
118
137
  ```
119
138
 
120
- ### Rename
121
- ```sh
122
- create_table "articles", force: true do |t|
123
- t.string "title"
124
- t.text "desc", rename_from: "text"
125
- t.text "author"
126
- t.datetime "created_at"
127
- t.datetime "updated_at"
128
- end
129
-
130
- create_table "user_comments", force: true, rename_from: "comments" do |t|
131
- t.string "commenter"
132
- t.text "body"
133
- t.integer "article_id"
134
- t.datetime "created_at"
135
- t.datetime "updated_at"
136
- end
137
- ```
138
-
139
139
  ### Reverse diff
140
140
  ```sh
141
141
  $ cat file1.schema
@@ -149,7 +149,7 @@ end
149
149
  $ cat file2.schema
150
150
  create_table "articles", force: true do |t|
151
151
  t.string "title"
152
- t.text "desc", rename_from: "text"
152
+ t.text "desc", renamed_from: "text"
153
153
  t.text "author"
154
154
  t.datetime "created_at"
155
155
  t.datetime "updated_at"
data/lib/ridgepole.rb CHANGED
@@ -14,5 +14,4 @@ require 'ridgepole/dumper'
14
14
  require 'ridgepole/logger'
15
15
  require 'ridgepole/migration_ext'
16
16
  require 'ridgepole/schema_dumper_ext'
17
- require 'ridgepole/string_ext'
18
17
  require 'ridgepole/version'
@@ -45,7 +45,7 @@ class Ridgepole::Diff
45
45
  to.dup.each do |table_name, to_attrs|
46
46
  next unless target?(table_name)
47
47
 
48
- if (from_table_name = (to_attrs[:options] || {}).delete(:rename_from))
48
+ if (from_table_name = (to_attrs[:options] || {}).delete(:renamed_from))
49
49
  # Already renamed
50
50
  next if from[table_name]
51
51
 
@@ -140,7 +140,7 @@ class Ridgepole::Diff
140
140
 
141
141
  def scan_column_rename(from, to, definition_delta)
142
142
  to.dup.each do |column_name, to_attrs|
143
- if (from_column_name = (to_attrs[:options] || {}).delete(:rename_from))
143
+ if (from_column_name = (to_attrs[:options] || {}).delete(:renamed_from))
144
144
  # Already renamed
145
145
  next if from[column_name]
146
146
 
@@ -34,7 +34,7 @@ class Ridgepole::Dumper
34
34
  line !~ /\A#/ &&
35
35
  line !~ /\AActiveRecord::Schema\.define/ &&
36
36
  line !~ /\Aend/
37
- }.join.undent.strip
37
+ }.join.strip_heredoc.strip
38
38
 
39
39
  definitions = []
40
40
 
@@ -1,3 +1,3 @@
1
1
  module Ridgepole
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -4,7 +4,7 @@ describe 'Ridgepole::Client#dump' do
4
4
  subject { client(disable_mysql_unsigned: true) }
5
5
 
6
6
  it {
7
- expect(subject.dump).to eq (<<-RUBY).undent.strip
7
+ expect(subject.dump).to eq <<-RUBY.strip_heredoc.strip
8
8
  create_table "clubs", force: true do |t|
9
9
  t.string "name", default: "", null: false
10
10
  end
@@ -143,7 +143,7 @@ describe 'Ridgepole::Client.diff' do
143
143
  it {
144
144
  delta = subject.diff(actual_dsl, expected_dsl)
145
145
  expect(delta.differ?).to be_truthy
146
- expect(delta.script).to eq (<<-RUBY).undent.strip
146
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
147
147
  change_column("employee_clubs", "club_id", :integer, {:unsigned=>false, :null=>true})
148
148
 
149
149
  change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX", :null=>false, :unsigned=>false})
@@ -4,7 +4,7 @@ describe 'Ridgepole::Client.dump' do
4
4
  subject { Ridgepole::Client }
5
5
 
6
6
  it {
7
- expect(subject.dump(conn_spec)).to eq (<<-RUBY).undent.strip
7
+ expect(subject.dump(conn_spec)).to eq <<-RUBY.strip_heredoc.strip
8
8
  create_table "clubs", force: true do |t|
9
9
  t.string "name", default: "", null: false
10
10
  end
@@ -4,7 +4,7 @@ describe 'Ridgepole::Client#dump' do
4
4
  subject { client(tables: ['employees', 'salaries']) }
5
5
 
6
6
  it {
7
- expect(subject.dump).to eq (<<-RUBY).undent.strip
7
+ expect(subject.dump).to eq <<-RUBY.strip_heredoc.strip
8
8
  create_table "employees", primary_key: "emp_no", force: true do |t|
9
9
  t.date "birth_date", null: false
10
10
  t.string "first_name", limit: 14, null: false
@@ -39,7 +39,7 @@ describe 'Ridgepole::Client#dump' do
39
39
  }
40
40
 
41
41
  it {
42
- expect(subject.dump).to eq (<<-RUBY).undent.strip
42
+ expect(subject.dump).to eq <<-RUBY.strip_heredoc.strip
43
43
  create_table "employees", primary_key: "emp_no", force: true do |t|
44
44
  t.date "birth_date", null: false
45
45
  t.string "first_name", limit: 14, null: false
@@ -4,7 +4,7 @@ describe 'Ridgepole::Client#dump' do
4
4
  subject { client }
5
5
 
6
6
  it {
7
- expect(subject.dump).to eq (<<-RUBY).undent.strip
7
+ expect(subject.dump).to eq <<-RUBY.strip_heredoc.strip
8
8
  create_table "clubs", force: true do |t|
9
9
  t.string "name", default: "", null: false
10
10
  end
@@ -147,15 +147,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
147
147
  it {
148
148
  delta = subject.diff(expected_dsl)
149
149
  expect(delta.differ?).to be_truthy
150
- expect(subject.dump).to eq actual_dsl.undent.strip
150
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
151
151
  delta.migrate
152
- expect(subject.dump).to eq expected_dsl.undent.strip
152
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
153
153
  }
154
154
 
155
155
  it {
156
156
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
157
157
  expect(delta.differ?).to be_truthy
158
- expect(delta.script).to eq (<<-RUBY).undent.strip
158
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
159
159
  remove_column("employee_clubs", "any_col")
160
160
 
161
161
  remove_column("employees", "age")
@@ -144,15 +144,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
144
144
  it {
145
145
  delta = subject.diff(expected_dsl)
146
146
  expect(delta.differ?).to be_truthy
147
- expect(subject.dump).to eq actual_dsl.undent.strip
147
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
148
148
  delta.migrate
149
- expect(subject.dump).to eq expected_dsl.undent.strip.gsub(/(\s*,\s*unsigned: false)?\s*,\s*null: true/, '')
149
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/(\s*,\s*unsigned: false)?\s*,\s*null: true/, '')
150
150
  }
151
151
 
152
152
  it {
153
153
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
154
154
  expect(delta.differ?).to be_truthy
155
- expect(delta.script).to eq (<<-RUBY).undent.strip
155
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
156
156
  change_column("employee_clubs", "club_id", :integer, {:unsigned=>true, :null=>false})
157
157
 
158
158
  change_column("employees", "last_name", :string, {:limit=>16, :null=>false, :unsigned=>false})
@@ -32,9 +32,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
32
32
  expect(Ridgepole::Logger.instance).to receive(:warn).with('[WARNING] Table `employees` options cannot be changed')
33
33
  delta = subject.diff(expected_dsl)
34
34
  expect(delta.differ?).to be_falsey
35
- expect(subject.dump).to eq actual_dsl.undent.strip
35
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
36
36
  delta.migrate
37
- expect(subject.dump).to eq actual_dsl.undent.strip
37
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
38
38
  }
39
39
 
40
40
  it {
@@ -83,15 +83,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
83
83
  it {
84
84
  delta = subject.diff(expected_dsl)
85
85
  expect(delta.differ?).to be_truthy
86
- expect(subject.dump.delete_empty_lines).to eq actual_dsl.undent.strip.delete_empty_lines
86
+ expect(subject.dump.delete_empty_lines).to eq actual_dsl.strip_heredoc.strip.delete_empty_lines
87
87
  delta.migrate
88
- expect(subject.dump.delete_empty_lines).to eq expected_dsl.undent.strip.delete_empty_lines
88
+ expect(subject.dump.delete_empty_lines).to eq expected_dsl.strip_heredoc.strip.delete_empty_lines
89
89
  }
90
90
 
91
91
  it {
92
92
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
93
93
  expect(delta.differ?).to be_truthy
94
- expect(delta.script).to eq (<<-RUBY).undent.strip
94
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
95
95
  remove_index("clubs", {:name=>"idx_name"})
96
96
 
97
97
  remove_index("employee_clubs", {:name=>"idx_emp_no_club_id"})
@@ -83,15 +83,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
83
83
  it {
84
84
  delta = subject.diff(expected_dsl)
85
85
  expect(delta.differ?).to be_truthy
86
- expect(subject.dump.delete_empty_lines).to eq actual_dsl.undent.strip.delete_empty_lines
86
+ expect(subject.dump.delete_empty_lines).to eq actual_dsl.strip_heredoc.strip.delete_empty_lines
87
87
  delta.migrate
88
- expect(subject.dump.delete_empty_lines).to eq expected_dsl.undent.strip.delete_empty_lines
88
+ expect(subject.dump.delete_empty_lines).to eq expected_dsl.strip_heredoc.strip.delete_empty_lines
89
89
  }
90
90
 
91
91
  it {
92
92
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
93
93
  expect(delta.differ?).to be_truthy
94
- expect(delta.script).to eq (<<-RUBY).undent.strip
94
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
95
95
  drop_table("clubs")
96
96
 
97
97
  drop_table("employee_clubs")
@@ -137,15 +137,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
137
137
  it {
138
138
  delta = subject.diff(expected_dsl)
139
139
  expect(delta.differ?).to be_truthy
140
- expect(subject.dump).to eq actual_dsl.undent.strip
140
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
141
141
  delta.migrate
142
- expect(subject.dump).to eq expected_dsl.undent.strip
142
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
143
143
  }
144
144
 
145
145
  it {
146
146
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
147
147
  expect(delta.differ?).to be_truthy
148
- expect(delta.script).to eq (<<-RUBY).undent.strip
148
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
149
149
  add_column("dept_emp", "from_date", :date, {:null=>false, :after=>"dept_no"})
150
150
  add_column("dept_emp", "to_date", :date, {:null=>false, :after=>"from_date"})
151
151
 
@@ -83,15 +83,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
83
83
  it {
84
84
  delta = subject.diff(expected_dsl)
85
85
  expect(delta.differ?).to be_truthy
86
- expect(subject.dump).to eq actual_dsl.undent.strip
86
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
87
87
  delta.migrate
88
- expect(subject.dump.each_line.select {|i| i !~ /\A\Z/ }.join).to eq expected_dsl.undent.strip.each_line.select {|i| i !~ /\A\Z/ }.join
88
+ expect(subject.dump.each_line.select {|i| i !~ /\A\Z/ }.join).to eq expected_dsl.strip_heredoc.strip.each_line.select {|i| i !~ /\A\Z/ }.join
89
89
  }
90
90
 
91
91
  it {
92
92
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
93
93
  expect(delta.differ?).to be_truthy
94
- expect(delta.script).to eq (<<-RUBY).undent.strip
94
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
95
95
  add_index("clubs", ["name"], {:name=>"idx_name", :unique=>true, :using=>:btree})
96
96
 
97
97
  add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_emp_no_club_id", :using=>:btree})
@@ -83,15 +83,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
83
83
  it {
84
84
  delta = subject.diff(expected_dsl)
85
85
  expect(delta.differ?).to be_truthy
86
- expect(subject.dump).to eq actual_dsl.undent.strip
86
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
87
87
  delta.migrate
88
- expect(subject.dump.each_line.select {|i| i !~ /\A\Z/ }.join).to eq expected_dsl.undent.strip.each_line.select {|i| i !~ /\A\Z/ }.join
88
+ expect(subject.dump.each_line.select {|i| i !~ /\A\Z/ }.join).to eq expected_dsl.strip_heredoc.strip.each_line.select {|i| i !~ /\A\Z/ }.join
89
89
  }
90
90
 
91
91
  it {
92
92
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
93
93
  expect(delta.differ?).to be_truthy
94
- expect(delta.script).to eq (<<-RUBY).undent.strip
94
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
95
95
  create_table("clubs", {}) do |t|
96
96
  t.string("name", {:default=>"", :null=>false})
97
97
  end
@@ -75,15 +75,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
75
75
  it {
76
76
  delta = subject.diff(expected_dsl)
77
77
  expect(delta.differ?).to be_truthy
78
- expect(subject.dump).to eq actual_dsl.undent.strip
78
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
79
79
  delta.migrate
80
- expect(subject.dump).to eq expected_dsl.undent.strip
80
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
81
81
  }
82
82
 
83
83
  it {
84
84
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
85
85
  expect(delta.differ?).to be_truthy
86
- expect(delta.script).to eq (<<-RUBY).undent.strip
86
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
87
87
  drop_table("clubs")
88
88
 
89
89
  drop_table("departments")
@@ -148,10 +148,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
148
148
  it {
149
149
  delta = subject.diff(expected_dsl.delete_create_table('clubs'))
150
150
  expect(delta.differ?).to be_truthy
151
- expect(subject.dump).to eq actual_dsl.undent.strip
151
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
152
152
  delta.migrate
153
153
  # `clubs` table is not deleted
154
- expect(subject.dump).to eq expected_dsl.undent.strip
154
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
155
155
  }
156
156
 
157
157
  it {
@@ -86,7 +86,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
86
86
  create_table "dept_emp", id: false, force: true do |t|
87
87
  t.integer "emp_no", null: false
88
88
  t.string "dept_no", limit: 4, null: false
89
- t.date "from_date2", null: false, rename_from: 'from_date'
89
+ t.date "from_date2", null: false, renamed_from: 'from_date'
90
90
  t.date "to_date", null: false
91
91
  end
92
92
 
@@ -97,7 +97,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
97
97
  t.string "dept_no", limit: 4, null: false
98
98
  t.integer "emp_no", null: false
99
99
  t.date "from_date", null: false
100
- t.date "to_date2", null: false, rename_from: 'to_date'
100
+ t.date "to_date2", null: false, renamed_from: 'to_date'
101
101
  end
102
102
 
103
103
  add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
@@ -114,7 +114,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
114
114
  t.date "birth_date", null: false
115
115
  t.string "first_name", limit: 14, null: false
116
116
  t.string "last_name", limit: 16, null: false
117
- t.string "gender2", limit: 1, null: false, rename_from: 'gender'
117
+ t.string "gender2", limit: 1, null: false, renamed_from: 'gender'
118
118
  t.date "hire_date", null: false
119
119
  end
120
120
 
@@ -144,15 +144,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
144
144
  it {
145
145
  delta = subject.diff(expected_dsl)
146
146
  expect(delta.differ?).to be_truthy
147
- expect(subject.dump).to eq actual_dsl.undent.strip
147
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
148
148
  delta.migrate
149
- expect(subject.dump).to eq expected_dsl.undent.strip.gsub(/\s*,\s*rename_from:.*$/, '')
149
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/\s*,\s*renamed_from:.*$/, '')
150
150
  }
151
151
 
152
152
  it {
153
153
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
154
154
  expect(delta.differ?).to be_truthy
155
- expect(delta.script).to eq (<<-RUBY).undent.strip
155
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
156
156
  rename_column("dept_emp", "from_date2", "from_date")
157
157
 
158
158
  rename_column("dept_manager", "to_date2", "to_date")
@@ -172,7 +172,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
172
172
  t.date "birth_date", null: false
173
173
  t.string "first_name", limit: 14, null: false
174
174
  t.string "last_name", limit: 16, null: false
175
- t.string "gender2", limit: 1, null: false, rename_from: 'age'
175
+ t.string "gender2", limit: 1, null: false, renamed_from: 'age'
176
176
  t.date "hire_date", null: false
177
177
  end
178
178
  RUBY
@@ -110,7 +110,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
110
110
 
111
111
  add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
112
112
 
113
- create_table "employees2", primary_key: "emp_no", force: true, rename_from: 'employees' do |t|
113
+ create_table "employees2", primary_key: "emp_no", force: true, renamed_from: 'employees' do |t|
114
114
  t.date "birth_date", null: false
115
115
  t.string "first_name", limit: 14, null: false
116
116
  t.string "last_name", limit: 16, null: false
@@ -144,15 +144,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
144
144
  it {
145
145
  delta = subject.diff(expected_dsl)
146
146
  expect(delta.differ?).to be_truthy
147
- expect(subject.dump).to eq actual_dsl.undent.strip
147
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
148
148
  delta.migrate
149
- expect(subject.dump).to eq expected_dsl.undent.strip.gsub(/, rename_from: 'employees'/, '')
149
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/, renamed_from: 'employees'/, '')
150
150
  }
151
151
 
152
152
  it {
153
153
  delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
154
154
  expect(delta.differ?).to be_truthy
155
- expect(delta.script).to eq (<<-RUBY).undent.strip
155
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
156
156
  rename_table("employees2", "employees")
157
157
  RUBY
158
158
  }
@@ -164,7 +164,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
164
164
 
165
165
  let(:dsl) {
166
166
  <<-RUBY
167
- create_table "employees2", primary_key: "emp_no", force: true, rename_from: 'not_employees' do |t|
167
+ create_table "employees2", primary_key: "emp_no", force: true, renamed_from: 'not_employees' do |t|
168
168
  t.date "birth_date", null: false
169
169
  t.string "first_name", limit: 14, null: false
170
170
  t.string "last_name", limit: 16, null: false
@@ -30,9 +30,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
30
30
  it {
31
31
  delta = subject.diff(expected_dsl)
32
32
  expect(delta.differ?).to be_falsey
33
- expect(subject.dump).to eq actual_dsl.undent.strip
33
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
34
34
  delta.migrate
35
- expect(subject.dump).to eq expected_dsl.undent.strip.gsub(/\s*,\s*null: true/, '')
35
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/\s*,\s*null: true/, '')
36
36
  }
37
37
  end
38
38
 
@@ -67,9 +67,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
67
67
  it {
68
68
  delta = subject.diff(expected_dsl)
69
69
  expect(delta.differ?).to be_falsey
70
- expect(subject.dump).to eq actual_dsl.undent.strip.gsub(/\s*,\s*null: true/, '')
70
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip.gsub(/\s*,\s*null: true/, '')
71
71
  delta.migrate
72
- expect(subject.dump).to eq expected_dsl.undent.strip
72
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
73
73
  }
74
74
  end
75
75
  end
@@ -24,9 +24,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
24
24
  it {
25
25
  delta = subject.diff(expected_dsl)
26
26
  expect(delta.differ?).to be_falsey
27
- expect(subject.dump).to eq actual_dsl.undent.strip
27
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
28
28
  delta.migrate
29
- expect(subject.dump).to eq expected_dsl.undent.strip.gsub('unsigned: false,', ' ')
29
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub('unsigned: false,', ' ')
30
30
  }
31
31
  end
32
32
 
@@ -55,9 +55,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
55
55
  it {
56
56
  delta = subject.diff(expected_dsl)
57
57
  expect(delta.differ?).to be_falsey
58
- expect(subject.dump).to eq actual_dsl.undent.strip.gsub('unsigned: false,', ' ')
58
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip.gsub('unsigned: false,', ' ')
59
59
  delta.migrate
60
- expect(subject.dump).to eq expected_dsl.undent.strip
60
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
61
61
  }
62
62
  end
63
63
  end
@@ -75,9 +75,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
75
75
  it {
76
76
  delta = subject.diff(dsl)
77
77
  expect(delta.differ?).to be_falsey
78
- expect(subject.dump).to eq dsl.undent.strip
78
+ expect(subject.dump).to eq dsl.strip_heredoc.strip
79
79
  delta.migrate
80
- expect(subject.dump).to eq dsl.undent.strip
80
+ expect(subject.dump).to eq dsl.strip_heredoc.strip
81
81
  }
82
82
  end
83
83
  end
@@ -86,7 +86,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
86
86
  create_table "dept_emp", id: false, force: true do |t|
87
87
  t.integer "emp_no", null: false
88
88
  t.string "dept_no", limit: 4, null: false
89
- t.date "from_date2", null: false, rename_from: 'from_date'
89
+ t.date "from_date2", null: false, renamed_from: 'from_date'
90
90
  t.date "to_date", null: false
91
91
  end
92
92
 
@@ -97,7 +97,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
97
97
  t.string "dept_no", limit: 4, null: false
98
98
  t.integer "emp_no", null: false
99
99
  t.date "from_date", null: false
100
- t.date "to_date2", null: false, rename_from: 'to_date'
100
+ t.date "to_date2", null: false, renamed_from: 'to_date'
101
101
  end
102
102
 
103
103
  add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
@@ -114,7 +114,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
114
114
  t.date "birth_date", null: false
115
115
  t.string "first_name", limit: 14, null: false
116
116
  t.string "last_name", limit: 16, null: false
117
- t.string "gender2", limit: 1, null: false, rename_from: 'gender'
117
+ t.string "gender2", limit: 1, null: false, renamed_from: 'gender'
118
118
  t.date "hire_date", null: false
119
119
  end
120
120
 
@@ -144,9 +144,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
144
144
  it {
145
145
  delta = subject.diff(expected_dsl)
146
146
  expect(delta.differ?).to be_falsey
147
- expect(subject.dump).to eq actual_dsl.undent.strip
147
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
148
148
  delta.migrate
149
- expect(subject.dump).to eq expected_dsl.undent.strip.gsub(/\s*,\s*rename_from:.*$/, '')
149
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/\s*,\s*renamed_from:.*$/, '')
150
150
  }
151
151
 
152
152
  it {
@@ -110,7 +110,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
110
110
 
111
111
  add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
112
112
 
113
- create_table "employees2", primary_key: "emp_no", force: true, rename_from: 'employees' do |t|
113
+ create_table "employees2", primary_key: "emp_no", force: true, renamed_from: 'employees' do |t|
114
114
  t.date "birth_date", null: false
115
115
  t.string "first_name", limit: 14, null: false
116
116
  t.string "last_name", limit: 16, null: false
@@ -144,9 +144,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
144
144
  it {
145
145
  delta = subject.diff(expected_dsl)
146
146
  expect(delta.differ?).to be_falsey
147
- expect(subject.dump).to eq actual_dsl.undent.strip
147
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
148
148
  delta.migrate
149
- expect(subject.dump).to eq expected_dsl.undent.strip.gsub(/, rename_from: 'employees'/, '')
149
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/, renamed_from: 'employees'/, '')
150
150
  }
151
151
 
152
152
  it {
@@ -60,9 +60,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
60
60
  it {
61
61
  delta = subject.diff(dsl)
62
62
  expect(delta.differ?).to be_falsey
63
- expect(subject.dump).to eq expected_dsl.undent.strip
63
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
64
64
  delta.migrate
65
- expect(subject.dump).to eq expected_dsl.undent.strip
65
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
66
66
  }
67
67
  end
68
68
 
@@ -139,15 +139,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
139
139
  it {
140
140
  delta = subject.diff(dsl)
141
141
  expect(delta.differ?).to be_truthy
142
- expect(subject.dump).to eq before_dsl.undent.strip
142
+ expect(subject.dump).to eq before_dsl.strip_heredoc.strip
143
143
  delta.migrate
144
- expect(subject.dump).to eq after_dsl.undent.strip
144
+ expect(subject.dump).to eq after_dsl.strip_heredoc.strip
145
145
  }
146
146
 
147
147
  it {
148
148
  delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true)
149
149
  expect(delta.differ?).to be_truthy
150
- expect(delta.script).to eq (<<-RUBY).undent.strip
150
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
151
151
  change_column("employees", "first_name", :string, {:limit=>14, :null=>false, :unsigned=>false})
152
152
  RUBY
153
153
  }
@@ -60,9 +60,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
60
60
  it {
61
61
  delta = subject.diff(dsl)
62
62
  expect(delta.differ?).to be_falsey
63
- expect(subject.dump).to eq expected_dsl.undent.strip
63
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
64
64
  delta.migrate
65
- expect(subject.dump).to eq expected_dsl.undent.strip
65
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
66
66
  }
67
67
  end
68
68
 
@@ -139,15 +139,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
139
139
  it {
140
140
  delta = subject.diff(dsl)
141
141
  expect(delta.differ?).to be_truthy
142
- expect(subject.dump).to eq before_dsl.undent.strip
142
+ expect(subject.dump).to eq before_dsl.strip_heredoc.strip
143
143
  delta.migrate
144
- expect(subject.dump).to eq after_dsl.undent.strip
144
+ expect(subject.dump).to eq after_dsl.strip_heredoc.strip
145
145
  }
146
146
 
147
147
  it {
148
148
  delta = Ridgepole::Client.diff(current_schema, dsl, tables: ['employees'], reverse: true)
149
149
  expect(delta.differ?).to be_truthy
150
- expect(delta.script).to eq (<<-RUBY).undent.strip
150
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
151
151
  change_column("employees", "first_name", :string, {:limit=>14, :null=>false, :unsigned=>false})
152
152
  RUBY
153
153
  }
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  $: << File.expand_path('..', __FILE__)
2
2
  require 'ridgepole'
3
+ require 'active_support/core_ext/string/strip'
3
4
  require 'string_ext'
4
5
 
5
6
  ActiveRecord::Migration.verbose = false
data/spec/string_ext.rb CHANGED
@@ -1,14 +1,4 @@
1
1
  class String
2
- def undent
3
- min_space_num = self.split("\n").delete_if {|s| s =~ /^\s*$/ }.map {|s| (s[/^\s+/] || '').length }.min
4
-
5
- if min_space_num and min_space_num > 0
6
- gsub(/^[ \t]{,#{min_space_num}}/, '')
7
- else
8
- self
9
- end
10
- end
11
-
12
2
  def delete_create_table(name)
13
3
  new_def = []
14
4
  in_block = false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridgepole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-04 00:00:00.000000000 Z
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -105,6 +105,7 @@ extra_rdoc_files: []
105
105
  files:
106
106
  - .gitignore
107
107
  - .rspec
108
+ - .travis.yml
108
109
  - Gemfile
109
110
  - LICENSE.txt
110
111
  - README.md
@@ -119,7 +120,6 @@ files:
119
120
  - lib/ridgepole/logger.rb
120
121
  - lib/ridgepole/migration_ext.rb
121
122
  - lib/ridgepole/schema_dumper_ext.rb
122
- - lib/ridgepole/string_ext.rb
123
123
  - lib/ridgepole/version.rb
124
124
  - ridgepole.gemspec
125
125
  - spec/0_diff/dump_disable_unsigned_spec.rb
@@ -1,11 +0,0 @@
1
- class String
2
- def undent
3
- min_space_num = self.split("\n").delete_if {|s| s =~ /^\s*$/ }.map {|s| (s[/^\s+/] || '').length }.min
4
-
5
- if min_space_num and min_space_num > 0
6
- gsub(/^[ \t]{,#{min_space_num}}/, '')
7
- else
8
- self
9
- end
10
- end
11
- end