cia 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3712c12e75de36585e91c2d00286ef9f376b2b79
4
+ data.tar.gz: dd0d6cd1b956421ae4112df71d0ed180e10793ce
5
+ SHA512:
6
+ metadata.gz: d9c904c7d2f3d5563235c56785e06b807fcc4b3797aa57aca94ac15fccd3aab85269f42ef826a467eec89dcb9123fc35da2e725ee778bed636193331a38c23a6
7
+ data.tar.gz: 6b68e9f53e2b7c9f4f529a60861a14eb870fc4c3e02e132d561c91e5ff2b8853b390a0b2c8c6095a022a2df2d2f5481c2fddfbff177b7aeb6edcf7082a8c2de2
data/lib/cia.rb CHANGED
@@ -58,9 +58,9 @@ module CIA
58
58
  transaction_attributes.reject! { |k, v| non_recordable_attributes.include?(k) } if non_recordable_attributes
59
59
 
60
60
  event = CIA::Event.new(transaction_attributes.merge(
61
- :action => action.to_s,
62
- :source => source,
63
- :message => message
61
+ action: action.to_s,
62
+ source: source,
63
+ message: message
64
64
  ))
65
65
  event.add_attribute_changes(changes)
66
66
  event.save!
@@ -5,22 +5,17 @@ module CIA
5
5
  include SourceValidation
6
6
  self.table_name = "cia_attribute_changes"
7
7
 
8
- belongs_to :event, :foreign_key => "cia_event_id"
9
- belongs_to :source, :polymorphic => true
8
+ belongs_to :event, foreign_key: "cia_event_id", inverse_of: :attribute_changes
9
+ belongs_to :source, polymorphic: true
10
10
 
11
11
  validates_presence_of :event, :attribute_name
12
12
 
13
- if ActiveRecord::VERSION::MAJOR > 2
14
- scope :previous, lambda { order("id desc") }
15
- else
16
- named_scope :previous, :order => "id desc"
17
- end
13
+ scope :previous, lambda { order("id desc") }
18
14
 
19
- delegate :created_at, :to => :event
15
+ delegate :created_at, to: :event
20
16
 
21
17
  def self.on_attribute(attribute)
22
- conditions = {:attribute_name => attribute}
23
- ActiveRecord::VERSION::MAJOR == 2 ? scoped(:conditions => conditions) : where(conditions)
18
+ where(attribute_name: attribute)
24
19
  end
25
20
 
26
21
  def self.max_value_size
@@ -28,8 +28,8 @@ module CIA
28
28
  raise "cannot have :if and :unless" if options[:if] && options[:unless]
29
29
  self.audited_attribute_options = options
30
30
 
31
- has_many :cia_events, :class_name => "CIA::Event", :as => :source
32
- has_many :cia_attribute_changes, :class_name => "CIA::AttributeChange", :as => :source
31
+ has_many :cia_events, class_name: "CIA::Event", as: :source
32
+ has_many :cia_attribute_changes, class_name: "CIA::AttributeChange", as: :source
33
33
  end
34
34
 
35
35
  def setup_auditing_callbacks(options)
@@ -39,11 +39,7 @@ module CIA
39
39
  [:create, :update, :destroy].each do |callback|
40
40
  method, args = if options[:callback] == :after_commit
41
41
  send("after_#{callback}"){ |record| record.cia_previous_changes(record.cia_changes) }
42
- if ActiveRecord::VERSION::MAJOR == 2
43
- ["after_commit_on_#{callback}", []]
44
- else # rails 3+
45
- [:after_commit, [{:on => callback}]]
46
- end
42
+ [:after_commit, [{on: callback}]]
47
43
  else
48
44
  ["after_#{callback}", []]
49
45
  end
@@ -3,15 +3,14 @@ module CIA
3
3
  include SourceValidation
4
4
  self.table_name = "cia_events"
5
5
 
6
- belongs_to :actor, :polymorphic => true
7
- belongs_to :source, :polymorphic => true
8
- has_many :attribute_changes, :foreign_key => :cia_event_id, :dependent => :destroy
6
+ belongs_to :actor, polymorphic: true
7
+ belongs_to :source, polymorphic: true
8
+ has_many :attribute_changes, foreign_key: :cia_event_id, inverse_of: :event, dependent: :destroy
9
9
 
10
10
  validates_presence_of :action
11
11
 
12
12
  def self.previous
13
- order = "created_at desc"
14
- ActiveRecord::VERSION::MAJOR == 2 ? scoped(:order => order) : order(order)
13
+ order("created_at desc")
15
14
  end
16
15
 
17
16
  def attribute_change_hash
@@ -24,11 +23,11 @@ module CIA
24
23
  def add_attribute_changes(changes)
25
24
  changes.each do |attribute_name, (old_value, new_value)|
26
25
  attribute_changes.build(
27
- :event => self,
28
- :attribute_name => attribute_name,
29
- :old_value => old_value,
30
- :new_value => new_value,
31
- :source => source
26
+ event: self,
27
+ attribute_name: attribute_name,
28
+ old_value: old_value,
29
+ new_value: new_value,
30
+ source: source
32
31
  )
33
32
  end
34
33
  end
@@ -1,8 +1,8 @@
1
1
  module CIA
2
2
  module SourceValidation
3
3
  def self.included(base)
4
- base.validates_presence_of :source_id, :source_type, :unless => :source_must_be_present?
5
- base.validates_presence_of :source, :if => :source_must_be_present?
4
+ base.validates_presence_of :source_id, :source_type, unless: :source_must_be_present?
5
+ base.validates_presence_of :source, if: :source_must_be_present?
6
6
  end
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module CIA
2
- VERSION = '0.5.8'
2
+ VERSION = '0.5.9'
3
3
  end
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
5
- prerelease:
4
+ version: 0.5.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Grosser
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-09-03 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bump
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '2'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '2'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: wwtd
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: activerecord
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: sqlite3
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description:
@@ -138,33 +123,26 @@ files:
138
123
  homepage: https://github.com/grosser/cia
139
124
  licenses:
140
125
  - MIT
126
+ metadata: {}
141
127
  post_install_message:
142
128
  rdoc_options: []
143
129
  require_paths:
144
130
  - lib
145
131
  required_ruby_version: !ruby/object:Gem::Requirement
146
- none: false
147
132
  requirements:
148
- - - ! '>='
133
+ - - ">="
149
134
  - !ruby/object:Gem::Version
150
- version: '0'
151
- segments:
152
- - 0
153
- hash: 3646470647389073675
135
+ version: 2.0.0
154
136
  required_rubygems_version: !ruby/object:Gem::Requirement
155
- none: false
156
137
  requirements:
157
- - - ! '>='
138
+ - - ">="
158
139
  - !ruby/object:Gem::Version
159
140
  version: '0'
160
- segments:
161
- - 0
162
- hash: 3646470647389073675
163
141
  requirements: []
164
142
  rubyforge_project:
165
- rubygems_version: 1.8.23
143
+ rubygems_version: 2.2.2
166
144
  signing_key:
167
- specification_version: 3
145
+ specification_version: 4
168
146
  summary: Audit model events like update/create/delete + attribute changes + group
169
147
  them by transaction, in normalized table layout for easy query access.
170
148
  test_files: []