table_renamable 0.0.1

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.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/javascripts/table_renamable/application.js +15 -0
  6. data/app/assets/stylesheets/table_renamable/application.css +13 -0
  7. data/app/controllers/table_renamable/application_controller.rb +4 -0
  8. data/app/helpers/table_renamable/application_helper.rb +4 -0
  9. data/app/views/layouts/table_renamable/application.html.erb +14 -0
  10. data/config/routes.rb +2 -0
  11. data/lib/table_renamable/connection_adapters/mysql2_adapter.rb +31 -0
  12. data/lib/table_renamable/connection_adapters/sqlite3_adapter.rb +62 -0
  13. data/lib/table_renamable/connection_adapters.rb +13 -0
  14. data/lib/table_renamable/deprecated_table.rb +106 -0
  15. data/lib/table_renamable/engine.rb +22 -0
  16. data/lib/table_renamable/model.rb +95 -0
  17. data/lib/table_renamable/version.rb +3 -0
  18. data/lib/table_renamable.rb +11 -0
  19. data/lib/tasks/table_renamable_tasks.rake +4 -0
  20. data/spec/dummy/README.rdoc +261 -0
  21. data/spec/dummy/Rakefile +7 -0
  22. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  23. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  24. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  25. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  26. data/spec/dummy/app/models/post.rb +3 -0
  27. data/spec/dummy/app/models/user.rb +5 -0
  28. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  29. data/spec/dummy/config/application.rb +65 -0
  30. data/spec/dummy/config/boot.rb +10 -0
  31. data/spec/dummy/config/database.yml +11 -0
  32. data/spec/dummy/config/environment.rb +5 -0
  33. data/spec/dummy/config/environments/development.rb +37 -0
  34. data/spec/dummy/config/environments/production.rb +67 -0
  35. data/spec/dummy/config/environments/test.rb +37 -0
  36. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  37. data/spec/dummy/config/initializers/inflections.rb +15 -0
  38. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  39. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  40. data/spec/dummy/config/initializers/session_store.rb +8 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/spec/dummy/config/locales/en.yml +5 -0
  43. data/spec/dummy/config/routes.rb +4 -0
  44. data/spec/dummy/config.ru +4 -0
  45. data/spec/dummy/db/test.sqlite3 +0 -0
  46. data/spec/dummy/log/test.log +1158 -0
  47. data/spec/dummy/public/404.html +26 -0
  48. data/spec/dummy/public/422.html +26 -0
  49. data/spec/dummy/public/500.html +25 -0
  50. data/spec/dummy/public/favicon.ico +0 -0
  51. data/spec/dummy/script/rails +6 -0
  52. data/spec/lib/table_renamable/model_spec.rb +82 -0
  53. data/spec/spec_helper.rb +40 -0
  54. metadata +157 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ module TableRenamable
