activerecord-table_version 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +8 -8
- data/Readme.textile +57 -0
- data/activerecord-table_version.gemspec +2 -2
- data/lib/activerecord/table_version.rb +17 -7
- data/spec/activerecord-table_version_spec.rb +1 -1
- metadata +6 -6
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
3
|
case ("rails%s" % ENV.fetch("RAILS_VERSION", "3")).to_sym
|
4
|
-
when :rails3; gem 'activerecord', '~> 3.0.
|
5
|
-
when :rails2; gem 'activerecord', '~> 2.3.
|
4
|
+
when :rails3; gem 'activerecord', '~> 3.0.5'
|
5
|
+
when :rails2; gem 'activerecord', '~> 2.3.11'
|
6
6
|
end
|
7
7
|
|
8
8
|
group :development do
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (3.0.
|
5
|
-
activesupport (= 3.0.
|
4
|
+
activemodel (3.0.5)
|
5
|
+
activesupport (= 3.0.5)
|
6
6
|
builder (~> 2.1.2)
|
7
7
|
i18n (~> 0.4)
|
8
|
-
activerecord (3.0.
|
9
|
-
activemodel (= 3.0.
|
10
|
-
activesupport (= 3.0.
|
8
|
+
activerecord (3.0.5)
|
9
|
+
activemodel (= 3.0.5)
|
10
|
+
activesupport (= 3.0.5)
|
11
11
|
arel (~> 2.0.2)
|
12
12
|
tzinfo (~> 0.3.23)
|
13
|
-
activesupport (3.0.
|
14
|
-
arel (2.0.
|
13
|
+
activesupport (3.0.5)
|
14
|
+
arel (2.0.9)
|
15
15
|
builder (2.1.2)
|
16
16
|
diff-lcs (1.1.2)
|
17
17
|
i18n (0.5.0)
|
@@ -30,7 +30,7 @@ PLATFORMS
|
|
30
30
|
ruby
|
31
31
|
|
32
32
|
DEPENDENCIES
|
33
|
-
activerecord (~> 3.0.
|
33
|
+
activerecord (~> 3.0.5)
|
34
34
|
bundler (~> 1.0.0)
|
35
35
|
rake (~> 0.8.7)
|
36
36
|
rspec (= 2.1.0)
|
data/Readme.textile
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
h1. ActiveRecord::TableVersion
|
2
|
+
|
3
|
+
Makes setting table name versions simple.
|
4
|
+
|
5
|
+
h2. Example
|
6
|
+
|
7
|
+
<pre><code>
|
8
|
+
class Model < ActiveRecord::Base
|
9
|
+
set_table_name "foos"
|
10
|
+
set_table_version "2011_01_25"
|
11
|
+
end
|
12
|
+
|
13
|
+
Model.table_name #=> "foos_2011_01_25"
|
14
|
+
</code></pre>
|
15
|
+
|
16
|
+
h2. Installation
|
17
|
+
|
18
|
+
Depends on ActiveRecord. Works with both versions 2.3.10 and 3.0.3.
|
19
|
+
|
20
|
+
Install the gem with:
|
21
|
+
<code>gem install activerecord-table_version</code>
|
22
|
+
|
23
|
+
Or, in your Gemfile:
|
24
|
+
<code>gem "activerecord-table_version", "~> 0.0.1"</code>
|
25
|
+
|
26
|
+
If you're on an older version of Rails:
|
27
|
+
<code>config.gem "activerecord-table_version", :version => "~> 0.0.1"</code>
|
28
|
+
|
29
|
+
h2. Migrations and Warning
|
30
|
+
|
31
|
+
In order to apply migrations, you will need to refer to the @table_name@ of the model directly.
|
32
|
+
|
33
|
+
NOTE: This has not seen extensive production use and this may result in problems in practice. You've been warned.
|
34
|
+
|
35
|
+
h2. License and Copyright
|
36
|
+
|
37
|
+
The MIT License
|
38
|
+
|
39
|
+
Copyright (c) 2011 Matt Todd.
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
42
|
+
of this software and associated documentation files (the "Software"), to deal
|
43
|
+
in the Software without restriction, including without limitation the rights
|
44
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
45
|
+
copies of the Software, and to permit persons to whom the Software is
|
46
|
+
furnished to do so, subject to the following conditions:
|
47
|
+
|
48
|
+
The above copyright notice and this permission notice shall be included in
|
49
|
+
all copies or substantial portions of the Software.
|
50
|
+
|
51
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
52
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
53
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
54
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
55
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
56
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
57
|
+
THE SOFTWARE.
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{activerecord-table_version}
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.2"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Matt Todd"]
|
7
|
-
s.date = %q{2011-
|
7
|
+
s.date = %q{2011-03-09}
|
8
8
|
s.description = %q{Specify a table name with a version number}
|
9
9
|
s.email = %q{chiology@gmail.com}
|
10
10
|
s.files = [
|
@@ -1,13 +1,23 @@
|
|
1
1
|
require 'active_record'
|
2
|
+
require 'active_support/core_ext/module/aliasing'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class ActiveRecord::Base
|
5
|
+
|
6
|
+
class_attribute :table_version, :instance_writer => false
|
7
|
+
self.table_version = nil
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def compute_table_name_with_version
|
11
|
+
return compute_table_name_without_version unless table_version.present?
|
12
|
+
"%s_%s" % [compute_table_name_without_version, table_version]
|
13
|
+
end
|
14
|
+
alias_method_chain :compute_table_name, :version
|
15
|
+
|
16
|
+
def set_table_version(version = nil)
|
17
|
+
self.table_version = version
|
18
|
+
reset_table_name
|
19
|
+
version
|
7
20
|
end
|
8
21
|
end
|
9
22
|
|
10
|
-
Base.class_eval do
|
11
|
-
extend TableVersion
|
12
|
-
end
|
13
23
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-table_version
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Todd
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-09 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
requirements: []
|
116
116
|
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.
|
118
|
+
rubygems_version: 1.4.2
|
119
119
|
signing_key:
|
120
120
|
specification_version: 3
|
121
121
|
summary: Specify a table name with a version number
|