项目作者: lazebny

项目描述 :
Sequel plugin for Paper Trail
高级语言: Ruby
项目地址: git://github.com/lazebny/sequel_paper_trail.git
创建时间: 2017-06-28T10:10:59Z
项目社区:https://github.com/lazebny/sequel_paper_trail

开源协议:MIT License

下载


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:

  1. 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:

  1. require 'sequel_paper_trail'
  2. require 'sequel'
  3. require 'sequel/plugins/has_paper_trail'
  4. Album.pligin :has_paper_trail,
  5. class_name: 'VersionClassName'
  6. # or
  7. Album.pligin :has_paper_trail,
  8. item_class_name: SomeAlbum,
  9. class_name: 'VersionClassName'

Enable versioning globaly:

  1. SequelPaperTrail.enabled = true

Enable versioning for block of code:

  1. SequelPaperTrail.with_versioning { 'code' }

Disable versioning globaly:

  1. SequelPaperTrail.enabled = false

Disable versioning for block of code

  1. SequelPaperTrail.with_versioning(false) { 'code' }

Set whodunnit:

  1. SequelPaperTrail.whodunnit = 'Mr. Smith'

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

  1. # If you have 'release' and 'instance' columns in a versions table you can populate them.
  2. 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.