trackzor 0.1.1 → 0.1.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.
data/README.rdoc CHANGED
@@ -1,12 +1,24 @@
1
- = Quick Start
1
+ == Setup
2
2
 
3
- Add "trackzored" to your model. By convention, any attribute that also has [ATTR]_updated_at or [ATTR]_updated_by will be tracked. If [ATTR]_updated_by is present, it is required by a validator.
3
+ Add "trackzored" to your model. By convention, any attribute that also has [ATTR]_updated_at or [ATTR]_updated_by will be maintained.
4
+ You can optionally specify :only and :except if this convention steps on your toes --
5
+ :except => :status would skip the check and update of status_updated_at and status_updated_by.
6
+ If [ATTR]_updated_by is present, it is required by a validator. If acts_as_audited is present, trackzor-maintained columns will be added to non_audited_columns to prevent double-auditing.
4
7
 
5
8
  Use the trackzor_migration generator to quickly add columns:
6
9
  script/generate trackzor_migration User email phone_number
7
10
  This will create a migration for adding email_updated_at, email_updated_by, phone_number_updated_at, and phone_number_updated_by columns.
8
11
 
12
+ == Usage
13
+
9
14
  To set the current user:
10
15
  Trackzor.as_user(user_obj) do
11
16
  ...
12
17
  end
18
+
19
+ Or, if you're also using acts_as_audited, its as_user method is supported:
20
+ Audit.as_user(user_obj) do
21
+ ...
22
+ end
23
+
24
+ For each trackzored [ATTR]_updated_by column, a belongs_to association (:[ATTR]_source) is added to link to the user.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('trackzor', '0.1.1') do |gem|
5
+ Echoe.new('trackzor', '0.1.2') do |gem|
6
6
  gem.description = "Track ATTR_updated_at and ATTR_updated_by"
7
7
  gem.url = "http://github.com/corneldm/trackzor"
8
8
  gem.author = "David Cornelius"
data/lib/trackzor.rb CHANGED
@@ -12,8 +12,14 @@ module Trackzor
12
12
  except |= Array(options[:except]).collect(&:to_s) if options[:except]
13
13
  end
14
14
 
15
- (self.column_names - except).select{|column| column =~ /_updated_by/ }.each do |col|
16
- belongs_to "#{col.split('_updated_by')[0]}_source".to_sym, :class_name => 'User', :foreign_key => col
15
+ aaa_present = self.respond_to?(:non_audited_columns)
16
+
17
+ (self.column_names - except).select{|column| column =~ /_updated_by|_updated_at/ }.each do |col|
18
+ if col =~ /_updated_by/
19
+ belongs_to "#{col.split('_updated_by')[0]}_source".to_sym, :class_name => 'User', :foreign_key => col
20
+ end
21
+
22
+ self.non_audited_columns << col if aaa_present
17
23
  end
18
24
 
19
25
  validate do |record|
data/trackzor.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{trackzor}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["David Cornelius"]
9
- s.date = %q{2010-01-13}
9
+ s.date = %q{2010-01-18}
10
10
  s.description = %q{Track ATTR_updated_at and ATTR_updated_by}
11
11
  s.email = %q{david.cornelius@bluefishwireless.net}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/trackzor.rb"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackzor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cornelius
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-13 00:00:00 -05:00
12
+ date: 2010-01-18 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15