Skip to content
Browse files

The SimplePager always prints to $stdout.

… because so does the system pager.
  • Loading branch information...
1 parent f65c915 commit 21d0f656cf05a1adec37071ddb4d39399dc4ecc4 Robert Gleeson committed Aug 9, 2012
Showing with 7 additions and 8 deletions.
  1. +2 −2 lib/pry/helpers/base_helpers.rb
  2. +5 −6 lib/pry/pager.rb
View
4 lib/pry/helpers/base_helpers.rb
@@ -137,10 +137,10 @@ def stagger_output(text, out = nil)
if text.lines.count < Pry::Pager.page_size || !Pry.pager
out.puts text
else
- Pry::Pager.page(text, out)
+ Pry::Pager.page(text)
end
rescue Errno::ENOENT
- simple_pager(text, out)
+ Pry::Pager.page(text)
rescue Errno::EPIPE
end
View
11 lib/pry/pager.rb
@@ -3,28 +3,27 @@ def self.page_size
27
end
- def self.page(text, out = $stdout)
+ def self.page(text)
is_jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
- is_jruby ? SimplePager.new(text, out).page : SystemPager.new(text, out).page
+ is_jruby ? SimplePager.new(text).page : SystemPager.new(text).page
end
def page
raise NotImplementedError, "#{self.class} does not implement #page."
end
- def initialize(text, out = $stdout)
+ def initialize(text)
@text = text
- @out = out
end
class SimplePager < Pry::Pager
def page
text_array = @text.lines.to_a
text_array.each_slice(Pry::Pager.page_size) do |chunk|
- @out.puts chunk.join
+ puts chunk.join
break if chunk.size < Pry::Pager.page_size
if text_array.size > Pry::Pager.page_size
- @out.puts "\n<page break> --- Press enter to continue ( q<enter> to break ) --- <page break>"
+ puts "\n<page break> --- Press enter to continue ( q<enter> to break ) --- <page break>"
break if $stdin.gets.chomp == "q"
end
end

0 comments on commit 21d0f65

Please sign in to comment.
Something went wrong with that request. Please try again.