From 5e3a3f068bdaa7b7b021782e9ea2c82b4be3013f Mon Sep 17 00:00:00 2001 From: John Mair Date: Tue, 15 Jan 2013 23:29:23 +0100 Subject: [PATCH] Thread.current -> Pry.current --- lib/pry/commands/edit/method_patcher.rb | 4 ++-- lib/pry/completion.rb | 10 +++++----- lib/pry/method.rb | 8 ++++---- lib/pry/pry_class.rb | 2 +- lib/pry/pry_instance.rb | 10 +++++----- lib/pry/test/helper.rb | 8 ++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/pry/commands/edit/method_patcher.rb b/lib/pry/commands/edit/method_patcher.rb index 1b7f8902..91283072 100644 --- a/lib/pry/commands/edit/method_patcher.rb +++ b/lib/pry/commands/edit/method_patcher.rb @@ -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. diff --git a/lib/pry/completion.rb b/lib/pry/completion.rb index 897f1512..f47ec17b 100644 --- a/lib/pry/completion.rb +++ b/lib/pry/completion.rb @@ -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 diff --git a/lib/pry/method.rb b/lib/pry/method.rb index d645e88e..e38c42f3 100644 --- a/lib/pry/method.rb +++ b/lib/pry/method.rb @@ -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 diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 070ca38b..06ec7959 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -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 diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 6ab40e9c..91889731 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -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 diff --git a/lib/pry/test/helper.rb b/lib/pry/test/helper.rb index 0c66ee07..37c66b13 100644 --- a/lib/pry/test/helper.rb +++ b/lib/pry/test/helper.rb @@ -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