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

Changed option :raw to true as default. #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1.6.2 (unreleased)
- Option :raw defaults to true. Expected behavior is that Objects are recursively formatted (Matt Martini)
- Improves spec performance and simplicity (Mauro George)
- Handle objects that have a custom #to_hash method (Elliot Shank)

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ Special thanks goes to awesome team of contributors, namely:
* Trevor Wennblom -- https://github.com/trevor
* vfrride -- https://github.com/vfrride
* Viktar Basharymau -- https://github.com/DNNX
* Matt Martini -- https://github.com/mattmartini

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Default options:
: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.
:raw => true, # Recursively format object instance variables.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont think we need to change defaults, since this is a breaking change and brokes the semantic versioning.

:sort_keys => false, # Do not sort hash keys.
:limit => false, # Limit large output for arrays and hashes. Set to a boolean or integer.
:color => {
Expand Down
8 changes: 4 additions & 4 deletions lib/awesome_print/ext/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def cast_with_active_record(object, type)

# Format ActiveRecord instance object.
#
# NOTE: by default only instance attributes (i.e. columns) are shown. To format
# ActiveRecord instance as regular object showing its instance variables and
# accessors use :raw => true option:
# NOTE: by default ActiveRecord instances are formatted as regular objects showing
# its instance variables and accessors. To format with only instance attributes
# (i.e. columns) use :raw => false option:
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 the AR need to keep his beahvior too.

#
# ap record, :raw => true
# ap record, :raw => false
#
#------------------------------------------------------------------------------
def awesome_active_record_instance(object)
Expand Down
8 changes: 4 additions & 4 deletions lib/awesome_print/ext/mongo_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def awesome_mongo_mapper_class(object)

# Format MongoMapper instance object.
#
# NOTE: by default only instance attributes (i.e. keys) are shown. To format
# MongoMapper instance as regular object showing its instance variables and
# accessors use :raw => true option:
# NOTE: by default MongoMapper instances are formatted as regular objects showing
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same that AR.

# its instance variables and accessors. To format with only instance attributes
# (i.e. keys) use :raw => false option:
#
# ap record, :raw => true
# ap record, :raw => false
#
#------------------------------------------------------------------------------
def awesome_mongo_mapper_instance(object)
Expand Down
7 changes: 4 additions & 3 deletions lib/awesome_print/ext/ripple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ def cast_with_ripple(object, type)

# Format Ripple instance object.
#
# NOTE: by default only instance attributes are shown. To format a Ripple document instance
# as a regular object showing its instance variables and accessors use :raw => true option:
# NOTE: by default Ripple document instances are formatted as regular objects showing
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same that AR.

# its instance variables and accessors. To format with only instance attributes
# use :raw => false option:
#
# ap document, :raw => true
# ap document, :raw => false
#
#------------------------------------------------------------------------------
def awesome_ripple_document_instance(object)
Expand Down
8 changes: 4 additions & 4 deletions lib/awesome_print/inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class Inspector
AP = :__awesome_print__

def initialize(options = {})
@options = {
@options = {
: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.
:raw => true, # 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.
:color => {
:color => {
:args => :pale,
:array => :white,
:bigdecimal => :blue,
Expand Down Expand Up @@ -92,7 +92,7 @@ def initialize(options = {})
@formatter = AwesomePrint::Formatter.new(self)
Thread.current[AP] ||= []
end

# Dispatcher that detects data nesting and invokes object-aware formatter.
#------------------------------------------------------------------------------
def awesome(object)
Expand Down
2 changes: 1 addition & 1 deletion spec/misc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def inspect
it "IPAddr workaround" do
require "ipaddr"
ipaddr = IPAddr.new("3ffe:505:2::1")
expect(ipaddr.ai).to eq("#<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>")
expect(ipaddr.ai(:raw => false)).to eq("#<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>")
end

# See https://github.com/michaeldv/awesome_print/issues/139
Expand Down