1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

config/default: rename prompt_safe_objects to prompt_safe_contexts

It makes sense to rename it because "objects" we are referring in the context of
prompt are actually prompt "contexts".
This commit is contained in:
Kyrylo Silin 2018-10-28 16:07:44 +08:00
parent a567efdffc
commit 3deeeee115
4 changed files with 5 additions and 5 deletions

View file

@ -18,8 +18,8 @@ class Pry::Config::Default
prompt: proc { prompt: proc {
Pry::Prompt::DEFAULT Pry::Prompt::DEFAULT
}, },
prompt_safe_objects: proc { prompt_safe_contexts: proc {
Pry::Prompt::SAFE_OBJECTS Pry::Prompt::SAFE_CONTEXTS
}, },
print: proc { print: proc {
Pry::DEFAULT_PRINT Pry::DEFAULT_PRINT

View file

@ -2,7 +2,7 @@ class Pry
class Prompt class Prompt
DEFAULT_NAME = 'pry'.freeze DEFAULT_NAME = 'pry'.freeze
SAFE_OBJECTS = [String, Numeric, Symbol, nil, true, false].freeze SAFE_CONTEXTS = [String, Numeric, Symbol, nil, true, false].freeze
# @return [String] # @return [String]
DEFAULT_TEMPLATE = DEFAULT_TEMPLATE =

View file

@ -241,7 +241,7 @@ you can add "Pry.config.windows_console_warning = false" to your pryrc.
# fixed as of https://github.com/jruby/jruby/commit/d365ebd309cf9df3dde28f5eb36ea97056e0c039 # fixed as of https://github.com/jruby/jruby/commit/d365ebd309cf9df3dde28f5eb36ea97056e0c039
# we can drop in the future. # we can drop in the future.
obj.to_s obj.to_s
elsif Pry.config.prompt_safe_objects.any? { |v| v === obj } && obj.inspect.length <= max elsif Pry.config.prompt_safe_contexts.any? { |v| v === obj } && obj.inspect.length <= max
obj.inspect obj.inspect
else else
id == true ? "#<#{obj.class}:0x%x>" % (obj.object_id << 1) : "#<#{obj.class}>" id == true ? "#<#{obj.class}:0x%x>" % (obj.object_id << 1) : "#<#{obj.class}>"

View file

@ -274,7 +274,7 @@ describe "test Pry defaults" do
it "returns the #inspect of the custom prompt safe objects" do it "returns the #inspect of the custom prompt safe objects" do
Barbie = Class.new { def inspect; "life is plastic, it's fantastic" end } Barbie = Class.new { def inspect; "life is plastic, it's fantastic" end }
Pry.config.prompt_safe_objects << Barbie Pry.config.prompt_safe_contexts << Barbie
output = Pry.view_clip(Barbie.new, DEFAULT_OPTIONS) output = Pry.view_clip(Barbie.new, DEFAULT_OPTIONS)
expect(output).to eq "life is plastic, it's fantastic" expect(output).to eq "life is plastic, it's fantastic"
end end