Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

GroundFloorUS/sequel_paper_trail

 
 

Repository files navigation

Sequel plugin for Paper Trail

This is a simple Sequel plugin for PaperTrail (with limited functionality).

Conributions are welcome!

Gem Version Travis badge Coverage Status Code Climate Badge Inch CI Dependency Status License

Features

  • model are able to subscribe on create, update, delete callback
  • can be specified whodunnit
  • can be specified info_for_paper_trail
  • versioning can be disabled or enabled globaly or in block context

Limitations

  • this gem doesn't create a version table
  • versions table has a structure as Paper Trail v0.6.x. has
  • whodunnit is global
  • info_for_paper_trail is global

Installation

Add this line to your application's Gemfile:

gem 'sequel_paper_trail'

Documentation

Usage

Our usage model:

Be sure that you have a proper tables from Paper Trail v0.6.x.

Than you can subscribe a model on create, update, destroy callbacks.

Quick start:

require 'sequel_paper_trail'
require 'sequel'
require 'sequel/plugins/has_paper_trail'

Album.pligin :has_paper_trail,
             class_name: 'VersionClassName'
# or

Album.pligin :has_paper_trail,
             item_class_name: SomeAlbum,
             class_name: 'VersionClassName'

Enable versioning globaly:

SequelPaperTrail.enabled = true

Enable versioning for block of code:

SequelPaperTrail.with_versioning { 'code' }

Disable versioning globaly:

SequelPaperTrail.enabled = false

Disable versioning for block of code

SequelPaperTrail.with_versioning(false) { 'code' }

Set whodunnit:

SequelPaperTrail.whodunnit = 'Mr. Smith'

Set info_for_paper_trail - additional info (Hash) which will be attached to versions table.

# If you have 'release' and 'instance' columns in a versions table you can populate them.

SequelPaperTrail.info_for_paper_trail = { release: 'asdf131234', instance: `hostname` }

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

This gem has a very limited functionality so conributions are welcome!

Bug reports and pull requests are welcome on GitHub at https://github.com/lazebny/sequel_paper_trail.

License

The gem is available as open source under the terms of the MIT License.

About

Sequel plugin for Paper Trail

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 95.7%
  • Dockerfile 3.4%
  • Shell 0.9%