diff --git a/CHANGELOG b/CHANGELOG index ea63378..bb3c7d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +0.2.0 + - Added support for logger.ap (including Rails logger) + - ap now works with scripts that use ActiveRecord/ActiveSupport outside Rails + - ap now correctly shows file and directory names with fancy characters (shell escape) + 0.1.4 - Format BigDecimal and Rational objects as Float scalars - Explicit options parameter can override custom defaults diff --git a/README.md b/README.md index 4ff9f95..cd049c4 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,18 @@ Supported color names: } rails> +### IRB integration ### +To use awesome_print as default formatter in irb and Rails console add the following +lines into your ~/.irbrc file: + + require "rubygems" + require "ap" + IRB::Irb.class_eval do + def output_value + ap @context.last_value + end + end + ### Logger Convenience Method ### awesome_print adds an ap method to the Logger and ActiveSupport::BufferedLogger classes, allowing you to call: @@ -158,7 +170,6 @@ in the custom defaults (see below), or you can override on a per call basis with logger.ap object, :warn - ### Setting Custom Defaults ### You can set your own default options by creating ``.aprc`` file in your home directory. Within that file assign your defaults to ``AwesomePrint.defaults``. @@ -180,8 +191,14 @@ For example: * Commit, do not mess with rakefile, version, or history. * Send me a pull request. +### Contributors ### + +* Daniel Bretoi -- http://github.com/danielb2 +* eregon -- http://github.com/eregon +* Tobias Crawley -- http://github.com/tobias + ### License ### Copyright (c) 2010 Michael Dvorkin %w(mike dvorkin.net) * "@" || %w(mike fatfreecrm.com) * "@" -Released under the MIT license. See LICENSE file for details. +Released under the MIT license. See LICENSE file for details. \ No newline at end of file diff --git a/lib/ap/awesome_print.rb b/lib/ap/awesome_print.rb index 56216ef..0d1a891 100755 --- a/lib/ap/awesome_print.rb +++ b/lib/ap/awesome_print.rb @@ -3,6 +3,8 @@ # Awesome Print is freely distributable under the terms of MIT license. # See LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ +require "shellwords" + class AwesomePrint AP = :__awesome_print__ CORE = [ :array, :hash, :class, :file, :dir, :bigdecimal, :rational ] @@ -103,14 +105,14 @@ class AwesomePrint # Format File object. #------------------------------------------------------------------------------ def awesome_file(f) - ls = File.directory?(f) ? `ls -adlF #{f.path}` : `ls -alF #{f.path}` + ls = File.directory?(f) ? `ls -adlF #{f.path.shellescape}` : `ls -alF #{f.path.shellescape}` awesome_self(f, :with => ls.empty? ? nil : "\n#{ls.chop}") end # Format Dir object. #------------------------------------------------------------------------------ def awesome_dir(d) - ls = `ls -alF #{d.path}` + ls = `ls -alF #{d.path.shellescape}` awesome_self(d, :with => ls.empty? ? nil : "\n#{ls.chop}") end