awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.07k stars 454 forks source link

Fixed warnings with Ruby 2.7 on Proc.new with no block. #373

Closed akshaymohite closed 3 years ago

akshaymohite commented 4 years ago

Ref: https://github.com/ruby/ruby/commit/9f1fb0a17febc59356d58cef5e98db61a3c03550

Warnings:

:001 > hash = {a: 4}
 :002 > ap hash
/Users/akshay/.rvm/gems/ruby-2.7.0/gems/awesome_print-1.8.0/lib/awesome_print/formatters/base_formatter.rb:113: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
/Users/akshay/.rvm/gems/ruby-2.7.0/gems/awesome_print-1.8.0/lib/awesome_print/inspector.rb:63: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
{
    :a => 4
}
nil

After this change:

 :001 > hash = {a: 4}
 :002 > ap hash
{
    :a => 4
}
nil
SimonVillage commented 4 years ago

can we get that merged?

oyeanuj commented 4 years ago

@imajes Can we please have this merged?

ekampp commented 4 years ago

Based on the number of closed PRs in the last year, and the general lack of maintainer engagement, I would guess this is not being merged. This means that in a very short timeframe gems that depend on AP for one reason or the other will have to migrate to another library.

TobiasBales commented 4 years ago

As a work around I placed the following in config/initializers/awesome_print.rb

module AwesomePrint
  module Formatters
    class BaseFormatter
      def indented(&block)
        inspector.increase_indentation(&block)
      end
    end
  end

  class Inspector
    def increase_indentation(&block)
      indentator.indent(&block)
    end
  end
end

works like a charm ;)

I am aware that it is not the best solution but for now if you have libraries that depend on it at least it cleans up your logs. A lot.

ghepting commented 4 years ago

What other libraries do folks recommend for nice console printing? I tried Hirb, but I must be missing something about the configuration options, it was a bit clunky.

ekampp commented 4 years ago

Someone has cloned and relaunched awesome print as amazing print. This is currently maintained. Give it a look :)

ghepting commented 4 years ago

Ah yeah, i ended up using pry-rails – that's definitely what I was looking for :P

ryanmjacobs commented 4 years ago

Yeah... I moved to amazing_print (the fork) for now. Fixes the deprecation warnings for me -- https://github.com/amazing-print/amazing_print

mayconmrr commented 4 years ago

Yeah... I moved to amazing_print (the fork) for now. Fixes the deprecation warnings for me -- https://github.com/amazing-print/amazing_print

thanks for the tip man

BryanH commented 3 years ago

PRs were submitted and I'm untangling the (unrelated) build errors - stay tuned!

BryanH commented 3 years ago

Fixed with latest PR - will be pushed out in next release!