acread 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree-1.8.7
6
+ # - rbx-19mode
7
+ # uncomment this line if your project needs to run something other than `rake`:
8
+ # script: bundle exec rspec spec
data/README.md CHANGED
@@ -18,44 +18,50 @@ add to your Gemfile :
18
18
 
19
19
  ## deprecate an attribute
20
20
 
21
- class Person < ActiveRecord::Base
22
- ...
23
- deprecate_attribute :long_name
24
- ...
25
- end
21
+ ```ruby
22
+ class Person < ActiveRecord::Base
23
+ ...
24
+ deprecate_attribute :long_name
25
+ ...
26
+ end
27
+ ```
26
28
 
27
29
  ## find attribute usage
28
30
  you can catch the `DeprecatedAttributeError` exception and for example put a backtrace in a specific logger.
29
31
 
30
- class ApplicationController
31
- rescue_from DeprecatedAttributeError, :with => :log_deprecate
32
-
33
- private
34
-
35
- def deprecated_logger
36
- @@deprecated_logger ||= Logger.new("#{Rails.root}/log/deprecated_calls.log")
37
- end
38
-
39
- def log_deprecated e
40
- deprecated_logger.error(e.stacktrace.join("\n"))
41
- end
42
- end
43
-
32
+ ```ruby
33
+ class ApplicationController
34
+ rescue_from DeprecatedAttributeError, :with => :log_deprecate
35
+
36
+ private
37
+
38
+ def deprecated_logger
39
+ @@deprecated_logger ||= Logger.new("#{Rails.root}/log/deprecated_calls.log")
40
+ end
41
+
42
+ def log_deprecated e
43
+ deprecated_logger.error(e.stacktrace.join("\n"))
44
+ end
45
+ end
46
+ ```
47
+
44
48
  ## zero downtime migration
45
49
  When you are done with cleaning your code from any usage of deprecated attributes, you can prepare a migration including some drop_columns.
46
50
 
47
51
  example :
48
52
 
49
- class RemoveLongNames < ActiveRecord::Migration
50
- def self.up
51
- remove_column :Person, :long_name
53
+ ```ruby
54
+ class RemoveLongNames < ActiveRecord::Migration
55
+ def self.up
56
+ remove_column :Person, :long_name
52
57
 
53
- end
58
+ end
54
59
 
55
- def self.down
56
- raise ActiveRecord::IrreversibleMigration
57
- end
58
- end
60
+ def self.down
61
+ raise ActiveRecord::IrreversibleMigration
62
+ end
63
+ end
64
+ ```
59
65
 
60
66
  Then you can safely follow the steps :
61
67
 
@@ -65,17 +71,7 @@ Then you can safely follow the steps :
65
71
  2. Remove deprecation declarations from your code
66
72
  3. Deploy your final clean version of code
67
73
 
68
- # Contributing to acread
69
-
70
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
71
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
72
- * Fork the project.
73
- * Start a feature/bugfix branch.
74
- * Commit and push until you are happy with your contribution.
75
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
76
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
77
-
78
74
  # Copyright
79
75
 
80
76
  Copyright (c) 2012 yann ARMAND under MIT See LICENSE.txt for
81
- further details.
77
+ further details.
data/Rakefile CHANGED
@@ -18,11 +18,7 @@ Jeweler::Tasks.new do |gem|
18
18
  gem.homepage = "http://github.com/yarmand/acread"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{An ActiveRecord Extension to deprecate attributes}
21
- gem.description = %Q{When you deprecate an attribute, acread can helps you in 3 ways :
22
-
23
- 1. helps you finding where you are using this attribute by creating glue to raise a `DeprecatedAttributeError`.
24
- 2. ignore this atribute when serializing the object through to_json, to_xml ...
25
- 3. helps your zero downtime migration by ignoring the attribute for objects already in memory when saving to database.}
21
+ gem.description = %Q{An ActiveRecord Extension to deprecate attributes}
26
22
  gem.email = "yann@harakys.com"
27
23
  gem.authors = ["yann ARMAND"]
28
24
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
data/acread.gemspec CHANGED
@@ -5,18 +5,19 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "acread"
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["yann ARMAND"]
12
- s.date = "2012-10-23"
13
- s.description = "When you deprecate an attribute, acread can helps you in 3 ways :\n\n1. helps you finding where you are using this attribute by creating glue to raise a `DeprecatedAttributeError`.\n2. ignore this atribute when serializing the object through to_json, to_xml ...\n3. helps your zero downtime migration by ignoring the attribute for objects already in memory when saving to database."
12
+ s.date = "2012-10-25"
13
+ s.description = "An ActiveRecord Extension to deprecate attributes"
14
14
  s.email = "yann@harakys.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.md"
