paper_trail_manager 0.3.0 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a4751f2d97b26b30c6e032a6abddab435f52ab5
4
- data.tar.gz: 304d9a344cbaa635c24ceb5be8ccc84243eff3ea
3
+ metadata.gz: 237613f3cbd029dce20a9cf59e754551550f712d
4
+ data.tar.gz: 60b579fcda4d97494c48513714c5290f4f24d1bc
5
5
  SHA512:
6
- metadata.gz: 728dbc39ed5c46ebfb8203e7da6169f9b071ebe4106dddb280030f8a87acb37c881c68089dac42c5fde82bcc32b89710c6251c9d58b09b294a1279c8b3179955
7
- data.tar.gz: c3d7a279aaba421c3a9c883770c59098ae957caab3a98c1711afeca1e0ccba3460eedcb561524b266c0a2124a98c553f79d31a8777bedfaf83736d53476a61c3
6
+ metadata.gz: da1ad13d7385129624206e5ba3d2083d79ea092523b308ccf26df020add6c3e3f4961b89705433bd9ead44716f940d1786f8ec63352f4e6a389f51c9b215bb48
7
+ data.tar.gz: 6997cda79358bf04d28edc830fade6f9829da2d99f24896e09581e3cf50687b28c698636df63bf312dc627eeff8af7779e1baf8acc4d9f0b39ac05369fc814d5
data/CHANGES.md CHANGED
@@ -1,6 +1,9 @@
1
1
  Changes to `paper_trail_manager`
2
2
  ================================
3
3
 
4
+ * 0.4.0
5
+ * Allow configuration of ChangesController's parent class, route helpers, and layout
6
+
4
7
  * 0.3.0
5
8
  * Support Rails 3.2, 4.0, 4.1, and 4.2
6
9
  * Drop support for Rails 3.0 and 3.1
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in paper_trail_manager.gemspec
4
4
  gemspec
