You are here: Noosfero>Dev>Console>UsingAP (02 Dec 2011, AurelioAHeckert) EditAttach

Using the Awesome Print Gem

You must use the Noosfero Console to follow this steps.

In Noosfero, and in every Rails project, you might have lots of classes and different types of objects that actually are not as simple as a string. Sometimes you need to debug an object that is related to other objects and when you try to see what's going on you need to build a script to show object attribute in a human way. That's where Awesome Print comes in!

Awesome Print is a gem written mostly by Michael Dvorkin that prints almost all kinds of objects in human, colorized, indented and AWESOME way! ^^ Here is a simple use of it showing how you will see a Profile with the default print and with Awesome Print:


Pretty neat, isn't it? So now that you started loving Awesome Print just like me, here are the steps to install and use it as your Rails stdout method:

1. Install awesome print

(sudo) gem install awesome_print   # "sudo" is for optional system wide installation
2. Include this lines to your ~/.irbrc
require 'rubygems'
require 'ap'

IRB::Irb.class_eval do
  def output_value
    ap @context.last_value

Done! Easy and awesome. Now you can just enjoy this cool gem at your console as the default printer. You can find Awesome Print sources and docs in this following page:

-- RodrigoSouto - 13 Jul 2010

Add comment
You need to login to be able to comment.
Topic revision: r2 - 02 Dec 2011 - 22:45:07 - AurelioAHeckert

irc Talk with Devs Now!

Translations: English
Search on Docs:
ActionItem Search:

Copyright © 2007-2015 by the Noosfero contributors
Colivre - Cooperativa de Tecnologias Livres