attr_deprecated 0.0.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 +15 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +1 -0
- data/attr_deprecated.gemspec +27 -0
- data/lib/active_model/deprecated_attribute_set.rb +9 -0
- data/lib/attr_deprecated.rb +92 -0
- data/lib/attr_deprecated/configuration.rb +23 -0
- data/lib/attr_deprecated/railtie.rb +17 -0
- data/lib/attr_deprecated/version.rb +3 -0
- data/lib/notifiers/airbrake_notifier.rb +17 -0
- data/lib/notifiers/deprecation_logger.rb +36 -0
- data/spec/attr_deprecated_spec.rb +102 -0
- data/spec/attr_deprected_active_record_spec.rb +33 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/active_record.rb +17 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmFkOWE1MDcyZGExNWZjNjkyODYxMjZiNTJmZGFkNDdhNzZjYjU5NA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTlmZTEyMzgwNGExY2ZkZTBkNmUxY2EzZWQ1NmU3NWM4MWM4OTg0Mg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjM1MDY3ZmUxZTkxOTRjZDhkMWIwMTNjNWUwMDk1ZGMxNWE4YTkzYWFjNjc4
|
10
|
+
NzY5ZWY1YzdiMDVkMGI5NGI1YzYzOTk5M2M1Yjg0Y2NiMDNiMGZlNGVjOWUx
|
11
|
+
OGE0NmNkM2Y0NDhiMTgzOWYwYTBkMTVkNzM1YmRjNWU5Yzg0M2M=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjQwOTc5YzNhZDAwZjdhOWE3OWFmOTBmNWNiOTcyZDBhMzI0OGYxZDc0NTg5
|
14
|
+
NDQ0ODRmYjE5ZDBmMDUwZjc0ZWUxMWUzNTU5Zjg4NzZmMDg5ZGE0MGIyZWM1
|
15
|
+
ZGI4YTlkOGUyZDhlN2JmZTQzMWMxZmFhY2YxNGViODM4ODEwYWM=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Anthony Erlinger
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# AttrDeprecated
|
2
|
+
|
3
|
+
A simple and non-intrusive way to mark deprecated columns/attributes in your models so they may be more safely removed.
|
4
|
+
Any usage of a deprecated attribute will be logged with a warning message and a trace of where the deprecated attribute
|
5
|
+
was called. Exceptions and Airbrake messages can be raised as well.
|
6
|
+
|
7
|
+
## Why?
|
8
|
+
|
9
|
+
Because we all have crap we don't want in our schema but are too afraid to remove.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'attr_deprecated'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install attr_deprecated
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
**In your model**
|
28
|
+
|
29
|
+
class User < ActiveRecord::Base
|
30
|
+
attr_deprecated :some_deprecated_column, :some_other_deprecated_column
|
31
|
+
|
32
|
+
...
|
33
|
+
end
|
34
|
+
|
35
|
+
**Example**:
|
36
|
+
|
37
|
+
> User.attr_deprecated
|
38
|
+
=> <DeprecatedAttributeSet: {"some_deprecated_column", "some_other_deprecated_column"}>
|
39
|
+
>
|
40
|
+
> User.attr_deprecated? :some_deprecated_column
|
41
|
+
=> true
|
42
|
+
>
|
43
|
+
> User.first.some_deprecated_column
|
44
|
+
WARNING: Called deprecated attribute on User: some_deprecated_column
|
45
|
+
.../.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:396:in `start'
|
46
|
+
.../.rvm/gems/ruby-2.1.0/gems/railties-3.2.17/lib/rails/commands/console.rb:47:in `start'
|
47
|
+
.../.rvm/gems/ruby-2.1.0/gems/railties-3.2.17/lib/rails/commands/console.rb:8:in `start'
|
48
|
+
.../.rvm/gems/ruby-2.1.0/gems/railties-3.2.17/lib/rails/commands.rb:41:in `<top (required)>'
|
49
|
+
...
|
50
|
+
|
51
|
+
|
52
|
+
## TODO:
|
53
|
+
|
54
|
+
Add configuration:
|
55
|
+
|
56
|
+
Suppose you have a project with a `production`, `staging`, `development`, and `test` environment defined. You can define the behavior of attr_deprecated for each environment through the config params:
|
57
|
+
|
58
|
+
AttrDeprecated.configure do |config|
|
59
|
+
config.do_logging = [:production, :staging, :development, :test]
|
60
|
+
config.do_exceptions = [:production]
|
61
|
+
|
62
|
+
# Only if you're using Airbrake:
|
63
|
+
config.do_airbrake = [:production, :staging]
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
1. Fork it ( http://github.com/Aerlinger/attr_deprecated/fork )
|
70
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
71
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
72
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
73
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'attr_deprecated/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "attr_deprecated"
|
8
|
+
spec.version = AttrDeprecated::VERSION
|
9
|
+
spec.authors = ["Anthony Erlinger"]
|
10
|
+
spec.email = ["anthony@handybook.com"]
|
11
|
+
spec.summary = %q{Mark unused model attributes as deprecated.}
|
12
|
+
spec.description = %q{A simple and non-intrusive way to mark deprecated columns/attributes in your models. Any usage of these attributes will logged with a warning message and a trace of where the deprecated attribute was called. An exception can be optionally raised as well.}
|
13
|
+
spec.homepage = "https://github.com/Aerlinger/attr_deprecated"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.test_files = spec.files.grep(%r{^(spec)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency 'activesupport', ['>= 3.0', '< 5.0']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'activerecord', ['>= 3.0', '< 5.0']
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec", "2.14.1"
|
26
|
+
spec.add_development_dependency "sqlite3"
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
require "attr_deprecated/version"
|
4
|
+
require "attr_deprecated/configuration"
|
5
|
+
|
6
|
+
require "notifiers/deprecation_logger"
|
7
|
+
require "active_model/deprecated_attribute_set"
|
8
|
+
|
9
|
+
require 'active_record'
|
10
|
+
require 'active_model'
|
11
|
+
|
12
|
+
module AttrDeprecated
|
13
|
+
extend ActiveSupport::Concern
|
14
|
+
|
15
|
+
included do
|
16
|
+
class_attribute :_deprecated_attributes, instance_writer: false
|
17
|
+
end
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
##
|
21
|
+
# == attr_deprecated
|
22
|
+
#
|
23
|
+
# class macro definition to non-destructively mark an attribute as deprecated.
|
24
|
+
#
|
25
|
+
# The original method (i.e. the one marked as deprecated) is renamed and wrapped in an alias that dispatches the notification.
|
26
|
+
# (See the `around_alias` pattern. [Paolo Perotta. Metaprogramming Ruby, p. 121])
|
27
|
+
#
|
28
|
+
def attr_deprecated(*attributes)
|
29
|
+
attributes = DeprecatedAttributeSet.new(attributes.compact)
|
30
|
+
self._deprecated_attributes ||= DeprecatedAttributeSet.new
|
31
|
+
|
32
|
+
# Rails uses lazy initialization to wrap methods, so make sure we pre-initialize any deprecated attributes
|
33
|
+
if defined?(ActiveRecord) && ancestors.include?(ActiveRecord::Base)
|
34
|
+
new(Hash[attributes.zip(attributes.map {})], without_protection: true)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Taking the difference of the two sets ensures we don't deprecate the same attribute more than once
|
38
|
+
(attributes - _deprecated_attributes).each do |attribute|
|
39
|
+
_set_attribute_as_deprecated attribute
|
40
|
+
end
|
41
|
+
|
42
|
+
self._deprecated_attributes += attributes
|
43
|
+
end
|
44
|
+
|
45
|
+
def deprecated_attribute?(attribute)
|
46
|
+
_deprecated_attributes.include?(attribute)
|
47
|
+
end
|
48
|
+
|
49
|
+
def deprecated_attributes
|
50
|
+
_deprecated_attributes || DeprecatedAttributeSet.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def clear_deprecated_attributes!
|
54
|
+
self._deprecated_attributes = _deprecated_attributes.clear
|
55
|
+
end
|
56
|
+
|
57
|
+
def _set_attribute_as_deprecated(attribute)
|
58
|
+
original_method = instance_method(attribute.to_sym)
|
59
|
+
|
60
|
+
klass = self
|
61
|
+
define_method attribute.to_sym do |*args|
|
62
|
+
klass._notify_deprecated_attribute_call(attribute)
|
63
|
+
|
64
|
+
original_method.bind(self).call(*args)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def _notify_deprecated_attribute_call(attribute)
|
69
|
+
@_deprecation_logger ||= AttrDeprecated::DeprecatedAttributeLogger.new(self)
|
70
|
+
|
71
|
+
@_deprecation_logger.log_deprecated_attribute_usage(self, attribute)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
module AttrDeprecated
|
77
|
+
class << self
|
78
|
+
include AttrDeprecated::Configuration
|
79
|
+
|
80
|
+
def configure(&block)
|
81
|
+
AttrDeprecated::Configuration.configure(&block)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
if defined? Rails || ENV['test']
|
87
|
+
class ActiveRecord::Base
|
88
|
+
include AttrDeprecated
|
89
|
+
end
|
90
|
+
|
91
|
+
require 'attr_deprecated/railtie.rb' if defined?(Rails)
|
92
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module AttrDeprecated
|
4
|
+
module Configuration
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
add_config :log_environments
|
9
|
+
add_config :exception_environments
|
10
|
+
add_config :airbrake_environments
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def configure
|
15
|
+
yield self
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_config(value)
|
19
|
+
@name = value if value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
|
3
|
+
module AttrDeprecated
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
initializer "attr_deprecated.active_record", :before => "active_record.set_configs" do |app|
|
6
|
+
ActiveSupport.on_load :active_record do
|
7
|
+
require 'attr_deprecated'
|
8
|
+
|
9
|
+
if app.config.respond_to?(:active_record)
|
10
|
+
class ActiveRecord::Base
|
11
|
+
include AttrDeprecated
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AttrDeprecated
|
2
|
+
class AirbrakeNotifier
|
3
|
+
def initialize(target)
|
4
|
+
@target = target
|
5
|
+
end
|
6
|
+
|
7
|
+
def notify_airbrake(attribute)
|
8
|
+
if defined?(Airbrake)
|
9
|
+
Airbrake.notify Exception.new
|
10
|
+
"WARNING: Called deprecated attribute for #{klass.name}: #{attrs.join(', ')}\n" +
|
11
|
+
backtrace.map { |trace| "\t#{trace}" }.join("\n")
|
12
|
+
|
13
|
+
end
|
14
|
+
rescue
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module AttrDeprecated
|
2
|
+
class DeprecatedAttributeLogger
|
3
|
+
def initialize(target)
|
4
|
+
@target = target
|
5
|
+
super()
|
6
|
+
end
|
7
|
+
|
8
|
+
def logger
|
9
|
+
@target.logger
|
10
|
+
end
|
11
|
+
|
12
|
+
def logger?
|
13
|
+
@target.respond_to?(:logger) && @target.logger
|
14
|
+
end
|
15
|
+
|
16
|
+
def backtrace
|
17
|
+
if defined? Rails
|
18
|
+
Rails.backtrace_cleaner.clean(caller)
|
19
|
+
else
|
20
|
+
caller
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def log_deprecated_attribute_usage(klass, *attrs)
|
25
|
+
warning_message = "WARNING: Called deprecated attribute on #{klass.name}: #{attrs.join(', ')}\n" +
|
26
|
+
backtrace.map { |trace| "\t#{trace}" }.join("\n")
|
27
|
+
if logger?
|
28
|
+
logger.warn do
|
29
|
+
warning_message
|
30
|
+
end
|
31
|
+
else
|
32
|
+
puts warning_message
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Foo
|
4
|
+
include AttrDeprecated
|
5
|
+
|
6
|
+
attr_accessor :fresh_attribute,
|
7
|
+
:an_unused_attribute
|
8
|
+
attr_deprecated :an_unused_attribute
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "Sample spec" do
|
12
|
+
specify "AttrDeprecated is defined" do
|
13
|
+
defined?(AttrDeprecated).should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
specify "A class that extends AttrDeprecated::Model will have attr_deprecated defined" do
|
17
|
+
Foo.methods.should include(:attr_deprecated)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has attr deprecated" do
|
21
|
+
Foo.deprecated_attributes.should eq [:an_unused_attribute]
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "A class includes AttrDeprecated" do
|
25
|
+
before do
|
26
|
+
@f = Foo.new
|
27
|
+
@f.an_unused_attribute = "asdf"
|
28
|
+
@f.fresh_attribute = "fresh"
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "declaring an unused attribute as deprecated" do
|
32
|
+
specify ".attr_deprecated? includes :an_unused_attribute" do
|
33
|
+
Foo.deprecated_attribute?(:an_unused_attribute).should be_true
|
34
|
+
end
|
35
|
+
|
36
|
+
specify "A getter attribute is defined as deprecated" do
|
37
|
+
@f.should_receive(:an_unused_attribute).exactly(1).times.and_call_original
|
38
|
+
Foo.should_receive(:_notify_deprecated_attribute_call)
|
39
|
+
|
40
|
+
@f.should_not_receive(:an_unused_attribute=)
|
41
|
+
|
42
|
+
@f.an_unused_attribute.should eq("asdf")
|
43
|
+
end
|
44
|
+
|
45
|
+
specify "A setter attribute is defined as deprecated" do
|
46
|
+
Foo.should_receive(:_notify_deprecated_attribute_call).exactly(2).times.and_call_original
|
47
|
+
|
48
|
+
@f.an_unused_attribute = "omg"
|
49
|
+
@f.an_unused_attribute
|
50
|
+
@f.an_unused_attribute.should eq("omg")
|
51
|
+
end
|
52
|
+
|
53
|
+
specify "calling attr_deprecated more than once shouldn't cause infinite regress" do
|
54
|
+
Foo.class_eval { attr_deprecated :an_unused_attribute }
|
55
|
+
|
56
|
+
@f.an_unused_attribute.should eq("asdf")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "Adding a new deprecated attribute (more than once)" do
|
61
|
+
before do
|
62
|
+
Foo.class_eval { attr_deprecated :fresh_attribute, :fresh_attribute}
|
63
|
+
end
|
64
|
+
|
65
|
+
it "only calls fresh_attribute once" do
|
66
|
+
@f.should_receive(:fresh_attribute).exactly(1).times.and_call_original
|
67
|
+
|
68
|
+
@f.fresh_attribute.should eq("fresh")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "clearing deprecated attributes" do
|
73
|
+
before do
|
74
|
+
Foo.clear_deprecated_attributes!
|
75
|
+
end
|
76
|
+
|
77
|
+
it "Doesn't have any deprecated attributes" do
|
78
|
+
Foo.deprecated_attributes.should eq([])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "A class doesn't have any deprecated attributes initially" do
|
84
|
+
before do
|
85
|
+
@dummy_class = Class.new do
|
86
|
+
include AttrDeprecated
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it "empty deprecated attributes" do
|
91
|
+
@dummy_class.deprecated_attributes.should eq([])
|
92
|
+
end
|
93
|
+
|
94
|
+
it "calling attr_deprecated alone doesn't raise an error" do
|
95
|
+
@dummy_class.class_eval do
|
96
|
+
attr_deprecated
|
97
|
+
end
|
98
|
+
|
99
|
+
@dummy_class.deprecated_attributes.should eq([])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class User < ActiveRecord::Base
|
4
|
+
attr_deprecated :a_deprecated_attribute
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Integration with ActiveRecord" do
|
8
|
+
before do
|
9
|
+
ActiveRecord::Base.send(:descendants).each do |klass|
|
10
|
+
begin
|
11
|
+
klass.delete_all
|
12
|
+
rescue
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let!(:user) { User.new(name: "rspec", a_deprecated_attribute: "wtf") }
|
18
|
+
|
19
|
+
it "has :a_deprecated_attribute method" do
|
20
|
+
User.instance_methods.should include(:a_deprecated_attribute)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "ensures we've initialized ActiveRecord correctly for our test suite" do
|
24
|
+
user.save!
|
25
|
+
|
26
|
+
expect(user.persisted?).to be_true
|
27
|
+
expect(user.a_deprecated_attribute).to eq("wtf")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has one deprecated attribute" do
|
31
|
+
expect(User.deprecated_attributes).to eq([:a_deprecated_attribute])
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
ENV['test'] = 'test'
|
5
|
+
|
6
|
+
require 'attr_deprecated'
|
7
|
+
require 'support/active_record'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.around do |example|
|
11
|
+
ActiveRecord::Base.transaction do
|
12
|
+
example.run
|
13
|
+
raise ActiveRecord::Rollback
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'attr_deprecated'
|
2
|
+
require 'active_record'
|
3
|
+
|
4
|
+
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
5
|
+
ActiveRecord::Schema.verbose = false
|
6
|
+
|
7
|
+
ActiveRecord::Schema.define do
|
8
|
+
create_table :users, :force => true do |t|
|
9
|
+
t.string :name
|
10
|
+
t.string :email
|
11
|
+
t.string :a_deprecated_attribute
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class User < ActiveRecord::Base
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: attr_deprecated
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anthony Erlinger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activerecord
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.0'
|
40
|
+
- - <
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '5.0'
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.0'
|
50
|
+
- - <
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '5.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.5'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.5'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 2.14.1
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.14.1
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: sqlite3
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
description: A simple and non-intrusive way to mark deprecated columns/attributes
|
110
|
+
in your models. Any usage of these attributes will logged with a warning message
|
111
|
+
and a trace of where the deprecated attribute was called. An exception can be optionally
|
112
|
+
raised as well.
|
113
|
+
email:
|
114
|
+
- anthony@handybook.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .gitignore
|
120
|
+
- .rspec
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- attr_deprecated.gemspec
|
126
|
+
- lib/active_model/deprecated_attribute_set.rb
|
127
|
+
- lib/attr_deprecated.rb
|
128
|
+
- lib/attr_deprecated/configuration.rb
|
129
|
+
- lib/attr_deprecated/railtie.rb
|
130
|
+
- lib/attr_deprecated/version.rb
|
131
|
+
- lib/notifiers/airbrake_notifier.rb
|
132
|
+
- lib/notifiers/deprecation_logger.rb
|
133
|
+
- spec/attr_deprecated_spec.rb
|
134
|
+
- spec/attr_deprected_active_record_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/support/active_record.rb
|
137
|
+
homepage: https://github.com/Aerlinger/attr_deprecated
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.1.11
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Mark unused model attributes as deprecated.
|
161
|
+
test_files:
|
162
|
+
- spec/attr_deprecated_spec.rb
|
163
|
+
- spec/attr_deprected_active_record_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/support/active_record.rb
|