active_admin_versioning 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11654ec0c3302c80446f5ca0dd39a08c81c5f94b
4
- data.tar.gz: cf331ead8ab512bd7c0cdd746a03922cd00833ca
3
+ metadata.gz: e4ca09c85b2c372d0f4d4b307f0faeb089b1eea5
4
+ data.tar.gz: b5d015db0abfc823104f4224ab5127b9abde1277
5
5
  SHA512:
6
- metadata.gz: 5a25e2018903997202602d7b08a496da5913d90e2e9fc975220938009509a5868ac27dfaea0820ef80f6a662766c47db5191e03e20023db66edf958d9d13c072
7
- data.tar.gz: 4bdf15895ef9a7f04aeec611d358ca9895831204a9294d0208ccfdf59ddd8b1ad4d66ffe19e1af6569d7b506c831be30a758f2f697a1a5c1bd1e2d9bcaa787a5
6
+ metadata.gz: 9c7044067bf8401565195fe294fc49c4be0813063697db71b84798cec7dfc46eec77cb46e7b5abaa320c865bc6549f5391c7bf3c5b9a6625b7b5fb06b8d528dc
7
+ data.tar.gz: b6af1cd6dfe53993442e9e671d082cee84c41d5ac4921865da5e0773f5888b5bfab4e77a09c7b6d58344a9a0e4b0fad99870cc6b5497bfe2156c39f3b30aea58
data/.travis.yml CHANGED
@@ -1,5 +1,10 @@
1
- sudo: false
2
- language: ruby
1
+ before_install: gem install bundler
2
+
3
3
  rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.13.6
4
+ - 2.3.3
5
+
6
+ gemfile:
7
+ - gemfiles/rails50.gemfile
8
+
9
+ script:
10
+ - bundle exec rspec spec
data/README.md CHANGED
@@ -14,6 +14,37 @@ And then execute:
14
14
 
15
15
  $ bundle
16
16
 
17
+ ## Configuration
18
+
19
+ In some cases you may need to display some extra or formatted text in whodunnit.
20
+ For example whodunit is an ID of your user. And you want to display not just a number, but his E-mail.
21
+
22
+ Create configuration 'config/initializers/active_admin_versionings.rb'
23
+
24
+ ```ruby
25
+ ActiveAdminVersioning.configure do |config|
26
+ config.whodunnit_attribute_name = :display_whodunnit
27
+ end
28
+ ```
29
+
30
+
31
+ In you model:
32
+
33
+ ```ruby
34
+ has_paper_trail class_name: 'MyPaperTrail'
35
+ ```
36
+
37
+ ```ruby
38
+ class MyPaperTrail < PaperTrail::Version
39
+ def display_whodunnit
40
+ AdminUser.find(whodunnit).email
41
+ end
42
+ end
43
+ ```
44
+
45
+ This alternative "whodunnit" will only be visible in "Version" sidebar and "Version" page.
46
+
47
+
17
48
  ## Recipe for Rails 5
18
49
 
19
50
  1. Add necessary gems to `Gemfile` and `bundle`:
@@ -2,7 +2,7 @@ paginated_collection(versions, display_total: false, download_links: false) do
2
2
  table_for(versions, i18n: ::PaperTrail::Version, class: "index_table") do
3
3
  column(:id)
4
4
  column(:whodunnit) do |record|
5
- record.whodunnit.presence || t("views.version.unknown_user")
5
+ record.send(ActiveAdminVersioning.configuration.whodunnit_attribute_name).presence || t("views.version.unknown_user")
6
6
  end
7
7
  column(:event, :event_i18n)
8
8
  column(:item_type, :item_class_i18n)
@@ -27,7 +27,8 @@ module ActiveAdminVersioning
27
27
  end
28
28
  row :event, &:event_i18n
29
29
  row :whodunnit do |record|
30
- record.whodunnit.presence || span(t("views.version.unknown_user"), class: "empty")
30
+ record.send(ActiveAdminVersioning.configuration.whodunnit_attribute_name).presence ||
31
+ span(t("views.version.unknown_user"), class: "empty")
31
32
  end
32
33
  row :created_at
33
34
  end
@@ -0,0 +1,22 @@
1
+ module ActiveAdminVersioning
2
+ class << self
3
+ attr_writer :configuration
4
+
5
+ def configuration
6
+ @configuration ||= Configuration.new
7
+ end
8
+
9
+ def configure
10
+ yield(configuration)
11
+ end
12
+ end
13
+
14
+
15
+ class Configuration
16
+ attr_accessor :whodunnit_attribute_name
17
+
18
+ def initialize
19
+ @whodunnit_attribute_name = :whodunnit
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminVersioning
2
- VERSION = "0.1.1".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "active_admin"
2
2
  require "paper_trail/version_concern"
3
3
  require "active_admin_versioning/engine"
4
+ require "active_admin_versioning/configuration"
4
5
  require "active_admin_versioning/active_admin/application"
5
6
  require "active_admin_versioning/active_admin/dsl"
6
7
  require "active_admin_versioning/active_admin/resource_controller"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshiyuki Hirano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-25 00:00:00.000000000 Z
11
+ date: 2016-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -102,6 +102,7 @@ files:
102
102
  - lib/active_admin_versioning/active_admin/application.rb
103
103
  - lib/active_admin_versioning/active_admin/dsl.rb
104
104
  - lib/active_admin_versioning/active_admin/resource_controller.rb
105
+ - lib/active_admin_versioning/configuration.rb
105
106
  - lib/active_admin_versioning/engine.rb
106
107
  - lib/active_admin_versioning/paper_trail/version_concern.rb
107
108
  - lib/active_admin_versioning/version.rb
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  requirements: []
128
129
  rubyforge_project:
129
- rubygems_version: 2.5.1
130
+ rubygems_version: 2.5.2
130
131
  signing_key:
131
132
  specification_version: 4
132
133
  summary: Good for auditing or versioning for Active Admin