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

added BasicObject support (class not instances).

And support inspecting objects without to_s and inspect by defaulting
to 'unknown'. Also slightly refactored tests, moved more stuff into test_helper.
This commit is contained in:
John Mair 2011-04-05 00:18:07 +12:00
parent 0fa6fdce5e
commit 137cc24917
4 changed files with 14 additions and 12 deletions

View file

@ -122,6 +122,9 @@ class Pry
else
obj.to_s
end
rescue NoMethodError
"unknown"
end
# A version of `Pry.view` that clips the output to `max_size` chars.

View file

@ -71,8 +71,8 @@ class Pry
Pry.active_instance = self
# Make sure special locals exist
target.eval("_pry_ = Pry.active_instance")
target.eval("_ = Pry.last_result")
target.eval("_pry_ = ::Pry.active_instance")
target.eval("_ = ::Pry.last_result")
self.session_target = target
end
@ -155,7 +155,7 @@ class Pry
# save the pry instance to active_instance
Pry.active_instance = self
target.eval("_pry_ = Pry.active_instance")
target.eval("_pry_ = ::Pry.active_instance")
# eval the expression and save to last_result
# Do not want __FILE__, __LINE__ here because we need to distinguish
@ -228,7 +228,7 @@ class Pry
# @param [Binding] target The binding to set `_` on.
def set_last_result(result, target)
Pry.last_result = result
target.eval("_ = Pry.last_result")
target.eval("_ = ::Pry.last_result")
end
# Set the last exception for a session.
@ -237,7 +237,7 @@ class Pry
# @param [Binding] target The binding to set `_ex_` on.
def set_last_exception(ex, target)
Pry.last_exception = ex
target.eval("_ex_ = Pry.last_exception")
target.eval("_ex_ = ::Pry.last_exception")
end
# Determine whether a Pry command was matched and return command data
@ -355,7 +355,7 @@ class Pry
end
end
if RUBY_VERSION =~ /1.9/
if RUBY_VERSION =~ /1.9/ && RUBY_ENGINE == "ruby"
require 'ripper'
# Determine if a string of code is a valid Ruby expression.

View file

@ -10,15 +10,9 @@ puts "Testing Pry #{Pry::VERSION}"
puts "With method_source version #{MethodSource::VERSION}"
puts "--"
# Ensure we do not execute any rc files
Pry::RC_FILES.clear
Pry.color = false
Pry.should_load_rc = false
describe Pry do
describe "open a Pry session on an object" do
describe "rep" do
before do
class Hello
end

View file

@ -1,3 +1,8 @@
# Ensure we do not execute any rc files
Pry::RC_FILES.clear
Pry.color = false
Pry.should_load_rc = false
class Module
public :remove_const
end