4
+
5
+ describe Model do
6
+
7
+ before(:each) do
8
+
9
+ Post.table_name = 'posts'
10
+
11
+ Post.connection.create_table :posts, force: true do |t|
12
+ t.string :title
13
+ t.string :body
14
+ t.integer :user_id
15
+ t.timestamps
16
+ end
17
+ Post.reset_column_information
18
+
19
+ Post.connection.execute("DROP TABLE IF EXISTS my_new_name")
20
+
21
+
22
+ # users
23
+ User.connection.create_table :users, force: true do |t|
24
+ t.string :name
25
+ t.string :description
26
+ t.timestamps
27
+ end
28
+
29
+ end
30
+
31
+ context 'with table rename' do
32
+
33
+ before(:each) do
34
+ # only do this once but it has to happen after the table is defined
35
+ unless Post.included_modules.include?(TableRenamable::Model)
36
+ Post.class_eval do
37
+
38
+ include TableRenamable::Model
39
+
40
+ deprecate_table_name(:posts, :my_new_name)
41
+ end
42
+ end
43
+ end
44
+
45
+ context '.deprecate_table_name' do
46
+
47
+ it 'allows tables to be renamed without missing a beat' do
48
+
49
+ Post.connection.rename_table(:posts, :my_new_name)
50
+
51
+ lambda { Post.all }.should_not raise_error
52
+
53
+ end
54
+
55
+ end
56
+ end
57
+
58
+ context '.deprecate_columns' do
59
+
60
+
61
+ it 'allows columns to be renamed without throwing errors' do
62
+ # need to call this to get the columns loaded
63
+ User.all
64
+
65
+
66
+ User.class_eval do
67
+
68
+ include TableRenamable::Model
69
+
70
+ deprecate_columns(:name)
71
+ end
72
+
73
+ User.columns.collect(&:name).should_not include "name"
74
+ User.column_names.should_not include "name"
75
+
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,40 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ # Requires supporting ruby files with custom matchers and macros, etc,
8
+ # in spec/support/ and its subdirectories.
9
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
10
+
11
+ RSpec.configure do |config|
12
+ # ## Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+
20
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
+ # examples within a transaction, remove the following line or assign false
25
+ # instead of true.
26
+ config.use_transactional_fixtures = true
27
+
28
+ # If true, the base class of anonymous controllers will be inferred
29
+ # automatically. This will be the default behavior in future versions of
30
+ # rspec-rails.
31
+ config.infer_base_class_for_anonymous_controllers = false
32
+
33
+ # Run specs in random order to surface order dependencies. If you find an
34
+ # order dependency and want to debug it, you can fix the order by providing
35
+ # the seed, which is printed after each run.
36
+ # --seed 1234
37
+ config.order = "random"
38
+
39
+
40
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: table_renamable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan Langevin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.14
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.14
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Gem to support live renaming of tables columns
42
+ email:
43
+ - dan.langevin@lifebooker.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - app/assets/javascripts/table_renamable/application.js
49
+ - app/assets/stylesheets/table_renamable/application.css
50
+ - app/controllers/table_renamable/application_controller.rb
51
+ - app/helpers/table_renamable/application_helper.rb
52
+ - app/views/layouts/table_renamable/application.html.erb
53
+ - config/routes.rb
54
+ - lib/table_renamable/connection_adapters/mysql2_adapter.rb
55
+ - lib/table_renamable/connection_adapters/sqlite3_adapter.rb
56
+ - lib/table_renamable/connection_adapters.rb
57
+ - lib/table_renamable/deprecated_table.rb
58
+ - lib/table_renamable/engine.rb
59
+ - lib/table_renamable/model.rb
60
+ - lib/table_renamable/version.rb
61
+ - lib/table_renamable.rb
62
+ - lib/tasks/table_renamable_tasks.rake
63
+ - MIT-LICENSE
64
+ - Rakefile
65
+ - README.rdoc
66
+ - spec/dummy/app/assets/javascripts/application.js
67
+ - spec/dummy/app/assets/stylesheets/application.css
68
+ - spec/dummy/app/controllers/application_controller.rb
69
+ - spec/dummy/app/helpers/application_helper.rb
70
+ - spec/dummy/app/models/post.rb
71
+ - spec/dummy/app/models/user.rb
72
+ - spec/dummy/app/views/layouts/application.html.erb
73
+ - spec/dummy/config/application.rb
74
+ - spec/dummy/config/boot.rb
75
+ - spec/dummy/config/database.yml
76
+ - spec/dummy/config/environment.rb
77
+ - spec/dummy/config/environments/development.rb
78
+ - spec/dummy/config/environments/production.rb
79
+ - spec/dummy/config/environments/test.rb
80
+ - spec/dummy/config/initializers/backtrace_silencers.rb
81
+ - spec/dummy/config/initializers/inflections.rb
82
+ - spec/dummy/config/initializers/mime_types.rb
83
+ - spec/dummy/config/initializers/secret_token.rb
84
+ - spec/dummy/config/initializers/session_store.rb
85
+ - spec/dummy/config/initializers/wrap_parameters.rb
86
+ - spec/dummy/config/locales/en.yml
87
+ - spec/dummy/config/routes.rb
88
+ - spec/dummy/config.ru
89
+ - spec/dummy/db/test.sqlite3
90
+ - spec/dummy/log/test.log
91
+ - spec/dummy/public/404.html
92
+ - spec/dummy/public/422.html
93
+ - spec/dummy/public/500.html
94
+ - spec/dummy/public/favicon.ico
95
+ - spec/dummy/Rakefile
96
+ - spec/dummy/README.rdoc
97
+ - spec/dummy/script/rails
98
+ - spec/lib/table_renamable/model_spec.rb
99
+ - spec/spec_helper.rb
100
+ homepage: http://github.com/LifebookerInc/table_renamable
101
+ licenses: []
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.0.3
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Renaming tables and columns
123
+ test_files:
124
+ - spec/dummy/app/assets/javascripts/application.js
125
+ - spec/dummy/app/assets/stylesheets/application.css
126
+ - spec/dummy/app/controllers/application_controller.rb
127
+ - spec/dummy/app/helpers/application_helper.rb
128
+ - spec/dummy/app/models/post.rb
129
+ - spec/dummy/app/models/user.rb
130
+ - spec/dummy/app/views/layouts/application.html.erb
131
+ - spec/dummy/config/application.rb
132
+ - spec/dummy/config/boot.rb
133
+ - spec/dummy/config/database.yml
134
+ - spec/dummy/config/environment.rb
135
+ - spec/dummy/config/environments/development.rb
136
+ - spec/dummy/config/environments/production.rb
137
+ - spec/dummy/config/environments/test.rb
138
+ - spec/dummy/config/initializers/backtrace_silencers.rb
139
+ - spec/dummy/config/initializers/inflections.rb
140
+ - spec/dummy/config/initializers/mime_types.rb
141
+ - spec/dummy/config/initializers/secret_token.rb
142
+ - spec/dummy/config/initializers/session_store.rb
143
+ - spec/dummy/config/initializers/wrap_parameters.rb
144
+ - spec/dummy/config/locales/en.yml
145
+ - spec/dummy/config/routes.rb
146
+ - spec/dummy/config.ru
147
+ - spec/dummy/db/test.sqlite3
148
+ - spec/dummy/log/test.log
149
+ - spec/dummy/public/404.html
150
+ - spec/dummy/public/422.html
151
+ - spec/dummy/public/500.html
152
+ - spec/dummy/public/favicon.ico
153
+ - spec/dummy/Rakefile
154
+ - spec/dummy/README.rdoc
155
+ - spec/dummy/script/rails
156
+ - spec/lib/table_renamable/model_spec.rb
157
+ - spec/spec_helper.rb