amazing_print 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Appraisals +0 -6
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +34 -36
- data/README.md +8 -5
- data/lib/amazing_print/colorize.rb +1 -3
- data/lib/amazing_print/core_ext/awesome_method_array.rb +4 -4
- data/lib/amazing_print/core_ext/class.rb +1 -1
- data/lib/amazing_print/core_ext/logger.rb +1 -3
- data/lib/amazing_print/core_ext/object.rb +1 -1
- data/lib/amazing_print/custom_defaults.rb +10 -3
- data/lib/amazing_print/ext/active_record.rb +5 -9
- data/lib/amazing_print/ext/active_support.rb +1 -3
- data/lib/amazing_print/ext/mongo_mapper.rb +4 -7
- data/lib/amazing_print/ext/mongoid.rb +2 -6
- data/lib/amazing_print/ext/nobrainer.rb +3 -5
- data/lib/amazing_print/ext/nokogiri.rb +1 -3
- data/lib/amazing_print/ext/ostruct.rb +1 -3
- data/lib/amazing_print/ext/ripple.rb +4 -5
- data/lib/amazing_print/formatter.rb +5 -6
- data/lib/amazing_print/formatters/array_formatter.rb +6 -5
- data/lib/amazing_print/formatters/base_formatter.rb +20 -25
- data/lib/amazing_print/formatters/class_formatter.rb +1 -0
- data/lib/amazing_print/formatters/dir_formatter.rb +1 -0
- data/lib/amazing_print/formatters/file_formatter.rb +1 -0
- data/lib/amazing_print/formatters/hash_formatter.rb +3 -2
- data/lib/amazing_print/formatters/method_formatter.rb +1 -0
- data/lib/amazing_print/formatters/object_formatter.rb +2 -1
- data/lib/amazing_print/formatters/simple_formatter.rb +1 -0
- data/lib/amazing_print/formatters/struct_formatter.rb +2 -1
- data/lib/amazing_print/inspector.rb +29 -5
- data/lib/amazing_print/version.rb +1 -1
- data/lib/amazing_print.rb +2 -6
- data/spec/active_record_helper.rb +3 -0
- data/spec/colors_spec.rb +6 -2
- data/spec/core_ext/logger_spec.rb +7 -7
- data/spec/core_ext/string_spec.rb +2 -2
- data/spec/ext/action_controller_spec.rb +2 -2
- data/spec/ext/active_model_spec.rb +1 -1
- data/spec/ext/active_record_spec.rb +23 -23
- data/spec/ext/active_support_spec.rb +3 -3
- data/spec/ext/mongo_mapper_spec.rb +15 -11
- data/spec/ext/mongoid_spec.rb +7 -3
- data/spec/ext/nobrainer_spec.rb +6 -2
- data/spec/ext/nokogiri_spec.rb +3 -3
- data/spec/ext/ripple_spec.rb +6 -2
- data/spec/formats_spec.rb +24 -18
- data/spec/methods_spec.rb +12 -4
- data/spec/misc_spec.rb +15 -10
- data/spec/objects_spec.rb +4 -0
- data/spec/spec_helper.rb +4 -8
- metadata +19 -5
    
        data/spec/ext/ripple_spec.rb
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            +
            # rubocop:disable Lint/ConstantDefinitionInBlock
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            require 'spec_helper'
         | 
| 4 6 |  | 
| 5 7 | 
             
            RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call do
         | 
| @@ -24,7 +26,7 @@ RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call | |
| 24 26 | 
             
                @ap = AmazingPrint::Inspector.new plain: true, sort_keys: true
         | 
| 25 27 | 
             
              end
         | 
| 26 28 |  | 
| 27 | 
            -
              it ' | 
| 29 | 
            +
              it 'prints class instance' do
         | 
| 28 30 | 
             
                user = RippleUser.new _id: '12345', first_name: 'Al', last_name: 'Capone'
         | 
| 29 31 | 
             
                out = @ap.send :awesome, user
         | 
| 30 32 |  | 
| @@ -37,7 +39,7 @@ RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call | |
| 37 39 | 
             
                EOS
         | 
| 38 40 | 
             
              end
         | 
| 39 41 |  | 
| 40 | 
            -
              it ' | 
| 42 | 
            +
              it 'prints the class' do
         | 
| 41 43 | 
             
                expect(@ap.send(:awesome, RippleUser)).to eq <<~EOS.strip
         | 
