cia 0.1.1 → 0.2.0

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cia (0.1.1)
4
+ cia (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/MIGRATION.rb CHANGED
@@ -1,24 +1,24 @@
1
- create_table :audit_transactions do |t|
1
+ create_table :cia_transactions do |t|
2
2
  t.integer :actor_id, :null => false
3
3
  t.string :actor_type, :null => false
4
4
  t.string :ip_address
5
5
  t.timestamp :created_at
6
6
  end
7
7
 
8
- create_table :audit_events do |t|
8
+ create_table :cia_events do |t|
9
9
  t.string :type, :source_type, :null => false
10
- t.integer :audit_transaction_id, :source_id, :null => false
10
+ t.integer :cia_transaction_id, :source_id, :null => false
11
11
  t.string :message
12
12
  t.timestamp :created_at
13
13
  end
14
14
 
15
- create_table :audit_attribute_changes do |t|
16
- t.integer :audit_event_id, :source_id, :null => false
15
+ create_table :cia_attribute_changes do |t|
16
+ t.integer :cia_event_id, :source_id, :null => false
17
17
  t.string :attribute_name, :source_type, :null => false
18
18
  t.string :old_value, :new_value
19
19
  end
20
20
 
21
21
  # DOWN
22
- # drop_table :audit_transactions
23
- # drop_table :audit_events
24
- # drop_table :audit_attribute_changes
22
+ # drop_table :cia_transactions
23
+ # drop_table :cia_events
24
+ # drop_table :cia_attribute_changes
data/Readme.md CHANGED
@@ -46,8 +46,8 @@ class ApplicationController < ActionController::Base
46
46
  end
47
47
 
48
48
  # quick access
49
- User.last.audit_events
50
- changes = User.last.audit_attribute_changes
49
+ User.last.cia_events
50
+ changes = User.last.cia_attribute_changes
51
51
  last_passwords = changes.where(:attribute_name => "crypted_password").map(&:new_value)
52
52
  ```
53
53
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/cia
3
3
  specs:
4
- cia (0.1.0)
4
+ cia (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/cia
3
3
  specs:
4
- cia (0.1.0)
4
+ cia (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/cia.rb CHANGED
@@ -11,14 +11,14 @@ require 'cia/attribute_change'
11
11
 
12
12
  module CIA
13
13
  def self.audit(options = {})
14
- Thread.current[:audit_transaction] = Transaction.new(options)
14
+ Thread.current[:cia_transaction] = Transaction.new(options)
15
15
  yield
16
16
  ensure
17
- Thread.current[:audit_transaction] = nil
17
+ Thread.current[:cia_transaction] = nil
18
18
  end
19
19
 
20
20
  def self.current_transaction
21
- Thread.current[:audit_transaction] || NullTransaction
21
+ Thread.current[:cia_transaction] || NullTransaction
22
22
  end
23
23
 
24
24
  def self.record_audit(event_type, object)
@@ -1,8 +1,8 @@
1
1
  module CIA
2
2
  class AttributeChange < ActiveRecord::Base
3
- self.table_name = "audit_attribute_changes"
3
+ self.table_name = "cia_attribute_changes"
4
4
 
5
- belongs_to :event, :foreign_key => "audit_event_id"
5
+ belongs_to :event, :foreign_key => "cia_event_id"
6
6
  belongs_to :source, :polymorphic => true
7
7
 
8
8
  validates_presence_of :event, :attribute_name, :source
data/lib/cia/auditable.rb CHANGED
@@ -13,8 +13,8 @@ module CIA
13
13
  self.audited_attributes = Set.new unless audited_attributes
14
14
  self.audited_attributes += attributes.map(&:to_s)
15
15
 
16
- has_many :audit_events, :class_name => "CIA::Event", :as => :source
17
- has_many :audit_attribute_changes, :class_name => "CIA::AttributeChange", :as => :source
16
+ has_many :cia_events, :class_name => "CIA::Event", :as => :source
17
+ has_many :cia_attribute_changes, :class_name => "CIA::AttributeChange", :as => :source
18
18
  end
19
19
  end
20
20
  end
data/lib/cia/event.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  module CIA
2
2
  class Event < ActiveRecord::Base
3
3
  abstract_class
4
- self.table_name = "audit_events"
4
+ self.table_name = "cia_events"
5
5
 
6
6
  belongs_to :source, :polymorphic => true
7
- belongs_to :transaction, :foreign_key => :audit_transaction_id
8
- has_many :attribute_changes, :foreign_key => :audit_event_id
7
+ belongs_to :transaction, :foreign_key => :cia_transaction_id
8
+ has_many :attribute_changes, :foreign_key => :cia_event_id
9
9
 
10
10
  validates_presence_of :transaction, :source, :type
11
11
 
@@ -1,9 +1,9 @@
1
1
  module CIA
2
2
  class Transaction < ActiveRecord::Base
3
- self.table_name = "audit_transactions"
3
+ self.table_name = "cia_transactions"
4
4
 
5
5
  belongs_to :actor, :polymorphic => true
6
- has_many :events, :foreign_key => :audit_transaction_id
6
+ has_many :events, :foreign_key => :cia_transaction_id
7
7
 
8
8
  def record(event_type, source)
9
9
  changes = source.changes.slice(*source.class.audited_attributes)
data/lib/cia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CIA
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -59,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  segments:
61
61
  - 0
62
- hash: -3489209353501167635
62
+ hash: 331448571299140438
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  segments:
70
70
  - 0
71
- hash: -3489209353501167635
71
+ hash: 331448571299140438
72
72
  requirements: []
73
73
  rubyforge_project:
74
74
  rubygems_version: 1.8.24