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

Workaround for JRuby console size. #518

Merged
merged 1 commit into from
Sep 13, 2017
Merged
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
10 changes: 8 additions & 2 deletions lib/rdoc/stats/normal.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down