active_admin_versioning 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +2 -0
- data/Appraisals +12 -0
- data/Gemfile +20 -1
- data/Rakefile +5 -4
- data/active_admin_versioning.gemspec +3 -9
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails42.gemfile +25 -0
- data/gemfiles/rails50.gemfile +25 -0
- data/lib/active_admin_versioning.rb +10 -1
- data/lib/active_admin_versioning/{extension → active_admin}/application.rb +1 -1
- data/lib/active_admin_versioning/active_admin/dsl.rb +49 -0
- data/lib/active_admin_versioning/{extension → active_admin}/resource_controller.rb +2 -2
- data/lib/active_admin_versioning/engine.rb +1 -11
- data/lib/active_admin_versioning/{extension/paper_trail.rb → paper_trail/version_concern.rb} +2 -2
- data/lib/active_admin_versioning/version.rb +1 -1
- data/tasks/test.rake +10 -0
- metadata +11 -48
- data/lib/active_admin_versioning/extension/dsl.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11654ec0c3302c80446f5ca0dd39a08c81c5f94b
|
4
|
+
data.tar.gz: cf331ead8ab512bd7c0cdd746a03922cd00833ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a25e2018903997202602d7b08a496da5913d90e2e9fc975220938009509a5868ac27dfaea0820ef80f6a662766c47db5191e03e20023db66edf958d9d13c072
|
7
|
+
data.tar.gz: 4bdf15895ef9a7f04aeec611d358ca9895831204a9294d0208ccfdf59ddd8b1ad4d66ffe19e1af6569d7b506c831be30a758f2f697a1a5c1bd1e2d9bcaa787a5
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Appraisals
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
appraise 'rails42' do
|
2
|
+
gem 'rails', '~> 4.2.0'
|
3
|
+
gem "paper_trail", "~> 4.2.0"
|
4
|
+
gem 'activeadmin', '1.0.0.pre4'
|
5
|
+
end
|
6
|
+
|
7
|
+
appraise 'rails50' do
|
8
|
+
gem 'rails', '~> 5.0.0'
|
9
|
+
gem "paper_trail", "~> 5.2.2"
|
10
|
+
gem 'inherited_resources', github: 'activeadmin/inherited_resources'
|
11
|
+
gem 'activeadmin', github: 'activeadmin/activeadmin'
|
12
|
+
end
|
data/Gemfile
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in active_admin_versioning.gemspec
|
4
3
|
gemspec
|
4
|
+
|
5
|
+
gem "rails", "~> 5.0.0"
|
6
|
+
gem "paper_trail", "~> 5.2.2"
|
7
|
+
gem "inherited_resources", github: "activeadmin/inherited_resources"
|
8
|
+
gem "activeadmin", github: "activeadmin/activeadmin"
|
9
|
+
gem "pry"
|
10
|
+
gem 'appraisal'
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem "rubocop", "~> 0.40.0"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem "capybara"
|
18
|
+
gem "rspec-rails"
|
19
|
+
gem "database_cleaner"
|
20
|
+
gem 'shoulda-matchers'
|
21
|
+
gem "sqlite3", platforms: :mri
|
22
|
+
gem "poltergeist"
|
23
|
+
end
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler'
|
2
|
+
require 'rake'
|
3
3
|
|
4
|
-
|
4
|
+
Bundler.setup
|
5
|
+
Bundler::GemHelper.install_tasks
|
5
6
|
|
6
|
-
task
|
7
|
+
FileList['tasks/**/*.rake'].each { |task| import task }
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "active_admin_versioning/version"
|
1
|
+
require File.join(File.dirname(__FILE__), "lib", "active_admin_versioning", "version")
|
5
2
|
|
6
3
|
Gem::Specification.new do |gem|
|
7
4
|
gem.name = "active_admin_versioning"
|
@@ -21,12 +18,9 @@ Gem::Specification.new do |gem|
|
|
21
18
|
|
22
19
|
gem.required_ruby_version = ">= 2.1.0"
|
23
20
|
|
24
|
-
gem.
|
25
|
-
gem.
|
21
|
+
gem.add_dependency "activeadmin", ">= 1.0.0.pre4"
|
22
|
+
gem.add_dependency "paper_trail", ">= 4.2.0"
|
26
23
|
|
27
24
|
gem.add_development_dependency "bundler", "~> 1.13"
|
28
25
|
gem.add_development_dependency "rake", "~> 10.0"
|
29
|
-
gem.add_development_dependency "rspec", "~> 3.0"
|
30
|
-
gem.add_development_dependency "pry", "~> 0.10.0"
|
31
|
-
gem.add_development_dependency "rubocop", "~> 0.40.0"
|
32
26
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 4.2.0"
|
6
|
+
gem "paper_trail", "~> 4.2.0"
|
7
|
+
gem "inherited_resources", :github => "activeadmin/inherited_resources"
|
8
|
+
gem "activeadmin", "1.0.0.pre4"
|
9
|
+
gem "pry"
|
10
|
+
gem "appraisal"
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem "rubocop", "~> 0.40.0"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem "capybara"
|
18
|
+
gem "rspec-rails"
|
19
|
+
gem "database_cleaner"
|
20
|
+
gem "shoulda-matchers"
|
21
|
+
gem "sqlite3", :platforms => :mri
|
22
|
+
gem "poltergeist"
|
23
|
+
end
|
24
|
+
|
25
|
+
gemspec :path => "../"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 5.0.0"
|
6
|
+
gem "paper_trail", "~> 5.2.2"
|
7
|
+
gem "inherited_resources", :github => "activeadmin/inherited_resources"
|
8
|
+
gem "activeadmin", :github => "activeadmin/activeadmin"
|
9
|
+
gem "pry"
|
10
|
+
gem "appraisal"
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem "rubocop", "~> 0.40.0"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem "capybara"
|
18
|
+
gem "rspec-rails"
|
19
|
+
gem "database_cleaner"
|
20
|
+
gem "shoulda-matchers"
|
21
|
+
gem "sqlite3", :platforms => :mri
|
22
|
+
gem "poltergeist"
|
23
|
+
end
|
24
|
+
|
25
|
+
gemspec :path => "../"
|
@@ -1,2 +1,11 @@
|
|
1
|
+
require "active_admin"
|
2
|
+
require "paper_trail/version_concern"
|
1
3
|
require "active_admin_versioning/engine"
|
2
|
-
require "active_admin_versioning/
|
4
|
+
require "active_admin_versioning/active_admin/application"
|
5
|
+
require "active_admin_versioning/active_admin/dsl"
|
6
|
+
require "active_admin_versioning/active_admin/resource_controller"
|
7
|
+
require "active_admin_versioning/paper_trail/version_concern"
|
8
|
+
|
9
|
+
::ActiveAdmin::Application.send :prepend, ActiveAdminVersioning::ActiveAdmin::Application
|
10
|
+
::ActiveAdmin::DSL.send :include, ActiveAdminVersioning::ActiveAdmin::DSL
|
11
|
+
::PaperTrail::VersionConcern.send :include, ActiveAdminVersioning::PaperTrail::VersionConcern
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module ActiveAdminVersioning
|
2
|
+
module ActiveAdmin
|
3
|
+
module DSL
|
4
|
+
def versioning
|
5
|
+
return unless enabled_paper_trail?
|
6
|
+
|
7
|
+
controller { include ActiveAdminVersioning::ActiveAdmin::ResourceController }
|
8
|
+
|
9
|
+
member_action(:versions) do
|
10
|
+
@versions = resource.versions.reorder(id: :desc, created_at: :desc).page(params[:page])
|
11
|
+
@page_title = ::PaperTrail::Version.model_name.human
|
12
|
+
render "versions"
|
13
|
+
end
|
14
|
+
|
15
|
+
with_options only: :show do
|
16
|
+
action_item :version do
|
17
|
+
link_to send("versions_admin_#{resource_instance_name}_path") do
|
18
|
+
::PaperTrail::Version.model_name.human
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
sidebar ::PaperTrail::Version.model_name.human do
|
23
|
+
if versions.present?
|
24
|
+
attributes_table_for versions[0] do
|
25
|
+
row ::PaperTrail::Version.model_name.human do |_|
|
26
|
+
version_number
|
27
|
+
end
|
28
|
+
row :event, &:event_i18n
|
29
|
+
row :whodunnit do |record|
|
30
|
+
record.whodunnit.presence || span(t("views.version.unknown_user"), class: "empty")
|
31
|
+
end
|
32
|
+
row :created_at
|
33
|
+
end
|
34
|
+
paginate versions, theme: :version
|
35
|
+
else
|
36
|
+
I18n.t("views.version.empty", model_name: ::PaperTrail::Version.model_name.human)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def enabled_paper_trail?
|
45
|
+
config.resource_class.try(:paper_trail).try(:enabled?) || config.resource_class.try(:paper_trail_enabled_for_model?)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ActiveAdminVersioning
|
2
|
-
module
|
2
|
+
module ActiveAdmin
|
3
3
|
module ResourceController
|
4
4
|
def self.included(base)
|
5
5
|
base.before_action(:set_paper_trail_whodunnit)
|
@@ -16,7 +16,7 @@ module ActiveAdminVersioning
|
|
16
16
|
protected
|
17
17
|
|
18
18
|
def user_for_paper_trail
|
19
|
-
|
19
|
+
respond_to?(:current_admin_user) ? current_admin_user.id : t("views.version.unknown_user")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,16 +1,6 @@
|
|
1
|
-
require "rails"
|
1
|
+
require "rails/engine"
|
2
2
|
|
3
3
|
module ActiveAdminVersioning
|
4
4
|
class Engine < ::Rails::Engine
|
5
|
-
config.after_initialize do
|
6
|
-
require "active_admin_versioning/extension/application"
|
7
|
-
require "active_admin_versioning/extension/dsl"
|
8
|
-
require "active_admin_versioning/extension/resource_controller"
|
9
|
-
require "active_admin_versioning/extension/paper_trail"
|
10
|
-
|
11
|
-
::ActiveAdmin::Application.send :prepend, ActiveAdminVersioning::Extension::Application
|
12
|
-
::ActiveAdmin::DSL.send :include, ActiveAdminVersioning::Extension::DSL
|
13
|
-
::PaperTrail::Version.send :include, ActiveAdminVersioning::Extension::PaperTrail
|
14
|
-
end
|
15
5
|
end
|
16
6
|
end
|
data/tasks/test.rake
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
desc "Creates a test rails app for the specs to run against"
|
2
|
+
task :setup do
|
3
|
+
require "rails/version"
|
4
|
+
system("mkdir spec/rails") unless File.exist?("spec/rails")
|
5
|
+
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb --skip-spring --skip-turbolinks"
|
6
|
+
end
|
7
|
+
|
8
|
+
require "rspec/core/rake_task"
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
|
+
task default: :spec
|
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.
|
4
|
+
version: 0.1.1
|
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-
|
11
|
+
date: 2016-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -66,48 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '3.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.10.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.10.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rubocop
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.40.0
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.40.0
|
111
69
|
description: Good for auditing or versioning for Active Admin
|
112
70
|
email:
|
113
71
|
- yhirano@me.com
|
@@ -122,6 +80,7 @@ files:
|
|
122
80
|
- ".rubocop.yml"
|
123
81
|
- ".ruby-style.yml"
|
124
82
|
- ".travis.yml"
|
83
|
+
- Appraisals
|
125
84
|
- Gemfile
|
126
85
|
- LICENSE.txt
|
127
86
|
- README.md
|
@@ -136,13 +95,17 @@ files:
|
|
136
95
|
- bin/setup
|
137
96
|
- config/locales/en.yml
|
138
97
|
- config/locales/ja.yml
|
98
|
+
- gemfiles/.bundle/config
|
99
|
+
- gemfiles/rails42.gemfile
|
100
|
+
- gemfiles/rails50.gemfile
|
139
101
|
- lib/active_admin_versioning.rb
|
102
|
+
- lib/active_admin_versioning/active_admin/application.rb
|
103
|
+
- lib/active_admin_versioning/active_admin/dsl.rb
|
104
|
+
- lib/active_admin_versioning/active_admin/resource_controller.rb
|
140
105
|
- lib/active_admin_versioning/engine.rb
|
141
|
-
- lib/active_admin_versioning/
|
142
|
-
- lib/active_admin_versioning/extension/dsl.rb
|
143
|
-
- lib/active_admin_versioning/extension/paper_trail.rb
|
144
|
-
- lib/active_admin_versioning/extension/resource_controller.rb
|
106
|
+
- lib/active_admin_versioning/paper_trail/version_concern.rb
|
145
107
|
- lib/active_admin_versioning/version.rb
|
108
|
+
- tasks/test.rake
|
146
109
|
homepage: https://github.com/yhirano55/active_admin_versioning
|
147
110
|
licenses:
|
148
111
|
- MIT
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module ActiveAdminVersioning
|
2
|
-
module Extension
|
3
|
-
module DSL
|
4
|
-
def versioning
|
5
|
-
return unless config.resource_class.try(:paper_trail_enabled_for_model?)
|
6
|
-
|
7
|
-
controller { include ActiveAdminVersioning::Extension::ResourceController }
|
8
|
-
|
9
|
-
member_action(:versions) do
|
10
|
-
@versions = resource.versions.reorder(id: :desc, created_at: :desc).page(params[:page])
|
11
|
-
@page_title = ::PaperTrail::Version.model_name.human
|
12
|
-
render "versions"
|
13
|
-
end
|
14
|
-
|
15
|
-
action_item(:version, only: :show) do
|
16
|
-
link_to send("versions_admin_#{resource_instance_name}_path") do
|
17
|
-
::PaperTrail::Version.model_name.human
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
sidebar(::PaperTrail::Version.model_name.human, only: :show) do
|
22
|
-
if versions.present?
|
23
|
-
attributes_table_for versions[0] do
|
24
|
-
row(::PaperTrail::Version.model_name.human) { |_| version_number }
|
25
|
-
row(:event, &:event_i18n)
|
26
|
-
row(:whodunnit) do |record|
|
27
|
-
record.whodunnit.presence || span(t("views.version.unknown_user"), class: "empty")
|
28
|
-
end
|
29
|
-
row(:created_at)
|
30
|
-
end
|
31
|
-
paginate(versions, theme: :version)
|
32
|
-
else
|
33
|
-
I18n.t("views.version.empty", model_name: ::PaperTrail::Version.model_name.human)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|