No release in over 3 years
Low commit activity in last 3 years
This gem provides PrettyPrint support for Sequel models.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

sequel_pretty_print   Gem Version Build Status Coverage Status

Installation

Just add gem "sequel_pretty_print" to your Gemfile.

Usage

# 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) 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:

# Before:
Artist.new
# => #<Artist @values={}>

# After:
Artist.new
# => #<Artist:0x00007f8d1967f8b0 id: nil, name: nil>
Artist.new(name: "Elvis")
# => #<Artist:0x00007f8d1b413ef8 id: nil, 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.

Supported by Umbrellio