Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Awesome Print vN.... (was v2, but not anymore..) #193

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
7e6e7c0
Remove conditional check against old Ruby versions
maurogeorge Feb 12, 2015
f6fbe02
Remove init.rb and rails/init.rb
maurogeorge Feb 19, 2015
c75c058
Remove the lib/ap.rb
maurogeorge Feb 19, 2015
cf91f4e
Remove copyright from each file
maurogeorge Feb 19, 2015
f5f494b
Split Inspector in 2 files
maurogeorge Feb 26, 2015
b48989c
Extract Array Formatter
maurogeorge Feb 26, 2015
141628d
Extract Hash Formmatter
maurogeorge Mar 4, 2015
f230268
Extract commom behavior from Formatters to a Base class
maurogeorge Mar 4, 2015
c2563be
Refactoring on Hash formatter
maurogeorge Mar 4, 2015
9ad2ddb
Extract Object Formmatter
maurogeorge Mar 5, 2015
708a79c
Extract Set Formatter
maurogeorge Mar 11, 2015
ffa2e30
Extract Struct Formatter
maurogeorge Mar 11, 2015
3470b72
Extract Class Formatter
maurogeorge Mar 11, 2015
db32b90
Extract File Formatter
maurogeorge Mar 11, 2015
3e0e124
Extract Dir Formatter
maurogeorge Mar 11, 2015
2d786cf
Extract BigDecimal Formatter
maurogeorge Mar 11, 2015
6ec149d
Extract Rational Formatter
maurogeorge Mar 11, 2015
2cbdbc8
Move Formatter#methods_array to Array formatter
maurogeorge Mar 11, 2015
040f129
Extract Method Formatter
maurogeorge Mar 11, 2015
d7fe4c8
Move some Formatter methods to their specific formatter
maurogeorge Mar 11, 2015
4b9f0bf
Extract specific methods of array and a hash
maurogeorge Mar 12, 2015
5a9da75
Create ActiveRecordInstance formatter
maurogeorge Mar 12, 2015
e9a4c72
Extract ActiveRecordClass Formatter
maurogeorge Mar 12, 2015
2426de2
Create a AwesomePrint::Formatters to include all formatters
maurogeorge Mar 12, 2015
2cffbaa
Extract ActiveSupport Formatter
maurogeorge Mar 14, 2015
556a1cc
Extract Mongoid formmatter
maurogeorge Mar 14, 2015
437857b
Extract MongoMapper formmatter
maurogeorge Mar 14, 2015
8696ec2
Extract NoBrainer formmatter
maurogeorge Mar 14, 2015
2727d38
Extract Nokogiri formmatter
maurogeorge Mar 14, 2015
b4e782c
Extract OpenStruct formmatter
maurogeorge Mar 14, 2015
02982d1
Extract Ripple formmatter
maurogeorge Mar 14, 2015
f791021
Extract Sequel formmatter
maurogeorge Mar 14, 2015
413a350
Create a method that instantiate and call all formatters
maurogeorge Mar 14, 2015
05fad93
Create FormatterFactory
maurogeorge Mar 16, 2015
9c320e6
Fix NoBrainer specs
maurogeorge Mar 16, 2015
1def646
Extract Self formatter
maurogeorge Mar 16, 2015
17abe6d
Extract MethodTuple module
maurogeorge Mar 16, 2015
d27284f
Create ActiveRecord type
maurogeorge Mar 17, 2015
58d618c
Create ActiveSupport type
maurogeorge Mar 17, 2015
0f5d96b
Create Mongoid type
maurogeorge Mar 17, 2015
4d6e963
Create MongoMapper type
maurogeorge Mar 17, 2015
ea274a5
Create NoBrainer type
maurogeorge Mar 17, 2015
9168b0d
Create Nokogiri type
maurogeorge Mar 17, 2015
ab63f91
Create OpenStruct type
maurogeorge Mar 17, 2015
ad175c1
Create Ripple type
maurogeorge Mar 17, 2015
9cb3a15
Create Sequel type
maurogeorge Mar 17, 2015
7695cfc
Simple load of files on AwesomePrint
maurogeorge Mar 17, 2015
a9629ba
Move some methods to the right place
maurogeorge Mar 18, 2015
3f24897
Notify about last release that support old rubies and rails
maurogeorge Mar 18, 2015
188becf
Add the new_hash_syntax syntax option
maurogeorge Mar 18, 2015
4332366
Add missing CHANGELOG
maurogeorge Mar 18, 2015
95c6bfd
Use a single place to define the Gem Version
maurogeorge Mar 18, 2015
d2a0719
Fix the load of version on gemspec
maurogeorge Mar 19, 2015
de51f83
Rename Base formatter to Formatter
maurogeorge Mar 19, 2015
896e8f7
Rename Base type to Type
maurogeorge Mar 19, 2015
a4d960f
Rename the option from new_hash_syntax to colonize_symbol_keys
maurogeorge Mar 19, 2015
1dd896f
Create AwesomePrint::FormatterFactory.from
maurogeorge Mar 19, 2015
a9c6a90
Fix broken specs on AR 4.2.1
maurogeorge Mar 26, 2015
aef581d
Automatically require all custom types
maurogeorge Mar 28, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
1.6.2 (unreleased)
2.0.0.beta (unreleased)
- Improves spec performance and simplicity (Mauro George)
- Remove the support for Ruby 1.8.x and Rails 2.x (Mauro George)
- New plugin structure, no more unnecessary monkey patching (Mauro George)
- Add the new hash syntax support (Mauro George)
- Handle objects that have a custom #to_hash method (Elliot Shank)

