legacy_woes 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,11 @@
1
+ = 0.2.0
2
+ * create_on_colum(Amos King)
3
+ * updated_on_colum(Amos King)
4
+ * condensed backend code to make it easy to add new column methods(Amos King)
5
+
6
+ = 0.1.2
7
+ * clean up code(Amos King)
8
+
9
+ = 0.1.0
10
+ * created_at_column(Amos King)
11
+ * updated_at_column(Amos King)
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Amos L. King
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,6 @@
1
+ CHANGELOG.rdoc
2
+ lib/legacy_woes.rb
3
+ Manifest
4
+ MIT-LICENSE
5
+ Rakefile
6
+ README.rdoc
data/README.rdoc ADDED
@@ -0,0 +1,26 @@
1
+ = Legacy Woes
2
+
3
+ If your working with
4
+
5
+ == Install as a gem
6
+
7
+ gem install adkron-legacy_woes --source http://gems.github.com
8
+
9
+ In Rails you can instead add this to your environment.rb file
10
+ config.gem "adkron-legacy_woes", :lib => 'legacy_woes', :source => 'http://gems.github.com'
11
+
12
+ == Install as a plugin
13
+
14
+ script/plugin install git://github.com/adkron/legacy_woes.git
15
+
16
+ == Example
17
+
18
+ require 'rubygems'
19
+ require 'legacy_woes'
20
+
21
+ class LegacyComments < ActiveRecord::Base
22
+ created_at_column :datesubmitted
23
+ end
24
+
25
+
26
+ **Copyright (c) 2008 Amos L. King, released under the MIT license**
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # Rakefile
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'echoe'
5
+
6
+ Echoe.new('legacy_woes', '0.2.0') do |p|
7
+ p.description = 'Tools for legacy databases and ActiveRecord'
8
+ p.url = 'http://github.com/adkron/legacy_woes'
9
+ p.author = 'Amos King'
10
+ p.email = 'amos.l.king@gmail.com'
11
+ p.ignore_pattern = ['tmp/*', 'script/*', 'example.rb', 'test/*', 'init.rb', '*.gemspec']
12
+ p.development_dependencies = []
13
+ end
14
+
15
+ Dir['#{File.dirname(__FILE__)}/tasks/*.rake'].sort.each
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{legacy_woes}
5
+ s.version = "0.2.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Amos King"]
9
+ s.date = %q{2009-01-28}
10
+ s.description = %q{Tools for legacy databases and ActiveRecord}
11
+ s.email = %q{amos.l.king@gmail.com}
12
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/legacy_woes.rb", "README.rdoc"]
13
+ s.files = ["CHANGELOG.rdoc", "lib/legacy_woes.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README.rdoc", "legacy_woes.gemspec", "CHANGELOG.rdoc"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/adkron/legacy_woes}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Legacy_woes", "--main", "README.rdoc", "CHANGELOG.rdoc", "MIT-LICENSE"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{legacy_woes}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Tools for legacy databases and ActiveRecord}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 2
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ else
28
+ end
29
+ else
30
+ end
31
+ end
@@ -0,0 +1,59 @@
1
+ # Get rid of some of the legacy database woes
2
+ #
3
+ # Author:: Amos King (mailto:amos.l.king@gmail.com)
4
+ # Copyright:: Copyright (c) 2008 Amos King
5
+ # License:: Released under the MIT license
6
+
7
+
8
+ module LegacyWoes
9
+ def self.included(base)
10
+ base.extend ClassMethods
11
+ end
12
+
13
+ module ClassMethods
14
+ # Sets the created_at column.
15
+ # Also defines methods for created_at and created_at=.
16
+ def created_at_column(legacy_column_name)
17
+ setup_legacy_method(legacy_column_name, :created_at)
18
+ end
19
+
20
+ # Sets the updated_at column.
21
+ # Also defines methods for updated_at and updated_at=.
22
+ def updated_at_column(legacy_column_name)
23
+ setup_legacy_method(legacy_column_name, :updated_at)
24
+ end
25
+
26
+ # Sets the created_on column.
27
+ # Also defines methods for created_on and created_on=.
28
+ def created_on_column(legacy_column_name)
29
+ setup_legacy_method(legacy_column_name, :created_on)
30
+ end
31
+
32
+ # Sets the updated_on column.
33
+ # Also defines methods for updated_on and updated_on=.
34
+ def updated_on_column(legacy_column_name)
35
+ setup_legacy_method(legacy_column_name, :updated_on)
36
+ end
37
+
38
+ def setup_legacy_method(legacy_column_name, replacement_column)
39
+ module_eval <<-EOB
40
+ def write_attribute_with_#{legacy_column_name}_#{replacement_column}(name, value, &block)
41
+ if name == '#{replacement_column}'
42
+ write_attribute('#{legacy_column_name}', value)
43
+ else
44
+ send(:write_attribute_without_#{legacy_column_name}_#{replacement_column}, name, value, &block)
45
+ end
46
+ end
47
+ EOB
48
+
49
+ alias_attribute replacement_column, legacy_column_name
50
+ alias_method_chain :write_attribute, "#{legacy_column_name}_#{replacement_column}"
51
+ end
52
+ protected :setup_legacy_method
53
+ end
54
+ end
55
+
56
+ class ActiveRecord::Base
57
+ include LegacyWoes
58
+ end
59
+
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: legacy_woes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Amos King
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-28 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Tools for legacy databases and ActiveRecord
17
+ email: amos.l.king@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - CHANGELOG.rdoc
24
+ - lib/legacy_woes.rb
25
+ - README.rdoc
26
+ files:
27
+ - CHANGELOG.rdoc
28
+ - lib/legacy_woes.rb
29
+ - Manifest
30
+ - MIT-LICENSE
31
+ - Rakefile
32
+ - README.rdoc
33
+ - legacy_woes.gemspec
34
+ has_rdoc: true
35
+ homepage: http://github.com/adkron/legacy_woes
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --line-numbers
41
+ - --inline-source
42
+ - --title
43
+ - Legacy_woes
44
+ - --main
45
+ - README.rdoc
46
+ - CHANGELOG.rdoc
47
+ - MIT-LICENSE
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "1.2"
61
+ version:
62
+ requirements: []
63
+
64
+ rubyforge_project: legacy_woes
65
+ rubygems_version: 1.3.5
66
+ signing_key:
67
+ specification_version: 2
68
+ summary: Tools for legacy databases and ActiveRecord
69
+ test_files: []
70
+