Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/umbrellio/sequel_pretty_print
PrettyPrint support for Sequel models.
https://github.com/umbrellio/sequel_pretty_print
pretty-print sequel
Last synced: about 2 months ago
JSON representation
PrettyPrint support for Sequel models.
- Host: GitHub
- URL: https://github.com/umbrellio/sequel_pretty_print
- Owner: umbrellio
- License: mit
- Created: 2018-01-21T14:03:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-16T11:33:20.000Z (over 1 year ago)
- Last Synced: 2024-07-21T10:44:56.337Z (2 months ago)
- Topics: pretty-print, sequel
- Language: Ruby
- Homepage:
- Size: 13.7 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# sequel_pretty_print [![Gem Version](https://badge.fury.io/rb/sequel_pretty_print.svg)](https://badge.fury.io/rb/sequel_pretty_print) ![Build Status](https://github.com/umbrellio/sequel_pretty_print/actions/workflows/ci.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/umbrellio/sequel_pretty_print/badge.svg?branch=master)](https://coveralls.io/github/umbrellio/sequel_pretty_print?branch=master)
## Installation
Just add `gem "sequel_pretty_print"` to your Gemfile.## Usage
```ruby
# Make all model subclasses use pretty_print (called before loading subclasses)
Sequel::Model.plugin :pretty_print# Make the Artist class use pretty_print
Artist.plugin :pretty_print
```The pretty_print plugin provides models with a `pretty_print` implementation (see [Ruby PrettyPrint module](http://ruby-doc.org/stdlib/libdoc/prettyprint/rdoc/PrettyPrint.html)) that can be used by tools like Pry. Assuming that we have class `Album` with columns `id` and `name` this provides the following functionality in Pry:
```ruby
# Before:
Artist.new
# => ## After:
Artist.new
# => #
Artist.new(name: "Elvis")
# => #
```For unsaved model instances, all column values are rendered. For retrieved instances, only the ones that were selected are shown. If there are some extra values (that are not represented in model columns) they are rendered after column values.
The display format is borrowed from ActiveRecord because I find it convenient.
## License
Released under MIT License.## Authors
Created by Yuri Smirnov.