1.6.1
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Awesome Print is a Ruby library that pretty prints Ruby objects in full color
exposing their internal structure with proper indentation. Rails ActiveRecord
objects and usage within Rails templates are supported via included mixins.

__NOTE__: awesome_print v1.2.0 is the last release supporting Ruby versions
prior to v1.9.3 and Rails versions prior to v3.0. The upcoming awesome_print
v2.0 will *require* Ruby v1.9.3 or later and Rails v3.0 or later.
__NOTE__: awesome_print v1.6.1 is the last release supporting Ruby versions
prior to v1.9.3 and Rails versions prior to v3.2. The upcoming awesome_print
v2.0 will *require* Ruby v1.9.3 or later and Rails v3.2 or later.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this README change deserves a separate PR, so it gets into the main README ASAP.


### Installation ###
# Installing as Ruby gem
Expand All @@ -33,14 +33,15 @@ ap object, options = {}
Default options:

```ruby
:indent => 4, # Indent using 4 spaces.
:index => true, # Display array indices.
:html => false, # Use ANSI color codes rather than HTML.
:multiline => true, # Display in multiple lines.
:plain => false, # Use colors.
:raw => false, # Do not recursively format object instance variables.
:sort_keys => false, # Do not sort hash keys.
:limit => false, # Limit large output for arrays and hashes. Set to a boolean or integer.
:indent => 4, # Indent using 4 spaces.
:index => true, # Display array indices.
:html => false, # Use ANSI color codes rather than HTML.
:multiline => true, # Display in multiple lines.
:plain => false, # Use colors.
:raw => false, # Do not recursively format object instance variables.
:sort_keys => false, # Do not sort hash keys.
:limit => false, # Limit large output for arrays and hashes. Set to a boolean or integer.
:colonize_symbol_keys => false, # Use the foo: 'bar' syntax, when the key is a symbol
:color => {
:args => :pale,
:array => :white,
Expand Down
10 changes: 4 additions & 6 deletions awesome_print.gemspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
$:.push File.expand_path('../lib', __FILE__)

require "rake"
require 'awesome_print/version'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe go back to require File.join(File.dirname(__FILE__), "lib", "awesome_print") for this file only?


Gem::Specification.new do |s|
s.name = "awesome_print"
s.version = "1.6.2"
s.version = AwesomePrint.version
# s.platform = Gem::Platform::RUBY
s.authors = "Michael Dvorkin"
s.date = Time.now.strftime("%Y-%m-%d")
Expand Down
1 change: 0 additions & 1 deletion init.rb

This file was deleted.

10 changes: 0 additions & 10 deletions lib/ap.rb

This file was deleted.

33 changes: 9 additions & 24 deletions lib/awesome_print.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
#
# AwesomePrint might be loaded implicitly through ~/.irbrc or ~/.pryrc
# so do nothing for subsequent requires.
#
unless defined?(AwesomePrint::Inspector)
%w(array string method object class kernel).each do |file|
require File.dirname(__FILE__) + "/awesome_print/core_ext/#{file}"
require "awesome_print/core_ext/#{file}"
end

require File.dirname(__FILE__) + "/awesome_print/inspector"
require File.dirname(__FILE__) + "/awesome_print/formatter"
require File.dirname(__FILE__) + "/awesome_print/version"
require File.dirname(__FILE__) + "/awesome_print/core_ext/logger" if defined?(Logger)
#
# Load the following under normal circumstances as well as in Rails
# console when required from ~/.irbrc or ~/.pryrc.
#
require File.dirname(__FILE__) + "/awesome_print/ext/active_record" if defined?(ActiveRecord) || AwesomePrint.rails_console?
require File.dirname(__FILE__) + "/awesome_print/ext/active_support" if defined?(ActiveSupport) || AwesomePrint.rails_console?
require 'awesome_print/support'
require 'awesome_print/configuration'
require 'awesome_print/inspector'
require 'awesome_print/formatter'
require 'awesome_print/version'
require 'awesome_print/core_ext/logger' if defined?(Logger)

#
# Load remaining extensions.
#
if defined?(ActiveSupport)
ActiveSupport.on_load(:action_view) do
require File.dirname(__FILE__) + "/awesome_print/ext/action_view"
require 'awesome_print/ext/action_view'
end
end
require File.dirname(__FILE__) + "/awesome_print/ext/mongo_mapper" if defined?(MongoMapper)
require File.dirname(__FILE__) + "/awesome_print/ext/mongoid" if defined?(Mongoid)
require File.dirname(__FILE__) + "/awesome_print/ext/nokogiri" if defined?(Nokogiri)
require File.dirname(__FILE__) + "/awesome_print/ext/nobrainer" if defined?(NoBrainer)
require File.dirname(__FILE__) + "/awesome_print/ext/ripple" if defined?(Ripple)
require File.dirname(__FILE__) + "/awesome_print/ext/sequel" if defined?(Sequel)
require File.dirname(__FILE__) + "/awesome_print/ext/ostruct" if defined?(OpenStruct)
end
44 changes: 44 additions & 0 deletions lib/awesome_print/configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module AwesomePrint

class << self # Class accessors for custom defaults.
attr_accessor :defaults, :force_colors

# Class accessor to force colorized output (ex. forked subprocess where TERM
# might be dumb).
#------------------------------------------------------------------------------
def force_colors!(value = true)
@force_colors = value
end

def console?
!!(defined?(IRB) || defined?(Pry))
end

def rails_console?
console? && !!(defined?(Rails::Console) || ENV["RAILS_ENV"])
end

def irb!
return unless defined?(IRB)
unless IRB.version.include?("DietRB")
IRB::Irb.class_eval do
def output_value
ap @context.last_value
end
end
else # MacRuby
IRB.formatter = Class.new(IRB::Formatter) do
def inspect_object(object)
object.ai
end
end.new
end
end

def pry!
if defined?(Pry)
Pry.print = proc { |output, value| output.puts value.ai }
end
end
end
end
5 changes: 0 additions & 5 deletions lib/awesome_print/core_ext/array.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
#
# The following makes it possible to invoke awesome_print while performing
# operations on method arrays, ex:
Expand Down
5 changes: 0 additions & 5 deletions lib/awesome_print/core_ext/class.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
class Class #:nodoc:
#
# Intercept methods below to inject @__awesome_print__ instance variable
Expand Down
5 changes: 0 additions & 5 deletions lib/awesome_print/core_ext/kernel.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
module Kernel
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 getting rid of the superfluous copyright lines. It's not necessary given a master license.


def ai(options = {})
Expand Down
5 changes: 0 additions & 5 deletions lib/awesome_print/core_ext/logger.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
module AwesomePrint
module Logger

Expand Down
5 changes: 0 additions & 5 deletions lib/awesome_print/core_ext/method.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
#
# Method#name was intorduced in Ruby 1.8.7 so we define it here as necessary.
#
Expand Down
5 changes: 0 additions & 5 deletions lib/awesome_print/core_ext/object.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
class Object #:nodoc:
#
# Intercept methods below to inject @__awesome_print__ instance variable
Expand Down
5 changes: 0 additions & 5 deletions lib/awesome_print/core_ext/string.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
class String
#
# ANSI color codes:
Expand Down
5 changes: 0 additions & 5 deletions lib/awesome_print/ext/action_view.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Copyright (c) 2010-2013 Michael Dvorkin
#
# Awesome Print is freely distributable under the terms of MIT license.
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
module AwesomePrint
module ActionView

Expand Down
70 changes: 0 additions & 70 deletions lib/awesome_print/ext/active_record.rb

This file was deleted.

47 changes: 0 additions & 47 deletions lib/awesome_print/ext/active_support.rb

This file was deleted.

Loading