cia 0.3.6 → 0.3.7

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 CHANGED
@@ -1,6 +1,7 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
+ gem 'bump'
4
5
  gem 'rake'
5
6
  gem 'rspec', '~>2'
6
7
  gem 'appraisal'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cia (0.3.6)
4
+ cia (0.3.7)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -22,6 +22,7 @@ GEM
22
22
  rake
23
23
  arel (3.0.2)
24
24
  builder (3.0.0)
25
+ bump (0.3.7)
25
26
  diff-lcs (1.1.3)
26
27
  i18n (0.6.0)
27
28
  multi_json (1.3.4)
@@ -43,6 +44,7 @@ PLATFORMS
43
44
  DEPENDENCIES
44
45
  activerecord
45
46
  appraisal
47
+ bump
46
48
  cia!
47
49
  rake
48
50
  rspec (~> 2)
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'appraisal'
2
2
  require 'bundler/gem_tasks'
3
+ require 'bump/tasks'
3
4
 
4
5
  task :default do
5
6
  sh "bundle exec rake appraisal:install && bundle exec rake appraisal spec"
@@ -8,20 +9,3 @@ end
8
9
  task :spec do
9
10
  sh "rspec spec/"
10
11
  end
11
-
12
- # extracted from https://github.com/grosser/project_template
13
- rule /^version:bump:.*/ do |t|
14
- sh "git status | grep 'nothing to commit'" # ensure we are not dirty
15
- index = ['major', 'minor','patch'].index(t.name.split(':').last)
16
- file = 'lib/cia/version.rb'
17
-
18
- version_file = File.read(file)
19
- old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
20
- version_parts[index] = version_parts[index].to_i + 1
21
- version_parts[2] = 0 if index < 2 # remove patch for minor
22
- version_parts[1] = 0 if index < 1 # remove minor for major
23
- new_version = version_parts * '.'
24
- File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
25
-
26
- sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
27
- end
data/Readme.md CHANGED
@@ -61,6 +61,14 @@ end
61
61
 
62
62
  # adding an actor e.g. for user creation
63
63
  CIA.current_actor = @user
64
+
65
+ # custom changes
66
+
67
+ class User < ActiveRecord::Base
68
+ def cia_changes
69
+ changes.merge("this" => ["always", "changes"])
70
+ end
71
+ end
64
72
  ```
65
73
 
66
74
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/cia
3
3
  specs:
4
- cia (0.3.5)
4
+ cia (0.3.6)
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.3.5)
4
+ cia (0.3.6)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/cia.rb CHANGED
@@ -36,7 +36,7 @@ module CIA
36
36
  return if options and options[:if] and not source.send(options[:if])
37
37
  return if options and options[:unless] and source.send(options[:unless])
38
38
 
39
- changes = source.changes.slice(*source.class.audited_attributes)
39
+ changes = source.cia_changes.slice(*source.class.audited_attributes)
40
40
  message = source.audit_message if source.respond_to?(:audit_message)
41
41
 
42
42
  return if not message and changes.empty? and action.to_s == "update"
data/lib/cia/auditable.rb CHANGED
@@ -8,6 +8,10 @@ module CIA
8
8
  base.after_destroy {|record| CIA.record(:destroy, record) }
9
9
  end
10
10
 
11
+ def cia_changes
12
+ changes
13
+ end
14
+
11
15
  module ClassMethods
12
16
  def audit_attribute(*attributes)
13
17
  options = (attributes.last.is_a?(Hash) ? attributes.pop : {})
data/lib/cia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CIA
2
- VERSION = '0.3.6'
2
+ VERSION = '0.3.7'
3
3
  end
data/spec/cia_spec.rb CHANGED
@@ -84,6 +84,22 @@ describe CIA do
84
84
  CIA::Event.last.action.should == "update"
85
85
  end
86
86
 
87
+ context "custom changes" do
88
+ let(:object) { CarWithCustomChanges.new }
89
+
90
+ it "tracks custom changes" do
91
+ object.save!
92
+ expect{
93
+ object.update_attributes(:wheels => 3)
94
+ }.to change{ CIA::Event.count }.by(+1)
95
+ CIA::Event.last.action.should == "update"
96
+ CIA::Event.last.attribute_change_hash.should == {
97
+ "wheels" => [nil, "3"],
98
+ "foo" => ["bar", "baz"]
99
+ }
100
+ end
101
+ end
102
+
87
103
  context ":if" do
88
104
  let(:object) { CarWithIf.new }
89
105
 
data/spec/spec_helper.rb CHANGED
@@ -63,6 +63,16 @@ class CarWithUnless < ActiveRecord::Base
63
63
  attr_accessor :tested
64
64
  end
65
65
 
66
+ class CarWithCustomChanges < ActiveRecord::Base
67
+ self.table_name = "cars"
68
+ include CIA::Auditable
69
+ audit_attribute :wheels, :foo
70
+
71
+ def cia_changes
72
+ changes.merge("foo" => ["bar", "baz"])
73
+ end
74
+ end
75
+
66
76
  def create_event(options={})
67
77
  CIA::Event.create!({:source => Car.create!, :actor => User.create!, :action => "update"}.merge(options))
68
78
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
5
4
  prerelease:
5
+ version: 0.3.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Grosser
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-18 00:00:00.000000000 Z
12
+ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: michael@grosser.it
@@ -46,23 +46,23 @@ rdoc_options: []
46
46
  require_paths:
47
47
  - lib
48
48
  required_ruby_version: !ruby/object:Gem::Requirement
49
- none: false
50
49
  requirements:
51
50
  - - ! '>='
52
51
  - !ruby/object:Gem::Version
53
52
  version: '0'
54
53
  segments:
55
54
  - 0
56
- hash: -3737857467428511425
57
- required_rubygems_version: !ruby/object:Gem::Requirement
55
+ hash: 933978664134993553
58
56
  none: false
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - ! '>='
61
60
  - !ruby/object:Gem::Version
62
61
  version: '0'
63
62
  segments:
64
63
  - 0
65
- hash: -3737857467428511425
64
+ hash: 933978664134993553
65
+ none: false
66
66
  requirements: []
67
67
  rubyforge_project:
68
68
  rubygems_version: 1.8.24