| 42 44 | 
             
                  class RippleUser < Object {
         | 
| 43 45 | 
             
                             :_id => :string,
         | 
| @@ -47,3 +49,5 @@ RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call | |
| 47 49 | 
             
                EOS
         | 
| 48 50 | 
             
              end
         | 
| 49 51 | 
             
            end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            # rubocop:enable Lint/ConstantDefinitionInBlock
         | 
    
        data/spec/formats_spec.rb
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            +
            # rubocop:disable Lint/ConstantDefinitionInBlock
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            require 'spec_helper'
         | 
| 4 6 | 
             
            require 'bigdecimal'
         | 
| 5 7 | 
             
            require 'set'
         | 
| @@ -159,7 +161,7 @@ RSpec.describe 'AmazingPrint' do | |
| 159 161 |  | 
| 160 162 | 
             
              #------------------------------------------------------------------------------
         | 
| 161 163 | 
             
              describe 'Limited Output Array' do
         | 
| 162 | 
            -
                before | 
| 164 | 
            +
                before do
         | 
| 163 165 | 
             
                  @arr = (1..1000).to_a
         | 
| 164 166 | 
             
                end
         | 
| 165 167 |  | 
| @@ -227,7 +229,7 @@ RSpec.describe 'AmazingPrint' do | |
| 227 229 |  | 
| 228 230 | 
             
              #------------------------------------------------------------------------------
         | 
| 229 231 | 
             
              describe 'Limited Output Hash' do
         | 
| 230 | 
            -
                before | 
| 232 | 
            +
                before do
         | 
| 231 233 | 
             
                  @hash = ('a'..'z').inject({}) { |h, v| h.merge({ v => v.to_sym }) }
         | 
| 232 234 | 
             
                end
         | 
| 233 235 |  | 
| @@ -305,7 +307,8 @@ RSpec.describe 'AmazingPrint' do | |
| 305 307 | 
             
                end
         | 
| 306 308 |  | 
| 307 309 | 
             
                it 'plain single line' do
         | 
| 308 | 
            -
                  expect(@hash.ai(plain: true, | 
| 310 | 
            +
                  expect(@hash.ai(plain: true,
         | 
| 311 | 
            +
                                  multiline: false)).to eq('{ 1 => { :sym => { "str" => { [ 1, 2, 3 ] => { { :k => :v } => Hash < Object } } } } }')
         | 
| 309 312 | 
             
                end
         | 
| 310 313 |  | 
| 311 314 | 
             
                it 'colored multiline (default)' do
         | 
| @@ -390,7 +393,7 @@ RSpec.describe 'AmazingPrint' do | |
| 390 393 | 
             
                it 'plain multiline' do
         | 
| 391 394 | 
             
                  out = @hash.ai(plain: true)
         | 
| 392 395 | 
             
                  if RUBY_VERSION.to_f < 1.9 # Order of @hash keys is not guaranteed.
         | 
| 393 | 
            -
                    expect(out).to match(/^\{[ | 
| 396 | 
            +
                    expect(out).to match(/^\{[^}]+\}/m)
         | 
| 394 397 | 
             
                    expect(out).to match(/        "b" => "b",?/)
         | 
| 395 398 | 
             
                    expect(out).to match(/         :a => "a",?/)
         | 
| 396 399 | 
             
                    expect(out).to match(/         :z => "z",?/)
         | 
| @@ -478,18 +481,18 @@ RSpec.describe 'AmazingPrint' do | |
| 478 481 |  | 
| 479 482 | 
             
              #------------------------------------------------------------------------------
         | 
| 480 483 | 
             
              describe 'Class' do
         | 
| 481 | 
            -
                it ' | 
| 484 | 
            +
                it 'shows superclass (plain)' do
         | 
| 482 485 | 
             
                  expect(self.class.ai(plain: true)).to eq("#{self.class} < #{self.class.superclass}")
         | 
| 483 486 | 
             
                end
         | 
| 484 487 |  | 
| 485 | 
            -
                it ' | 
| 488 | 
            +
                it 'shows superclass (color)' do
         | 
| 486 489 | 
             
                  expect(self.class.ai).to eq("#{self.class} < #{self.class.superclass}".yellow)
         | 
| 487 490 | 
             
                end
         | 
| 488 491 | 
             
              end
         | 
| 489 492 |  | 
| 490 493 | 
             
              #------------------------------------------------------------------------------
         | 
| 491 494 | 
             
              describe 'File' do
         | 
| 492 | 
            -
                it ' | 
| 495 | 
            +
                it 'displays a file (plain)' do
         | 
| 493 496 | 
             
                  File.open(__FILE__, 'r') do |f|
         | 
| 494 497 | 
             
                    expect(f.ai(plain: true)).to eq("#{f.inspect}\n" + `ls -alF #{f.path}`.chop)
         | 
| 495 498 | 
             
                  end
         | 
| @@ -498,7 +501,7 @@ RSpec.describe 'AmazingPrint' do | |
| 498 501 |  | 
| 499 502 | 
             
              #------------------------------------------------------------------------------
         | 
| 500 503 | 
             
              describe 'Dir' do
         | 
| 501 | 
            -
                it ' | 
| 504 | 
            +
                it 'displays a direcory (plain)' do
         | 
| 502 505 | 
             
                  Dir.open(File.dirname(__FILE__)) do |d|
         | 
| 503 506 | 
             
                    expect(d.ai(plain: true)).to eq("#{d.inspect}\n" + `ls -alF #{d.path}`.chop)
         | 
| 504 507 | 
             
                  end
         | 
| @@ -507,12 +510,12 @@ RSpec.describe 'AmazingPrint' do | |
| 507 510 |  | 
| 508 511 | 
             
              #------------------------------------------------------------------------------
         | 
| 509 512 | 
             
              describe 'BigDecimal and Rational' do
         | 
| 510 | 
            -
                it ' | 
| 513 | 
            +
                it 'presents BigDecimal object with arbitrary precision' do
         | 
| 511 514 | 
             
                  big = BigDecimal('201020102010201020102010201020102010.4')
         | 
| 512 515 | 
             
                  expect(big.ai(plain: true)).to eq('201020102010201020102010201020102010.4')
         | 
| 513 516 | 
             
                end
         | 
| 514 517 |  | 
| 515 | 
            -
                it ' | 
| 518 | 
            +
                it 'presents Rational object with arbitrary precision' do
         | 
| 516 519 | 
             
                  rat = Rational(201_020_102_010_201_020_102_010_201_020_102_010, 2)
         | 
| 517 520 | 
             
                  out = rat.ai(plain: true)
         | 
| 518 521 | 
             
                  #
         | 
| @@ -530,7 +533,7 @@ RSpec.describe 'AmazingPrint' do | |
| 530 533 |  | 
| 531 534 | 
             
              #------------------------------------------------------------------------------
         | 
| 532 535 | 
             
              describe 'Utility methods' do
         | 
| 533 | 
            -
                it ' | 
| 536 | 
            +
                it 'merges options' do
         | 
| 534 537 | 
             
                  ap = AmazingPrint::Inspector.new
         | 
| 535 538 | 
             
                  ap.send(:merge_options!, { color: { array: :black }, indent: 0 })
         | 
| 536 539 | 
             
                  options = ap.instance_variable_get('@options')
         | 
| @@ -576,7 +579,8 @@ RSpec.describe 'AmazingPrint' do | |
| 576 579 | 
             
                  end
         | 
| 577 580 |  | 
| 578 581 | 
             
                  it 'plain single line' do
         | 
| 579 | 
            -
                    expect(@set.sort_by(&:to_s).ai(plain: true, | 
| 582 | 
            +
                    expect(@set.sort_by(&:to_s).ai(plain: true,
         | 
| 583 | 
            +
                                                   multiline: false)).to eq(@arr.sort_by(&:to_s).ai(plain: true, multiline: false))
         | 
| 580 584 | 
             
                  end
         | 
| 581 585 |  | 
| 582 586 | 
             
                  it 'colored multiline (default)' do
         | 
| @@ -693,10 +697,10 @@ RSpec.describe 'AmazingPrint' do | |
| 693 697 | 
             
                  class My < File; end
         | 
| 694 698 |  | 
| 695 699 | 
             
                  my = begin
         | 
| 696 | 
            -
             | 
| 697 | 
            -
             | 
| 698 | 
            -
             | 
| 699 | 
            -
             | 
| 700 | 
            +
                    File.new('/dev/null')
         | 
| 701 | 
            +
                  rescue StandardError
         | 
| 702 | 
            +
                    File.new('nul')
         | 
| 703 | 
            +
                  end
         | 
| 700 704 | 
             
                  expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + `ls -alF #{my.path}`.chop)
         | 
| 701 705 | 
             
                end
         | 
| 702 706 |  | 
| @@ -708,7 +712,7 @@ RSpec.describe 'AmazingPrint' do | |
| 708 712 | 
             
                  expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + `ls -alF #{my.path}`.chop)
         | 
| 709 713 | 
             
                end
         | 
| 710 714 |  | 
| 711 | 
            -
                it ' | 
| 715 | 
            +
                it 'handles a class that defines its own #send method' do
         | 
| 712 716 | 
             
                  class My
         | 
| 713 717 | 
             
                    def send(arg1, arg2, arg3); end
         | 
| 714 718 | 
             
                  end
         | 
| @@ -717,7 +721,7 @@ RSpec.describe 'AmazingPrint' do | |
| 717 721 | 
             
                  expect { my.methods.ai(plain: true) }.not_to raise_error
         | 
| 718 722 | 
             
                end
         | 
| 719 723 |  | 
| 720 | 
            -
                it ' | 
| 724 | 
            +
                it 'handles a class defines its own #method method (ex. request.method)' do
         | 
| 721 725 | 
             
                  class My
         | 
| 722 726 | 
             
                    def method
         | 
| 723 727 | 
             
                      'POST'
         | 
| @@ -779,3 +783,5 @@ RSpec.describe 'AmazingPrint' do | |
| 779 783 | 
             
                end
         | 
| 780 784 | 
             
              end
         | 
| 781 785 | 
             
            end
         | 
| 786 | 
            +
             | 
| 787 | 
            +
            # rubocop:enable Lint/ConstantDefinitionInBlock
         | 
    
        data/spec/methods_spec.rb
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            +
            # rubocop:disable Lint/ConstantDefinitionInBlock
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            require 'spec_helper'
         | 
| 4 6 |  | 
| 5 7 | 
             
            RSpec.describe 'Single method' do
         | 
| @@ -385,7 +387,8 @@ if RUBY_VERSION >= '1.9.2' | |
| 385 387 |  | 
| 386 388 | 
             
                it ':opt' do
         | 
| 387 389 | 
             
                  class Hello
         | 
| 388 | 
            -
                     | 
| 390 | 
            +
                    # m1(a, *b, *c)
         | 
| 391 | 
            +
                    def m1(a, b = 1, c = 2); end
         | 
| 389 392 | 
             
                  end
         | 
| 390 393 | 
             
                  out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
         | 
| 391 394 | 
             
                  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, \*c\)\s+Hello$/)
         | 
| @@ -393,7 +396,8 @@ if RUBY_VERSION >= '1.9.2' | |
| 393 396 |  | 
| 394 397 | 
             
                it ':rest' do
         | 
| 395 398 | 
             
                  class Hello
         | 
| 396 | 
            -
                     | 
| 399 | 
            +
                    # m1(*a)
         | 
| 400 | 
            +
                    def m1(*a); end
         | 
| 397 401 | 
             
                  end
         | 
| 398 402 | 
             
                  out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
         | 
| 399 403 | 
             
                  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\*a\)\s+Hello$/)
         | 
| @@ -401,7 +405,8 @@ if RUBY_VERSION >= '1.9.2' | |
| 401 405 |  | 
| 402 406 | 
             
                it ':block' do
         | 
| 403 407 | 
             
                  class Hello
         | 
| 404 | 
            -
                     | 
| 408 | 
            +
                    # m1(a, *b, &blk)
         | 
| 409 | 
            +
                    def m1(a, b = nil, &blk); end
         | 
| 405 410 | 
             
                  end
         | 
| 406 411 | 
             
                  out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
         | 
| 407 412 | 
             
                  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, &blk\)\s+Hello$/)
         | 
