blamer 4.0.0 → 4.0.1
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 +23 -25
- data/README.md +12 -8
- data/lib/blamer/userstamp.rb +5 -6
- data/test/blame_test.rb +20 -0
- data/test/test_helper.rb +6 -0
- metadata +21 -28
- checksums.yaml +0 -15
- data/CHANGELOG.md +0 -8
- data/blamer.gemspec +0 -23
data/Gemfile.lock
CHANGED
@@ -1,46 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
5
|
-
activerecord (
|
6
|
-
activesupport (>= 4.0.0)
|
4
|
+
blamer (4.0.0)
|
5
|
+
activerecord (> 4.0.8, < 5.0.0)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
10
9
|
specs:
|
11
|
-
activemodel (4.0
|
12
|
-
activesupport (= 4.0
|
13
|
-
builder (~> 3.1
|
14
|
-
activerecord (4.0
|
15
|
-
activemodel (= 4.0
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
arel (4.0.2)
|
27
|
-
builder (3.1.4)
|
10
|
+
activemodel (4.2.0)
|
11
|
+
activesupport (= 4.2.0)
|
12
|
+
builder (~> 3.1)
|
13
|
+
activerecord (4.2.0)
|
14
|
+
activemodel (= 4.2.0)
|
15
|
+
activesupport (= 4.2.0)
|
16
|
+
arel (~> 6.0)
|
17
|
+
activesupport (4.2.0)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
arel (6.0.0)
|
24
|
+
builder (3.2.2)
|
28
25
|
i18n (0.7.0)
|
29
|
-
|
30
|
-
|
26
|
+
json (1.8.2)
|
27
|
+
minitest (5.5.1)
|
31
28
|
power_assert (0.2.2)
|
32
29
|
rake (10.4.2)
|
33
30
|
sqlite3 (1.3.10)
|
34
|
-
test-unit (3.0.
|
31
|
+
test-unit (3.0.9)
|
35
32
|
power_assert
|
36
33
|
thread_safe (0.3.4)
|
37
|
-
tzinfo (
|
34
|
+
tzinfo (1.2.2)
|
35
|
+
thread_safe (~> 0.1)
|
38
36
|
|
39
37
|
PLATFORMS
|
40
38
|
ruby
|
41
39
|
|
42
40
|
DEPENDENCIES
|
43
|
-
|
41
|
+
blamer!
|
44
42
|
rake
|
45
43
|
sqlite3
|
46
44
|
test-unit
|
data/README.md
CHANGED
@@ -3,9 +3,11 @@
|
|
3
3
|
[](https://rubygems.org/gems/blamer)
|
4
4
|
[](http://travis-ci.org/infused/blamer)
|
5
5
|
[](https://codeclimate.com/github/infused/blamer)
|
6
|
+
[](https://codeclimate.com/github/infused/blamer)
|
7
|
+
[](https://gemnasium.com/infused/blamer)
|
6
8
|
|
7
9
|
Automatically userstamps create and update operations if the table has columns named *created_by* and/or *updated_by*.
|
8
|
-
The
|
10
|
+
The Blamer gem attempts to mirror the simplicity of ActiveRecord's timestamp module.
|
9
11
|
|
10
12
|
Blamer expects User.current_user to return the current user. Basic setup involves assigning to `User.current_user` in a controller before filter:
|
11
13
|
|
@@ -53,32 +55,34 @@ Blamer adds a *userstamps* migration helper which will add the created_by and up
|
|
53
55
|
|
54
56
|
## Installation
|
55
57
|
|
58
|
+
You must use the correct version of blamer for the version of Rails you are running:
|
59
|
+
|
56
60
|
|
57
61
|
### Rails 2.x
|
58
62
|
|
59
63
|
Add a line to your environment.rb
|
60
64
|
|
61
|
-
config.gem '
|
65
|
+
config.gem 'blamer', '~> 3.0.0'
|
62
66
|
|
63
|
-
### Rails 3.
|
67
|
+
### Rails 3.0, 3.1 and 3.2
|
64
68
|
|
65
69
|
Add to your Gemfile
|
66
70
|
|
67
|
-
gem '
|
71
|
+
gem 'blamer', '~> 3.0.0'
|
68
72
|
|
69
73
|
Or
|
70
74
|
|
71
|
-
gem '
|
75
|
+
gem 'blamer', :github => 'infused/blamer', :branch => '3_stable'
|
72
76
|
|
73
|
-
### Rails 4.
|
77
|
+
### Rails 4.0, 4.1 and 4.2
|
74
78
|
|
75
79
|
Add to your Gemfile
|
76
80
|
|
77
|
-
gem '
|
81
|
+
gem 'blamer', '~> 4.0.0'
|
78
82
|
|
79
83
|
Or
|
80
84
|
|
81
|
-
gem '
|
85
|
+
gem 'blamer', :github => 'infused/blamer'
|
82
86
|
|
83
87
|
|
84
88
|
## Credit
|
data/lib/blamer/userstamp.rb
CHANGED
@@ -19,19 +19,18 @@ module Blamer
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def _create_record(*args)
|
22
|
-
if record_userstamps
|
23
|
-
write_attribute(created_userstamp_column, userstamp_object.id) if respond_to?(created_userstamp_column)
|
24
|
-
write_attribute(updated_userstamp_column, userstamp_object.id) if respond_to?(updated_userstamp_column)
|
22
|
+
if record_userstamps
|
23
|
+
write_attribute(created_userstamp_column, userstamp_object.try(:id)) if respond_to?(created_userstamp_column)
|
24
|
+
write_attribute(updated_userstamp_column, userstamp_object.try(:id)) if respond_to?(updated_userstamp_column)
|
25
25
|
end
|
26
26
|
|
27
27
|
super
|
28
28
|
end
|
29
29
|
|
30
30
|
def _update_record(*args)
|
31
|
-
if record_userstamps &&
|
32
|
-
write_attribute(updated_userstamp_column, userstamp_object.id) if respond_to?(updated_userstamp_column)
|
31
|
+
if record_userstamps && changed?
|
32
|
+
write_attribute(updated_userstamp_column, userstamp_object.try(:id)) if respond_to?(updated_userstamp_column)
|
33
33
|
end
|
34
|
-
|
35
34
|
super
|
36
35
|
end
|
37
36
|
|
data/test/blame_test.rb
CHANGED
@@ -25,4 +25,24 @@ class BlameTest < Test::Unit::TestCase
|
|
25
25
|
assert_equal @user2.id, @widget.updated_by
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_console_create
|
29
|
+
User.current_user = nil
|
30
|
+
another_widget = Widget.create! :name => "Ten"
|
31
|
+
|
32
|
+
assert_equal 'Ten', another_widget.name
|
33
|
+
assert_equal nil, another_widget.created_by
|
34
|
+
assert_equal nil, another_widget.updated_by
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_console_update
|
38
|
+
User.current_user = nil
|
39
|
+
@widget.update_attribute(:name, 'Three')
|
40
|
+
|
41
|
+
@widget.reload
|
42
|
+
|
43
|
+
assert_equal 'Three', @widget.name
|
44
|
+
assert_equal @user1.id, @widget.created_by
|
45
|
+
assert_equal nil, @widget.updated_by
|
46
|
+
end
|
47
|
+
|
28
48
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,38 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Keith Morrison
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-
|
12
|
+
date: 2015-09-30 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activerecord
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - ! '
|
19
|
+
- - ! '>'
|
18
20
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.0.
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
21
|
+
version: 4.0.8
|
22
|
+
- - <
|
25
23
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 4.0.0
|
24
|
+
version: 5.0.0
|
34
25
|
type: :runtime
|
35
26
|
prerelease: false
|
36
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
37
29
|
requirements:
|
38
|
-
- - ! '
|
30
|
+
- - ! '>'
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.0.8
|
33
|
+
- - <
|
39
34
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
35
|
+
version: 5.0.0
|
41
36
|
description: Automatically userstamps create and update operations if the table has
|
42
37
|
created_by and/or updated_by columns
|
43
38
|
email: keithm@infused.org
|
@@ -45,18 +40,15 @@ executables: []
|
|
45
40
|
extensions: []
|
46
41
|
extra_rdoc_files:
|
47
42
|
- README.md
|
48
|
-
- CHANGELOG.md
|
49
43
|
- LICENSE
|
50
44
|
files:
|
51
|
-
- CHANGELOG.md
|
52
45
|
- Gemfile
|
53
46
|
- Gemfile.lock
|
54
47
|
- LICENSE
|
55
|
-
- README.md
|
56
48
|
- Rakefile
|
57
|
-
-
|
58
|
-
- lib/blamer.rb
|
49
|
+
- README.md
|
59
50
|
- lib/blamer/userstamp.rb
|
51
|
+
- lib/blamer.rb
|
60
52
|
- test/blame_test.rb
|
61
53
|
- test/models/monkey.rb
|
62
54
|
- test/models/sprocket.rb
|
@@ -66,30 +58,31 @@ files:
|
|
66
58
|
- test/partial_blame_test.rb
|
67
59
|
- test/schema.rb
|
68
60
|
- test/test_helper.rb
|
69
|
-
homepage: http://github.com/infused/
|
61
|
+
homepage: http://github.com/infused/blame
|
70
62
|
licenses:
|
71
63
|
- MIT
|
72
|
-
metadata: {}
|
73
64
|
post_install_message:
|
74
65
|
rdoc_options:
|
75
66
|
- --charset=UTF-8
|
76
67
|
require_paths:
|
77
68
|
- lib
|
78
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
79
71
|
requirements:
|
80
72
|
- - ! '>='
|
81
73
|
- !ruby/object:Gem::Version
|
82
74
|
version: '0'
|
83
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
84
77
|
requirements:
|
85
78
|
- - ! '>='
|
86
79
|
- !ruby/object:Gem::Version
|
87
80
|
version: 1.3.0
|
88
81
|
requirements: []
|
89
82
|
rubyforge_project:
|
90
|
-
rubygems_version:
|
83
|
+
rubygems_version: 1.8.25
|
91
84
|
signing_key:
|
92
|
-
specification_version:
|
85
|
+
specification_version: 3
|
93
86
|
summary: Userstamps for ActiveRecord
|
94
87
|
test_files:
|
95
88
|
- test/blame_test.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
Mjg3YTVhMzdjNjZmMmU1MmMyY2MyYmMxYWZiNzY4MDJhMDE1YTRmMA==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Zjc2NjEyYTQ4N2NkOGYzMTM2ZGYzZTU5NmU5MTQyMmJjNzAyZGU5Yg==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZmIyNTIwYzA3ZjM1MGMyMTVlOGQ5ZTMyNTJhNDk3OTA4ZDhjZTJkNWNhMDgx
|
10
|
-
NWEwMGE5NjljNzg5NDFkYWZhZDI3N2UzZDhjNDZkNzRjMjY4MGFiYmNlZDZm
|
11
|
-
MTBjNTk4YjNjM2Y4MWEyZGQwODU3M2JiOGJlZDNjOGY4ZjhkOWQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OTZkMTU5MTMxZjExYjk4NzU0ZTg1ZTMzNTFiODkyNTc4ZDM0NTg4OWMzODJk
|
14
|
-
ZDAxMDhkNzNhOGFiYjA4YmQ1NDg4OTY2OTk0ZmVlYjQxMGFkOGUzMmNlMDkz
|
15
|
-
YmE3MWE2MzA3YTdlOTA0NDVlYTQwMzU2MTcwYzY2ODJjMTc2N2I=
|
data/CHANGELOG.md
DELETED
data/blamer.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
lib = File.expand_path('../lib/', __FILE__)
|
2
|
-
$:.unshift lib unless $:.include?(lib)
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = 'blamer'
|
6
|
-
s.version = '4.0.0'
|
7
|
-
s.authors = ['Keith Morrison']
|
8
|
-
s.email = 'keithm@infused.org'
|
9
|
-
s.homepage = 'http://github.com/infused/blamer'
|
10
|
-
s.summary = 'Userstamps for ActiveRecord'
|
11
|
-
s.description = 'Automatically userstamps create and update operations if the table has created_by and/or updated_by columns'
|
12
|
-
s.license = 'MIT'
|
13
|
-
|
14
|
-
s.rdoc_options = ['--charset=UTF-8']
|
15
|
-
s.extra_rdoc_files = ['README.md', 'CHANGELOG.md', 'LICENSE']
|
16
|
-
s.files = Dir['[A-Z]*', '{lib,test}/**/*', 'blamer.gemspec']
|
17
|
-
s.test_files = Dir.glob('test/**/*_test.rb')
|
18
|
-
s.require_paths = ['lib']
|
19
|
-
|
20
|
-
s.required_rubygems_version = '>= 1.3.0'
|
21
|
-
s.add_dependency 'activerecord', '>= 4.0.0'
|
22
|
-
s.add_dependency 'activesupport', '>= 4.0.0'
|
23
|
-
end
|