lib/bumbler/progress.rb in bumbler-0.8.0 vs lib/bumbler/progress.rb in bumbler-0.9.0
- old
+ new
@@ -1,7 +1,9 @@
# frozen_string_literal: true
# TODO: replace with ruby-progressbar dependency
+require 'io/console'
+
module Bumbler
module Progress
@item_count = 0
@loaded_items = 0
@@ -34,10 +36,11 @@
render_progress
end
def tty_width
- `tput cols`.to_i || 80
+ # console_winsize: https://github.com/ruby/ruby/blob/f27eb8148f5a72bbacfebfecc7de9305471bb5c9/ext/io/console/console.c#L796
+ IO.console.winsize[1]
end
def bar(width)
inner_size = width - 2