| @@ -431,10 +436,11 @@ RSpec.describe 'Methods arrays' do | |
| 431 436 |  | 
| 432 437 | 
             
                  def self.m2; end
         | 
| 433 438 | 
             
                end
         | 
| 439 | 
            +
             | 
| 434 440 | 
             
                class World
         | 
| 435 441 | 
             
                  def self.m1; end
         | 
| 436 442 | 
             
                end
         | 
| 437 | 
            -
                out = (Hello.methods & World.methods - Class.methods).ai(plain: true)
         | 
| 443 | 
            +
                out = (Hello.methods & (World.methods - Class.methods)).ai(plain: true)
         | 
| 438 444 | 
             
                expect(out).to eq("[\n    [0] m1() Hello\n]")
         | 
| 439 445 | 
             
              end
         | 
| 440 446 |  | 
| @@ -510,3 +516,5 @@ RSpec.describe 'Methods arrays' do | |
| 510 516 | 
             
                end
         | 
| 511 517 | 
             
              end
         | 
| 512 518 | 
             
            end
         | 
| 519 | 
            +
             | 
| 520 | 
            +
            # rubocop:enable Lint/ConstantDefinitionInBlock
         | 
    
        data/spec/misc_spec.rb
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            +
            # rubocop:disable Lint/ConstantDefinitionInBlock, Lint/EmptyClass
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            require 'spec_helper'
         | 
