From b9b8fd6d608be7e1a8dafff27476e72384e3e746 Mon Sep 17 00:00:00 2001 From: Jordon Bedwell Date: Sat, 11 Feb 2012 01:53:13 -0600 Subject: [PATCH] Be more liberal with stagger_out and fall to Pry.out then $stdout. Signed-off-by: Jordon Bedwell --- lib/pry/helpers/base_helpers.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/pry/helpers/base_helpers.rb b/lib/pry/helpers/base_helpers.rb index ff2932f5..0d560b71 100644 --- a/lib/pry/helpers/base_helpers.rb +++ b/lib/pry/helpers/base_helpers.rb @@ -126,15 +126,27 @@ class Pry # Try to use `less` for paging, if it fails then use # simple_pager. Also do not page if Pry.pager is falsey # FIXME! Another JRuby hack - def stagger_output(text, output=output()) + def stagger_output(text, out = nil) + out || = case + when respond_to?(:output) + # Mixin. + output + when Pry.respond_to?(:output) + # Parent. + Pry.output + else + # Sys. + $stdout + end + if text.lines.count < page_size || !Pry.pager - output.puts text + out.puts text return end # FIXME! Another JRuby hack if jruby? - simple_pager(text, output) + simple_pager(text, out) else lesspipe { |less| less.puts text } end