pry 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +162 -1
- data/LICENSE +1 -1
- data/README.md +331 -269
- data/bin/pry +5 -0
- data/lib/pry.rb +132 -119
- data/lib/pry/basic_object.rb +8 -4
- data/lib/pry/block_command.rb +22 -0
- data/lib/pry/class_command.rb +194 -0
- data/lib/pry/cli.rb +43 -51
- data/lib/pry/code.rb +40 -28
- data/lib/pry/code/code_file.rb +28 -24
- data/lib/pry/code/code_range.rb +4 -2
- data/lib/pry/code/loc.rb +15 -8
- data/lib/pry/code_object.rb +40 -38
- data/lib/pry/color_printer.rb +47 -46
- data/lib/pry/command.rb +166 -369
- data/lib/pry/command_set.rb +76 -73
- data/lib/pry/command_state.rb +31 -0
- data/lib/pry/commands/amend_line.rb +86 -81
- data/lib/pry/commands/bang.rb +18 -14
- data/lib/pry/commands/bang_pry.rb +15 -11
- data/lib/pry/commands/cat.rb +61 -54
- data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
- data/lib/pry/commands/cat/exception_formatter.rb +71 -60
- data/lib/pry/commands/cat/file_formatter.rb +55 -49
- data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
- data/lib/pry/commands/cd.rb +40 -35
- data/lib/pry/commands/change_inspector.rb +29 -22
- data/lib/pry/commands/change_prompt.rb +44 -39
- data/lib/pry/commands/clear_screen.rb +16 -10
- data/lib/pry/commands/code_collector.rb +148 -133
- data/lib/pry/commands/disable_pry.rb +23 -19
- data/lib/pry/commands/easter_eggs.rb +19 -30
- data/lib/pry/commands/edit.rb +184 -161
- 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/exit.rb +39 -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 -160
- data/lib/pry/commands/fix_indent.rb +16 -12
- data/lib/pry/commands/help.rb +140 -133
- data/lib/pry/commands/hist.rb +151 -150
- data/lib/pry/commands/import_set.rb +20 -16
- data/lib/pry/commands/jump_to.rb +25 -21
- data/lib/pry/commands/list_inspectors.rb +35 -28
- data/lib/pry/commands/ls.rb +124 -102
- data/lib/pry/commands/ls/constants.rb +59 -42
- data/lib/pry/commands/ls/formatter.rb +50 -46
- data/lib/pry/commands/ls/globals.rb +38 -34
- data/lib/pry/commands/ls/grep.rb +17 -13
- data/lib/pry/commands/ls/instance_vars.rb +29 -27
- 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 -22
- data/lib/pry/commands/ls/local_vars.rb +38 -28
- data/lib/pry/commands/ls/ls_entity.rb +47 -51
- data/lib/pry/commands/ls/methods.rb +44 -43
- data/lib/pry/commands/ls/methods_helper.rb +46 -42
- data/lib/pry/commands/ls/self_methods.rb +23 -22
- data/lib/pry/commands/nesting.rb +21 -17
- data/lib/pry/commands/play.rb +93 -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 +27 -22
- data/lib/pry/commands/reload_code.rb +60 -48
- data/lib/pry/commands/reset.rb +16 -12
- data/lib/pry/commands/ri.rb +55 -45
- data/lib/pry/commands/save_file.rb +45 -43
- data/lib/pry/commands/shell_command.rb +51 -51
- data/lib/pry/commands/shell_mode.rb +21 -17
- data/lib/pry/commands/show_doc.rb +80 -68
- data/lib/pry/commands/show_info.rb +189 -171
- data/lib/pry/commands/show_input.rb +16 -11
- data/lib/pry/commands/show_source.rb +110 -45
- 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.rb +89 -86
- data/lib/pry/commands/watch_expression/expression.rb +32 -27
- data/lib/pry/commands/whereami.rb +156 -148
- data/lib/pry/commands/wtf.rb +75 -50
- data/lib/pry/config.rb +307 -25
- 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/control_d_handler.rb +28 -0
- data/lib/pry/core_extensions.rb +9 -7
- data/lib/pry/editor.rb +48 -21
- data/lib/pry/env.rb +18 -0
- data/lib/pry/exception_handler.rb +43 -0
- data/lib/pry/exceptions.rb +13 -16
- data/lib/pry/forwardable.rb +5 -1
- data/lib/pry/helpers.rb +2 -0
- data/lib/pry/helpers/base_helpers.rb +68 -197
- data/lib/pry/helpers/command_helpers.rb +50 -61
- data/lib/pry/helpers/documentation_helpers.rb +20 -13
- data/lib/pry/helpers/options_helpers.rb +14 -7
- data/lib/pry/helpers/platform.rb +7 -5
- data/lib/pry/helpers/table.rb +33 -26
- data/lib/pry/helpers/text.rb +17 -14
- data/lib/pry/history.rb +48 -56
- data/lib/pry/hooks.rb +21 -12
- data/lib/pry/indent.rb +54 -50
- data/lib/pry/input_completer.rb +248 -230
- data/lib/pry/input_lock.rb +8 -9
- data/lib/pry/inspector.rb +36 -24
- data/lib/pry/last_exception.rb +45 -45
- data/lib/pry/method.rb +141 -94
- data/lib/pry/method/disowned.rb +16 -4
- data/lib/pry/method/patcher.rb +12 -3
- data/lib/pry/method/weird_method_locator.rb +68 -44
- data/lib/pry/object_path.rb +33 -25
- data/lib/pry/output.rb +121 -35
- data/lib/pry/pager.rb +186 -180
- data/lib/pry/prompt.rb +123 -54
- data/lib/pry/pry_class.rb +61 -103
- data/lib/pry/pry_instance.rb +217 -215
- data/lib/pry/repl.rb +18 -22
- data/lib/pry/repl_file_loader.rb +27 -21
- data/lib/pry/ring.rb +11 -6
- data/lib/pry/slop.rb +574 -563
- data/lib/pry/slop/commands.rb +164 -169
- data/lib/pry/slop/option.rb +172 -168
- data/lib/pry/syntax_highlighter.rb +26 -0
- data/lib/pry/system_command_handler.rb +17 -0
- data/lib/pry/testable.rb +59 -61
- data/lib/pry/testable/evalable.rb +21 -12
- data/lib/pry/testable/mockable.rb +18 -10
- data/lib/pry/testable/pry_tester.rb +71 -56
- data/lib/pry/testable/utility.rb +29 -21
- data/lib/pry/testable/variables.rb +49 -43
- data/lib/pry/version.rb +3 -1
- data/lib/pry/warning.rb +27 -0
- data/lib/pry/wrapped_module.rb +51 -42
- data/lib/pry/wrapped_module/candidate.rb +21 -14
- metadata +35 -35
- data/lib/pry/commands.rb +0 -6
- 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/gem_readme.rb +0 -25
- data/lib/pry/commands/gem_search.rb +0 -40
- data/lib/pry/commands/gem_stats.rb +0 -83
- data/lib/pry/commands/gist.rb +0 -102
- data/lib/pry/commands/install_command.rb +0 -54
- data/lib/pry/config/behavior.rb +0 -255
- data/lib/pry/config/convenience.rb +0 -28
- data/lib/pry/config/default.rb +0 -159
- data/lib/pry/config/memoization.rb +0 -48
- data/lib/pry/platform.rb +0 -91
- data/lib/pry/plugins.rb +0 -122
- data/lib/pry/rubygem.rb +0 -84
- data/lib/pry/terminal.rb +0 -91
@@ -1,46 +1,52 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# @example
|
4
|
-
# temporary_constants(:Foo, :Bar) do
|
5
|
-
# Foo = Class.new(RuntimeError)
|
6
|
-
# Bar = Class.new(RuntimeError)
|
7
|
-
# end
|
8
|
-
# Foo # => NameError
|
9
|
-
# Bar # => NameError
|
10
|
-
#
|
11
|
-
# @param [Array<Symbol>] names
|
12
|
-
# An array of constant names that be defined by a block,
|
13
|
-
# and removed by this method afterwards.
|
14
|
-
#
|
15
|
-
# @return [void]
|
16
|
-
#
|
17
|
-
def temporary_constants(*names)
|
18
|
-
names.each do |name|
|
19
|
-
Object.remove_const name if Object.const_defined?(name)
|
20
|
-
end
|
21
|
-
yield
|
22
|
-
ensure
|
23
|
-
names.each do |name|
|
24
|
-
Object.remove_const name if Object.const_defined?(name)
|
25
|
-
end
|
26
|
-
end
|
1
|
+
# frozen_string_literal: true
|
27
2
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
3
|
+
class Pry
|
4
|
+
module Testable
|
5
|
+
module Variables
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# temporary_constants(:Foo, :Bar) do
|
9
|
+
# Foo = Class.new(RuntimeError)
|
10
|
+
# Bar = Class.new(RuntimeError)
|
11
|
+
# end
|
12
|
+
# Foo # => NameError
|
13
|
+
# Bar # => NameError
|
14
|
+
#
|
15
|
+
# @param [Array<Symbol>] names
|
16
|
+
# An array of constant names that be defined by a block,
|
17
|
+
# and removed by this method afterwards.
|
18
|
+
#
|
19
|
+
# @return [void]
|
20
|
+
#
|
21
|
+
def temporary_constants(*names)
|
22
|
+
names.each do |name|
|
23
|
+
Object.remove_const name if Object.const_defined?(name)
|
24
|
+
end
|
25
|
+
yield
|
26
|
+
ensure
|
27
|
+
names.each do |name|
|
28
|
+
Object.remove_const name if Object.const_defined?(name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# @param [String] name
|
34
|
+
# The name of a variable.
|
35
|
+
#
|
36
|
+
# @param [String] value
|
37
|
+
# Its value.
|
38
|
+
#
|
39
|
+
# @param [Binding] binding
|
40
|
+
# The binding object to insert a variable into.
|
41
|
+
#
|
42
|
+
# @return [void]
|
43
|
+
#
|
44
|
+
def insert_variable(name, value, binding)
|
45
|
+
Pry.current[:pry_local] = value
|
46
|
+
binding.eval("#{name} = ::Pry.current[:pry_local]")
|
47
|
+
ensure
|
48
|
+
Pry.current[:pry_local] = nil
|
49
|
+
end
|
50
|
+
end
|
45
51
|
end
|
46
52
|
end
|
data/lib/pry/version.rb
CHANGED
data/lib/pry/warning.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
# @api private
|
5
|
+
# @since v0.13.0
|
6
|
+
module Warning
|
7
|
+
# Prints a warning message with exact file and line location, similar to how
|
8
|
+
# Ruby's -W prints warnings.
|
9
|
+
#
|
10
|
+
# @param [String] message
|
11
|
+
# @return [void]
|
12
|
+
def self.warn(message)
|
13
|
+
if Kernel.respond_to?(:caller_locations)
|
14
|
+
location = caller_locations(2..2).first
|
15
|
+
path = location.path
|
16
|
+
lineno = location.lineno
|
17
|
+
else
|
18
|
+
# Ruby 1.9.3 support.
|
19
|
+
frame = caller[1].split(':') # rubocop:disable Performance/Caller
|
20
|
+
path = frame.first
|
21
|
+
lineno = frame[1]
|
22
|
+
end
|
23
|
+
|
24
|
+
Kernel.warn("#{path}:#{lineno}: warning: #{message}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/pry/wrapped_module.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Pry
|
4
4
|
class << self
|
@@ -27,11 +27,7 @@ class Pry
|
|
27
27
|
# @example
|
28
28
|
# Pry::WrappedModule.from_str("Pry::Code")
|
29
29
|
def self.from_str(mod_name, target = TOPLEVEL_BINDING)
|
30
|
-
if safe_to_evaluate?(mod_name, target)
|
31
|
-
Pry::WrappedModule.new(target.eval(mod_name))
|
32
|
-
else
|
33
|
-
nil
|
34
|
-
end
|
30
|
+
Pry::WrappedModule.new(target.eval(mod_name)) if safe_to_evaluate?(mod_name, target)
|
35
31
|
rescue RescuableException
|
36
32
|
nil
|
37
33
|
end
|
@@ -58,7 +54,10 @@ class Pry
|
|
58
54
|
# @raise [ArgumentError] if the argument is not a `Module`
|
59
55
|
# @param [Module] mod
|
60
56
|
def initialize(mod)
|
61
|
-
|
57
|
+
unless mod.is_a?(Module)
|
58
|
+
raise ArgumentError, "Tried to initialize a WrappedModule with a " \
|
59
|
+
"non-module #{mod.inspect}"
|
60
|
+
end
|
62
61
|
|
63
62
|
@wrapped = mod
|
64
63
|
@memoized_candidates = []
|
@@ -85,7 +84,7 @@ class Pry
|
|
85
84
|
# @return String
|
86
85
|
def method_prefix
|
87
86
|
if singleton_class?
|
88
|
-
if Module === singleton_instance
|
87
|
+
if Module === singleton_instance # rubocop:disable Style/CaseEquality
|
89
88
|
"#{WrappedModule.new(singleton_instance).nonblank_name}."
|
90
89
|
else
|
91
90
|
"self."
|
@@ -134,22 +133,30 @@ class Pry
|
|
134
133
|
#
|
135
134
|
# @return [Object]
|
136
135
|
def singleton_instance
|
137
|
-
|
136
|
+
unless singleton_class?
|
137
|
+
raise ArgumentError, "tried to get instance of non singleton class"
|
138
|
+
end
|
138
139
|
|
139
140
|
if Helpers::Platform.jruby?
|
140
141
|
wrapped.to_java.attached
|
141
142
|
else
|
142
|
-
@singleton_instance ||= ObjectSpace.each_object(wrapped).detect
|
143
|
+
@singleton_instance ||= ObjectSpace.each_object(wrapped).detect do |x|
|
144
|
+
(class << x; self; end) == wrapped
|
145
|
+
end
|
143
146
|
end
|
144
147
|
end
|
145
148
|
|
146
149
|
# Forward method invocations to the wrapped module
|
147
150
|
def method_missing(method_name, *args, &block)
|
148
|
-
wrapped.
|
151
|
+
if wrapped.respond_to?(method_name)
|
152
|
+
wrapped.send(method_name, *args, &block)
|
153
|
+
else
|
154
|
+
super
|
155
|
+
end
|
149
156
|
end
|
150
157
|
|
151
|
-
def
|
152
|
-
|
158
|
+
def respond_to_missing?(method_name, include_private = false)
|
159
|
+
wrapped.respond_to?(method_name, include_private) || super
|
153
160
|
end
|
154
161
|
|
155
162
|
# Retrieve the source location of a module. Return value is in same
|
@@ -169,14 +176,14 @@ class Pry
|
|
169
176
|
def file
|
170
177
|
Array(source_location).first
|
171
178
|
end
|
172
|
-
|
179
|
+
alias source_file file
|
173
180
|
|
174
181
|
# @return [Fixnum, nil] The associated line for the module (i.e
|
175
182
|
# the primary candidate: highest ranked monkeypatch).
|
176
183
|
def line
|
177
184
|
Array(source_location).last
|
178
185
|
end
|
179
|
-
|
186
|
+
alias source_line line
|
180
187
|
|
181
188
|
# Returns documentation for the module.
|
182
189
|
# This documentation is for the primary candidate, if
|
@@ -247,10 +254,10 @@ class Pry
|
|
247
254
|
# other rubies returns Enumerator
|
248
255
|
def candidates
|
249
256
|
enum = Enumerator.new do |y|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
257
|
+
(0...number_of_candidates).each do |num|
|
258
|
+
y.yield candidate(num)
|
259
|
+
end
|
260
|
+
end
|
254
261
|
Helpers::Platform.jruby_19? ? enum.to_a : enum
|
255
262
|
end
|
256
263
|
|
@@ -268,11 +275,12 @@ class Pry
|
|
268
275
|
def super(times = 1)
|
269
276
|
return self if times.zero?
|
270
277
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
278
|
+
sup =
|
279
|
+
if wrapped.is_a?(Class)
|
280
|
+
ancestors.select { |v| v.is_a?(Class) }[times]
|
281
|
+
else
|
282
|
+
ancestors[times]
|
283
|
+
end
|
276
284
|
|
277
285
|
Pry::WrappedModule(sup) if sup
|
278
286
|
end
|
@@ -287,9 +295,7 @@ class Pry
|
|
287
295
|
# candidate of rank 0 will be returned, or a CommandError raised if
|
288
296
|
# there are no candidates at all.
|
289
297
|
def primary_candidate
|
290
|
-
@primary_candidate ||= candidates.find
|
291
|
-
# This will raise an exception if there is no candidate at all.
|
292
|
-
candidate(0)
|
298
|
+
@primary_candidate ||= candidates.find(&:file) || candidate(0)
|
293
299
|
end
|
294
300
|
|
295
301
|
# @return [Array<Array<Pry::Method>>] The array of `Pry::Method` objects,
|
@@ -309,14 +315,16 @@ class Pry
|
|
309
315
|
def all_source_locations_by_popularity
|
310
316
|
return @all_source_locations_by_popularity if @all_source_locations_by_popularity
|
311
317
|
|
312
|
-
ims = all_relevant_methods_for(wrapped)
|
313
|
-
|
314
|
-
|
315
|
-
expanded = File.expand_path(path)
|
316
|
-
load_order = $LOADED_FEATURES.index { |file| expanded.end_with?(file) }
|
318
|
+
ims = all_relevant_methods_for(wrapped).group_by do |v|
|
319
|
+
Array(v.source_location).first
|
320
|
+
end
|
317
321
|
|
318
|
-
|
319
|
-
|
322
|
+
@all_source_locations_by_popularity = ims.sort_by do |path, methods|
|
323
|
+
expanded = File.expand_path(path)
|
324
|
+
load_order = $LOADED_FEATURES.index { |file| expanded.end_with?(file) }
|
325
|
+
|
326
|
+
[-methods.size, load_order || (1.0 / 0.0)]
|
327
|
+
end
|
320
328
|
end
|
321
329
|
|
322
330
|
# We only want methods that have a non-nil `source_location`. We also
|
@@ -324,8 +332,8 @@ class Pry
|
|
324
332
|
#
|
325
333
|
# @return [Array<Pry::Method>]
|
326
334
|
def all_relevant_methods_for(mod)
|
327
|
-
methods = all_methods_for(mod).select(&:source_location)
|
328
|
-
reject { |x| method_defined_by_forwardable_module?(x) }
|
335
|
+
methods = all_methods_for(mod).select(&:source_location)
|
336
|
+
.reject { |x| method_defined_by_forwardable_module?(x) }
|
329
337
|
|
330
338
|
return methods unless methods.empty?
|
331
339
|
|
@@ -349,7 +357,7 @@ class Pry
|
|
349
357
|
return if safe_send(parent, :autoload?, name)
|
350
358
|
|
351
359
|
child = safe_send(parent, :const_get, name)
|
352
|
-
return unless Module
|
360
|
+
return unless child.is_a?(Module)
|
353
361
|
return unless safe_send(child, :name) == "#{safe_send(parent, :name)}::#{name}"
|
354
362
|
|
355
363
|
child
|
@@ -368,11 +376,12 @@ class Pry
|
|
368
376
|
def lines_for_file(file)
|
369
377
|
@lines_for_file ||= {}
|
370
378
|
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
379
|
+
@lines_for_file[file] ||=
|
380
|
+
if file == Pry.eval_path
|
381
|
+
Pry.line_buffer.drop(1)
|
382
|
+
else
|
383
|
+
File.readlines(file)
|
384
|
+
end
|
376
385
|
end
|
377
386
|
end
|
378
387
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Pry
|
4
4
|
class WrappedModule
|
@@ -12,11 +12,11 @@ class Pry
|
|
12
12
|
|
13
13
|
# @return [String] The file where the module definition is located.
|
14
14
|
attr_reader :file
|
15
|
-
|
15
|
+
alias source_file file
|
16
16
|
|
17
17
|
# @return [Fixnum] The line where the module definition is located.
|
18
18
|
attr_reader :line
|
19
|
-
|
19
|
+
alias source_line line
|
20
20
|
|
21
21
|
# Methods to delegate to associated `Pry::WrappedModule
|
22
22
|
# instance`.
|
@@ -40,8 +40,12 @@ class Pry
|
|
40
40
|
|
41
41
|
if number_of_candidates <= 0
|
42
42
|
raise CommandError, "Cannot find a definition for #{name} module!"
|
43
|
-
|
44
|
-
|
43
|
+
end
|
44
|
+
|
45
|
+
if rank > (number_of_candidates - 1)
|
46
|
+
raise CommandError,
|
47
|
+
"No such module candidate. Allowed candidates range is " \
|
48
|
+
"from 0 to #{number_of_candidates - 1}"
|
45
49
|
end
|
46
50
|
|
47
51
|
@source = @source_location = nil
|
@@ -56,7 +60,9 @@ class Pry
|
|
56
60
|
return nil if file.nil?
|
57
61
|
return @source if @source
|
58
62
|
|
59
|
-
@source ||= strip_leading_whitespace(
|
63
|
+
@source ||= strip_leading_whitespace(
|
64
|
+
Pry::Code.from_file(file).expression_at(line, number_of_lines_in_first_chunk)
|
65
|
+
)
|
60
66
|
end
|
61
67
|
|
62
68
|
# @raise [Pry::CommandError] If documentation cannot be found.
|
@@ -74,7 +80,7 @@ class Pry
|
|
74
80
|
return @source_location if @source_location
|
75
81
|
|
76
82
|
file, line = first_method_source_location
|
77
|
-
return nil
|
83
|
+
return nil unless file.is_a?(String)
|
78
84
|
|
79
85
|
@source_location = [file, first_line_of_module_definition(file, line)]
|
80
86
|
rescue Pry::RescuableException
|
@@ -97,7 +103,7 @@ class Pry
|
|
97
103
|
|
98
104
|
def class_regexes
|
99
105
|
mod_type_string = wrapped.class.to_s.downcase
|
100
|
-
[
|
106
|
+
[/(^|=)\s*#{mod_type_string}\s+(?:(?:\w*)::)*?#{wrapped.name.split(/::/).last}/,
|
101
107
|
/^\s*(::)?#{wrapped.name.split(/::/).last}\s*?=\s*?#{wrapped.class}/,
|
102
108
|
/^\s*(::)?#{wrapped.name.split(/::/).last}\.(class|instance)_eval/]
|
103
109
|
end
|
@@ -113,14 +119,15 @@ class Pry
|
|
113
119
|
# @return [Array] The source location of the last method in this
|
114
120
|
# candidate's module definition.
|
115
121
|
def last_method_source_location
|
116
|
-
@
|
122
|
+
@last_method_source_location ||= method_candidates[@rank].last.source_location
|
117
123
|
end
|
118
124
|
|
119
|
-
# Return the number of lines between the start of the class definition
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
125
|
+
# Return the number of lines between the start of the class definition and
|
126
|
+
# the start of the last method. We use this value so we can quickly grab
|
127
|
+
# these lines from the file (without having to check each intervening line
|
128
|
+
# for validity, which is expensive) speeding up source extraction.
|
129
|
+
#
|
130
|
+
# @return [Integer] number of lines.
|
124
131
|
def number_of_lines_in_first_chunk
|
125
132
|
end_method_line = last_method_source_location.last
|
126
133
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mair (banisterfiend)
|
@@ -11,37 +11,40 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-02-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
+
name: coderay
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
18
19
|
requirements:
|
19
20
|
- - "~>"
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.1
|
22
|
-
name: coderay
|
23
|
-
prerelease: false
|
22
|
+
version: '1.1'
|
24
23
|
type: :runtime
|
24
|
+
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.1
|
29
|
+
version: '1.1'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
+
name: method_source
|
31
32
|
requirement: !ruby/object:Gem::Requirement
|
32
33
|
requirements:
|
33
34
|
- - "~>"
|
34
35
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
36
|
-
name: method_source
|
37
|
-
prerelease: false
|
36
|
+
version: '1.0'
|
38
37
|
type: :runtime
|
38
|
+
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
description:
|
43
|
+
version: '1.0'
|
44
|
+
description: |
|
45
|
+
Pry is a runtime developer console and IRB alternative with powerful
|
46
|
+
introspection capabilities. Pry aims to be more than an IRB replacement. It is
|
47
|
+
an attempt to bring REPL driven programming to the Ruby language.
|
45
48
|
email:
|
46
49
|
- jrmair@gmail.com
|
47
50
|
- conrad.irwin@gmail.com
|
@@ -58,6 +61,8 @@ files:
|
|
58
61
|
- bin/pry
|
59
62
|
- lib/pry.rb
|
60
63
|
- lib/pry/basic_object.rb
|
64
|
+
- lib/pry/block_command.rb
|
65
|
+
- lib/pry/class_command.rb
|
61
66
|
- lib/pry/cli.rb
|
62
67
|
- lib/pry/code.rb
|
63
68
|
- lib/pry/code/code_file.rb
|
@@ -67,7 +72,7 @@ files:
|
|
67
72
|
- lib/pry/color_printer.rb
|
68
73
|
- lib/pry/command.rb
|
69
74
|
- lib/pry/command_set.rb
|
70
|
-
- lib/pry/
|
75
|
+
- lib/pry/command_state.rb
|
71
76
|
- lib/pry/commands/amend_line.rb
|
72
77
|
- lib/pry/commands/bang.rb
|
73
78
|
- lib/pry/commands/bang_pry.rb
|
@@ -82,7 +87,6 @@ files:
|
|
82
87
|
- lib/pry/commands/clear_screen.rb
|
83
88
|
- lib/pry/commands/code_collector.rb
|
84
89
|
- lib/pry/commands/disable_pry.rb
|
85
|
-
- lib/pry/commands/disabled_commands.rb
|
86
90
|
- lib/pry/commands/easter_eggs.rb
|
87
91
|
- lib/pry/commands/edit.rb
|
88
92
|
- lib/pry/commands/edit/exception_patcher.rb
|
@@ -92,18 +96,9 @@ files:
|
|
92
96
|
- lib/pry/commands/exit_program.rb
|
93
97
|
- lib/pry/commands/find_method.rb
|
94
98
|
- lib/pry/commands/fix_indent.rb
|
95
|
-
- lib/pry/commands/gem_cd.rb
|
96
|
-
- lib/pry/commands/gem_install.rb
|
97
|
-
- lib/pry/commands/gem_list.rb
|
98
|
-
- lib/pry/commands/gem_open.rb
|
99
|
-
- lib/pry/commands/gem_readme.rb
|
100
|
-
- lib/pry/commands/gem_search.rb
|
101
|
-
- lib/pry/commands/gem_stats.rb
|
102
|
-
- lib/pry/commands/gist.rb
|
103
99
|
- lib/pry/commands/help.rb
|
104
100
|
- lib/pry/commands/hist.rb
|
105
101
|
- lib/pry/commands/import_set.rb
|
106
|
-
- lib/pry/commands/install_command.rb
|
107
102
|
- lib/pry/commands/jump_to.rb
|
108
103
|
- lib/pry/commands/list_inspectors.rb
|
109
104
|
- lib/pry/commands/ls.rb
|
@@ -143,12 +138,15 @@ files:
|
|
143
138
|
- lib/pry/commands/whereami.rb
|
144
139
|
- lib/pry/commands/wtf.rb
|
145
140
|
- lib/pry/config.rb
|
146
|
-
- lib/pry/config/
|
147
|
-
- lib/pry/config/
|
148
|
-
- lib/pry/config/
|
149
|
-
- lib/pry/config/
|
141
|
+
- lib/pry/config/attributable.rb
|
142
|
+
- lib/pry/config/lazy_value.rb
|
143
|
+
- lib/pry/config/memoized_value.rb
|
144
|
+
- lib/pry/config/value.rb
|
145
|
+
- lib/pry/control_d_handler.rb
|
150
146
|
- lib/pry/core_extensions.rb
|
151
147
|
- lib/pry/editor.rb
|
148
|
+
- lib/pry/env.rb
|
149
|
+
- lib/pry/exception_handler.rb
|
152
150
|
- lib/pry/exceptions.rb
|
153
151
|
- lib/pry/forwardable.rb
|
154
152
|
- lib/pry/helpers.rb
|
@@ -173,20 +171,18 @@ files:
|
|
173
171
|
- lib/pry/object_path.rb
|
174
172
|
- lib/pry/output.rb
|
175
173
|
- lib/pry/pager.rb
|
176
|
-
- lib/pry/platform.rb
|
177
|
-
- lib/pry/plugins.rb
|
178
174
|
- lib/pry/prompt.rb
|
179
175
|
- lib/pry/pry_class.rb
|
180
176
|
- lib/pry/pry_instance.rb
|
181
177
|
- lib/pry/repl.rb
|
182
178
|
- lib/pry/repl_file_loader.rb
|
183
179
|
- lib/pry/ring.rb
|
184
|
-
- lib/pry/rubygem.rb
|
185
180
|
- lib/pry/slop.rb
|
186
181
|
- lib/pry/slop/LICENSE
|
187
182
|
- lib/pry/slop/commands.rb
|
188
183
|
- lib/pry/slop/option.rb
|
189
|
-
- lib/pry/
|
184
|
+
- lib/pry/syntax_highlighter.rb
|
185
|
+
- lib/pry/system_command_handler.rb
|
190
186
|
- lib/pry/testable.rb
|
191
187
|
- lib/pry/testable/evalable.rb
|
192
188
|
- lib/pry/testable/mockable.rb
|
@@ -194,12 +190,16 @@ files:
|
|
194
190
|
- lib/pry/testable/utility.rb
|
195
191
|
- lib/pry/testable/variables.rb
|
196
192
|
- lib/pry/version.rb
|
193
|
+
- lib/pry/warning.rb
|
197
194
|
- lib/pry/wrapped_module.rb
|
198
195
|
- lib/pry/wrapped_module/candidate.rb
|
199
|
-
homepage: http://
|
196
|
+
homepage: http://pry.github.io
|
200
197
|
licenses:
|
201
198
|
- MIT
|
202
|
-
metadata:
|
199
|
+
metadata:
|
200
|
+
changelog_uri: https://github.com/pry/pry/blob/master/CHANGELOG.md
|
201
|
+
source_code_uri: https://github.com/pry/pry
|
202
|
+
bug_tracker_uri: https://github.com/pry/pry/issues
|
203
203
|
post_install_message:
|
204
204
|
rdoc_options: []
|
205
205
|
require_paths:
|
@@ -215,9 +215,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
|
-
|
219
|
-
rubygems_version: 2.7.6
|
218
|
+
rubygems_version: 3.1.2
|
220
219
|
signing_key:
|
221
220
|
specification_version: 4
|
222
|
-
summary:
|
221
|
+
summary: A runtime developer console and IRB alternative with powerful introspection
|
222
|
+
capabilities.
|
223
223
|
test_files: []
|