Yes, we are still enjoying ruby progressbar :) Still need defaults! Here's our current monkeypatch, if anyone is interested:
class ProgressBar
class Base
DEFAULTS = {
format: "%j%% %B %c/%u • %e",
progress_mark: "\e[0;38;5;46m━\e[0m",
remainder_mark: "\e[0;38;5;237m━\e[0m",
length: 72,
}
alias initialize_without_defaults initialize
def initialize(options = {}, *args, &block)
options = DEFAULTS.merge(options || {})
initialize_without_defaults(options, *args, &block)
end
end
end
also a custom Enumerator monkeypatch that includes cursor show/hide the cursor:
class Enumerator
def with_progressbar(options = {}, &block)
return enum_for(__method__, options.dup) if !block
output = options[:output] || ($stdout.isatty ? $stdout : $stderr)
bar = ProgressBar.create(defaults.merge(options))
begin
output.write "\e[?25l"
each do
bar.increment
yield(_1)
end
ensure
output.write "\e[?25h"
end
end
end
Yes, we are still enjoying ruby progressbar :) Still need defaults! Here's our current monkeypatch, if anyone is interested:
also a custom Enumerator monkeypatch that includes cursor show/hide the cursor: