amazing_print 1.4.0 → 1.5.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/CHANGELOG.md +6 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +43 -37
- data/README.md +1 -2
- data/lib/amazing_print/colorize.rb +5 -12
- data/lib/amazing_print/colors.rb +37 -0
- data/lib/amazing_print/formatters/array_formatter.rb +1 -1
- data/lib/amazing_print/formatters/dir_formatter.rb +10 -1
- data/lib/amazing_print/formatters/file_formatter.rb +10 -1
- data/lib/amazing_print/formatters/hash_formatter.rb +2 -1
- data/lib/amazing_print/formatters/mswin_helper.rb +63 -0
- data/lib/amazing_print/inspector.rb +1 -1
- data/lib/amazing_print/version.rb +1 -1
- data/lib/amazing_print.rb +1 -1
- data/spec/colors_spec.rb +9 -4
- data/spec/ext/action_controller_spec.rb +3 -3
- data/spec/ext/active_record_spec.rb +24 -58
- data/spec/ext/nokogiri_spec.rb +4 -4
- data/spec/ext/sequel_spec.rb +1 -1
- data/spec/formats_spec.rb +82 -77
- data/spec/misc_spec.rb +14 -60
- data/spec/spec_helper.rb +7 -1
- metadata +10 -156
- data/lib/amazing_print/core_ext/string.rb +0 -45
- data/spec/core_ext/string_spec.rb +0 -15
    
        data/spec/formats_spec.rb
    CHANGED
    
    | @@ -93,7 +93,7 @@ RSpec.describe 'AmazingPrint' do | |