5
+
6
+ gem "byebug"
data/README.md CHANGED
@@ -1,16 +1,14 @@
1
1
  [![Build Status](https://secure.travis-ci.org/fusion94/paper_trail_manager.png)](http://travis-ci.org/fusion94/paper_trail_manager)
2
2
 
3
- PaperTrailManager
4
- ================
3
+ # PaperTrailManager
5
4
 
6
5
  Browse, subscribe, view and revert changes to records when using Ruby on Rails 3 and the `paper_trail` gem.
7
6
 
8
7
  This software has been in use for a year at http://calagator.org and http://epdx.org. It works well. It has reasonable tests. However, it could definitely use more work.
9
8
 
10
- Installation
11
- ------------
9
+ ## Installation
12
10
 
13
- If you have a Ruby on Rails 3 application where you're using the `paper_trail` gem to track changes to your records, you can make use of this like:
11
+ If you have a Ruby on Rails 3 or 4 application where you're using the `paper_trail` gem to track changes to your records, you can make use of this like:
14
12
 
15
13
  Add the following line to your `Gemfile`:
16
14
  gem 'paper_trail_manager'
@@ -27,8 +25,35 @@ Restart the server and go to the `/changes` URI to browse, subscribe, view and r
27
25
 
28
26
  http://localhost:3000/changes
29
27
 
30
- Development
31
- -----------
28
+ ### Configuration
29
+
30
+ Several aspects of PaperTrailManager may be optionally configured
31
+ by creating an initializer in your application
32
+ (e.g. `config/initializers/paper_trail_manager.rb`).
33
+
34
+ To specify when reverts are allowed:
35
+
36
+ PaperTrailManager.allow_revert_when do |controller, version|
37
+ controller.current_user and controller.current_user.admin?
38
+ end
39
+
40
+ To specify how to look up users/memebers/etc specified in Paper Trail's 'whodunnit' column:
41
+
42
+ PaperTrailManager.whodunnit_class = User
43
+ PaperTrailManager.whodunnit_name_method = :nicename # defaults to :name
44
+
45
+ When including PaperTrailManager within another Rails engine, you may need to
46
+ override PaperTrailManager::ChangesController's parent class to reference the
47
+ engine's ApplicationController configure it to use your engine's url helpers:
48
+
49
+ PaperTrailManager.base_controller = "MyEngine::ApplicationController"
50
+ PaperTrailManager.route_helpers = MyEngine::Engine.routes.url_helpers
51
+
52
+ You can also specify the layout:
53
+
54
+ PaperTrailManager.layout = 'my_engine/application'
55
+
56
+ ## Development
32
57
 
33
58
  Setup:
34
59
 
@@ -50,12 +75,10 @@ Adding support for new Rails versions:
50
75
  * Fix whatever breaks.
51
76
  * Please contribute your fixes with a Github pull request.
52
77
 
53
- License
54
- -------
78
+ ## License
55
79
 
56
80
  This program is provided under an MIT open source license, read the [LICENSE.txt](http://github.com/igal/paper_trail_manager/blob/master/LICENSE.txt) file for details.
57
81
 
58
- To Note:
59
- --------
82
+ ## To Note:
60
83
 
61
84
  This project was originally devloped by [Igal Koshevoy](http://github.com/igal). Unfortunately @igal passed away on April 9th, 2013 and I took over the project afterwords.
@@ -1,7 +1,14 @@
1
- class PaperTrailManager::ChangesController < ApplicationController
1
+ # Allow the parent class of ChangesController to be configured in the host app
2
+ PaperTrailManager::ChangesController = Class.new(PaperTrailManager.base_controller.constantize)
3
+
4
+ class PaperTrailManager::ChangesController
2
5
  # Default number of changes to list on a pagenated index page.
3
6
  PER_PAGE = 50
4
7
 
8
+ helper PaperTrailManager.route_helpers if PaperTrailManager.route_helpers
9
+ helper PaperTrailManager::ChangesHelper
10
+ layout PaperTrailManager.layout if PaperTrailManager.layout
11
+
5
12
  # List changes
6
13
  def index
7
14
  unless change_index_allowed?
@@ -2,25 +2,11 @@ require 'rails'
2
2
  require 'paper_trail'
3
3
  require 'will_paginate'
4
4
 
5
- # = PaperTrailManager
6
- #
7
- # == Example usage
8
- #
9
- # To specify when reverts are allowed, write an initializer similar to this:
10
- #
11
- # # config/initializers/paper_trail_manager.rb
12
- # PaperTrailManager.allow_revert_when do |controller, version|
13
- # controller.current_user and controller.current_user.admin?
14
- # end
15
- #
16
- # To specify how to look up users/memebers/etc specified in Paper Trail's 'whodunnit' column:
17
- #
18
- # PaperTrailManager.whodunnit_class = User
19
- # PaperTrailManager.whodunnit_name_method = :nicename # defaults to :name
20
- #
21
5
  class PaperTrailManager < Rails::Engine
22
6
  @@whodunnit_name_method = :name
23
- cattr_accessor :whodunnit_class, :whodunnit_name_method
7
+ cattr_accessor :whodunnit_class, :whodunnit_name_method, :route_helpers, :layout, :base_controller
8
+
9
+ self.base_controller = "ApplicationController"
24
10
 
25
11
  (Pathname(__FILE__).dirname + '..').tap do |base|
26
12
  paths["app/controller"] = base + 'app/controllers'
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "paper_trail_manager"
7
- spec.version = "0.3.0"
7
+ spec.version = "0.4.0"
8
8
  spec.authors = ["Igal Koshevoy", "Reid Beels"]
9
9
  spec.authors = ["mail@reidbeels.com"]
10
10
  spec.summary = "A user interface for `paper_trail` versioning data in Ruby on Rails 3 applications."
@@ -28,6 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "rspec-activemodel-mocks", "~> 1.0"
29
29
  spec.add_development_dependency "rspec-its", "~> 1.0"
30
30
  spec.add_development_dependency "appraisal", "~> 1.0"
31
- spec.add_development_dependency "byebug"
32
31
  end
33
32
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_trail_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mail@reidbeels.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-22 00:00:00.000000000 Z
11
+ date: 2015-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -156,20 +156,6 @@ dependencies:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
158
  version: '1.0'
159
- - !ruby/object:Gem::Dependency
160
- name: byebug
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- version: '0'
173
159
  description: Browse, subscribe, view and revert changes to records when using Ruby
174
160
  on Rails 3 and the `paper_trail` gem.
175
161
  email:
@@ -408,3 +394,4 @@ test_files:
408
394
  - spec/views/platforms/index.html.erb_spec.rb
409
395
  - spec/views/platforms/new.html.erb_spec.rb
410
396
  - spec/views/platforms/show.html.erb_spec.rb
397
+ has_rdoc: