pry 0.10.1 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +378 -11
- data/LICENSE +1 -1
- data/README.md +352 -306
- data/bin/pry +4 -7
- data/lib/pry/basic_object.rb +10 -0
- data/lib/pry/block_command.rb +22 -0
- data/lib/pry/class_command.rb +194 -0
- data/lib/pry/cli.rb +81 -74
- data/lib/pry/code/code_file.rb +37 -26
- data/lib/pry/code/code_range.rb +7 -5
- data/lib/pry/code/loc.rb +26 -13
- data/lib/pry/code.rb +49 -30
- data/lib/pry/code_object.rb +53 -28
- data/lib/pry/color_printer.rb +46 -35
- data/lib/pry/command.rb +197 -369
- data/lib/pry/command_set.rb +89 -114
- data/lib/pry/command_state.rb +31 -0
- data/lib/pry/commands/amend_line.rb +86 -82
- data/lib/pry/commands/bang.rb +18 -14
- data/lib/pry/commands/bang_pry.rb +15 -11
- data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
- data/lib/pry/commands/cat/exception_formatter.rb +85 -72
- data/lib/pry/commands/cat/file_formatter.rb +56 -46
- data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
- data/lib/pry/commands/cat.rb +62 -54
- data/lib/pry/commands/cd.rb +40 -35
- data/lib/pry/commands/change_inspector.rb +29 -22
- data/lib/pry/commands/change_prompt.rb +48 -23
- data/lib/pry/commands/clear_screen.rb +20 -0
- data/lib/pry/commands/code_collector.rb +148 -131
- data/lib/pry/commands/disable_pry.rb +23 -19
- data/lib/pry/commands/easter_eggs.rb +23 -34
- data/lib/pry/commands/edit/exception_patcher.rb +21 -17
- data/lib/pry/commands/edit/file_and_line_locator.rb +34 -23
- data/lib/pry/commands/edit.rb +185 -157
- data/lib/pry/commands/exit.rb +40 -35
- data/lib/pry/commands/exit_all.rb +24 -20
- data/lib/pry/commands/exit_program.rb +20 -16
- data/lib/pry/commands/find_method.rb +168 -162
- data/lib/pry/commands/fix_indent.rb +16 -12
- data/lib/pry/commands/help.rb +140 -133
- data/lib/pry/commands/hist.rb +151 -149
- data/lib/pry/commands/import_set.rb +20 -15
- data/lib/pry/commands/jump_to.rb +25 -21
- data/lib/pry/commands/list_inspectors.rb +35 -28
- data/lib/pry/commands/ls/constants.rb +59 -31
- data/lib/pry/commands/ls/formatter.rb +42 -36
- data/lib/pry/commands/ls/globals.rb +38 -36
- data/lib/pry/commands/ls/grep.rb +17 -15
- data/lib/pry/commands/ls/instance_vars.rb +29 -28
- data/lib/pry/commands/ls/interrogatable.rb +18 -12
- data/lib/pry/commands/ls/jruby_hacks.rb +47 -41
- data/lib/pry/commands/ls/local_names.rb +26 -24
- data/lib/pry/commands/ls/local_vars.rb +38 -30
- data/lib/pry/commands/ls/ls_entity.rb +47 -52
- data/lib/pry/commands/ls/methods.rb +49 -51
- data/lib/pry/commands/ls/methods_helper.rb +46 -42
- data/lib/pry/commands/ls/self_methods.rb +23 -21
- data/lib/pry/commands/ls.rb +124 -103
- data/lib/pry/commands/nesting.rb +21 -17
- data/lib/pry/commands/play.rb +92 -82
- data/lib/pry/commands/pry_backtrace.rb +22 -17
- data/lib/pry/commands/pry_version.rb +15 -11
- data/lib/pry/commands/raise_up.rb +33 -27
- data/lib/pry/commands/reload_code.rb +60 -48
- data/lib/pry/commands/reset.rb +16 -12
- data/lib/pry/commands/ri.rb +57 -42
- data/lib/pry/commands/save_file.rb +45 -43
- data/lib/pry/commands/shell_command.rb +56 -29
- data/lib/pry/commands/shell_mode.rb +22 -18
- data/lib/pry/commands/show_doc.rb +81 -70
- data/lib/pry/commands/show_info.rb +194 -155
- data/lib/pry/commands/show_input.rb +16 -11
- data/lib/pry/commands/show_source.rb +109 -42
- data/lib/pry/commands/stat.rb +35 -31
- data/lib/pry/commands/switch_to.rb +21 -15
- data/lib/pry/commands/toggle_color.rb +20 -16
- data/lib/pry/commands/watch_expression/expression.rb +32 -27
- data/lib/pry/commands/watch_expression.rb +89 -84
- data/lib/pry/commands/whereami.rb +156 -141
- data/lib/pry/commands/wtf.rb +78 -40
- data/lib/pry/config/attributable.rb +22 -0
- data/lib/pry/config/lazy_value.rb +29 -0
- data/lib/pry/config/memoized_value.rb +34 -0
- data/lib/pry/config/value.rb +24 -0
- data/lib/pry/config.rb +317 -20
- data/lib/pry/control_d_handler.rb +28 -0
- data/lib/pry/core_extensions.rb +22 -9
- data/lib/pry/editor.rb +53 -33
- data/lib/pry/env.rb +18 -0
- data/lib/pry/exception_handler.rb +43 -0
- data/lib/pry/exceptions.rb +13 -17
- data/lib/pry/forwardable.rb +27 -0
- data/lib/pry/helpers/base_helpers.rb +20 -62
- data/lib/pry/helpers/command_helpers.rb +52 -62
- data/lib/pry/helpers/documentation_helpers.rb +20 -12
- data/lib/pry/helpers/options_helpers.rb +15 -8
- data/lib/pry/helpers/platform.rb +60 -0
- data/lib/pry/helpers/table.rb +44 -32
- data/lib/pry/helpers/text.rb +96 -85
- data/lib/pry/helpers.rb +3 -0
- data/lib/pry/history.rb +81 -55
- data/lib/pry/hooks.rb +60 -110
- data/lib/pry/indent.rb +72 -66
- data/lib/pry/input_completer.rb +199 -158
- data/lib/pry/input_lock.rb +7 -10
- data/lib/pry/inspector.rb +36 -24
- data/lib/pry/last_exception.rb +45 -45
- data/lib/pry/method/disowned.rb +19 -5
- data/lib/pry/method/patcher.rb +14 -8
- data/lib/pry/method/weird_method_locator.rb +79 -43
- data/lib/pry/method.rb +177 -124
- data/lib/pry/object_path.rb +37 -28
- data/lib/pry/output.rb +102 -16
- data/lib/pry/pager.rb +187 -174
- data/lib/pry/plugins.rb +49 -13
- data/lib/pry/prompt.rb +213 -25
- data/lib/pry/pry_class.rb +106 -93
- data/lib/pry/pry_instance.rb +261 -224
- data/lib/pry/repl.rb +82 -27
- data/lib/pry/repl_file_loader.rb +27 -22
- data/lib/pry/ring.rb +89 -0
- data/lib/pry/slop/LICENSE +20 -0
- data/lib/pry/slop/commands.rb +190 -0
- data/lib/pry/slop/option.rb +210 -0
- data/lib/pry/slop.rb +672 -0
- data/lib/pry/syntax_highlighter.rb +26 -0
- data/lib/pry/system_command_handler.rb +17 -0
- data/lib/pry/testable/evalable.rb +24 -0
- data/lib/pry/testable/mockable.rb +22 -0
- data/lib/pry/testable/pry_tester.rb +88 -0
- data/lib/pry/testable/utility.rb +34 -0
- data/lib/pry/testable/variables.rb +52 -0
- data/lib/pry/testable.rb +68 -0
- data/lib/pry/version.rb +3 -1
- data/lib/pry/warning.rb +27 -0
- data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +29 -27
- data/lib/pry/wrapped_module.rb +67 -57
- data/lib/pry.rb +134 -149
- metadata +49 -59
- data/lib/pry/commands/disabled_commands.rb +0 -2
- data/lib/pry/commands/gem_cd.rb +0 -26
- data/lib/pry/commands/gem_install.rb +0 -32
- data/lib/pry/commands/gem_list.rb +0 -33
- data/lib/pry/commands/gem_open.rb +0 -29
- data/lib/pry/commands/gist.rb +0 -101
- data/lib/pry/commands/install_command.rb +0 -53
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/simple_prompt.rb +0 -22
- data/lib/pry/commands.rb +0 -6
- data/lib/pry/config/behavior.rb +0 -139
- data/lib/pry/config/convenience.rb +0 -25
- data/lib/pry/config/default.rb +0 -161
- data/lib/pry/history_array.rb +0 -121
- data/lib/pry/rbx_path.rb +0 -22
- data/lib/pry/rubygem.rb +0 -82
- data/lib/pry/terminal.rb +0 -79
- data/lib/pry/test/helper.rb +0 -170
data/lib/pry/pry_class.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'stringio'
|
4
|
+
require 'pathname'
|
5
|
+
|
2
6
|
class Pry
|
7
|
+
LOCAL_RC_FILE = "./.pryrc".freeze
|
3
8
|
|
4
|
-
|
5
|
-
|
9
|
+
# @return [Boolean] true if this Ruby supports safe levels and tainting,
|
10
|
+
# to guard against using deprecated or unsupported features
|
11
|
+
HAS_SAFE_LEVEL = (
|
12
|
+
RUBY_ENGINE == 'ruby' &&
|
13
|
+
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
|
14
|
+
)
|
6
15
|
|
7
16
|
class << self
|
8
|
-
extend Forwardable
|
17
|
+
extend Pry::Forwardable
|
9
18
|
attr_accessor :custom_completions
|
10
19
|
attr_accessor :current_line
|
11
20
|
attr_accessor :line_buffer
|
@@ -14,23 +23,30 @@ class Pry
|
|
14
23
|
attr_accessor :quiet
|
15
24
|
attr_accessor :last_internal_error
|
16
25
|
attr_accessor :config
|
17
|
-
attr_writer :history
|
18
26
|
|
19
27
|
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
|
20
28
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def_delegators(
|
30
|
+
:@config, :input, :input=, :output, :output=, :commands,
|
31
|
+
:commands=, :print, :print=, :exception_handler, :exception_handler=,
|
32
|
+
:hooks, :hooks=, :color, :color=, :pager, :pager=, :editor, :editor=,
|
33
|
+
:memory_size, :memory_size=, :extra_sticky_locals, :extra_sticky_locals=,
|
34
|
+
:prompt, :prompt=, :history, :history=
|
35
|
+
)
|
36
|
+
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# Pry.configure do |config|
|
40
|
+
# config.eager_load! # optional
|
41
|
+
# config.input = # ..
|
42
|
+
# config.foo = 2
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# @yield [config]
|
46
|
+
# Yields a block with {Pry.config} as its argument.
|
47
|
+
#
|
48
|
+
def configure
|
49
|
+
yield config
|
34
50
|
end
|
35
51
|
end
|
36
52
|
|
@@ -47,7 +63,7 @@ class Pry
|
|
47
63
|
# Returns a value store for an instance of Pry running on the current thread.
|
48
64
|
#
|
49
65
|
def self.current
|
50
|
-
Thread.current[:__pry__] ||=
|
66
|
+
Thread.current[:__pry__] ||= {}
|
51
67
|
end
|
52
68
|
|
53
69
|
# Load the given file in the context of `Pry.toplevel_binding`
|
@@ -58,8 +74,8 @@ class Pry
|
|
58
74
|
puts "Error loading #{file}: #{e}\n#{e.backtrace.first}"
|
59
75
|
end
|
60
76
|
|
61
|
-
# Load
|
62
|
-
#
|
77
|
+
# Load RC files if appropriate This method can also be used to reload the
|
78
|
+
# files if they have changed.
|
63
79
|
def self.load_rc_files
|
64
80
|
rc_files_to_load.each do |file|
|
65
81
|
critical_section do
|
@@ -71,17 +87,15 @@ class Pry
|
|
71
87
|
# Load the local RC file (./.pryrc)
|
72
88
|
def self.rc_files_to_load
|
73
89
|
files = []
|
74
|
-
files <<
|
90
|
+
files << Pry.config.rc_file if Pry.config.should_load_rc
|
75
91
|
files << LOCAL_RC_FILE if Pry.config.should_load_local_rc
|
76
92
|
files.map { |file| real_path_to(file) }.compact.uniq
|
77
93
|
end
|
78
94
|
|
79
95
|
# Expand a file to its canonical name (following symlinks as appropriate)
|
80
96
|
def self.real_path_to(file)
|
81
|
-
|
82
|
-
|
83
|
-
File.exist?(expanded) ? expanded : nil
|
84
|
-
rescue Errno::ENOENT
|
97
|
+
Pathname.new(File.expand_path(file)).realpath.to_s
|
98
|
+
rescue Errno::ENOENT, Errno::EACCES
|
85
99
|
nil
|
86
100
|
end
|
87
101
|
|
@@ -95,63 +109,71 @@ class Pry
|
|
95
109
|
# Trap interrupts on jruby, and make them behave like MRI so we can
|
96
110
|
# catch them.
|
97
111
|
def self.load_traps
|
98
|
-
trap('INT'){ raise Interrupt }
|
112
|
+
trap('INT') { raise Interrupt }
|
99
113
|
end
|
100
114
|
|
101
115
|
def self.load_win32console
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
warn <<-WARNING if Pry.config.windows_console_warning
|
116
|
+
require 'win32console'
|
117
|
+
# The mswin and mingw versions of pry require win32console, so this should
|
118
|
+
# only fail on jruby (where win32console doesn't work).
|
119
|
+
# Instead we'll recommend ansicon, which does.
|
120
|
+
rescue LoadError
|
121
|
+
warn <<-WARNING if Pry.config.windows_console_warning
|
109
122
|
For a better Pry experience on Windows, please use ansicon:
|
110
123
|
https://github.com/adoxa/ansicon
|
111
124
|
If you use an alternative to ansicon and don't want to see this warning again,
|
112
|
-
you can add "Pry.config.windows_console_warning = false" to your
|
113
|
-
|
114
|
-
end
|
125
|
+
you can add "Pry.config.windows_console_warning = false" to your pryrc.
|
126
|
+
WARNING
|
115
127
|
end
|
116
128
|
|
117
|
-
# Do basic setup for initial session
|
118
|
-
#
|
119
|
-
# loading history.
|
129
|
+
# Do basic setup for initial session including: loading pryrc, plugins,
|
130
|
+
# requires, and history.
|
120
131
|
def self.initial_session_setup
|
121
132
|
return unless initial_session?
|
133
|
+
|
122
134
|
@initial_session = false
|
123
135
|
|
124
|
-
# note these have to be loaded here rather than in
|
136
|
+
# note these have to be loaded here rather than in _pry_ as
|
125
137
|
# we only want them loaded once per entire Pry lifetime.
|
126
138
|
load_rc_files
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.final_session_setup
|
142
|
+
return if @session_finalized
|
143
|
+
|
144
|
+
@session_finalized = true
|
127
145
|
load_plugins if Pry.config.should_load_plugins
|
128
146
|
load_requires if Pry.config.should_load_requires
|
129
|
-
load_history if Pry.config.
|
147
|
+
load_history if Pry.config.history_load
|
130
148
|
load_traps if Pry.config.should_trap_interrupts
|
131
|
-
load_win32console if
|
149
|
+
load_win32console if Helpers::Platform.windows? && !Helpers::Platform.windows_ansi?
|
132
150
|
end
|
133
151
|
|
134
152
|
# Start a Pry REPL.
|
135
|
-
# This method also loads
|
136
|
-
# first time it is invoked.
|
153
|
+
# This method also loads `pryrc` as necessary the first time it is invoked.
|
137
154
|
# @param [Object, Binding] target The receiver of the Pry session
|
138
155
|
# @param [Hash] options
|
139
156
|
# @option options (see Pry#initialize)
|
140
157
|
# @example
|
141
158
|
# Pry.start(Object.new, :input => MyInput.new)
|
142
|
-
def self.start(target=nil, options={})
|
143
|
-
return if
|
159
|
+
def self.start(target = nil, options = {})
|
160
|
+
return if Pry::Env['DISABLE_PRY']
|
161
|
+
if Pry::Env['FAIL_PRY']
|
162
|
+
raise 'You have FAIL_PRY set to true, which results in Pry calls failing'
|
163
|
+
end
|
164
|
+
|
144
165
|
options = options.to_hash
|
145
166
|
|
146
167
|
if in_critical_section?
|
147
168
|
output.puts "ERROR: Pry started inside Pry."
|
148
|
-
output.puts "This can happen if you have a binding.pry inside a #to_s
|
169
|
+
output.puts "This can happen if you have a binding.pry inside a #to_s " \
|
170
|
+
"or #inspect function."
|
149
171
|
return
|
150
172
|
end
|
151
173
|
|
152
174
|
options[:target] = Pry.binding_for(target || toplevel_binding)
|
153
|
-
options[:hooks] = Pry::Hooks.from_hash options.delete(:hooks) if options.key?(:hooks)
|
154
175
|
initial_session_setup
|
176
|
+
final_session_setup
|
155
177
|
|
156
178
|
# Unless we were given a backtrace, save the current one
|
157
179
|
if options[:backtrace].nil?
|
@@ -175,7 +197,6 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
|
|
175
197
|
# Execute the file through the REPL loop, non-interactively.
|
176
198
|
# @param [String] file_name File name to load through the REPL.
|
177
199
|
def self.load_file_through_repl(file_name)
|
178
|
-
require "pry/repl_file_loader"
|
179
200
|
REPLFileLoader.new(file_name).load
|
180
201
|
end
|
181
202
|
|
@@ -201,17 +222,23 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
|
|
201
222
|
def self.view_clip(obj, options = {})
|
202
223
|
max = options.fetch :max_length, 60
|
203
224
|
id = options.fetch :id, false
|
204
|
-
if obj.
|
225
|
+
if obj.is_a?(Module) && obj.name.to_s != "" && obj.name.to_s.length <= max
|
205
226
|
obj.name.to_s
|
206
227
|
elsif Pry.main == obj
|
207
|
-
#
|
208
|
-
#
|
228
|
+
# Special-case to support jruby. Fixed as of:
|
229
|
+
# https://github.com/jruby/jruby/commit/d365ebd309cf9df3dde28f5eb36ea97056e0c039
|
209
230
|
# we can drop in the future.
|
210
231
|
obj.to_s
|
211
|
-
|
232
|
+
# rubocop:disable Style/CaseEquality
|
233
|
+
elsif Pry.config.prompt_safe_contexts.any? { |v| v === obj } &&
|
234
|
+
obj.inspect.length <= max
|
235
|
+
# rubocop:enable Style/CaseEquality
|
236
|
+
|
212
237
|
obj.inspect
|
238
|
+
elsif id
|
239
|
+
format("#<#{obj.class}:0x%<id>x>", id: obj.object_id << 1)
|
213
240
|
else
|
214
|
-
|
241
|
+
"#<#{obj.class}>"
|
215
242
|
end
|
216
243
|
rescue RescuableException
|
217
244
|
"unknown"
|
@@ -233,7 +260,7 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
|
|
233
260
|
# @param [String] command_string The Pry command (including arguments,
|
234
261
|
# if any).
|
235
262
|
# @param [Hash] options Optional named parameters.
|
236
|
-
# @return [
|
263
|
+
# @return [nil]
|
237
264
|
# @option options [Object, Binding] :target The object to run the
|
238
265
|
# command under. Defaults to `TOPLEVEL_BINDING` (main).
|
239
266
|
# @option options [Boolean] :show_output Whether to show command
|
@@ -244,32 +271,21 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
|
|
244
271
|
# Pry.run_command "ls -m", :target => Pry
|
245
272
|
# @example Display command output.
|
246
273
|
# Pry.run_command "ls -av", :show_output => true
|
247
|
-
def self.run_command(command_string, options={})
|
274
|
+
def self.run_command(command_string, options = {})
|
248
275
|
options = {
|
249
|
-
:
|
250
|
-
:
|
251
|
-
:
|
252
|
-
:
|
276
|
+
target: TOPLEVEL_BINDING,
|
277
|
+
show_output: true,
|
278
|
+
output: Pry.config.output,
|
279
|
+
commands: Pry.config.commands
|
253
280
|
}.merge!(options)
|
254
281
|
|
255
282
|
# :context for compatibility with <= 0.9.11.4
|
256
283
|
target = options[:context] || options[:target]
|
257
284
|
output = options[:show_output] ? options[:output] : StringIO.new
|
258
285
|
|
259
|
-
pry = Pry.new(:
|
286
|
+
pry = Pry.new(output: output, target: target, commands: options[:commands])
|
260
287
|
pry.eval command_string
|
261
|
-
|
262
|
-
|
263
|
-
def self.default_editor_for_platform
|
264
|
-
return ENV['VISUAL'] if ENV['VISUAL'] and not ENV['VISUAL'].empty?
|
265
|
-
return ENV['EDITOR'] if ENV['EDITOR'] and not ENV['EDITOR'].empty?
|
266
|
-
if Helpers::BaseHelpers.windows?
|
267
|
-
'notepad'
|
268
|
-
else
|
269
|
-
%w(editor nano vi).detect do |editor|
|
270
|
-
system("which #{editor} > /dev/null 2>&1")
|
271
|
-
end
|
272
|
-
end
|
288
|
+
nil
|
273
289
|
end
|
274
290
|
|
275
291
|
def self.auto_resize!
|
@@ -281,23 +297,23 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
|
|
281
297
|
end
|
282
298
|
|
283
299
|
if Readline::VERSION =~ /edit/i
|
284
|
-
warn
|
300
|
+
warn(<<-WARN)
|
285
301
|
Readline version #{Readline::VERSION} detected - will not auto_resize! correctly.
|
286
302
|
For the fix, use GNU Readline instead:
|
287
|
-
https://github.com/guard/guard/wiki/Add-
|
288
|
-
|
303
|
+
https://github.com/guard/guard/wiki/Add-Readline-support-to-Ruby-on-Mac-OS-X
|
304
|
+
WARN
|
289
305
|
return
|
290
306
|
end
|
291
307
|
|
292
308
|
trap :WINCH do
|
293
309
|
begin
|
294
|
-
Readline.set_screen_size(*
|
295
|
-
rescue => e
|
310
|
+
Readline.set_screen_size(*output.size)
|
311
|
+
rescue StandardError => e
|
296
312
|
warn "\nPry.auto_resize!'s Readline.set_screen_size failed: #{e}"
|
297
313
|
end
|
298
314
|
begin
|
299
315
|
Readline.refresh_line
|
300
|
-
rescue => e
|
316
|
+
rescue StandardError => e
|
301
317
|
warn "\nPry.auto_resize!'s Readline.refresh_line failed: #{e}"
|
302
318
|
end
|
303
319
|
end
|
@@ -306,7 +322,9 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
|
|
306
322
|
# Set all the configurable options back to their default values
|
307
323
|
def self.reset_defaults
|
308
324
|
@initial_session = true
|
309
|
-
|
325
|
+
@session_finalized = nil
|
326
|
+
|
327
|
+
self.config = Pry::Config.new
|
310
328
|
self.cli = false
|
311
329
|
self.current_line = 1
|
312
330
|
self.line_buffer = [""]
|
@@ -326,15 +344,10 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
|
|
326
344
|
# @param [Object] target The object to get a `Binding` object for.
|
327
345
|
# @return [Binding] The `Binding` object.
|
328
346
|
def self.binding_for(target)
|
329
|
-
if Binding === target
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
TOPLEVEL_BINDING
|
334
|
-
else
|
335
|
-
target.__binding__
|
336
|
-
end
|
337
|
-
end
|
347
|
+
return target if Binding === target # rubocop:disable Style/CaseEquality
|
348
|
+
return TOPLEVEL_BINDING if Pry.main == target
|
349
|
+
|
350
|
+
target.__binding__
|
338
351
|
end
|
339
352
|
|
340
353
|
def self.toplevel_binding
|
@@ -354,8 +367,8 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
|
|
354
367
|
@toplevel_binding
|
355
368
|
end
|
356
369
|
|
357
|
-
|
358
|
-
|
370
|
+
class << self
|
371
|
+
attr_writer :toplevel_binding
|
359
372
|
end
|
360
373
|
|
361
374
|
def self.in_critical_section?
|
@@ -363,7 +376,7 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
|
|
363
376
|
Thread.current[:pry_critical_section] > 0
|
364
377
|
end
|
365
378
|
|
366
|
-
def self.critical_section
|
379
|
+
def self.critical_section
|
367
380
|
Thread.current[:pry_critical_section] ||= 0
|
368
381
|
Thread.current[:pry_critical_section] += 1
|
369
382
|
yield
|