| 4 6 |  | 
| 5 7 | 
             
            RSpec.describe 'AmazingPrint' do
         | 
| @@ -24,7 +26,7 @@ RSpec.describe 'AmazingPrint' do | |
| 24 26 |  | 
| 25 27 | 
             
                # See https://github.com/awesome-print/awesome_print/issues/35
         | 
| 26 28 | 
             
                it 'handle array grep when pattern contains / chapacter' do
         | 
| 27 | 
            -
                  hash = { '1/x' => 1, '2//x' => : | 
| 29 | 
            +
                  hash = { '1/x' => 1, '2//x' => :'2' }
         | 
| 28 30 | 
             
                  grepped = hash.keys.sort.grep(%r{^(\d+)/}) { Regexp.last_match(1) }
         | 
| 29 31 | 
             
                  expect(grepped.ai(plain: true, multiline: false)).to eq('[ "1", "2" ]')
         | 
| 30 32 | 
             
                end
         | 
| @@ -46,7 +48,7 @@ RSpec.describe 'AmazingPrint' do | |
| 46 48 |  | 
| 47 49 | 
             
                # Require different file name this time (lib/ap.rb vs. lib/amazing_print).
         | 
| 48 50 | 
             
                it "several require 'amazing_print' should do no harm" do
         | 
| 49 | 
            -
                  require File.expand_path(File.dirname(__FILE__) | 
| 51 | 
            +
                  require File.expand_path("#{File.dirname(__FILE__)}/../lib/ap")
         | 
| 50 52 | 
             
                  expect { rand.ai }.not_to raise_error
         | 
| 51 53 | 
             
                end
         | 
| 52 54 |  | 
| @@ -127,7 +129,7 @@ RSpec.describe 'AmazingPrint' do | |
| 127 129 | 
             
                end
         | 
| 128 130 |  | 
| 129 131 | 
             
                # See https://github.com/awesome-print/awesome_print/issues/98
         | 
| 130 | 
            -
                it ' | 
| 132 | 
            +
                it 'properlies merge the defaults' do
         | 
| 131 133 | 
             
                  AmazingPrint.defaults = { indent: -2, sort_keys: true }
         | 
| 132 134 | 
             
                  hash = { [0, 0, 255] => :yellow, :red => 'rgb(255, 0, 0)', 'magenta' => 'rgb(255, 0, 255)' }
         | 
| 133 135 | 
             
                  out = hash.ai(plain: true)
         | 
| @@ -187,7 +189,7 @@ RSpec.describe 'AmazingPrint' do | |
| 187 189 |  | 
| 188 190 | 
             
              #------------------------------------------------------------------------------
         | 
| 189 191 | 
             
              describe 'Console' do
         | 
| 190 | 
            -
                it ' | 
| 192 | 
            +
                it 'detects IRB' do
         | 
| 191 193 | 
             
                  class IRB; end
         | 
| 192 194 | 
             
                  ENV.delete('RAILS_ENV')
         | 
| 193 195 | 
             
                  expect(AmazingPrint.console?).to eq(true)
         | 
| @@ -195,7 +197,7 @@ RSpec.describe 'AmazingPrint' do | |
| 195 197 | 
             
                  Object.instance_eval { remove_const :IRB }
         | 
| 196 198 | 
             
                end
         | 
| 197 199 |  | 
| 198 | 
            -
                it ' | 
| 200 | 
            +
                it 'detects Pry' do
         | 
| 199 201 | 
             
                  class Pry; end
         | 
| 200 202 | 
             
                  ENV.delete('RAILS_ENV')
         | 
| 201 203 | 
             
                  expect(AmazingPrint.console?).to eq(true)
         | 
| @@ -203,8 +205,9 @@ RSpec.describe 'AmazingPrint' do | |
| 203 205 | 
             
                  Object.instance_eval { remove_const :Pry }
         | 
| 204 206 | 
             
                end
         | 
| 205 207 |  | 
| 206 | 
            -
                it ' | 
| 208 | 
            +
                it 'detects Rails::Console' do
         | 
| 207 209 | 
             
                  class IRB; end
         | 
| 210 | 
            +
             | 
| 208 211 | 
             
                  module Rails; class Console; end; end
         | 
| 209 212 | 
             
                  expect(AmazingPrint.console?).to eq(true)
         | 
| 210 213 | 
             
                  expect(AmazingPrint.rails_console?).to eq(true)
         | 
| @@ -212,7 +215,7 @@ RSpec.describe 'AmazingPrint' do | |
| 212 215 | 
             
                  Object.instance_eval { remove_const :Rails }
         | 
| 213 216 | 
             
                end
         | 
| 214 217 |  | 
| 215 | 
            -
                it " | 
| 218 | 
            +
                it "detects ENV['RAILS_ENV']" do
         | 
| 216 219 | 
             
                  class Pry; end
         | 
| 217 220 | 
             
                  ENV['RAILS_ENV'] = 'development'
         | 
| 218 221 | 
             
                  expect(AmazingPrint.console?).to eq(true)
         | 
| @@ -220,12 +223,12 @@ RSpec.describe 'AmazingPrint' do | |
| 220 223 | 
             
                  Object.instance_eval { remove_const :Pry }
         | 
| 221 224 | 
             
                end
         | 
| 222 225 |  | 
| 223 | 
            -
                it ' | 
| 226 | 
            +
                it 'returns the actual object when *not* running under console' do
         | 
| 224 227 | 
             
                  expect(capture! { ap([1, 2, 3]) }).to eq([1, 2, 3])
         | 
| 225 228 | 
             
                  expect(capture! { ap({ a: 1 }) }).to eq({ a: 1 })
         | 
| 226 229 | 
             
                end
         | 
| 227 230 |  | 
| 228 | 
            -
                it ' | 
| 231 | 
            +
                it 'returns nil when running under console' do
         | 
| 229 232 | 
             
                  class IRB; end
         | 
| 230 233 | 
             
                  expect(capture! { ap([1, 2, 3]) }).to eq(nil)
         | 
| 231 234 | 
             
                  expect(capture! { ap({ a: 1 }) }).to eq(nil)
         | 
| @@ -240,8 +243,10 @@ RSpec.describe 'AmazingPrint' do | |
| 240 243 | 
             
                  irb.instance_eval { @context = irb_context }
         | 
| 241 244 | 
             
                  AmazingPrint.irb!
         | 
| 242 245 | 
             
                  expect(irb).to receive(:puts).with("(Object doesn't support #ai)")
         | 
| 243 | 
            -
                  expect { irb.output_value }. | 
| 246 | 
            +
                  expect { irb.output_value }.not_to raise_error
         | 
| 244 247 | 
             
                  Object.instance_eval { remove_const :IRB }
         | 
| 245 248 | 
             
                end
         | 
| 246 249 | 
             
              end
         | 
| 247 250 | 
             
            end
         | 
| 251 | 
            +
             | 
| 252 | 
            +
            # rubocop:enable Lint/ConstantDefinitionInBlock, Lint/EmptyClass
         | 
    
        data/spec/objects_spec.rb
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            +
            # rubocop:disable Lint/ConstantDefinitionInBlock
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            require 'spec_helper'
         | 
| 4 6 |  | 
| 5 7 | 
             
            RSpec.describe 'Objects' do
         | 
| @@ -219,3 +221,5 @@ RSpec.describe 'Objects' do | |
| 219 221 | 
             
                end
         | 
| 220 222 | 
             
              end
         | 
| 221 223 | 
             
            end
         | 
| 224 | 
            +
             | 
| 225 | 
            +
            # rubocop:enable Lint/ConstantDefinitionInBlock
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -23,7 +23,7 @@ | |
| 23 23 | 
             
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         | 
| 24 24 | 
             
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         | 
| 25 25 |  | 
| 26 | 
            -
            Dir[File.dirname(__FILE__) | 
| 26 | 
            +
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each do |file|
         | 
| 27 27 | 
             
              require file
         | 
| 28 28 | 
             
            end
         | 
| 29 29 |  | 
| @@ -63,7 +63,7 @@ RSpec.configure do |config| | |
| 63 63 |  | 
| 64 64 | 
             
              # Run before all examples. Using suite or all will not work as stubs are
         | 
| 65 65 | 
             
              # killed after each example ends.
         | 
| 66 | 
            -
              config.before | 
| 66 | 
            +
              config.before do |_example|
         | 
| 67 67 | 
             
                stub_dotfile!
         | 
| 68 68 | 
             
              end
         | 
| 69 69 | 
             
            end
         | 
| @@ -86,12 +86,8 @@ end | |
| 86 86 | 
             
            # that an ID is present and not that it matches a certain value. This is
         | 
| 87 87 | 
             
            # necessary as the Object IDs are not deterministic.
         | 
| 88 88 | 
             
            def normalize_object_id_strings(str, options)
         | 
| 89 | 
            -
              unless options[:skip_standard]
         | 
| 90 | 
            -
             | 
| 91 | 
            -
              end
         | 
| 92 | 
            -
              unless options[:skip_bson]
         | 
| 93 | 
            -
                str = str.gsub(/BSON::ObjectId\('[a-f\d]{24}'\)/, 'placeholder_bson_id')
         | 
| 94 | 
            -
              end
         | 
| 89 | 
            +
              str = str.gsub(/#<(.*?):0x[a-f\d]+/, '#<\1:placeholder_id') unless options[:skip_standard]
         | 
| 90 | 
            +
              str = str.gsub(/BSON::ObjectId\('[a-f\d]{24}'\)/, 'placeholder_bson_id') unless options[:skip_bson]
         | 
| 95 91 | 
             
              str
         | 
| 96 92 | 
             
            end
         | 
| 97 93 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: amazing_print
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Michael Dvorkin
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire:
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2021- | 
| 12 | 
            +
            date: 2021-10-06 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: appraisal
         | 
| @@ -87,14 +87,28 @@ dependencies: | |
| 87 87 | 
             
                requirements:
         | 
| 88 88 | 
             
                - - "~>"
         | 
| 89 89 | 
             
                  - !ruby/object:Gem::Version
         | 
| 90 | 
            -
                    version:  | 
| 90 | 
            +
                    version: '1.20'
         | 
| 91 91 | 
             
              type: :development
         | 
| 92 92 | 
             
              prerelease: false
         | 
| 93 93 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 94 94 | 
             
                requirements:
         | 
| 95 95 | 
             
                - - "~>"
         | 
| 96 96 | 
             
                  - !ruby/object:Gem::Version
         | 
| 97 | 
            -
                    version:  | 
| 97 | 
            +
                    version: '1.20'
         | 
| 98 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 99 | 
            +
              name: rubocop-rspec
         | 
| 100 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 101 | 
            +
                requirements:
         | 
| 102 | 
            +
                - - "~>"
         | 
| 103 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 104 | 
            +
                    version: '2.4'
         | 
| 105 | 
            +
              type: :development
         | 
| 106 | 
            +
              prerelease: false
         | 
| 107 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 108 | 
            +
                requirements:
         | 
| 109 | 
            +
                - - "~>"
         | 
| 110 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 111 | 
            +
                    version: '2.4'
         | 
| 98 112 | 
             
            description: 'Great Ruby debugging companion: pretty print Ruby objects to visualize
         | 
| 99 113 | 
             
              their structure. Supports custom object formatting via plugins'
         | 
| 100 114 | 
             
            email: harlemsquirrel@gmail.com
         | 
| @@ -213,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 213 227 | 
             
                - !ruby/object:Gem::Version
         | 
| 214 228 | 
             
                  version: '0'
         | 
| 215 229 | 
             
            requirements: []
         | 
| 216 | 
            -
            rubygems_version: 3.2. | 
| 230 | 
            +
            rubygems_version: 3.2.22
         | 
| 217 231 | 
             
            signing_key:
         | 
| 218 232 | 
             
            specification_version: 4
         | 
| 219 233 | 
             
            summary: Pretty print Ruby objects with proper indentation and colors
         |