| 93 93 | 
             
                    [
         | 
| 94 94 | 
             
                        \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
         | 
| 95 95 | 
             
                        \e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
         | 
| 96 | 
            -
                        \e[1;37m[2] \e[0m\e[0;33m | 
| 96 | 
            +
                        \e[1;37m[2] \e[0m\e[0;33m"three"\e[0m,
         | 
| 97 97 | 
             
                        \e[1;37m[3] \e[0m[
         | 
| 98 98 | 
             
                            \e[1;37m[0] \e[0m\e[1;31mnil\e[0m,
         | 
| 99 99 | 
             
                            \e[1;37m[1] \e[0m[
         | 
| @@ -110,7 +110,7 @@ RSpec.describe 'AmazingPrint' do | |
| 110 110 | 
             
                    [
         | 
| 111 111 | 
             
                            \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
         | 
| 112 112 | 
             
                            \e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
         | 
| 113 | 
            -
                            \e[1;37m[2] \e[0m\e[0;33m | 
| 113 | 
            +
                            \e[1;37m[2] \e[0m\e[0;33m"three"\e[0m,
         | 
| 114 114 | 
             
                            \e[1;37m[3] \e[0m[
         | 
| 115 115 | 
             
                                    \e[1;37m[0] \e[0m\e[1;31mnil\e[0m,
         | 
| 116 116 | 
             
                                    \e[1;37m[1] \e[0m[
         | 
| @@ -316,7 +316,7 @@ RSpec.describe 'AmazingPrint' do | |
| 316 316 | 
             
                    {
         | 
| 317 317 | 
             
                        1\e[0;37m => \e[0m{
         | 
| 318 318 | 
             
                            :sym\e[0;37m => \e[0m{
         | 
| 319 | 
            -
                                 | 
| 319 | 
            +
                                "str"\e[0;37m => \e[0m{
         | 
| 320 320 | 
             
                                    [ 1, 2, 3 ]\e[0;37m => \e[0m{
         | 
| 321 321 | 
             
                                        { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
         | 
| 322 322 | 
             
                                    }
         | 
| @@ -331,8 +331,8 @@ RSpec.describe 'AmazingPrint' do | |
| 331 331 | 
             
                  expect(@hash.ai(ruby19_syntax: true)).to eq <<~EOS.strip
         | 
| 332 332 | 
             
                    {
         | 
| 333 333 | 
             
                        1\e[0;37m => \e[0m{
         | 
| 334 | 
            -
                            sym | 
| 335 | 
            -
                                 | 
| 334 | 
            +
                            sym: {
         | 
| 335 | 
            +
                                "str"\e[0;37m => \e[0m{
         | 
| 336 336 | 
             
                                    [ 1, 2, 3 ]\e[0;37m => \e[0m{
         | 
| 337 337 | 
             
                                        { k: :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
         | 
| 338 338 | 
             
                                    }
         | 
| @@ -348,7 +348,7 @@ RSpec.describe 'AmazingPrint' do | |
| 348 348 | 
             
                    {
         | 
| 349 349 | 
             
                      1\e[0;37m => \e[0m{
         | 
| 350 350 | 
             
                        :sym\e[0;37m => \e[0m{
         | 
| 351 | 
            -
                           | 
| 351 | 
            +
                          "str"\e[0;37m => \e[0m{
         | 
| 352 352 | 
             
                            [ 1, 2, 3 ]\e[0;37m => \e[0m{
         | 
| 353 353 | 
             
                              { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m
         | 
| 354 354 | 
             
                            }
         | 
| @@ -392,22 +392,14 @@ RSpec.describe 'AmazingPrint' do | |
| 392 392 |  | 
| 393 393 | 
             
                it 'plain multiline' do
         | 
| 394 394 | 
             
                  out = @hash.ai(plain: true)
         | 
| 395 | 
            -
                   | 
| 396 | 
            -
                     | 
| 397 | 
            -
             | 
| 398 | 
            -
             | 
| 399 | 
            -
             | 
| 400 | 
            -
             | 
| 401 | 
            -
             | 
| 402 | 
            -
             | 
| 403 | 
            -
                      {
         | 
| 404 | 
            -
                              "b" => "b",
         | 
| 405 | 
            -
                               :a => "a",
         | 
| 406 | 
            -
                               :z => "z",
         | 
| 407 | 
            -
                          "alpha" => "alpha"
         | 
| 408 | 
            -
                      }
         | 
| 409 | 
            -
                    EOS
         | 
| 410 | 
            -
                  end
         | 
| 395 | 
            +
                  expect(out).to eq <<~EOS.strip
         | 
| 396 | 
            +
                    {
         | 
| 397 | 
            +
                            "b" => "b",
         | 
| 398 | 
            +
                             :a => "a",
         | 
| 399 | 
            +
                             :z => "z",
         | 
| 400 | 
            +
                        "alpha" => "alpha"
         | 
| 401 | 
            +
                    }
         | 
| 402 | 
            +
                  EOS
         | 
| 411 403 | 
             
                end
         | 
| 412 404 |  | 
| 413 405 | 
             
                it 'plain multiline with sorted keys' do
         | 
| @@ -479,6 +471,21 @@ RSpec.describe 'AmazingPrint' do | |
| 479 471 | 
             
                end
         | 
| 480 472 | 
             
              end
         | 
| 481 473 |  | 
| 474 | 
            +
              #
         | 
| 475 | 
            +
              # With Ruby 1.9 syntax
         | 
| 476 | 
            +
              #
         | 
| 477 | 
            +
              it 'hash keys must be left aligned' do
         | 
| 478 | 
            +
                hash = { [0, 0, 255] => :yellow, :bloodiest_red => 'rgb(255, 0, 0)', 'magenta' => 'rgb(255, 0, 255)' }
         | 
| 479 | 
            +
                out = hash.ai(plain: true, indent: -2, ruby19_syntax: true, sort_keys: true)
         | 
| 480 | 
            +
                expect(out).to eq <<~EOS.strip
         | 
| 481 | 
            +
                  {
         | 
| 482 | 
            +
                    [ 0, 0, 255 ]  => :yellow,
         | 
| 483 | 
            +
                    bloodiest_red: "rgb(255, 0, 0)",
         | 
| 484 | 
            +
                    "magenta"      => "rgb(255, 0, 255)"
         | 
| 485 | 
            +
                  }
         | 
| 486 | 
            +
                EOS
         | 
| 487 | 
            +
              end
         | 
| 488 | 
            +
             | 
| 482 489 | 
             
              #------------------------------------------------------------------------------
         | 
| 483 490 | 
             
              describe 'Class' do
         | 
| 484 491 | 
             
                it 'shows superclass (plain)' do
         | 
| @@ -486,26 +493,38 @@ RSpec.describe 'AmazingPrint' do | |
| 486 493 | 
             
                end
         | 
| 487 494 |  | 
| 488 495 | 
             
                it 'shows superclass (color)' do
         | 
| 489 | 
            -
                  expect(self.class.ai).to eq("#{self.class} < #{self.class.superclass}" | 
| 496 | 
            +
                  expect(self.class.ai).to eq(AmazingPrint::Colors.yellow("#{self.class} < #{self.class.superclass}"))
         | 
| 490 497 | 
             
                end
         | 
| 491 498 | 
             
              end
         | 
| 492 499 |  | 
| 493 500 | 
             
              #------------------------------------------------------------------------------
         | 
| 494 501 | 
             
              describe 'File' do
         | 
| 495 | 
            -
                it 'displays a file (plain)' do
         | 
| 502 | 
            +
                it 'displays a file (plain)', unix: true do
         | 
| 496 503 | 
             
                  File.open(__FILE__, 'r') do |f|
         | 
| 497 504 | 
             
                    expect(f.ai(plain: true)).to eq("#{f.inspect}\n" + `ls -alF #{f.path}`.chop)
         | 
| 498 505 | 
             
                  end
         | 
| 499 506 | 
             
                end
         | 
| 507 | 
            +
             | 
| 508 | 
            +
                it 'displays a file (plain) akin to powershell Get-ChildItem', mswin: true do
         | 
| 509 | 
            +
                  File.open(__FILE__, 'r') do |f|
         | 
| 510 | 
            +
                    expect(f.ai(plain: true)).to eq("#{f.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(f.path).to_s)
         | 
| 511 | 
            +
                  end
         | 
| 512 | 
            +
                end
         | 
| 500 513 | 
             
              end
         | 
| 501 514 |  | 
| 502 515 | 
             
              #------------------------------------------------------------------------------
         | 
| 503 516 | 
             
              describe 'Dir' do
         | 
| 504 | 
            -
                it 'displays a direcory (plain)' do
         | 
| 517 | 
            +
                it 'displays a direcory (plain)', unix: true do
         | 
| 505 518 | 
             
                  Dir.open(File.dirname(__FILE__)) do |d|
         | 
| 506 519 | 
             
                    expect(d.ai(plain: true)).to eq("#{d.inspect}\n" + `ls -alF #{d.path}`.chop)
         | 
| 507 520 | 
             
                  end
         | 
| 508 521 | 
             
                end
         | 
| 522 | 
            +
             | 
| 523 | 
            +
                it 'displays a directory (plain) akin to powershell Get-ChildItem', mswin: true do
         | 
| 524 | 
            +
                  Dir.open(File.dirname(__FILE__)) do |d|
         | 
| 525 | 
            +
                    expect(d.ai(plain: true)).to eq("#{d.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(d.path).to_s)
         | 
| 526 | 
            +
                  end
         | 
| 527 | 
            +
                end
         | 
| 509 528 | 
             
              end
         | 
| 510 529 |  | 
| 511 530 | 
             
              #------------------------------------------------------------------------------
         | 
| @@ -518,16 +537,7 @@ RSpec.describe 'AmazingPrint' do | |
| 518 537 | 
             
                it 'presents Rational object with arbitrary precision' do
         | 
| 519 538 | 
             
                  rat = Rational(201_020_102_010_201_020_102_010_201_020_102_010, 2)
         | 
| 520 539 | 
             
                  out = rat.ai(plain: true)
         | 
| 521 | 
            -
                   | 
| 522 | 
            -
                  # Ruby 1.9 slightly changed the format of Rational#to_s, see
         | 
| 523 | 
            -
                  # http://techtime.getharvest.com/blog/harvest-is-now-on-ruby-1-dot-9-3 and
         | 
| 524 | 
            -
                  # http://www.ruby-forum.com/topic/189397
         | 
| 525 | 
            -
                  #
         | 
| 526 | 
            -
                  if RUBY_VERSION < '1.9'
         | 
| 527 | 
            -
                    expect(out).to eq('100510051005100510051005100510051005')
         | 
| 528 | 
            -
                  else
         | 
| 529 | 
            -
                    expect(out).to eq('100510051005100510051005100510051005/1')
         | 
| 530 | 
            -
                  end
         | 
| 540 | 
            +
                  expect(out).to eq('100510051005100510051005100510051005/1')
         | 
| 531 541 | 
             
                end
         | 
| 532 542 | 
             
              end
         | 
| 533 543 |  | 
| @@ -553,39 +563,20 @@ RSpec.describe 'AmazingPrint' do | |
| 553 563 | 
             
                  expect(Set.new.ai).to eq([].ai)
         | 
| 554 564 | 
             
                end
         | 
| 555 565 |  | 
| 556 | 
            -
                 | 
| 557 | 
            -
                   | 
| 558 | 
            -
             | 
| 559 | 
            -
                  end
         | 
| 560 | 
            -
             | 
| 561 | 
            -
                  it 'plain multiline indented' do
         | 
| 562 | 
            -
                    expect(@set.ai(plain: true, indent: 1)).to eq(@arr.ai(plain: true, indent: 1))
         | 
| 563 | 
            -
                  end
         | 
| 564 | 
            -
             | 
| 565 | 
            -
                  it 'plain single line' do
         | 
| 566 | 
            -
                    expect(@set.ai(plain: true, multiline: false)).to eq(@arr.ai(plain: true, multiline: false))
         | 
| 567 | 
            -
                  end
         | 
| 568 | 
            -
             | 
| 569 | 
            -
                  it 'colored multiline (default)' do
         | 
| 570 | 
            -
                    expect(@set.ai).to eq(@arr.ai)
         | 
| 571 | 
            -
                  end
         | 
| 572 | 
            -
                else # Prior to Ruby 1.9 the order of set values is unpredicatble.
         | 
| 573 | 
            -
                  it 'plain multiline' do
         | 
| 574 | 
            -
                    expect(@set.sort_by(&:to_s).ai(plain: true)).to eq(@arr.sort_by(&:to_s).ai(plain: true))
         | 
| 575 | 
            -
                  end
         | 
| 566 | 
            +
                it 'plain multiline' do
         | 
| 567 | 
            +
                  expect(@set.ai(plain: true)).to eq(@arr.ai(plain: true))
         | 
| 568 | 
            +
                end
         | 
| 576 569 |  | 
| 577 | 
            -
             | 
| 578 | 
            -
             | 
| 579 | 
            -
             | 
| 570 | 
            +
                it 'plain multiline indented' do
         | 
| 571 | 
            +
                  expect(@set.ai(plain: true, indent: 1)).to eq(@arr.ai(plain: true, indent: 1))
         | 
| 572 | 
            +
                end
         | 
| 580 573 |  | 
| 581 | 
            -
             | 
| 582 | 
            -
             | 
| 583 | 
            -
             | 
| 584 | 
            -
                  end
         | 
| 574 | 
            +
                it 'plain single line' do
         | 
| 575 | 
            +
                  expect(@set.ai(plain: true, multiline: false)).to eq(@arr.ai(plain: true, multiline: false))
         | 
| 576 | 
            +
                end
         | 
| 585 577 |  | 
| 586 | 
            -
             | 
| 587 | 
            -
             | 
| 588 | 
            -
                  end
         | 
| 578 | 
            +
                it 'colored multiline (default)' do
         | 
| 579 | 
            +
                  expect(@set.ai).to eq(@arr.ai)
         | 
| 589 580 | 
             
                end
         | 
| 590 581 | 
             
              end
         | 
| 591 582 |  | 
| @@ -607,12 +598,12 @@ RSpec.describe 'AmazingPrint' do | |
| 607 598 |  | 
| 608 599 | 
             
                it 'plain multiline' do
         | 
| 609 600 | 
             
                  s1 = <<-EOS.strip
         | 
| 610 | 
            -
                address =  | 
| 611 | 
            -
                name =  | 
| 601 | 
            +
                address = "1313 Mockingbird Lane",
         | 
| 602 | 
            +
                name = "Herman Munster"
         | 
| 612 603 | 
             
                  EOS
         | 
| 613 604 | 
             
                  s2 = <<-EOS.strip
         | 
| 614 | 
            -
                name =  | 
| 615 | 
            -
                address =  | 
| 605 | 
            +
                name = "Herman Munster",
         | 
| 606 | 
            +
                address = "1313 Mockingbird Lane"
         | 
| 616 607 | 
             
                  EOS
         | 
| 617 608 | 
             
                  expect(@struct.ai(plain: true)).to satisfy { |out| out.match(s1) || out.match(s2) }
         | 
| 618 609 | 
             
                end
         | 
| @@ -637,12 +628,12 @@ RSpec.describe 'AmazingPrint' do | |
| 637 628 |  | 
| 638 629 | 
             
                it 'colored multiline (default)' do
         | 
| 639 630 | 
             
                  s1 = <<-EOS.strip
         | 
| 640 | 
            -
                address\e[0;37m = \e[0m\e[0;33m | 
| 641 | 
            -
                name\e[0;37m = \e[0m\e[0;33m | 
| 631 | 
            +
                address\e[0;37m = \e[0m\e[0;33m"1313 Mockingbird Lane"\e[0m,
         | 
| 632 | 
            +
                name\e[0;37m = \e[0m\e[0;33m"Herman Munster"\e[0m
         | 
| 642 633 | 
             
                  EOS
         | 
| 643 634 | 
             
                  s2 = <<-EOS.strip
         | 
| 644 | 
            -
                name\e[0;37m = \e[0m\e[0;33m | 
| 645 | 
            -
                address\e[0;37m = \e[0m\e[0;33m | 
| 635 | 
            +
                name\e[0;37m = \e[0m\e[0;33m"Herman Munster"\e[0m,
         | 
| 636 | 
            +
                address\e[0;37m = \e[0m\e[0;33m"1313 Mockingbird Lane"\e[0m
         | 
| 646 637 | 
             
                  EOS
         | 
| 647 638 | 
             
                  expect(@struct.ai).to satisfy { |out| out.include?(s1) || out.include?(s2) }
         | 
| 648 639 | 
             
                end
         | 
| @@ -693,7 +684,7 @@ RSpec.describe 'AmazingPrint' do | |
| 693 684 | 
             
                  EOS
         | 
| 694 685 | 
             
                end
         | 
| 695 686 |  | 
| 696 | 
            -
                it 'inherited from File should be displayed as File' do
         | 
| 687 | 
            +
                it 'inherited from File should be displayed as File', unix: true do
         | 
| 697 688 | 
             
                  class My < File; end
         | 
| 698 689 |  | 
| 699 690 | 
             
                  my = begin
         | 
| @@ -704,7 +695,13 @@ RSpec.describe 'AmazingPrint' do | |
| 704 695 | 
             
                  expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + `ls -alF #{my.path}`.chop)
         | 
| 705 696 | 
             
                end
         | 
| 706 697 |  | 
| 707 | 
            -
                it 'inherited from  | 
| 698 | 
            +
                it 'inherited from File should be displayed as File', mswin: true do
         | 
| 699 | 
            +
                  class My < File; end
         | 
| 700 | 
            +
                  my = My.new('nul') # it's /dev/null in Windows
         | 
| 701 | 
            +
                  expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(my.path).to_s)
         | 
| 702 | 
            +
                end
         | 
| 703 | 
            +
             | 
| 704 | 
            +
                it 'inherited from Dir should be displayed as Dir', unix: true do
         | 
| 708 705 | 
             
                  class My < Dir; end
         | 
| 709 706 |  | 
| 710 707 | 
             
                  require 'tmpdir'
         | 
| @@ -712,6 +709,14 @@ RSpec.describe 'AmazingPrint' do | |
| 712 709 | 
             
                  expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + `ls -alF #{my.path}`.chop)
         | 
| 713 710 | 
             
                end
         | 
| 714 711 |  | 
| 712 | 
            +
                it 'inherited from Dir are displayed as Dir', mswin: true do
         | 
| 713 | 
            +
                  class My < Dir; end
         | 
| 714 | 
            +
             | 
| 715 | 
            +
                  require 'tmpdir'
         | 
| 716 | 
            +
                  my = My.new(Dir.tmpdir)
         | 
| 717 | 
            +
                  expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(my.path).to_s)
         | 
| 718 | 
            +
                end
         | 
| 719 | 
            +
             | 
| 715 720 | 
             
                it 'handles a class that defines its own #send method' do
         | 
| 716 721 | 
             
                  class My
         | 
| 717 722 | 
             
                    def send(arg1, arg2, arg3); end
         | 
| @@ -757,7 +762,7 @@ RSpec.describe 'AmazingPrint' do | |
| 757 762 | 
             
                    class My
         | 
| 758 763 | 
             
                      def to_hash
         | 
| 759 764 | 
             
                        object = Object.new
         | 
| 760 | 
            -
                        object.define_singleton_method('[]') {  | 
| 765 | 
            +
                        object.define_singleton_method('[]') { nil }
         | 
| 761 766 |  | 
| 762 767 | 
             
                        object
         | 
| 763 768 | 
             
                      end
         | 
| @@ -771,7 +776,7 @@ RSpec.describe 'AmazingPrint' do | |
| 771 776 | 
             
                    class My
         | 
| 772 777 | 
             
                      def to_hash
         | 
| 773 778 | 
             
                        object = Object.new
         | 
| 774 | 
            -
                        object.define_singleton_method(:keys) {  | 
| 779 | 
            +
                        object.define_singleton_method(:keys) { [:foo] }
         | 
| 775 780 |  | 
| 776 781 | 
             
                        object
         | 
| 777 782 | 
             
                      end
         | 
    
        data/spec/misc_spec.rb
    CHANGED
    
    | @@ -32,12 +32,10 @@ RSpec.describe 'AmazingPrint' do | |
| 32 32 | 
             
                end
         | 
| 33 33 |  | 
| 34 34 | 
             
                # See https://github.com/awesome-print/awesome_print/issues/85
         | 
| 35 | 
            -
                 | 
| 36 | 
            -
                   | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
                    expect(grepped.ai(plain: true, multiline: false)).to eq('[ 2, 3, 4, 5 ]')
         | 
| 40 | 
            -
                  end
         | 
| 35 | 
            +
                it "handle array grep when a method is defined in C and thus doesn't have a binding" do
         | 
| 36 | 
            +
                  arr = (0..6).to_a
         | 
| 37 | 
            +
                  grepped = arr.grep(1..4, &:succ)
         | 
| 38 | 
            +
                  expect(grepped.ai(plain: true, multiline: false)).to eq('[ 2, 3, 4, 5 ]')
         | 
| 41 39 | 
             
                end
         | 
| 42 40 |  | 
| 43 41 | 
             
                it 'returns value passed as a parameter' do
         | 
| @@ -143,65 +141,21 @@ RSpec.describe 'AmazingPrint' do | |
| 143 141 | 
             
                end
         | 
| 144 142 | 
             
              end
         | 
| 145 143 |  | 
| 146 | 
            -
              #------------------------------------------------------------------------------
         | 
| 147 | 
            -
              describe 'Coexistence with the colorize gem' do
         | 
| 148 | 
            -
                before do # Redefine String#red just like colorize gem does it.
         | 
| 149 | 
            -
                  @awesome_method = ''.method(:red)
         | 
| 150 | 
            -
             | 
| 151 | 
            -
                  String.instance_eval do
         | 
| 152 | 
            -
                    define_method :red do # Method arity is now 0 in Ruby 1.9+.
         | 
| 153 | 
            -
                      "[red]#{self}[/red]"
         | 
| 154 | 
            -
                    end
         | 
| 155 | 
            -
                  end
         | 
| 156 | 
            -
                end
         | 
| 157 | 
            -
             | 
| 158 | 
            -
                after do # Restore String#red method.
         | 
| 159 | 
            -
                  awesome_method = @awesome_method
         | 
| 160 | 
            -
                  String.instance_eval do
         | 
| 161 | 
            -
                    define_method :red, awesome_method
         | 
| 162 | 
            -
                  end
         | 
| 163 | 
            -
                end
         | 
| 164 | 
            -
             | 
| 165 | 
            -
                it 'shoud not raise ArgumentError when formatting HTML' do
         | 
| 166 | 
            -
                  out = 'hello'.ai(color: { string: :red }, html: true)
         | 
| 167 | 
            -
                  if RUBY_VERSION >= '1.9'
         | 
| 168 | 
            -
                    expect(out).to eq(%(<pre>[red]<kbd style="color:red">"hello"</kbd>[/red]</pre>))
         | 
| 169 | 
            -
                  else
         | 
| 170 | 
            -
                    expect(out).to eq(%(<pre>[red]"hello"[/red]</pre>))
         | 
| 171 | 
            -
                  end
         | 
| 172 | 
            -
                end
         | 
| 173 | 
            -
             | 
| 174 | 
            -
                it 'shoud not raise ArgumentError when formatting HTML (shade color)' do
         | 
| 175 | 
            -
                  out = 'hello'.ai(color: { string: :redish }, html: true)
         | 
| 176 | 
            -
                  expect(out).to eq(%(<pre><kbd style="color:darkred">"hello"</kbd></pre>))
         | 
| 177 | 
            -
                end
         | 
| 178 | 
            -
             | 
| 179 | 
            -
                it 'shoud not raise ArgumentError when formatting non-HTML' do
         | 
| 180 | 
            -
                  out = 'hello'.ai(color: { string: :red }, html: false)
         | 
| 181 | 
            -
                  expect(out).to eq(%([red]"hello"[/red]))
         | 
| 182 | 
            -
                end
         | 
| 183 | 
            -
             | 
| 184 | 
            -
                it 'shoud not raise ArgumentError when formatting non-HTML (shade color)' do
         | 
| 185 | 
            -
                  out = 'hello'.ai(color: { string: :redish }, html: false)
         | 
| 186 | 
            -
                  expect(out).to eq(%(\e[0;31m"hello"\e[0m))
         | 
| 187 | 
            -
                end
         | 
| 188 | 
            -
              end
         | 
| 189 | 
            -
             | 
| 190 144 | 
             
              #------------------------------------------------------------------------------
         | 
| 191 145 | 
             
              describe 'Console' do
         | 
| 192 146 | 
             
                it 'detects IRB' do
         | 
| 193 147 | 
             
                  class IRB; end
         | 
| 194 148 | 
             
                  ENV.delete('RAILS_ENV')
         | 
| 195 | 
            -
                  expect(AmazingPrint.console?).to  | 
| 196 | 
            -
                  expect(AmazingPrint.rails_console?).to  | 
| 149 | 
            +
                  expect(AmazingPrint.console?).to be(true)
         | 
| 150 | 
            +
                  expect(AmazingPrint.rails_console?).to be(false)
         | 
| 197 151 | 
             
                  Object.instance_eval { remove_const :IRB }
         | 
| 198 152 | 
             
                end
         | 
| 199 153 |  | 
| 200 154 | 
             
                it 'detects Pry' do
         | 
| 201 155 | 
             
                  class Pry; end
         | 
| 202 156 | 
             
                  ENV.delete('RAILS_ENV')
         | 
| 203 | 
            -
                  expect(AmazingPrint.console?).to  | 
| 204 | 
            -
                  expect(AmazingPrint.rails_console?).to  | 
| 157 | 
            +
                  expect(AmazingPrint.console?).to be(true)
         | 
| 158 | 
            +
                  expect(AmazingPrint.rails_console?).to be(false)
         | 
| 205 159 | 
             
                  Object.instance_eval { remove_const :Pry }
         | 
| 206 160 | 
             
                end
         | 
| 207 161 |  | 
| @@ -209,8 +163,8 @@ RSpec.describe 'AmazingPrint' do | |
| 209 163 | 
             
                  class IRB; end
         | 
| 210 164 |  | 
| 211 165 | 
             
                  module Rails; class Console; end; end
         | 
| 212 | 
            -
                  expect(AmazingPrint.console?).to  | 
| 213 | 
            -
                  expect(AmazingPrint.rails_console?).to  | 
| 166 | 
            +
                  expect(AmazingPrint.console?).to be(true)
         | 
| 167 | 
            +
                  expect(AmazingPrint.rails_console?).to be(true)
         | 
| 214 168 | 
             
                  Object.instance_eval { remove_const :IRB }
         | 
| 215 169 | 
             
                  Object.instance_eval { remove_const :Rails }
         | 
| 216 170 | 
             
                end
         | 
| @@ -218,8 +172,8 @@ RSpec.describe 'AmazingPrint' do | |
| 218 172 | 
             
                it "detects ENV['RAILS_ENV']" do
         | 
| 219 173 | 
             
                  class Pry; end
         | 
| 220 174 | 
             
                  ENV['RAILS_ENV'] = 'development'
         | 
| 221 | 
            -
                  expect(AmazingPrint.console?).to  | 
| 222 | 
            -
                  expect(AmazingPrint.rails_console?).to  | 
| 175 | 
            +
                  expect(AmazingPrint.console?).to be(true)
         | 
| 176 | 
            +
                  expect(AmazingPrint.rails_console?).to be(true)
         | 
| 223 177 | 
             
                  Object.instance_eval { remove_const :Pry }
         | 
| 224 178 | 
             
                end
         | 
| 225 179 |  | 
| @@ -230,8 +184,8 @@ RSpec.describe 'AmazingPrint' do | |
| 230 184 |  | 
| 231 185 | 
             
                it 'returns nil when running under console' do
         | 
| 232 186 | 
             
                  class IRB; end
         | 
| 233 | 
            -
                  expect(capture! { ap([1, 2, 3]) }).to  | 
| 234 | 
            -
                  expect(capture! { ap({ a: 1 }) }).to  | 
| 187 | 
            +
                  expect(capture! { ap([1, 2, 3]) }).to be_nil
         | 
| 188 | 
            +
                  expect(capture! { ap({ a: 1 }) }).to be_nil
         | 
| 235 189 | 
             
                  Object.instance_eval { remove_const :IRB }
         | 
| 236 190 | 
             
                end
         | 
| 237 191 |  | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -41,7 +41,7 @@ ExtVerifier.require_dependencies!( | |
| 41 41 | 
             
                sequel
         | 
| 42 42 | 
             
              ]
         | 
| 43 43 | 
             
            )
         | 
| 44 | 
            -
            require 'nokogiri'
         | 
| 44 | 
            +
            require 'nokogiri' unless RUBY_PLATFORM.include?('mswin')
         | 
| 45 45 | 
             
            require 'amazing_print'
         | 
| 46 46 |  | 
| 47 47 | 
             
            RSpec.configure do |config|
         | 
| @@ -66,6 +66,12 @@ RSpec.configure do |config| | |
| 66 66 | 
             
              config.before do |_example|
         | 
| 67 67 | 
             
                stub_dotfile!
         | 
| 68 68 | 
             
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              if RUBY_PLATFORM.include?('mswin')
         | 
| 71 | 
            +
                config.filter_run_excluding unix: true
         | 
| 72 | 
            +
              else
         | 
| 73 | 
            +
                config.filter_run_excluding mswin: true
         | 
| 74 | 
            +
              end
         | 
| 69 75 | 
             
            end
         | 
| 70 76 |  | 
| 71 77 | 
             
            # This matcher handles the normalization of objects to replace non deterministic
         | 
    
        metadata
    CHANGED
    
    | @@ -1,114 +1,16 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: amazing_print
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.5.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Michael Dvorkin
         | 
| 8 8 | 
             
            - Kevin McCormackPatrik Wenger
         | 
| 9 | 
            -
            autorequire:
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 13 | 
            -
            dependencies:
         | 
| 14 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            -
              name: appraisal
         | 
| 16 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            -
                requirements:
         | 
| 18 | 
            -
                - - "~>"
         | 
| 19 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 20 | 
            -
                    version: '2.3'
         | 
| 21 | 
            -
              type: :development
         | 
| 22 | 
            -
              prerelease: false
         | 
| 23 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 24 | 
            -
                requirements:
         | 
| 25 | 
            -
                - - "~>"
         | 
| 26 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 27 | 
            -
                    version: '2.3'
         | 
| 28 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 29 | 
            -
              name: fakefs
         | 
| 30 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 31 | 
            -
                requirements:
         | 
| 32 | 
            -
                - - "~>"
         | 
| 33 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 34 | 
            -
                    version: '1.2'
         | 
| 35 | 
            -
              type: :development
         | 
| 36 | 
            -
              prerelease: false
         | 
| 37 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 38 | 
            -
                requirements:
         | 
| 39 | 
            -
                - - "~>"
         | 
| 40 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 41 | 
            -
                    version: '1.2'
         | 
| 42 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 43 | 
            -
              name: nokogiri
         | 
| 44 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 45 | 
            -
                requirements:
         | 
| 46 | 
            -
                - - "~>"
         | 
| 47 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 48 | 
            -
                    version: '1.10'
         | 
| 49 | 
            -
              type: :development
         | 
| 50 | 
            -
              prerelease: false
         | 
| 51 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 52 | 
            -
                requirements:
         | 
| 53 | 
            -
                - - "~>"
         | 
| 54 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 55 | 
            -
                    version: '1.10'
         | 
| 56 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 57 | 
            -
              name: pry
         | 
| 58 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 59 | 
            -
                requirements:
         | 
| 60 | 
            -
                - - ">="
         | 
| 61 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            -
                    version: '0'
         | 
| 63 | 
            -
              type: :development
         | 
| 64 | 
            -
              prerelease: false
         | 
| 65 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 66 | 
            -
                requirements:
         | 
| 67 | 
            -
                - - ">="
         | 
| 68 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            -
                    version: '0'
         | 
| 70 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 71 | 
            -
              name: rspec
         | 
| 72 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 73 | 
            -
                requirements:
         | 
| 74 | 
            -
                - - "~>"
         | 
| 75 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            -
                    version: '3.9'
         | 
| 77 | 
            -
              type: :development
         | 
| 78 | 
            -
              prerelease: false
         | 
| 79 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 80 | 
            -
                requirements:
         | 
| 81 | 
            -
                - - "~>"
         | 
| 82 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 83 | 
            -
                    version: '3.9'
         | 
| 84 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 85 | 
            -
              name: rubocop
         | 
| 86 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 87 | 
            -
                requirements:
         | 
| 88 | 
            -
                - - "~>"
         | 
| 89 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 90 | 
            -
                    version: '1.20'
         | 
| 91 | 
            -
              type: :development
         | 
| 92 | 
            -
              prerelease: false
         | 
| 93 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 94 | 
            -
                requirements:
         | 
| 95 | 
            -
                - - "~>"
         | 
| 96 | 
            -
                  - !ruby/object:Gem::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'
         | 
| 12 | 
            +
            date: 2023-05-24 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies: []
         | 
| 112 14 | 
             
            description: 'Great Ruby debugging companion: pretty print Ruby objects to visualize
         | 
| 113 15 | 
             
              their structure. Supports custom object formatting via plugins'
         | 
| 114 16 | 
             
            email: harlemsquirrel@gmail.com
         | 
| @@ -127,12 +29,12 @@ files: | |
| 127 29 | 
             
            - Rakefile
         | 
| 128 30 | 
             
            - lib/amazing_print.rb
         | 
| 129 31 | 
             
            - lib/amazing_print/colorize.rb
         | 
| 32 | 
            +
            - lib/amazing_print/colors.rb
         | 
| 130 33 | 
             
            - lib/amazing_print/core_ext/awesome_method_array.rb
         | 
| 131 34 | 
             
            - lib/amazing_print/core_ext/class.rb
         | 
| 132 35 | 
             
            - lib/amazing_print/core_ext/kernel.rb
         | 
| 133 36 | 
             
            - lib/amazing_print/core_ext/logger.rb
         | 
| 134 37 | 
             
            - lib/amazing_print/core_ext/object.rb
         | 
| 135 | 
            -
            - lib/amazing_print/core_ext/string.rb
         | 
| 136 38 | 
             
            - lib/amazing_print/custom_defaults.rb
         | 
| 137 39 | 
             
            - lib/amazing_print/ext/action_view.rb
         | 
| 138 40 | 
             
            - lib/amazing_print/ext/active_record.rb
         | 
| @@ -153,6 +55,7 @@ files: | |
| 153 55 | 
             
            - lib/amazing_print/formatters/file_formatter.rb
         | 
| 154 56 | 
             
            - lib/amazing_print/formatters/hash_formatter.rb
         | 
| 155 57 | 
             
            - lib/amazing_print/formatters/method_formatter.rb
         | 
| 58 | 
            +
            - lib/amazing_print/formatters/mswin_helper.rb
         | 
| 156 59 | 
             
            - lib/amazing_print/formatters/object_formatter.rb
         | 
| 157 60 | 
             
            - lib/amazing_print/formatters/simple_formatter.rb
         | 
| 158 61 | 
             
            - lib/amazing_print/formatters/struct_formatter.rb
         | 
| @@ -163,7 +66,6 @@ files: | |
| 163 66 | 
             
            - spec/active_record_helper.rb
         | 
| 164 67 | 
             
            - spec/colors_spec.rb
         | 
| 165 68 | 
             
            - spec/core_ext/logger_spec.rb
         | 
| 166 | 
            -
            - spec/core_ext/string_spec.rb
         | 
| 167 69 | 
             
            - spec/ext/action_controller_spec.rb
         | 
| 168 70 | 
             
            - spec/ext/action_view_spec.rb
         | 
| 169 71 | 
             
            - spec/ext/active_model_spec.rb
         | 
| @@ -212,7 +114,7 @@ homepage: https://github.com/amazing-print/amazing_print | |
| 212 114 | 
             
            licenses:
         | 
| 213 115 | 
             
            - MIT
         | 
| 214 116 | 
             
            metadata: {}
         | 
| 215 | 
            -
            post_install_message:
         | 
| 117 | 
            +
            post_install_message: 
         | 
| 216 118 | 
             
            rdoc_options: []
         | 
| 217 119 | 
             
            require_paths:
         | 
| 218 120 | 
             
            - lib
         | 
| @@ -227,56 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 227 129 | 
             
                - !ruby/object:Gem::Version
         | 
| 228 130 | 
             
                  version: '0'
         | 
| 229 131 | 
             
            requirements: []
         | 
| 230 | 
            -
            rubygems_version: 3. | 
| 231 | 
            -
            signing_key:
         | 
| 132 | 
            +
            rubygems_version: 3.4.10
         | 
| 133 | 
            +
            signing_key: 
         | 
| 232 134 | 
             
            specification_version: 4
         | 
| 233 135 | 
             
            summary: Pretty print Ruby objects with proper indentation and colors
         | 
| 234 | 
            -
            test_files:
         | 
| 235 | 
            -
            - spec/active_record_helper.rb
         | 
| 236 | 
            -
            - spec/colors_spec.rb
         | 
| 237 | 
            -
            - spec/core_ext/logger_spec.rb
         | 
| 238 | 
            -
            - spec/core_ext/string_spec.rb
         | 
| 239 | 
            -
            - spec/ext/action_controller_spec.rb
         | 
| 240 | 
            -
            - spec/ext/action_view_spec.rb
         | 
| 241 | 
            -
            - spec/ext/active_model_spec.rb
         | 
| 242 | 
            -
            - spec/ext/active_record_spec.rb
         | 
| 243 | 
            -
            - spec/ext/active_support_spec.rb
         | 
| 244 | 
            -
            - spec/ext/mongo_mapper_spec.rb
         | 
| 245 | 
            -
            - spec/ext/mongoid_spec.rb
         | 
| 246 | 
            -
            - spec/ext/nobrainer_spec.rb
         | 
| 247 | 
            -
            - spec/ext/nokogiri_spec.rb
         | 
| 248 | 
            -
            - spec/ext/ostruct_spec.rb
         | 
| 249 | 
            -
            - spec/ext/ripple_spec.rb
         | 
| 250 | 
            -
            - spec/ext/sequel_spec.rb
         | 
| 251 | 
            -
            - spec/formats_spec.rb
         | 
| 252 | 
            -
            - spec/methods_spec.rb
         | 
| 253 | 
            -
            - spec/misc_spec.rb
         | 
| 254 | 
            -
            - spec/objects_spec.rb
         | 
| 255 | 
            -
            - spec/sequel_helper.rb
         | 
| 256 | 
            -
            - spec/spec_helper.rb
         | 
| 257 | 
            -
            - spec/support/active_record_data/3_2_diana.txt
         | 
| 258 | 
            -
            - spec/support/active_record_data/3_2_diana_legacy.txt
         | 
| 259 | 
            -
            - spec/support/active_record_data/3_2_multi.txt
         | 
| 260 | 
            -
            - spec/support/active_record_data/3_2_multi_legacy.txt
         | 
| 261 | 
            -
            - spec/support/active_record_data/4_0_diana.txt
         | 
| 262 | 
            -
            - spec/support/active_record_data/4_0_multi.txt
         | 
| 263 | 
            -
            - spec/support/active_record_data/4_1_diana.txt
         | 
| 264 | 
            -
            - spec/support/active_record_data/4_1_multi.txt
         | 
| 265 | 
            -
            - spec/support/active_record_data/4_2_diana.txt
         | 
| 266 | 
            -
            - spec/support/active_record_data/4_2_diana_legacy.txt
         | 
| 267 | 
            -
            - spec/support/active_record_data/4_2_multi.txt
         | 
| 268 | 
            -
            - spec/support/active_record_data/4_2_multi_legacy.txt
         | 
| 269 | 
            -
            - spec/support/active_record_data/5_0_diana.txt
         | 
| 270 | 
            -
            - spec/support/active_record_data/5_0_multi.txt
         | 
| 271 | 
            -
            - spec/support/active_record_data/5_1_diana.txt
         | 
| 272 | 
            -
            - spec/support/active_record_data/5_1_multi.txt
         | 
| 273 | 
            -
            - spec/support/active_record_data/5_2_diana.txt
         | 
| 274 | 
            -
            - spec/support/active_record_data/5_2_multi.txt
         | 
| 275 | 
            -
            - spec/support/active_record_data/6_0_diana.txt
         | 
| 276 | 
            -
            - spec/support/active_record_data/6_0_multi.txt
         | 
| 277 | 
            -
            - spec/support/active_record_data/6_1_diana.txt
         | 
| 278 | 
            -
            - spec/support/active_record_data/6_1_multi.txt
         | 
| 279 | 
            -
            - spec/support/active_record_data.rb
         | 
| 280 | 
            -
            - spec/support/ext_verifier.rb
         | 
| 281 | 
            -
            - spec/support/mongoid_versions.rb
         | 
| 282 | 
            -
            - spec/support/rails_versions.rb
         | 
| 136 | 
            +
            test_files: []
         |