Thread.current -> Pry.current

This commit is contained in:
John Mair 2013-01-15 23:29:23 +01:00
parent 0531b8a7bd
commit 5e3a3f068b
6 changed files with 21 additions and 21 deletions

View File

@ -94,8 +94,8 @@ class Pry
# @param [String] source The source to wrap
# @return [String]
def wrap_for_owner(source)
Thread.current[:__pry_owner__] = code_object.owner
source = "Thread.current[:__pry_owner__].class_eval do\n#{source}\nend"
Pry.current[:pry_owner] = code_object.owner
source = "Pry.current[:pry_owner].class_eval do\n#{source}\nend"
end
# Update the new source code to have the correct Module.nesting.

View File

@ -10,17 +10,17 @@ class Pry
start
end
Pry.th[:pry] = pry
Pry.current[:pry] = pry
proc{ |*a| Bond.agent.call(*a) }
end
def self.start
Bond.start(:eval_binding => lambda{ Pry.th[:pry].current_context })
Bond.start(:eval_binding => lambda{ Pry.current[:pry].current_context })
Bond.complete(:on => /\A/) do |input|
Pry.commands.complete(input.line,
:pry_instance => Pry.th[:pry],
:target => Pry.th[:pry].current_context,
:command_set => Pry.th[:pry].commands)
:pry_instance => Pry.current[:pry],
:target => Pry.current[:pry].current_context,
:command_set => Pry.current[:pry].commands)
end
end

View File

@ -124,12 +124,12 @@ class Pry
# @param [Binding] target The binding where the method is looked up.
# @return [Method, UnboundMethod] The 'refined' method object.
def lookup_method_via_binding(obj, method_name, method_type, target=TOPLEVEL_BINDING)
Pry.th[:obj] = obj
Pry.th[:name] = method_name
Pry.current[:obj] = obj
Pry.current[:name] = method_name
receiver = obj.is_a?(Module) ? "Module" : "Kernel"
target.eval("::#{receiver}.instance_method(:#{method_type}).bind(Pry.th[:obj]).call(Pry.th[:name])")
target.eval("::#{receiver}.instance_method(:#{method_type}).bind(Pry.current[:obj]).call(Pry.current[:name])")
ensure
Pry.th[:obj] = Pry.th[:name] = nil
Pry.current[:obj] = Pry.current[:name] = nil
end
# Given a `Class` or `Module` and the name of a method, try to

View File

@ -9,7 +9,7 @@ class Pry
LOCAL_RC_FILE = "./.pryrc"
# @return [Hash] Pry's `Thread.current` hash
def self.th
def self.current
Thread.current[:__pry__] ||= {}
end

View File

@ -145,10 +145,10 @@ class Pry
# @param [Binding] b The binding to set the local on.
# @return [Object] The value the local was set to.
def inject_local(name, value, b)
Thread.current[:__pry_local__] = value.is_a?(Proc) ? value.call : value
b.eval("#{name} = ::Thread.current[:__pry_local__]")
Pry.current[:pry_local] = value.is_a?(Proc) ? value.call : value
b.eval("#{name} = ::Pry.current[:pry_local]")
ensure
Thread.current[:__pry_local__] = nil
Pry.current[:pry_local] = nil
end
# @return [Integer] The maximum amount of objects remembered by the inp and
@ -447,7 +447,7 @@ class Pry
})
# set a temporary (just so we can inject the value we want into eval_string)
Thread.current[:__pry_cmd_result__] = result
Pry.current[:pry_cmd_result] = result
# note that `result` wraps the result of command processing; if a
# command was matched and invoked then `result.command?` returns true,
@ -457,7 +457,7 @@ class Pry
# the command that was invoked was non-void (had a return value) and so we make
# the value of the current expression equal to the return value
# of the command.
eval_string.replace "Thread.current[:__pry_cmd_result__].retval\n"
eval_string.replace "::Pry.current[:pry_cmd_result].retval\n"
end
true
else

View File

@ -29,10 +29,10 @@ module PryTestHelpers
# inject a variable into a binding
def inject_var(name, value, b)
Thread.current[:__pry_local__] = value
b.eval("#{name} = Thread.current[:__pry_local__]")
Pry.current[:pry_local] = value
b.eval("#{name} = ::Pry.current[:pry_local]")
ensure
Thread.current[:__pry_local__] = nil
Pry.current[:pry_local] = nil
end
def constant_scope(*names)
@ -165,7 +165,7 @@ class PryTester
protected
def last_command_result
result = Thread.current[:__pry_cmd_result__]
result = Pry.current[:pry_cmd_result]
result.retval if result
end