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

Revert "remove special-case for 'main' from Pry.view_clip()."

This reverts commit a56ac3f73d.

because, jruby.
cc @headius
This commit is contained in:
Robert Gleeson 2014-01-17 08:58:20 +01:00
parent a56ac3f73d
commit ea6cd413a4
2 changed files with 5 additions and 1 deletions

View file

@ -65,7 +65,7 @@ class Pry
}
]
DEFAULT_PROMPT_SAFE_OBJECTS = [String, Numeric, Symbol, nil, true, false, TOPLEVEL_BINDING.eval("self")]
DEFAULT_PROMPT_SAFE_OBJECTS = [String, Numeric, Symbol, nil, true, false]
# A simple prompt - doesn't display target or nesting level
SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]

View file

@ -130,11 +130,15 @@ class Pry
def self.view_clip(obj, max_length = 60)
if obj.kind_of?(Module) && obj.name.to_s != "" && obj.name.to_s.length <= max_length
obj.name.to_s
elsif TOPLEVEL_BINDING.eval('self') == obj
# special case for 'main' object :)
obj.to_s
elsif Pry.config.prompt_safe_objects.any? { |v| v === obj } && obj.inspect.length <= max_length
obj.inspect
else
"#<#{obj.class}>"#:%x>"# % (obj.object_id << 1)
end
rescue RescuableException
"unknown"
end