diff --git a/CHANGELOG b/CHANGELOG index bb3c7d7..6c9ce28 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ 0.2.0 - Added support for logger.ap (including Rails logger) + - Added support for HashWithIndifferentAccess from ActiveSupport - ap now works with scripts that use ActiveRecord/ActiveSupport outside Rails - ap now correctly shows file and directory names with fancy characters (shell escape) diff --git a/VERSION b/VERSION index 845639e..0ea3a94 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.4 +0.2.0 diff --git a/awesome_print.gemspec b/awesome_print.gemspec index 7ca2701..d4a83ab 100644 --- a/awesome_print.gemspec +++ b/awesome_print.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{awesome_print} - s.version = "0.1.4" + s.version = "0.2.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Michael Dvorkin"] - s.date = %q{2010-04-08} + s.date = %q{2010-05-05} s.description = %q{Great Ruby dubugging companion: pretty print Ruby objects to visualize their structure. Supports Rails ActiveRecord objects via included mixin.} s.email = %q{mike@dvorkin.net} s.extra_rdoc_files = [ @@ -26,11 +26,14 @@ Gem::Specification.new do |s| "lib/ap.rb", "lib/ap/awesome_print.rb", "lib/ap/core_ext/kernel.rb", + "lib/ap/core_ext/logger.rb", "lib/ap/core_ext/string.rb", - "lib/ap/mixin/rails.rb", + "lib/ap/mixin/active_record.rb", + "lib/ap/mixin/active_support.rb", "rails/init.rb", + "spec/active_record_spec.rb", "spec/awesome_print_spec.rb", - "spec/rails_spec.rb", + "spec/logger_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/string_spec.rb" @@ -42,8 +45,9 @@ Gem::Specification.new do |s| s.rubygems_version = %q{1.3.6} s.summary = %q{Pretty print Ruby objects with proper indentation and colors.} s.test_files = [ - "spec/awesome_print_spec.rb", - "spec/rails_spec.rb", + "spec/active_record_spec.rb", + "spec/awesome_print_spec.rb", + "spec/logger_spec.rb", "spec/spec_helper.rb", "spec/string_spec.rb" ] diff --git a/lib/ap/awesome_print.rb b/lib/ap/awesome_print.rb index 0d1a891..be5f9f9 100755 --- a/lib/ap/awesome_print.rb +++ b/lib/ap/awesome_print.rb @@ -22,7 +22,7 @@ class AwesomePrint :falseclass => :red, :fixnum => :blue, :float => :blue, - :hash => :gray, + :hash => :pale, :nilclass => :red, :string => :yellowish, :symbol => :cyanish, diff --git a/lib/ap/mixin/active_support.rb b/lib/ap/mixin/active_support.rb index 5c2c74c..5e17fb1 100644 --- a/lib/ap/mixin/active_support.rb +++ b/lib/ap/mixin/active_support.rb @@ -17,6 +17,8 @@ module AwesomePrintActiveSupport if printable == :self if object.is_a?(ActiveSupport::TimeWithZone) printable = :active_support_time + elsif object.is_a?(HashWithIndifferentAccess) + printable = :hash_with_indifferent_access end end printable @@ -28,6 +30,15 @@ module AwesomePrintActiveSupport awesome_self(object, :as => :time) end + # Format HashWithIndifferentAccess as standard Hash. + # + # NOTE: can't use awesome_self(object, :as => :hash) since awesome_self uses + # object.inspect internally, i.e. it would convert hash to string. + #------------------------------------------------------------------------------ + def awesome_hash_with_indifferent_access(object) + awesome_hash(object) + end + end AwesomePrint.send(:include, AwesomePrintActiveSupport)