Skip to content

Commit 08908d4

Browse files
authored
Drop ColorPrinter's workaround for BasicObject (#1051)
`pp` 0.6.0+ includes ruby/pp#26 to handle BasicObject, so we can drop the workaround.
1 parent a6b976c commit 08908d4

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
with:
4343
ruby-version: ${{ matrix.ruby }}
4444
bundler-cache: true
45+
# Added to make Ruby 2.7 correctly require installed default gems, like `pp`.
46+
rubygems: latest
4547
- name: Run tests
4648
run: bundle exec rake test
4749
- name: Run tests in isolation

irb.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ Gem::Specification.new do |spec|
4242

4343
spec.add_dependency "reline", ">= 0.4.2"
4444
spec.add_dependency "rdoc", ">= 4.0.0"
45+
spec.add_dependency "pp", ">= 0.6.0"
4546
end

lib/irb/color_printer.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
module IRB
66
class ColorPrinter < ::PP
7-
METHOD_RESPOND_TO = Object.instance_method(:respond_to?)
8-
METHOD_INSPECT = Object.instance_method(:inspect)
9-
107
class << self
118
def pp(obj, out = $>, width = screen_width)
129
q = ColorPrinter.new(out, width)
@@ -28,8 +25,6 @@ def pp(obj)
2825
if String === obj
2926
# Avoid calling Ruby 2.4+ String#pretty_print that splits a string by "\n"
3027
text(obj.inspect)
31-
elsif !METHOD_RESPOND_TO.bind(obj).call(:inspect)
32-
text(METHOD_INSPECT.bind(obj).call)
3328
else
3429
super
3530
end

0 commit comments

Comments
 (0)