18
18
  ]
19
19
  s.files = [
20
+ ".travis.yml",
20
21
  "Gemfile",
21
22
  "LICENSE.txt",
22
23
  "README.md",
@@ -32,7 +33,7 @@ Gem::Specification.new do |s|
32
33
  s.homepage = "http://github.com/yarmand/acread"
33
34
  s.licenses = ["MIT"]
34
35
  s.require_paths = ["lib"]
35
- s.rubygems_version = "1.8.24"
36
+ s.rubygems_version = "1.8.15"
36
37
  s.summary = "An ActiveRecord Extension to deprecate attributes"
37
38
 
38
39
  if s.respond_to? :specification_version then
@@ -1,5 +1,7 @@
1
1
  module Deprecatable
2
2
 
3
+ ACCESSORS = [ '', '=', '_before_type_cast', '?', '_changed?', '_change', '_will_change!', '_was']
4
+
3
5
  def deprecate_attribute attr
4
6
  @deprecated_attributes ||=[]
5
7
  @deprecated_attributes << attr.to_s
@@ -10,9 +12,14 @@ module Deprecatable
10
12
  @deprecated_attributes
11
13
  end
12
14
 
15
+ def accessors
16
+ # TODO: replace this constant by an ActiveRecord inspection
17
+ ACCESSORS
18
+ end
19
+
13
20
  def overide_accessors attr
14
21
  msg = "You can't access atribute #{attr}, it has been deprecated"
15
- [ '', '=', '?', '_changed?'].each do |term|
22
+ accessors.each do |term|
16
23
  define_method("#{attr}#{term}") do |e=nil|
17
24
  raise DeprecatedAttributeError, msg
18
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-23 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70279980508580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '3.0'
24
+ version_requirements: *70279980508580
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: shoulda
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70279980519540 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: '0'
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *70279980519540
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: rdoc
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &70279980530260 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ! '>='
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: '3.12'
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '3.12'
46
+ version_requirements: *70279980530260
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: bundler
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &70279980525260 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ! '>='
@@ -69,15 +54,10 @@ dependencies:
69
54
  version: 1.0.0
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: 1.0.0
57
+ version_requirements: *70279980525260
78
58
  - !ruby/object:Gem::Dependency
79
59
  name: jeweler
80
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &70279980524080 !ruby/object:Gem::Requirement
81
61
  none: false
82
62
  requirements:
83
63
  - - ! '>='
@@ -85,15 +65,10 @@ dependencies:
85
65
  version: 1.8.4
86
66
  type: :development
87
67
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: 1.8.4
68
+ version_requirements: *70279980524080
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: sqlite3
96
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &70279980588660 !ruby/object:Gem::Requirement
97
72
  none: false
98
73
  requirements:
99
74
  - - ! '>='
@@ -101,22 +76,8 @@ dependencies:
101
76
  version: '0'
102
77
  type: :development
103
78
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- description: ! 'When you deprecate an attribute, acread can helps you in 3 ways :
111
-
112
-
113
- 1. helps you finding where you are using this attribute by creating glue to raise
114
- a `DeprecatedAttributeError`.
115
-
116
- 2. ignore this atribute when serializing the object through to_json, to_xml ...
117
-
118
- 3. helps your zero downtime migration by ignoring the attribute for objects already
119
- in memory when saving to database.'
79
+ version_requirements: *70279980588660
80
+ description: An ActiveRecord Extension to deprecate attributes
120
81
  email: yann@harakys.com
121
82
  executables: []
122
83
  extensions: []
@@ -124,6 +85,7 @@ extra_rdoc_files:
124
85
  - LICENSE.txt
125
86
  - README.md
126
87
  files:
88
+ - .travis.yml
127
89
  - Gemfile
128
90
  - LICENSE.txt
129
91
  - README.md
@@ -150,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
112
  version: '0'
151
113
  segments:
152
114
  - 0
153
- hash: -2680666247373849907
115
+ hash: 4433754992090898860
154
116
  required_rubygems_version: !ruby/object:Gem::Requirement
155
117
  none: false
156
118
  requirements:
@@ -159,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
121
  version: '0'
160
122
  requirements: []
161
123
  rubyforge_project:
162
- rubygems_version: 1.8.24
124
+ rubygems_version: 1.8.15
163
125
  signing_key:
164
126
  specification_version: 3
165
127
  summary: An ActiveRecord Extension to deprecate attributes