Skip to content

Commit f10e5c8

Browse files
authored
Merge pull request #518 from ruby/console-size-for-jruby
Workaround for JRuby console size.
2 parents ba1fdd1 + 0006f77 commit f10e5c8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/rdoc/stats/normal.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# frozen_string_literal: false
2-
require 'io/console/size'
2+
begin
3+
require 'io/console/size'
4+
rescue LoadError
5+
# for JRuby
6+
require 'io/console'
7+
end
38

49
##
510
# Stats printer that prints just the files being documented with a progress
@@ -23,7 +28,8 @@ def print_file files_so_far, filename
2328

2429
# Print a progress bar, but make sure it fits on a single line. Filename
2530
# will be truncated if necessary.
26-
terminal_width = IO.console_size[1].to_i.nonzero? || 80
31+
size = IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize
32+
terminal_width = size[1].to_i.nonzero? || 80
2733
max_filename_size = terminal_width - progress_bar.size
2834

2935
if filename.size > max_filename_size then

0 commit comments

Comments
 (0)