Skip to content

Commit

Permalink
Drop ColorPrinter's workaround for BasicObject (#1051)
Browse files Browse the repository at this point in the history
`pp` 0.6.0+ includes ruby/pp#26 to handle BasicObject,
so we can drop the workaround.
  • Loading branch information
st0012 authored Jan 12, 2025
1 parent a6b976c commit 08908d4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
# Added to make Ruby 2.7 correctly require installed default gems, like `pp`.
rubygems: latest
- name: Run tests
run: bundle exec rake test
- name: Run tests in isolation
Expand Down
1 change: 1 addition & 0 deletions irb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ Gem::Specification.new do |spec|

spec.add_dependency "reline", ">= 0.4.2"
spec.add_dependency "rdoc", ">= 4.0.0"
spec.add_dependency "pp", ">= 0.6.0"
end
5 changes: 0 additions & 5 deletions lib/irb/color_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

module IRB
class ColorPrinter < ::PP
METHOD_RESPOND_TO = Object.instance_method(:respond_to?)
METHOD_INSPECT = Object.instance_method(:inspect)

class << self
def pp(obj, out = $>, width = screen_width)
q = ColorPrinter.new(out, width)
Expand All @@ -28,8 +25,6 @@ def pp(obj)
if String === obj
# Avoid calling Ruby 2.4+ String#pretty_print that splits a string by "\n"
text(obj.inspect)
elsif !METHOD_RESPOND_TO.bind(obj).call(:inspect)
text(METHOD_INSPECT.bind(obj).call)
else
super
end
Expand Down

0 comments on commit 08908d4

Please # to comment.