pry 0.10.3 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +251 -16
- data/LICENSE +1 -1
- data/README.md +35 -51
- data/bin/pry +3 -11
- data/lib/pry/basic_object.rb +6 -0
- data/lib/pry/cli.rb +50 -52
- data/lib/pry/code/code_file.rb +13 -6
- data/lib/pry/code/code_range.rb +3 -3
- data/lib/pry/code/loc.rb +14 -8
- data/lib/pry/code.rb +12 -5
- data/lib/pry/code_object.rb +27 -4
- data/lib/pry/color_printer.rb +20 -10
- data/lib/pry/command.rb +76 -45
- data/lib/pry/command_set.rb +17 -45
- data/lib/pry/commands/amend_line.rb +3 -4
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat/exception_formatter.rb +10 -8
- data/lib/pry/commands/cat/file_formatter.rb +7 -3
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cat.rb +7 -6
- data/lib/pry/commands/change_prompt.rb +29 -9
- data/lib/pry/commands/clear_screen.rb +14 -0
- data/lib/pry/commands/code_collector.rb +25 -23
- data/lib/pry/commands/easter_eggs.rb +12 -12
- data/lib/pry/commands/edit/file_and_line_locator.rb +1 -1
- data/lib/pry/commands/edit.rb +15 -10
- data/lib/pry/commands/exit.rb +2 -1
- data/lib/pry/commands/find_method.rb +12 -14
- data/lib/pry/commands/gem_cd.rb +1 -1
- data/lib/pry/commands/gem_install.rb +2 -2
- data/lib/pry/commands/gem_list.rb +2 -2
- data/lib/pry/commands/gem_open.rb +2 -2
- data/lib/pry/commands/gem_readme.rb +25 -0
- data/lib/pry/commands/gem_search.rb +40 -0
- data/lib/pry/commands/gem_stats.rb +83 -0
- data/lib/pry/commands/gist.rb +7 -6
- data/lib/pry/commands/help.rb +3 -3
- data/lib/pry/commands/hist.rb +11 -10
- data/lib/pry/commands/import_set.rb +2 -1
- data/lib/pry/commands/install_command.rb +7 -6
- data/lib/pry/commands/jump_to.rb +7 -7
- data/lib/pry/commands/list_inspectors.rb +2 -2
- data/lib/pry/commands/ls/constants.rb +14 -3
- data/lib/pry/commands/ls/formatter.rb +4 -2
- data/lib/pry/commands/ls/globals.rb +0 -2
- data/lib/pry/commands/ls/grep.rb +0 -2
- data/lib/pry/commands/ls/instance_vars.rb +0 -1
- data/lib/pry/commands/ls/jruby_hacks.rb +2 -2
- data/lib/pry/commands/ls/local_names.rb +0 -2
- data/lib/pry/commands/ls/local_vars.rb +0 -2
- data/lib/pry/commands/ls/ls_entity.rb +0 -1
- data/lib/pry/commands/ls/methods.rb +0 -3
- data/lib/pry/commands/ls/methods_helper.rb +1 -1
- data/lib/pry/commands/ls/self_methods.rb +2 -1
- data/lib/pry/commands/ls.rb +30 -31
- data/lib/pry/commands/play.rb +3 -4
- data/lib/pry/commands/pry_backtrace.rb +1 -1
- data/lib/pry/commands/raise_up.rb +2 -1
- data/lib/pry/commands/reload_code.rb +2 -2
- data/lib/pry/commands/ri.rb +9 -4
- data/lib/pry/commands/shell_command.rb +36 -9
- data/lib/pry/commands/shell_mode.rb +6 -6
- data/lib/pry/commands/show_doc.rb +5 -7
- data/lib/pry/commands/show_info.rb +41 -20
- data/lib/pry/commands/show_source.rb +5 -2
- data/lib/pry/commands/stat.rb +1 -1
- data/lib/pry/commands/watch_expression/expression.rb +1 -1
- data/lib/pry/commands/watch_expression.rb +9 -7
- data/lib/pry/commands/whereami.rb +16 -9
- data/lib/pry/commands/wtf.rb +15 -2
- data/lib/pry/config/behavior.rb +230 -114
- data/lib/pry/config/convenience.rb +24 -21
- data/lib/pry/config/default.rb +151 -153
- data/lib/pry/config/memoization.rb +48 -0
- data/lib/pry/config.rb +30 -19
- data/lib/pry/core_extensions.rb +15 -4
- data/lib/pry/editor.rb +5 -12
- data/lib/pry/exceptions.rb +1 -3
- data/lib/pry/forwardable.rb +23 -0
- data/lib/pry/helpers/base_helpers.rb +197 -110
- data/lib/pry/helpers/command_helpers.rb +5 -4
- data/lib/pry/helpers/documentation_helpers.rb +3 -2
- data/lib/pry/helpers/options_helpers.rb +6 -6
- data/lib/pry/helpers/platform.rb +58 -0
- data/lib/pry/helpers/table.rb +20 -15
- data/lib/pry/helpers/text.rb +82 -74
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/history.rb +44 -10
- data/lib/pry/hooks.rb +50 -109
- data/lib/pry/indent.rb +21 -19
- data/lib/pry/input_completer.rb +146 -123
- data/lib/pry/input_lock.rb +0 -2
- data/lib/pry/last_exception.rb +2 -2
- data/lib/pry/method/disowned.rb +3 -1
- data/lib/pry/method/patcher.rb +2 -5
- data/lib/pry/method/weird_method_locator.rb +21 -11
- data/lib/pry/method.rb +44 -38
- data/lib/pry/object_path.rb +5 -4
- data/lib/pry/output.rb +37 -37
- data/lib/pry/pager.rb +195 -181
- data/lib/pry/platform.rb +91 -0
- data/lib/pry/plugins.rb +27 -8
- data/lib/pry/prompt.rb +144 -25
- data/lib/pry/pry_class.rb +83 -33
- data/lib/pry/pry_instance.rb +94 -59
- data/lib/pry/repl.rb +70 -11
- data/lib/pry/repl_file_loader.rb +2 -3
- data/lib/pry/ring.rb +84 -0
- data/lib/pry/rubygem.rb +9 -7
- data/lib/pry/slop/LICENSE +20 -0
- data/lib/pry/slop/commands.rb +195 -0
- data/lib/pry/slop/option.rb +206 -0
- data/lib/pry/slop.rb +661 -0
- data/lib/pry/terminal.rb +18 -6
- data/lib/pry/testable/evalable.rb +15 -0
- data/lib/pry/testable/mockable.rb +14 -0
- data/lib/pry/testable/pry_tester.rb +73 -0
- data/lib/pry/testable/utility.rb +26 -0
- data/lib/pry/testable/variables.rb +46 -0
- data/lib/pry/testable.rb +70 -0
- data/lib/pry/version.rb +1 -1
- data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +9 -14
- data/lib/pry/wrapped_module.rb +22 -21
- data/lib/pry.rb +21 -50
- metadata +35 -46
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/simple_prompt.rb +0 -22
- data/lib/pry/history_array.rb +0 -121
- data/lib/pry/rbx_path.rb +0 -22
- data/lib/pry/test/helper.rb +0 -170
data/lib/pry/input_completer.rb
CHANGED
@@ -34,7 +34,7 @@ class Pry::InputCompleter
|
|
34
34
|
"yield" ]
|
35
35
|
|
36
36
|
Operators = [
|
37
|
-
"%", "&", "*", "**", "+",
|
37
|
+
"%", "&", "*", "**", "+", "-", "/",
|
38
38
|
"<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
|
39
39
|
"[]", "[]=", "^", "!", "!=", "!~"
|
40
40
|
]
|
@@ -92,7 +92,7 @@ class Pry::InputCompleter
|
|
92
92
|
when SYMBOL_REGEXP # Symbol
|
93
93
|
if Symbol.respond_to?(:all_symbols)
|
94
94
|
sym = Regexp.quote($1)
|
95
|
-
candidates = Symbol.all_symbols.collect{|s| ":" << s.id2name}
|
95
|
+
candidates = Symbol.all_symbols.collect { |s| ":" << s.id2name }
|
96
96
|
candidates.grep(/^#{sym}/)
|
97
97
|
else
|
98
98
|
[]
|
@@ -100,143 +100,166 @@ class Pry::InputCompleter
|
|
100
100
|
when TOPLEVEL_LOOKUP_REGEXP # Absolute Constant or class methods
|
101
101
|
receiver = $1
|
102
102
|
candidates = Object.constants.collect(&:to_s)
|
103
|
-
candidates.grep(/^#{receiver}/).collect{|e| "::" << e}
|
103
|
+
candidates.grep(/^#{receiver}/).collect { |e| "::" << e }
|
104
104
|
when CONSTANT_REGEXP # Constant
|
105
105
|
message = $1
|
106
106
|
begin
|
107
107
|
context = target.eval("self")
|
108
108
|
context = context.class unless context.respond_to? :constants
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
109
|
+
candidates = context.constants.collect(&:to_s)
|
110
|
+
rescue
|
111
|
+
candidates = []
|
112
|
+
end
|
113
|
+
candidates = candidates.grep(/^#{message}/).collect(&path)
|
114
|
+
when CONSTANT_OR_METHOD_REGEXP # Constant or class methods
|
115
|
+
receiver = $1
|
116
|
+
message = Regexp.quote($2)
|
117
|
+
begin
|
118
|
+
candidates = eval("#{receiver}.constants.collect(&:to_s)", bind)
|
119
|
+
candidates |= eval("#{receiver}.methods.collect(&:to_s)", bind)
|
120
|
+
rescue Pry::RescuableException
|
121
|
+
candidates = []
|
122
|
+
end
|
123
|
+
candidates.grep(/^#{message}/).collect { |e| receiver + "::" + e }
|
124
|
+
when SYMBOL_METHOD_CALL_REGEXP # method call on a Symbol
|
125
|
+
receiver = $1
|
126
|
+
message = Regexp.quote($2)
|
127
|
+
candidates = Symbol.instance_methods.collect(&:to_s)
|
128
|
+
select_message(path, receiver, message, candidates)
|
129
|
+
when NUMERIC_REGEXP
|
130
|
+
# Numeric
|
131
|
+
receiver = $1
|
132
|
+
message = Regexp.quote($5)
|
133
|
+
begin
|
134
|
+
candidates = eval(receiver, bind).methods.collect(&:to_s)
|
135
|
+
rescue Pry::RescuableException
|
136
|
+
candidates = []
|
137
|
+
end
|
138
|
+
select_message(path, receiver, message, candidates)
|
139
|
+
when HEX_REGEXP
|
140
|
+
# Numeric(0xFFFF)
|
141
|
+
receiver = $1
|
142
|
+
message = Regexp.quote($2)
|
143
|
+
begin
|
144
|
+
candidates = eval(receiver, bind).methods.collect(&:to_s)
|
145
|
+
rescue Pry::RescuableException
|
146
|
+
candidates = []
|
147
|
+
end
|
148
|
+
select_message(path, receiver, message, candidates)
|
149
|
+
when GLOBALVARIABLE_REGEXP # global
|
150
|
+
regmessage = Regexp.new(Regexp.quote($1))
|
151
|
+
candidates = global_variables.collect(&:to_s).grep(regmessage)
|
152
|
+
when VARIABLE_REGEXP # variable
|
153
|
+
receiver = $1
|
154
|
+
message = Regexp.quote($2)
|
155
|
+
|
156
|
+
gv = eval("global_variables", bind).collect(&:to_s)
|
157
|
+
lv = eval("local_variables", bind).collect(&:to_s)
|
158
|
+
cv = eval("self.class.constants", bind).collect(&:to_s)
|
159
|
+
|
160
|
+
if (gv | lv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
|
161
|
+
# foo.func and foo is local var. OR
|
162
|
+
# Foo::Bar.func
|
143
163
|
begin
|
144
|
-
candidates = eval(receiver, bind).
|
164
|
+
candidates = eval("#{receiver}.methods", bind).collect(&:to_s)
|
145
165
|
rescue Pry::RescuableException
|
146
166
|
candidates = []
|
147
167
|
end
|
148
|
-
select_message(path, receiver, message, candidates)
|
149
|
-
when GLOBALVARIABLE_REGEXP # global
|
150
|
-
regmessage = Regexp.new(Regexp.quote($1))
|
151
|
-
candidates = global_variables.collect(&:to_s).grep(regmessage)
|
152
|
-
when VARIABLE_REGEXP # variable
|
153
|
-
receiver = $1
|
154
|
-
message = Regexp.quote($2)
|
155
|
-
|
156
|
-
gv = eval("global_variables", bind).collect(&:to_s)
|
157
|
-
lv = eval("local_variables", bind).collect(&:to_s)
|
158
|
-
cv = eval("self.class.constants", bind).collect(&:to_s)
|
159
|
-
|
160
|
-
if (gv | lv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
|
161
|
-
# foo.func and foo is local var. OR
|
162
|
-
# Foo::Bar.func
|
163
|
-
begin
|
164
|
-
candidates = eval("#{receiver}.methods", bind).collect(&:to_s)
|
165
|
-
rescue Pry::RescuableException
|
166
|
-
candidates = []
|
167
|
-
end
|
168
|
-
else
|
169
|
-
# func1.func2
|
170
|
-
candidates = []
|
171
|
-
ObjectSpace.each_object(Module){|m|
|
172
|
-
begin
|
173
|
-
name = m.name.to_s
|
174
|
-
rescue Pry::RescuableException
|
175
|
-
name = ""
|
176
|
-
end
|
177
|
-
next if name != "IRB::Context" and
|
178
|
-
/^(IRB|SLex|RubyLex|RubyToken)/ =~ name
|
179
|
-
|
180
|
-
# jruby doesn't always provide #instance_methods() on each
|
181
|
-
# object.
|
182
|
-
if m.respond_to?(:instance_methods)
|
183
|
-
candidates.concat m.instance_methods(false).collect(&:to_s)
|
184
|
-
end
|
185
|
-
}
|
186
|
-
candidates.sort!
|
187
|
-
candidates.uniq!
|
188
|
-
end
|
189
|
-
select_message(path, receiver, message, candidates)
|
190
|
-
when /^\.([^.]*)$/
|
191
|
-
# Unknown(maybe String)
|
192
|
-
receiver = ""
|
193
|
-
message = Regexp.quote($1)
|
194
|
-
candidates = String.instance_methods(true).collect(&:to_s)
|
195
|
-
select_message(path, receiver, message, candidates)
|
196
168
|
else
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
169
|
+
# func1.func2
|
170
|
+
require 'set'
|
171
|
+
candidates = Set.new
|
172
|
+
to_ignore = ignored_modules
|
173
|
+
ObjectSpace.each_object(Module) { |m|
|
174
|
+
next if (to_ignore.include?(m) rescue true)
|
175
|
+
|
176
|
+
# jruby doesn't always provide #instance_methods() on each
|
177
|
+
# object.
|
178
|
+
if m.respond_to?(:instance_methods)
|
179
|
+
candidates.merge m.instance_methods(false).collect(&:to_s)
|
180
|
+
end
|
181
|
+
}
|
182
|
+
end
|
183
|
+
select_message(path, receiver, message, candidates.sort)
|
184
|
+
when /^\.([^.]*)$/
|
185
|
+
# Unknown(maybe String)
|
186
|
+
receiver = ""
|
187
|
+
message = Regexp.quote($1)
|
188
|
+
candidates = String.instance_methods(true).collect(&:to_s)
|
189
|
+
select_message(path, receiver, message, candidates)
|
190
|
+
else
|
191
|
+
candidates = eval(
|
192
|
+
"methods | private_methods | local_variables | " \
|
193
|
+
"self.class.constants | instance_variables",
|
194
|
+
bind
|
195
|
+
).collect(&:to_s)
|
196
|
+
|
197
|
+
if eval("respond_to?(:class_variables)", bind)
|
198
|
+
candidates += eval("class_variables", bind).collect(&:to_s)
|
208
199
|
end
|
209
|
-
|
210
|
-
|
200
|
+
candidates = (candidates | ReservedWords | custom_completions).grep(/^#{Regexp.quote(input)}/)
|
201
|
+
candidates.collect(&path)
|
211
202
|
end
|
203
|
+
rescue Pry::RescuableException
|
204
|
+
[]
|
212
205
|
end
|
206
|
+
end
|
213
207
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
208
|
+
def select_message(path, receiver, message, candidates)
|
209
|
+
candidates.grep(/^#{message}/).collect { |e|
|
210
|
+
case e
|
211
|
+
when /^[a-zA-Z_]/
|
212
|
+
path.call(receiver + "." << e)
|
213
|
+
when /^[0-9]/
|
214
|
+
when *Operators
|
215
|
+
#receiver + " " << e
|
216
|
+
end
|
217
|
+
}.compact
|
218
|
+
end
|
219
|
+
|
220
|
+
# build_path seperates the input into two parts: path and input.
|
221
|
+
# input is the partial string that should be completed
|
222
|
+
# path is a proc that takes an input and builds a full path.
|
223
|
+
def build_path(input)
|
224
|
+
# check to see if the input is a regex
|
225
|
+
return proc { |i| i.to_s }, input if input[/\/\./]
|
226
|
+
|
227
|
+
trailing_slash = input.end_with?('/')
|
228
|
+
contexts = input.chomp('/').split(/\//)
|
229
|
+
input = contexts[-1]
|
230
|
+
path = proc do |i|
|
231
|
+
p = contexts[0..-2].push(i).join('/')
|
232
|
+
p += '/' if trailing_slash && !i.nil?
|
233
|
+
p
|
224
234
|
end
|
235
|
+
return path, input
|
236
|
+
end
|
237
|
+
|
238
|
+
def ignored_modules
|
239
|
+
# We could cache the result, but IRB is not loaded by default.
|
240
|
+
# And this is very fast anyway.
|
241
|
+
# By using this approach, we avoid Module#name calls, which are
|
242
|
+
# relatively slow when there are a lot of anonymous modules defined.
|
243
|
+
s = Set.new
|
225
244
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
contexts = input.chomp('/').split(/\//)
|
234
|
-
input = contexts[-1]
|
235
|
-
path = proc do |i|
|
236
|
-
p = contexts[0..-2].push(i).join('/')
|
237
|
-
p += '/' if trailing_slash && !i.nil?
|
238
|
-
p
|
245
|
+
scanner = lambda do |m|
|
246
|
+
next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
|
247
|
+
|
248
|
+
s << m
|
249
|
+
m.constants(false).each do |c|
|
250
|
+
value = m.const_get(c)
|
251
|
+
scanner.call(value) if value.is_a?(Module)
|
239
252
|
end
|
240
|
-
return path, input
|
241
253
|
end
|
254
|
+
|
255
|
+
# FIXME: Add Pry here as well?
|
256
|
+
[:IRB, :SLex, :RubyLex, :RubyToken].each do |module_name|
|
257
|
+
next unless Object.const_defined?(module_name)
|
258
|
+
|
259
|
+
scanner.call(Object.const_get(module_name))
|
260
|
+
end
|
261
|
+
|
262
|
+
s.delete(IRB::Context) if defined?(IRB::Context)
|
263
|
+
s
|
264
|
+
end
|
242
265
|
end
|
data/lib/pry/input_lock.rb
CHANGED
data/lib/pry/last_exception.rb
CHANGED
data/lib/pry/method/disowned.rb
CHANGED
@@ -20,8 +20,9 @@ class Pry
|
|
20
20
|
#
|
21
21
|
# @param [Object] receiver
|
22
22
|
# @param [String] method_name
|
23
|
-
def initialize(receiver, method_name
|
23
|
+
def initialize(receiver, method_name)
|
24
24
|
@receiver, @name = receiver, method_name
|
25
|
+
@method = nil
|
25
26
|
end
|
26
27
|
|
27
28
|
# Is the method undefined? (aka `Disowned`)
|
@@ -46,6 +47,7 @@ class Pry
|
|
46
47
|
# Raise a more useful error message instead of trying to forward to nil.
|
47
48
|
def method_missing(meth_name, *args, &block)
|
48
49
|
raise "Cannot call '#{meth_name}' on an undef'd method." if method(:name).respond_to?(meth_name)
|
50
|
+
|
49
51
|
Object.instance_method(:method_missing).bind(self).call(meth_name, *args, &block)
|
50
52
|
end
|
51
53
|
end
|
data/lib/pry/method/patcher.rb
CHANGED
@@ -42,9 +42,6 @@ class Pry
|
|
42
42
|
# transation we make that not happen, which means that alias_method_chains, etc.
|
43
43
|
# continue to work.
|
44
44
|
#
|
45
|
-
# @param [String] meth_name The method name before aliasing
|
46
|
-
# @param [Module] target The owner of the method
|
47
|
-
|
48
45
|
def with_method_transaction
|
49
46
|
temp_name = "__pry_#{method.original_name}__"
|
50
47
|
method = self.method
|
@@ -97,7 +94,7 @@ class Pry
|
|
97
94
|
def wrap_for_owner(source)
|
98
95
|
Pry.current[:pry_owner] = method.owner
|
99
96
|
owner_source = definition_for_owner(source)
|
100
|
-
visibility_fix = "#{method.visibility
|
97
|
+
visibility_fix = "#{method.visibility} #{method.name.to_sym.inspect}"
|
101
98
|
"Pry.current[:pry_owner].class_eval do; #{owner_source}\n#{visibility_fix}\nend"
|
102
99
|
end
|
103
100
|
|
@@ -116,7 +113,7 @@ class Pry
|
|
116
113
|
def wrap_for_nesting(source)
|
117
114
|
nesting = Pry::Code.from_file(method.source_file).nesting_at(method.source_line)
|
118
115
|
|
119
|
-
(nesting + [source] + nesting.map{ "end" } + [""]).join(";")
|
116
|
+
(nesting + [source] + nesting.map { "end" } + [""]).join(";")
|
120
117
|
rescue Pry::Indent::UnparseableNestingError
|
121
118
|
source
|
122
119
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class Pry
|
2
2
|
class Method
|
3
|
-
|
4
3
|
# This class is responsible for locating the *real* `Pry::Method`
|
5
4
|
# object captured by a binding.
|
6
5
|
#
|
@@ -16,7 +15,6 @@ class Pry
|
|
16
15
|
# Pry::Method and return it, or return nil if we fail.
|
17
16
|
class WeirdMethodLocator
|
18
17
|
class << self
|
19
|
-
|
20
18
|
# Whether the given method object matches the associated binding.
|
21
19
|
# If the method object does not match the binding, then it's
|
22
20
|
# most likely not the method captured by the binding, and we
|
@@ -26,13 +24,17 @@ class Pry
|
|
26
24
|
# @param [Binding] b
|
27
25
|
# @return [Boolean]
|
28
26
|
def normal_method?(method, b)
|
29
|
-
method
|
30
|
-
|
31
|
-
|
27
|
+
if method and method.source_file and method.source_range
|
28
|
+
binding_file, binding_line = b.eval('__FILE__'), b.eval('__LINE__')
|
29
|
+
File.expand_path(method.source_file) == File.expand_path(binding_file) and
|
30
|
+
method.source_range.include?(binding_line)
|
31
|
+
end
|
32
|
+
rescue
|
33
|
+
false
|
32
34
|
end
|
33
35
|
|
34
36
|
def weird_method?(method, b)
|
35
|
-
|
37
|
+
not normal_method?(method, b)
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -61,6 +63,11 @@ class Pry
|
|
61
63
|
|
62
64
|
private
|
63
65
|
|
66
|
+
def skip_superclass_search?
|
67
|
+
target_mod = @target.eval('self').class
|
68
|
+
target_mod.ancestors.take_while { |mod| mod != target_mod }.any?
|
69
|
+
end
|
70
|
+
|
64
71
|
def normal_method?(method)
|
65
72
|
self.class.normal_method?(method, target)
|
66
73
|
end
|
@@ -91,13 +98,15 @@ class Pry
|
|
91
98
|
# __FILE__ and __LINE__ the binding is at, we can hope to disambiguate these cases.
|
92
99
|
#
|
93
100
|
# This obviously won't work if the source is unavaiable for some reason, or if both
|
94
|
-
# methods have the same __FILE__ and __LINE__
|
95
|
-
# is broken.
|
101
|
+
# methods have the same __FILE__ and __LINE__.
|
96
102
|
#
|
97
103
|
# @return [Pry::Method, nil] The Pry::Method representing the
|
98
104
|
# superclass method.
|
99
105
|
def find_method_in_superclass
|
100
106
|
guess = method
|
107
|
+
if skip_superclass_search?
|
108
|
+
return guess
|
109
|
+
end
|
101
110
|
|
102
111
|
while guess
|
103
112
|
# needs rescue if this is a Disowned method or a C method or something...
|
@@ -111,9 +120,9 @@ class Pry
|
|
111
120
|
end
|
112
121
|
end
|
113
122
|
|
114
|
-
# Uhoh... none of the methods in the chain had the right __FILE__ and
|
115
|
-
#
|
116
|
-
#
|
123
|
+
# Uhoh... none of the methods in the chain had the right `__FILE__` and
|
124
|
+
# `__LINE__` due to unknown circumstances.
|
125
|
+
# TODO: we should warn the user when this happens.
|
117
126
|
nil
|
118
127
|
end
|
119
128
|
|
@@ -125,6 +134,7 @@ class Pry
|
|
125
134
|
# renamed method
|
126
135
|
def find_renamed_method
|
127
136
|
return if !valid_file?(target_file)
|
137
|
+
|
128
138
|
alias_name = all_methods_for(target_self).find do |v|
|
129
139
|
expanded_source_location(target_self.method(v).source_location) == renamed_method_source_location
|
130
140
|
end
|