mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Move Pry::DEFAULT_PRINT to Config
This commit is contained in:
parent
4e3200eece
commit
19db442263
4 changed files with 11 additions and 14 deletions
|
@ -6,14 +6,6 @@ require 'pry/helpers/base_helpers'
|
|||
require 'pry/hooks'
|
||||
|
||||
class Pry
|
||||
# The default print
|
||||
DEFAULT_PRINT = proc do |_output, value, _pry_|
|
||||
_pry_.pager.open do |pager|
|
||||
pager.print _pry_.config.output_prefix
|
||||
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
|
||||
end
|
||||
end
|
||||
|
||||
# may be convenient when working with enormous objects and
|
||||
# pretty_print is too slow
|
||||
SIMPLE_PRINT = proc do |output, value|
|
||||
|
|
|
@ -17,7 +17,14 @@ class Pry
|
|||
prompt_name: Pry::Prompt::DEFAULT_NAME,
|
||||
prompt: Pry::Prompt[:default],
|
||||
prompt_safe_contexts: Pry::Prompt::SAFE_CONTEXTS,
|
||||
print: Pry::DEFAULT_PRINT,
|
||||
|
||||
print: proc do |_output, value, _pry_|
|
||||
_pry_.pager.open do |pager|
|
||||
pager.print _pry_.config.output_prefix
|
||||
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
|
||||
end
|
||||
end,
|
||||
|
||||
quiet: false,
|
||||
exception_handler: Pry::DEFAULT_EXCEPTION_HANDLER,
|
||||
unrescued_exceptions: Pry::DEFAULT_UNRESCUED_EXCEPTIONS,
|
||||
|
|
|
@ -2,7 +2,7 @@ class Pry
|
|||
class Inspector
|
||||
MAP = {
|
||||
"default" => {
|
||||
value: Pry::DEFAULT_PRINT,
|
||||
value: Pry::Config.defaults.print,
|
||||
description: <<-DESCRIPTION.each_line.map(&:lstrip!)
|
||||
The default Pry inspector. It has paging and color support, and uses
|
||||
pretty_inspect when printing an object.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
describe Pry do
|
||||
describe "output failsafe" do
|
||||
after do
|
||||
Pry.config.print = Pry::DEFAULT_PRINT
|
||||
end
|
||||
after { Pry.config.print = Pry::Config.defaults.print }
|
||||
|
||||
it "should catch serialization exceptions" do
|
||||
Pry.config.print = proc { raise "catch-22" }
|
||||
|
@ -31,7 +29,7 @@ describe Pry do
|
|||
end
|
||||
end
|
||||
|
||||
describe "DEFAULT_PRINT" do
|
||||
describe "default print" do
|
||||
it "should output the right thing" do
|
||||
expect(mock_pry("[1]")).to match(/^=> \[1\]/)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue