From 0006f77269ef6ba6d6c296adb78c5e1ec7f7e943 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Wed, 13 Sep 2017 10:27:25 +0900 Subject: [PATCH] Workaround for JRuby console size. Fixed #517 --- lib/rdoc/stats/normal.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rdoc/stats/normal.rb b/lib/rdoc/stats/normal.rb index ba00b6cbdf..9f7ca59c34 100644 --- a/lib/rdoc/stats/normal.rb +++ b/lib/rdoc/stats/normal.rb @@ -1,5 +1,10 @@ # frozen_string_literal: false -require 'io/console/size' +begin + require 'io/console/size' +rescue LoadError + # for JRuby + require 'io/console' +end ## # Stats printer that prints just the files being documented with a progress @@ -23,7 +28,8 @@ def print_file files_so_far, filename # Print a progress bar, but make sure it fits on a single line. Filename # will be truncated if necessary. - terminal_width = IO.console_size[1].to_i.nonzero? || 80 + size = IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize + terminal_width = size[1].to_i.nonzero? || 80 max_filename_size = terminal_width - progress_bar.size if filename.size > max_filename_size then