visual_migrate 4.0.1.2
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +1 -0
- data/Rakefile +34 -0
- data/app/assets/images/visual_migrate/bg_pagetop.gif +0 -0
- data/app/assets/javascripts/common.js +21 -0
- data/app/assets/javascripts/jquery.cookie.js +95 -0
- data/app/assets/javascripts/jquery.js +4 -0
- data/app/assets/javascripts/visual_migrate/application.js +13 -0
- data/app/assets/javascripts/visual_migrate/dialog.js +2 -0
- data/app/assets/javascripts/visual_migrate/index.js +2 -0
- data/app/assets/javascripts/vm-application.js +35 -0
- data/app/assets/stylesheets/visual_migrate/application.css +13 -0
- data/app/assets/stylesheets/visual_migrate/dialog.css +4 -0
- data/app/assets/stylesheets/visual_migrate/index.css +4 -0
- data/app/assets/stylesheets/vm-application.css +40 -0
- data/app/assets/stylesheets/vm-common.css +335 -0
- data/app/assets/template/sim003_blue.zip +0 -0
- data/app/assets/template/sim003_blue/src/css/common.css +329 -0
- data/app/assets/template/sim003_blue/src/images/bg_pagetop.gif +0 -0
- data/app/assets/template/sim003_blue/src/index.html +153 -0
- data/app/assets/template/sim003_blue/src/js/common.js +21 -0
- data/app/assets/template/sim003_blue/src/js/jquery.js +4 -0
- data/app/controllers/visual_migrate/application_controller.rb +5 -0
- data/app/controllers/visual_migrate/dialog_controller.rb +9 -0
- data/app/controllers/visual_migrate/index_controller.rb +174 -0
- data/app/helpers/visual_migrate/application_helper.rb +97 -0
- data/app/helpers/visual_migrate/dialog_helper.rb +4 -0
- data/app/helpers/visual_migrate/index_helper.rb +4 -0
- data/app/models/schema_migration.rb +2 -0
- data/app/views/layouts/visual_migrate/_columns.html.erb +133 -0
- data/app/views/layouts/visual_migrate/_func_add_column.html.erb +24 -0
- data/app/views/layouts/visual_migrate/_func_add_index.html.erb +20 -0
- data/app/views/layouts/visual_migrate/_func_add_timestamps.html.erb +8 -0
- data/app/views/layouts/visual_migrate/_func_change_column.html.erb +24 -0
- data/app/views/layouts/visual_migrate/_func_change_column_default.html.erb +12 -0
- data/app/views/layouts/visual_migrate/_func_create_table.html.erb +33 -0
- data/app/views/layouts/visual_migrate/_func_drop_table.html.erb +8 -0
- data/app/views/layouts/visual_migrate/_func_remove_column.html.erb +9 -0
- data/app/views/layouts/visual_migrate/_func_remove_index.html.erb +17 -0
- data/app/views/layouts/visual_migrate/_func_remove_timestamps.html.erb +8 -0
- data/app/views/layouts/visual_migrate/_func_rename_column.html.erb +12 -0
- data/app/views/layouts/visual_migrate/_func_rename_index.html.erb +10 -0
- data/app/views/layouts/visual_migrate/_func_rename_table.html.erb +9 -0
- data/app/views/layouts/visual_migrate/_migration_class.html.erb +20 -0
- data/app/views/layouts/visual_migrate/_migration_method.html.erb +40 -0
- data/app/views/layouts/visual_migrate/application.html.erb +68 -0
- data/app/views/layouts/visual_migrate/dialog.html.erb +28 -0
- data/app/views/visual_migrate/dialog/add_new_func.html.erb +45 -0
- data/app/views/visual_migrate/index/_section_migrations.html.erb +19 -0
- data/app/views/visual_migrate/index/_section_tables.html.erb +10 -0
- data/app/views/visual_migrate/index/command_line.html.erb +34 -0
- data/app/views/visual_migrate/index/direct_edit.html.erb +9 -0
- data/app/views/visual_migrate/index/edit_migration.html.erb +15 -0
- data/app/views/visual_migrate/index/modify_table.html.erb +1 -0
- data/config/routes.rb +70 -0
- data/lib/class_filter.rb +126 -0
- data/lib/func_filter.rb +560 -0
- data/lib/method_filter.rb +104 -0
- data/lib/migration_defs.rb +626 -0
- data/lib/tasks/visual-migrate_tasks.rake +4 -0
- data/lib/tasks/visual_migrate_tasks.rake +4 -0
- data/lib/visual_migrate.rb +6 -0
- data/lib/visual_migrate/activerecord.rb +23 -0
- data/lib/visual_migrate/engine.rb +5 -0
- data/lib/visual_migrate/migration.rb +15 -0
- data/lib/visual_migrate/version.rb +3 -0
- data/lib/visual_migrate_ripper.rb +157 -0
- data/test/dummy/Gemfile +84 -0
- data/test/dummy/Gemfile.lock +218 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/index.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/index.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/index_controller.rb +9 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/index_helper.rb +2 -0
- data/test/dummy/app/models/test_table.rb +2 -0
- data/test/dummy/app/views/index/index.html.erb +23 -0
- data/test/dummy/app/views/layouts/application.html.erb +43 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +30 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20131006135044_create_test_tables.rb +9 -0
- data/test/dummy/db/migrate/20131007030825_add_column_test_table.rb +13 -0
- data/test/dummy/db/migrate/20131026214458_rename_column_test_table.rb +5 -0
- data/test/dummy/db/migrate/20131030105601_change_column_test.rb +10 -0
- data/test/dummy/db/migrate/20131104225745_index_test.rb +9 -0
- data/test/dummy/db/migrate/20131105025821_rename_index_test.rb +5 -0
- data/test/dummy/db/migrate/20131105042853_remove_timestamps_test.rb +9 -0
- data/test/dummy/db/schema.rb +28 -0
- data/test/dummy/db/seeds.rb +20 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +90374 -0
- data/test/dummy/log/production.log +329 -0
- data/test/dummy/log/test.log +489 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/index.html.bak +38 -0
- data/test/dummy/spec/controllers/index_controller_spec.rb +19 -0
- data/test/dummy/spec/spec_helper.rb +46 -0
- data/test/dummy/spec/views/index/index.html.erb_spec.rb +17 -0
- data/test/dummy/test/controllers/index_controller_test.rb +7 -0
- data/test/dummy/test/fixtures/test_tables.yml +11 -0
- data/test/dummy/test/helpers/index_helper_test.rb +4 -0
- data/test/dummy/test/models/test_table_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/021fe5e1eadff30885806b7245f7e66e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0a9126be05e74d1b89f024c687b7dbfd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0b682b760de6f7c47a7236f024fee55d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0caf4a7a233e329f7d3bfe3fc2f37910 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0e059cd92931990c10b6c5b78014ec92 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/178af67c2277a751289e81fc2f96dc7d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/18650e945a1a2ad87b3d8997d1ccac10 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/19bf9cd3f01562cdecb4b5c825c8f36d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1b5f6c8780c3fcb34d2bbbabe38c3d94 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1df2ccc1ade2cfe4a9d0ce8b0ec2dadf +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/272853fd0642f08e38174a609a2be457 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2aff43fdd4d59cb6a75288268ec363ee +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2c853768baf811357d81d41bdfd05dcf +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/314d48e543146f617c4d3439a4d8d40d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/320853225bbf3512349dc1ef4ea80874 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/32f1a742d35f7250e984b1de0554a894 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3807e3adca7677de6842a8048ad6d83b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/42ad84505ad8dfc0a4a724e8c889c607 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/46c5c46e37f5a22449050d7fc6f1dc26 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4fbe2f2c44de1e405b3562e4935176b9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/52d191f68c69ae795e8da63ef51ca640 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/54cf088ee215412d3800d9b1e0263c30 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/55165e8d7dcda66caf51df6c6417142d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/576fe10a40538bd3999a2b1b3fe334d1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5793e837a2934ce3b84aac8785a874ce +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5900a8937fa5118d2a6ee8289614c854 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5a9053557c1035de31eb2162db5b9d34 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5df80a6ab7f25724f11ce3179173ad60 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6373000f4849668f51493aaf8503c8e8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/65048e3e4fd096e06f7ca69a5af7ab9f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6bb983076781d92edbb1da256023c14b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6dfaf2d0d571c61e96bce5377fcddf7f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6efc50a7f372f50e09a67daa7ac00940 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6f7dfedc6e14ea8772e0284497539f90 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/70f64d1c4421c935f01a8d5aa647d792 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7999e525c88173c1beb785f002effc1d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7c188f2b1cb38e1b55dc8a8bb8785fe8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7d48e39953ffcdd70751e98d08d1282c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7ddca3ef38a810d93ddc026ee5fa7959 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7fecd8a0b0c56f928c31450f839c4731 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/842d637730ce4255c6beacff60b80157 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/89cd476f554d26de50608ac9ce6d0606 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9519989fc45811670fa6b1184fedecc7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/99cdbaecd1b34008d0853764ec707246 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a093237e72888c88a730f537a544e03b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a7c148cd78906c44016fdeb236569b5b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a83bebd10c561b2264affb4ed6a9f83b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b3ed09e62124bd9cf5f7a1ac14298d4f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/be45f47d31b8e7fd54a0b6087eeaf5de +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c00bfe3da0096cbd0434a6c66262fe23 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c78109332f6461183a94718da0068da6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cee8c6b09c33d2b276753e959712724e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d08ae02c560f15a5cb4d0447b0da29ad +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d990155237ca59ccb96cf2253f8059ae +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/df600f50f002512c95d93bcfbab891ed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e2a3afc837465539886843291aedd0f3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/eb7b0ec5bff36142ba070d1a39e194b1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f3aee0380718ef20b2e587a842ce697e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f408c68444462a9ae2effa5230b43edf +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f898358aceb33227eb4403237acca034 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fc7201c6cbef32453aa4175c520c8eae +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fca81105f7109a6a96f05aedd0f1b883 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fdd7a6a4d56761d6463b3c34768fbc78 +0 -0
- data/test/dummy/tmp/restart.txt +0 -0
- data/test/dummy/tmp/visual-migrate_tmp.rb +5 -0
- data/test/dummy/tmp/visual_migrate_tmp.rb +10 -0
- data/test/fixtures/visual_migrate/schema_migrations.yml +11 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/visual_migrate/schema_migration_test.rb +9 -0
- data/test/test_helper.rb +15 -0
- data/test/visual_migrate_test.rb +7 -0
- metadata +487 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<h3>Tables</h3>
|
|
2
|
+
<% if !(@tables.nil? || @tables.blank?) %>
|
|
3
|
+
<ul>
|
|
4
|
+
<% @tables.each do |t| %>
|
|
5
|
+
<%= (link_to t, :action => :select_table, :id => t) + raw('<br />') if t != 'schema_migrations'%>
|
|
6
|
+
<% end %>
|
|
7
|
+
</ul>
|
|
8
|
+
<% else %>
|
|
9
|
+
tables not found.<br />
|
|
10
|
+
<% end %>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<%= form_tag(action: :run_command) do %>
|
|
2
|
+
<%= text_field_tag 'command_line', params[:command_line].nil? ? 'rake db:' : params[:command_line], size: 50 %>
|
|
3
|
+
<br />
|
|
4
|
+
<!--input type="button" value="run" onclick="send_text();" ><br /-->
|
|
5
|
+
<%= submit_tag "run" %><br />
|
|
6
|
+
<% end %>
|
|
7
|
+
<br />
|
|
8
|
+
<%= raw(nl2br @run_result) if !@run_result.nil? %><br />
|
|
9
|
+
<div id="text_result"></div>
|
|
10
|
+
|
|
11
|
+
<script type="text/javascript">
|
|
12
|
+
function send_text(){
|
|
13
|
+
ajax_post(document.getElementById("command_line").value);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function ajax_post(text){
|
|
17
|
+
$.ajax({
|
|
18
|
+
url: "/visual_migrate/index/run_command",
|
|
19
|
+
type: 'POST',
|
|
20
|
+
dataType: 'text',
|
|
21
|
+
data: {command_line:text},
|
|
22
|
+
success: function(data){
|
|
23
|
+
if(data.length>0){
|
|
24
|
+
$("#text_result").html(data);
|
|
25
|
+
} else {
|
|
26
|
+
$("#text_result").html("no data");
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
error: function(){
|
|
30
|
+
alert("AJAX failed");
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<% if @vm_ripper.nil? %>
|
|
2
|
+
Select Migration.
|
|
3
|
+
<% else %>
|
|
4
|
+
<%= form_tag({action: :save_migration, id: params[:id]}, {name: :vm_edit}) do %>
|
|
5
|
+
<%= show_class @vm_ripper.class %>
|
|
6
|
+
<br />
|
|
7
|
+
<%= submit_tag 'save', data: {disable_with: "Sending..."} %>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% end %>
|
|
10
|
+
|
|
11
|
+
<%#= raw nl2br @migration_content if !@migration_content.nil? %><!--hr />
|
|
12
|
+
<%#= raw nl2br @context if !@context.nil? %><hr />
|
|
13
|
+
<%#= params.inspect %><hr />
|
|
14
|
+
<%#= @vm_ripper.inspect %><hr />
|
|
15
|
+
<%#= @mi_lex.inspect %><hr /-->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
add migrate
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
VisualMigrate::Engine.routes.draw do
|
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
|
3
|
+
# See how all your routes lay out with "rake routes".
|
|
4
|
+
|
|
5
|
+
# You can have the root of your site routed with "root"
|
|
6
|
+
root to: 'index#index' #Why needs?
|
|
7
|
+
|
|
8
|
+
# Example of regular route:
|
|
9
|
+
# get 'products/:id' => 'catalog#view'
|
|
10
|
+
|
|
11
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
|
12
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
|
13
|
+
|
|
14
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
|
15
|
+
# resources :index
|
|
16
|
+
|
|
17
|
+
# Example resource route with options:
|
|
18
|
+
# resources :products do
|
|
19
|
+
# member do
|
|
20
|
+
# get 'short'
|
|
21
|
+
# post 'toggle'
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# collection do
|
|
25
|
+
# get 'sold'
|
|
26
|
+
# end
|
|
27
|
+
# end
|
|
28
|
+
|
|
29
|
+
# Example resource route with sub-resources:
|
|
30
|
+
# resources :products do
|
|
31
|
+
# resources :comments, :sales
|
|
32
|
+
# resource :seller
|
|
33
|
+
# end
|
|
34
|
+
|
|
35
|
+
# Example resource route with more complex sub-resources:
|
|
36
|
+
# resources :products do
|
|
37
|
+
# resources :comments
|
|
38
|
+
# resources :sales do
|
|
39
|
+
# get 'recent', on: :collection
|
|
40
|
+
# end
|
|
41
|
+
# end
|
|
42
|
+
|
|
43
|
+
# Example resource route with concerns:
|
|
44
|
+
# concern :toggleable do
|
|
45
|
+
# post 'toggle'
|
|
46
|
+
# end
|
|
47
|
+
# resources :posts, concerns: :toggleable
|
|
48
|
+
# resources :photos, concerns: :toggleable
|
|
49
|
+
|
|
50
|
+
# Example resource route within a namespace:
|
|
51
|
+
# namespace :visual_migrate do
|
|
52
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
|
53
|
+
# # (app/controllers/admin/products_controller.rb)
|
|
54
|
+
# resources :index
|
|
55
|
+
# end
|
|
56
|
+
#
|
|
57
|
+
#match ':controller(/:action(/:id))(.:format)'
|
|
58
|
+
#match 'index/run_command', to: "index#run_command", via: [:get, :post]
|
|
59
|
+
match 'index(/:action(/:id))(.:format)', to: "index#:action", via: [:get, :post]
|
|
60
|
+
#get 'index(/:action(/:id(.:format)))', to: "index#:action"
|
|
61
|
+
get 'dialog(/:action(/:id(.:format)))', to: "dialog#:action"
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
=begin
|
|
65
|
+
Rails.application.routes.draw do
|
|
66
|
+
#get ':controller(/:action(/:id(.:format)))'
|
|
67
|
+
#get ':controller(/:action(/:id(.:format)))', to: {controller: 'visual_migrate/index'}
|
|
68
|
+
match ':controller(/:action(/:id))(.:format)', via: [:get, :post]
|
|
69
|
+
end
|
|
70
|
+
=end
|
data/lib/class_filter.rb
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# To change this template, choose Tools | Templates
|
|
3
|
+
# and open the template in the editor.
|
|
4
|
+
|
|
5
|
+
require 'ripper'
|
|
6
|
+
require 'migration_defs'
|
|
7
|
+
require 'method_filter'
|
|
8
|
+
|
|
9
|
+
class ClassFilter < Ripper::Filter
|
|
10
|
+
attr_accessor :class, :class_str, :methods_str, :method_filters
|
|
11
|
+
|
|
12
|
+
def initialize(src)
|
|
13
|
+
super src
|
|
14
|
+
|
|
15
|
+
@class_str = ''
|
|
16
|
+
@methods_str = Array.new
|
|
17
|
+
@method_filters = Array.new
|
|
18
|
+
@methods = Array.new
|
|
19
|
+
@is_class = false
|
|
20
|
+
@is_method = false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def add_tok tok
|
|
24
|
+
if @is_method
|
|
25
|
+
@methods_str[-1] += tok
|
|
26
|
+
elsif @is_class
|
|
27
|
+
@class_str += tok
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def on_default(event, tok, f)
|
|
32
|
+
add_tok tok
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def on_kw(tok, f)
|
|
36
|
+
if tok == 'class'
|
|
37
|
+
@is_class = true
|
|
38
|
+
elsif tok == 'def'
|
|
39
|
+
@is_method = true
|
|
40
|
+
@methods_str << ''
|
|
41
|
+
elsif tok == 'do'
|
|
42
|
+
@is_do = true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
add_tok tok
|
|
46
|
+
|
|
47
|
+
if tok == 'end'
|
|
48
|
+
if @is_do
|
|
49
|
+
@is_do = false
|
|
50
|
+
elsif @is_func
|
|
51
|
+
@is_func = false
|
|
52
|
+
elsif @is_method
|
|
53
|
+
@methods << @class.add_method(@method_name)
|
|
54
|
+
@is_method = false
|
|
55
|
+
elsif @is_class
|
|
56
|
+
index = 0
|
|
57
|
+
@methods_str.each do |m|
|
|
58
|
+
@method_filters << MethodFilter.new(m, @methods[index])
|
|
59
|
+
@method_filters.last.parse
|
|
60
|
+
index += 1
|
|
61
|
+
end
|
|
62
|
+
@is_class = false
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def on_ident(tok, f)
|
|
68
|
+
if @is_method && MigrationDefs::MethodName.include?(tok)
|
|
69
|
+
@method_name = tok
|
|
70
|
+
@class.add_method(tok)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
add_tok tok
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def on_const(tok, f)
|
|
77
|
+
if @is_ancestors
|
|
78
|
+
@parent_name += '::' + tok
|
|
79
|
+
elsif @is_super
|
|
80
|
+
@parent_name = tok
|
|
81
|
+
elsif @is_class
|
|
82
|
+
@class_name = tok
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
add_tok tok
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def on_op(tok, f)
|
|
89
|
+
if @is_class
|
|
90
|
+
if tok == '<'
|
|
91
|
+
@is_super = true
|
|
92
|
+
elsif @is_super && tok == '::'
|
|
93
|
+
@is_ancestors = true
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
add_tok tok
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def on_nl(tok, f)
|
|
101
|
+
if @is_class && !@class_name.nil?
|
|
102
|
+
@class = MigrationDefs::MigrationClass.new(@class_name, @parent_name)
|
|
103
|
+
@class_name = nil
|
|
104
|
+
@is_ancestors = false
|
|
105
|
+
@is_super = false
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
add_tok tok
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def on_do_block(tok, f)
|
|
112
|
+
@is_do = true
|
|
113
|
+
add_tok tok
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def on_lbrase(tok, f)
|
|
117
|
+
@is_do = true
|
|
118
|
+
add_tok tok
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def on_rbrase(tok, f)
|
|
122
|
+
@is_do = false
|
|
123
|
+
add_tok tok
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
end
|
data/lib/func_filter.rb
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# To change this template, choose Tools | Templates
|
|
3
|
+
# and open the template in the editor.
|
|
4
|
+
|
|
5
|
+
require 'migration_defs'
|
|
6
|
+
|
|
7
|
+
class FuncFilterFactory
|
|
8
|
+
def self.get(func, src)
|
|
9
|
+
if func.instance_of? MigrationDefs::CreateTableFunc
|
|
10
|
+
return CreateTableFuncFilter.new(src, func)
|
|
11
|
+
elsif func.instance_of? MigrationDefs::RenameTableFunc
|
|
12
|
+
return RenameTableFuncFilter.new(src, func)
|
|
13
|
+
elsif func.instance_of? MigrationDefs::DropTableFunc
|
|
14
|
+
return DropTableFuncFilter.new(src, func)
|
|
15
|
+
elsif func.instance_of? MigrationDefs::AddColumnFunc
|
|
16
|
+
return AddColumnFuncFilter.new(src, func)
|
|
17
|
+
elsif func.instance_of? MigrationDefs::RemoveColumnFunc
|
|
18
|
+
return RemoveColumnFuncFilter.new(src, func)
|
|
19
|
+
elsif func.instance_of? MigrationDefs::RenameColumnFunc
|
|
20
|
+
return RenameColumnFuncFilter.new(src, func)
|
|
21
|
+
elsif func.instance_of? MigrationDefs::ChangeColumnFunc
|
|
22
|
+
return ChangeColumnFuncFilter.new(src, func)
|
|
23
|
+
elsif func.instance_of? MigrationDefs::ChangeColumnDefaultFunc
|
|
24
|
+
return ChangeColumnDefaultFuncFilter.new(src, func)
|
|
25
|
+
elsif func.instance_of? MigrationDefs::AddIndexFunc
|
|
26
|
+
return AddIndexFuncFilter.new(src, func)
|
|
27
|
+
elsif func.instance_of? MigrationDefs::RemoveIndexFunc
|
|
28
|
+
return RemoveIndexFuncFilter.new(src, func)
|
|
29
|
+
elsif func.instance_of? MigrationDefs::RenameIndexFunc
|
|
30
|
+
return RenameIndexFuncFilter.new(src, func)
|
|
31
|
+
elsif func.instance_of? MigrationDefs::AddTimestampsFunc
|
|
32
|
+
return AddTimestampsFuncFilter.new(src, func)
|
|
33
|
+
elsif func.instance_of? MigrationDefs::RemoveTimestampsFunc
|
|
34
|
+
return RemoveTimestampsFuncFilter.new(src, func)
|
|
35
|
+
else
|
|
36
|
+
return nil
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class CreateTableFuncFilter < Ripper::Filter
|
|
42
|
+
attr_accessor :fclass, :func_str, :func_option_str, :column_option_str
|
|
43
|
+
|
|
44
|
+
def initialize(src, fclass)
|
|
45
|
+
super src
|
|
46
|
+
|
|
47
|
+
@fclass = fclass
|
|
48
|
+
@func_str = ''
|
|
49
|
+
@is_func_option = true
|
|
50
|
+
@func_option_str = ''
|
|
51
|
+
@is_do = false
|
|
52
|
+
@is_column_option = false
|
|
53
|
+
@column_option_str = Array.new
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def add_tok(tok)
|
|
57
|
+
if @is_column_option
|
|
58
|
+
@column_option_str[-1] += tok
|
|
59
|
+
elsif @is_func_option
|
|
60
|
+
@func_option_str += tok
|
|
61
|
+
elsif @is_func
|
|
62
|
+
@func_str += tok
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def on_default(event, tok, f)
|
|
67
|
+
add_tok tok
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def on_kw(tok, f)
|
|
71
|
+
if tok == 'end'
|
|
72
|
+
if @is_do
|
|
73
|
+
@is_do = false
|
|
74
|
+
end
|
|
75
|
+
elsif tok == 'true' || tok == 'false'
|
|
76
|
+
if @is_column_option && !@column_option.nil?
|
|
77
|
+
@fclass.columns.last.set_option(@column_option, "'" + tok + "'")
|
|
78
|
+
@column_option = nil
|
|
79
|
+
elsif @is_func_option && !@func_option.nil?
|
|
80
|
+
@fclass.option.set_option(@func_option, tok)
|
|
81
|
+
@func_option = nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
add_tok tok
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def on_ident(tok, f)
|
|
88
|
+
if tok == 't'
|
|
89
|
+
@is_column = true
|
|
90
|
+
elsif @is_column
|
|
91
|
+
if (tok != 'timestamps') && (tok != 'attachment')
|
|
92
|
+
@column_type = tok
|
|
93
|
+
@is_column_type = true
|
|
94
|
+
@column_option_str << ''
|
|
95
|
+
else
|
|
96
|
+
@fclass.add_column(tok)
|
|
97
|
+
@is_column_type = false
|
|
98
|
+
end
|
|
99
|
+
@is_column = false
|
|
100
|
+
elsif @is_column_type
|
|
101
|
+
@fclass.add_column(@column_type, tok)
|
|
102
|
+
@is_column_type = false
|
|
103
|
+
@is_column_option = true
|
|
104
|
+
@column_type = nil
|
|
105
|
+
elsif @is_column_option
|
|
106
|
+
@column_option = tok
|
|
107
|
+
elsif @is_func_option
|
|
108
|
+
@func_option = tok
|
|
109
|
+
end
|
|
110
|
+
add_tok tok
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def on_nl(tok, f)
|
|
114
|
+
@is_func_option = false
|
|
115
|
+
@is_column = false
|
|
116
|
+
@is_column_option = false
|
|
117
|
+
add_tok tok
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def on_do_block(tok, f)
|
|
121
|
+
@is_do = true
|
|
122
|
+
add_tok tok
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def on_lbrase(tok, f)
|
|
126
|
+
@is_do = true
|
|
127
|
+
add_tok tok
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def on_rbrase(tok, f)
|
|
131
|
+
@is_do = false
|
|
132
|
+
add_tok tok
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def on_tstring_content(tok, f)
|
|
136
|
+
if @is_column_option && !@column_option.nil?
|
|
137
|
+
@fclass.columns.last.set_option(@column_option, "'" + tok + "'")
|
|
138
|
+
@column_option = nil
|
|
139
|
+
elsif @is_func_option && !@func_option.nil?
|
|
140
|
+
@fclass.option.set_option(@func_option, "'" + tok + "'")
|
|
141
|
+
@func_option = nil
|
|
142
|
+
end
|
|
143
|
+
@is_tstring_content = true
|
|
144
|
+
add_tok tok
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def on_tstring_beg(tok, f)
|
|
148
|
+
@is_tstring_content = false
|
|
149
|
+
add_tok tok
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def on_tstring_end(tok, f)
|
|
153
|
+
if !@is_tstring_content
|
|
154
|
+
on_tstring_content("", f)
|
|
155
|
+
end
|
|
156
|
+
add_tok tok
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def on_int(tok, f)
|
|
160
|
+
if @is_column_option && !@column_option.nil?
|
|
161
|
+
@fclass.columns.last.set_option(@column_option, tok)
|
|
162
|
+
@column_option = nil
|
|
163
|
+
elsif @is_func_option && !@func_option.nil?
|
|
164
|
+
@fclass.option.set_option(@func_option, tok)
|
|
165
|
+
@func_option = nil
|
|
166
|
+
end
|
|
167
|
+
add_tok tok
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def on_float(tok, f)
|
|
171
|
+
if @is_column_option && !@column_option.nil?
|
|
172
|
+
@fclass.columns.last.set_option(@column_option, tok)
|
|
173
|
+
@column_option = nil
|
|
174
|
+
elsif @is_func_option && !@func_option.nil?
|
|
175
|
+
@fclass.option.set_option(@func_option, tok)
|
|
176
|
+
@func_option = nil
|
|
177
|
+
end
|
|
178
|
+
add_tok tok
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
class RenameTableFuncFilter < CreateTableFuncFilter
|
|
184
|
+
def on_ident(tok, f)
|
|
185
|
+
if @is_func_option && @is_comma
|
|
186
|
+
@fclass.add_new_name tok
|
|
187
|
+
@is_func_option = false
|
|
188
|
+
@is_comma = false
|
|
189
|
+
end
|
|
190
|
+
add_tok tok
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def on_comma(tok, f)
|
|
194
|
+
@is_comma = true
|
|
195
|
+
add_tok tok
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
class DropTableFuncFilter < CreateTableFuncFilter
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
class AddColumnFuncFilter < CreateTableFuncFilter
|
|
204
|
+
def initialize(src, fclass)
|
|
205
|
+
super src, fclass
|
|
206
|
+
|
|
207
|
+
@is_func_name = true
|
|
208
|
+
@is_table_name = false
|
|
209
|
+
@is_column = false
|
|
210
|
+
@is_column_type = false
|
|
211
|
+
@column_option_str = ''
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def add_tok(tok)
|
|
215
|
+
if @is_column_option
|
|
216
|
+
@column_option_str += tok
|
|
217
|
+
elsif @is_func_option
|
|
218
|
+
@func_option_str += tok
|
|
219
|
+
elsif @is_func
|
|
220
|
+
@func_str += tok
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def on_kw(tok, f)
|
|
225
|
+
if tok == 'end'
|
|
226
|
+
if @is_do
|
|
227
|
+
@is_do = false
|
|
228
|
+
end
|
|
229
|
+
elsif tok == 'true' || tok == 'false'
|
|
230
|
+
if @is_column_option && !@column_option.nil?
|
|
231
|
+
@fclass.column.set_option(@column_option, "'" + tok + "'")
|
|
232
|
+
@column_option = nil
|
|
233
|
+
elsif @is_func_option && !@func_option.nil?
|
|
234
|
+
@fclass.option.set_option(@func_option, tok)
|
|
235
|
+
@func_option = nil
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
add_tok tok
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def on_ident(tok, f)
|
|
242
|
+
if @is_func_name
|
|
243
|
+
@is_func_name = false
|
|
244
|
+
@is_table_name = true
|
|
245
|
+
elsif @is_table_name
|
|
246
|
+
@is_table_name = false
|
|
247
|
+
@is_column = true
|
|
248
|
+
elsif @is_column
|
|
249
|
+
@column_name = tok
|
|
250
|
+
@is_column = false
|
|
251
|
+
@is_column_type = true
|
|
252
|
+
elsif @is_column_type
|
|
253
|
+
@fclass.add_column(tok, @column_name)
|
|
254
|
+
@is_column_type = false
|
|
255
|
+
@is_column_option = true
|
|
256
|
+
elsif @is_column_option
|
|
257
|
+
@column_option = tok
|
|
258
|
+
end
|
|
259
|
+
add_tok tok
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def on_tstring_content(tok, f)
|
|
263
|
+
if @is_column_option && !@column_option.nil?
|
|
264
|
+
@fclass.column.set_option(@column_option, "'" + tok + "'")
|
|
265
|
+
@column_option = nil
|
|
266
|
+
elsif @is_func_option && !@func_option.nil?
|
|
267
|
+
@fclass.option.set_option(@func_option, "'" + tok + "'")
|
|
268
|
+
@func_option = nil
|
|
269
|
+
end
|
|
270
|
+
@is_tstring_content = true
|
|
271
|
+
add_tok tok
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def on_int(tok, f)
|
|
275
|
+
if @is_column_option && !@column_option.nil?
|
|
276
|
+
@fclass.column.set_option(@column_option, tok)
|
|
277
|
+
@column_option = nil
|
|
278
|
+
elsif @is_func_option && !@func_option.nil?
|
|
279
|
+
@fclass.option.set_option(@func_option, tok)
|
|
280
|
+
@func_option = nil
|
|
281
|
+
end
|
|
282
|
+
add_tok tok
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def on_float(tok, f)
|
|
286
|
+
if @is_column_option && !@column_option.nil?
|
|
287
|
+
@fclass.column.set_option(@column_option, tok)
|
|
288
|
+
@column_option = nil
|
|
289
|
+
elsif @is_func_option && !@func_option.nil?
|
|
290
|
+
@fclass.option.set_option(@func_option, tok)
|
|
291
|
+
@func_option = nil
|
|
292
|
+
end
|
|
293
|
+
add_tok tok
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
class RemoveColumnFuncFilter < RenameTableFuncFilter
|
|
299
|
+
def on_ident(tok, f)
|
|
300
|
+
if @is_func_option && @is_comma
|
|
301
|
+
@fclass.add_column_name tok
|
|
302
|
+
@is_func_option = false
|
|
303
|
+
@is_comma = false
|
|
304
|
+
end
|
|
305
|
+
add_tok tok
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
class RenameColumnFuncFilter < RenameTableFuncFilter
|
|
311
|
+
def initialize(src, fclass)
|
|
312
|
+
super src, fclass
|
|
313
|
+
|
|
314
|
+
@is_new_column = false;
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
def on_ident(tok, f)
|
|
318
|
+
if @is_func_option && @is_comma
|
|
319
|
+
@fclass.add_column_name tok
|
|
320
|
+
@is_func_option = false
|
|
321
|
+
@is_comma = false
|
|
322
|
+
@is_new_column = true;
|
|
323
|
+
elsif @is_new_column && @is_comma
|
|
324
|
+
@fclass.add_new_column_name tok
|
|
325
|
+
@is_comma = false
|
|
326
|
+
@is_new_column = false;
|
|
327
|
+
end
|
|
328
|
+
add_tok tok
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
class ChangeColumnFuncFilter < AddColumnFuncFilter
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
class ChangeColumnDefaultFuncFilter < RenameTableFuncFilter
|
|
336
|
+
def initialize(src, fclass)
|
|
337
|
+
super src, fclass
|
|
338
|
+
|
|
339
|
+
@is_default = false
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def on_kw(tok, f)
|
|
343
|
+
if tok == 'end'
|
|
344
|
+
if @is_do
|
|
345
|
+
@is_do = false
|
|
346
|
+
end
|
|
347
|
+
elsif tok == 'true' || tok == 'false'
|
|
348
|
+
if @is_default && @is_comma
|
|
349
|
+
@fclass.set_column_default tok
|
|
350
|
+
@is_comma = false
|
|
351
|
+
@is_default = false;
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
add_tok tok
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
def on_ident(tok, f)
|
|
358
|
+
if @is_func_option && @is_comma
|
|
359
|
+
@fclass.add_column_name tok
|
|
360
|
+
@is_func_option = false
|
|
361
|
+
@is_comma = false
|
|
362
|
+
@is_default = true;
|
|
363
|
+
elsif @is_default && @is_comma
|
|
364
|
+
@fclass.set_column_default tok
|
|
365
|
+
@is_comma = false
|
|
366
|
+
@is_default = false;
|
|
367
|
+
end
|
|
368
|
+
add_tok tok
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def on_tstring_content(tok, f)
|
|
372
|
+
if @is_default && @is_comma
|
|
373
|
+
@fclass.set_column_default "'#{tok}'"
|
|
374
|
+
@is_comma = false
|
|
375
|
+
@is_default = false;
|
|
376
|
+
end
|
|
377
|
+
@is_tstring_content = true
|
|
378
|
+
add_tok tok
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def on_int(tok, f)
|
|
382
|
+
if @is_default && @is_comma
|
|
383
|
+
@fclass.set_column_default tok
|
|
384
|
+
@is_comma = false
|
|
385
|
+
@is_default = false;
|
|
386
|
+
end
|
|
387
|
+
add_tok tok
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def on_float(tok, f)
|
|
391
|
+
if @is_default && @is_comma
|
|
392
|
+
@fclass.set_column_default tok
|
|
393
|
+
@is_comma = false
|
|
394
|
+
@is_default = false;
|
|
395
|
+
end
|
|
396
|
+
add_tok tok
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
class AddIndexFuncFilter < Ripper::Filter
|
|
402
|
+
attr_accessor :fclass, :func_str
|
|
403
|
+
|
|
404
|
+
def initialize(src, fclass)
|
|
405
|
+
super src
|
|
406
|
+
|
|
407
|
+
@fclass = fclass
|
|
408
|
+
@func_str = ''
|
|
409
|
+
@is_columns = false
|
|
410
|
+
@columns = ''
|
|
411
|
+
@is_index_option = false
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
def add_tok(tok)
|
|
415
|
+
if @is_columns
|
|
416
|
+
@columns += tok
|
|
417
|
+
end
|
|
418
|
+
@func_str += tok
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
def on_default(event, tok, f)
|
|
422
|
+
add_tok tok
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def on_kw(tok, f)
|
|
426
|
+
if @is_index_option && (tok == 'true' || tok == 'false')
|
|
427
|
+
@fclass.option.set_option('unique', tok)
|
|
428
|
+
end
|
|
429
|
+
add_tok tok
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
def on_tstring_content(tok, f)
|
|
433
|
+
if @is_index_option
|
|
434
|
+
@fclass.option.set_option('name', "'#{tok}'")
|
|
435
|
+
end
|
|
436
|
+
add_tok tok
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
def on_int(tok, f)
|
|
440
|
+
if @is_index_option
|
|
441
|
+
@fclass.option.set_option('length', tok)
|
|
442
|
+
end
|
|
443
|
+
add_tok tok
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def on_lbracket(tok, f)
|
|
447
|
+
@is_columns = true
|
|
448
|
+
add_tok tok
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
def on_rbracket(tok, f)
|
|
452
|
+
add_tok tok
|
|
453
|
+
@fclass.columns = @columns
|
|
454
|
+
@is_index_option = true;
|
|
455
|
+
@is_columns = false
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
class RemoveIndexFuncFilter < Ripper::Filter
|
|
461
|
+
attr_accessor :fclass, :func_str
|
|
462
|
+
|
|
463
|
+
def initialize(src, fclass)
|
|
464
|
+
super src
|
|
465
|
+
|
|
466
|
+
@fclass = fclass
|
|
467
|
+
@func_str = ''
|
|
468
|
+
@is_columns = false
|
|
469
|
+
@columns = ''
|
|
470
|
+
@is_name = false
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
def add_tok(tok)
|
|
474
|
+
if @is_columns
|
|
475
|
+
@columns += tok
|
|
476
|
+
end
|
|
477
|
+
@func_str += tok
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def on_default(event, tok, f)
|
|
481
|
+
add_tok tok
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def on_ident(tok, f)
|
|
485
|
+
if tok == 'name'
|
|
486
|
+
@is_name = true
|
|
487
|
+
@is_columns = false
|
|
488
|
+
elsif tok == 'column'
|
|
489
|
+
@is_name = false
|
|
490
|
+
end
|
|
491
|
+
add_tok tok
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
def on_tstring_content(tok, f)
|
|
495
|
+
if @is_name
|
|
496
|
+
@fclass.option.set_option('name', "'#{tok}'")
|
|
497
|
+
end
|
|
498
|
+
add_tok tok
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
def on_lbracket(tok, f)
|
|
502
|
+
@is_columns = true
|
|
503
|
+
add_tok tok
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
def on_rbracket(tok, f)
|
|
507
|
+
add_tok tok
|
|
508
|
+
@fclass.option.set_option('column', @columns)
|
|
509
|
+
@is_columns = false
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
class RenameIndexFuncFilter < RenameTableFuncFilter
|
|
515
|
+
def initialize(src, fclass)
|
|
516
|
+
super src, fclass
|
|
517
|
+
|
|
518
|
+
@is_comma = false;
|
|
519
|
+
@is_index = false
|
|
520
|
+
@is_new_index = false
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
def on_tstring_content(tok, f)
|
|
524
|
+
if @is_new_index && @is_comma
|
|
525
|
+
@fclass.new_index_name = "'#{tok}'"
|
|
526
|
+
@is_comma = false
|
|
527
|
+
elsif @is_index && @is_comma
|
|
528
|
+
@fclass.index_name = "'#{tok}'"
|
|
529
|
+
@is_new_index = true
|
|
530
|
+
@is_comma = false
|
|
531
|
+
end
|
|
532
|
+
add_tok tok
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
def on_comma(tok, f)
|
|
536
|
+
@is_comma = true
|
|
537
|
+
@is_index = true
|
|
538
|
+
add_tok tok
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
class AddTimestampsFuncFilter < Ripper::Filter
|
|
544
|
+
attr_accessor :fclass, :func_str
|
|
545
|
+
|
|
546
|
+
def initialize(src, fclass)
|
|
547
|
+
super src
|
|
548
|
+
|
|
549
|
+
@fclass = fclass
|
|
550
|
+
@func_str = ''
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
def add_tok(tok)
|
|
554
|
+
@func_str += tok
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
class RemoveTimestampsFuncFilter < AddTimestampsFuncFilter
|
|
560
|
+
end
|