Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix easter_egg run without RDoc, fix input-method test run without RDoc #998

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/irb/easter-egg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ def render_frame(i)
end

private def easter_egg(type = nil)
print "\e[?1049h"
type ||= [:logo, :dancing].sample
case type
when :logo
require "rdoc"
RDoc::RI::Driver.new.page do |io|
type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode_large : :ascii_large
io.write easter_egg_logo(type)
Pager.page do |io|
logo_type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode_large : :ascii_large
io.write easter_egg_logo(logo_type)
STDIN.raw { STDIN.getc } if io == STDOUT
end
when :dancing
STDOUT.cooked do
Expand All @@ -138,10 +139,11 @@ def render_frame(i)
end
rescue Interrupt
ensure
print "\e[0m\e[?1049l"
trap("SIGINT", prev_trap)
end
end
ensure
print "\e[0m\e[?1049l"
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions test/irb/test_input_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def test_initialization_without_use_autocomplete
end

def test_initialization_with_use_autocomplete
omit 'This test requires RDoc' unless defined?(RDoc)
original_show_doc_proc = Reline.dialog_proc(:show_doc)&.dialog_proc
empty_proc = Proc.new {}
Reline.add_dialog_proc(:show_doc, empty_proc)
Expand Down Expand Up @@ -190,5 +191,5 @@ def test_perfect_matching_handles_nil_namespace
def has_rdoc_content?
File.exist?(RDoc::RI::Paths::BASE)
end
end
end if defined?(RDoc)
end if defined?(RDoc)
end
Loading