pry 0.11.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 +157 -1
- data/LICENSE +1 -1
- data/README.md +13 -30
- data/bin/pry +0 -4
- data/lib/pry/cli.rb +17 -24
- data/lib/pry/code/code_file.rb +5 -4
- data/lib/pry/code/code_range.rb +3 -3
- data/lib/pry/code/loc.rb +14 -8
- data/lib/pry/code.rb +6 -6
- data/lib/pry/code_object.rb +4 -4
- data/lib/pry/color_printer.rb +1 -0
- data/lib/pry/command.rb +36 -29
- data/lib/pry/command_set.rb +17 -52
- 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 +9 -8
- 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 +9 -9
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +8 -7
- data/lib/pry/commands/exit.rb +2 -1
- data/lib/pry/commands/find_method.rb +11 -13
- 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 +1 -1
- data/lib/pry/commands/gem_search.rb +2 -2
- 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 +9 -8
- data/lib/pry/commands/import_set.rb +2 -1
- data/lib/pry/commands/install_command.rb +7 -6
- data/lib/pry/commands/list_inspectors.rb +2 -2
- data/lib/pry/commands/ls/constants.rb +4 -4
- data/lib/pry/commands/ls/formatter.rb +3 -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/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 +0 -1
- data/lib/pry/commands/ls.rb +27 -30
- data/lib/pry/commands/play.rb +1 -2
- data/lib/pry/commands/pry_backtrace.rb +1 -1
- data/lib/pry/commands/raise_up.rb +2 -1
- data/lib/pry/commands/ri.rb +5 -4
- data/lib/pry/commands/shell_command.rb +3 -2
- 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 +25 -18
- data/lib/pry/commands/show_source.rb +5 -2
- data/lib/pry/commands/stat.rb +1 -1
- data/lib/pry/commands/watch_expression.rb +9 -7
- data/lib/pry/commands/whereami.rb +4 -4
- data/lib/pry/commands/wtf.rb +15 -2
- data/lib/pry/config/behavior.rb +229 -205
- data/lib/pry/config/convenience.rb +24 -21
- data/lib/pry/config/default.rb +153 -143
- data/lib/pry/config/memoization.rb +41 -37
- data/lib/pry/config.rb +33 -9
- data/lib/pry/core_extensions.rb +4 -3
- data/lib/pry/editor.rb +5 -12
- data/lib/pry/exceptions.rb +0 -2
- data/lib/pry/helpers/base_helpers.rb +133 -4
- data/lib/pry/helpers/command_helpers.rb +5 -4
- data/lib/pry/helpers/documentation_helpers.rb +2 -2
- data/lib/pry/helpers/options_helpers.rb +5 -5
- data/lib/pry/helpers/platform.rb +58 -0
- data/lib/pry/helpers/table.rb +20 -15
- data/lib/pry/helpers/text.rb +3 -4
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/history.rb +21 -8
- data/lib/pry/hooks.rb +3 -3
- data/lib/pry/indent.rb +15 -17
- data/lib/pry/input_completer.rb +12 -7
- data/lib/pry/input_lock.rb +0 -2
- data/lib/pry/last_exception.rb +1 -1
- data/lib/pry/method/disowned.rb +2 -1
- data/lib/pry/method/patcher.rb +2 -2
- data/lib/pry/method/weird_method_locator.rb +7 -8
- data/lib/pry/method.rb +37 -31
- data/lib/pry/object_path.rb +5 -4
- data/lib/pry/output.rb +3 -2
- data/lib/pry/pager.rb +194 -186
- data/lib/pry/platform.rb +79 -81
- data/lib/pry/plugins.rb +7 -3
- data/lib/pry/prompt.rb +144 -25
- data/lib/pry/pry_class.rb +53 -29
- data/lib/pry/pry_instance.rb +88 -55
- data/lib/pry/repl.rb +33 -4
- data/lib/pry/repl_file_loader.rb +1 -2
- data/lib/pry/ring.rb +84 -0
- data/lib/pry/rubygem.rb +6 -6
- data/lib/pry/slop/commands.rb +3 -4
- data/lib/pry/slop/option.rb +19 -21
- data/lib/pry/slop.rb +17 -17
- data/lib/pry/terminal.rb +2 -1
- data/lib/pry/testable/mockable.rb +2 -2
- data/lib/pry/testable/pry_tester.rb +1 -1
- data/lib/pry/testable/utility.rb +2 -2
- data/lib/pry/testable/variables.rb +1 -1
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module/candidate.rb +2 -2
- data/lib/pry/wrapped_module.rb +15 -15
- data/lib/pry.rb +17 -47
- metadata +8 -20
- 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/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,7 +100,7 @@ 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
|
@@ -120,7 +120,7 @@ class Pry::InputCompleter
|
|
120
120
|
rescue Pry::RescuableException
|
121
121
|
candidates = []
|
122
122
|
end
|
123
|
-
candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
|
123
|
+
candidates.grep(/^#{message}/).collect { |e| receiver + "::" + e }
|
124
124
|
when SYMBOL_METHOD_CALL_REGEXP # method call on a Symbol
|
125
125
|
receiver = $1
|
126
126
|
message = Regexp.quote($2)
|
@@ -167,10 +167,12 @@ class Pry::InputCompleter
|
|
167
167
|
end
|
168
168
|
else
|
169
169
|
# func1.func2
|
170
|
+
require 'set'
|
170
171
|
candidates = Set.new
|
171
172
|
to_ignore = ignored_modules
|
172
|
-
ObjectSpace.each_object(Module){|m|
|
173
|
+
ObjectSpace.each_object(Module) { |m|
|
173
174
|
next if (to_ignore.include?(m) rescue true)
|
175
|
+
|
174
176
|
# jruby doesn't always provide #instance_methods() on each
|
175
177
|
# object.
|
176
178
|
if m.respond_to?(:instance_methods)
|
@@ -195,7 +197,7 @@ class Pry::InputCompleter
|
|
195
197
|
if eval("respond_to?(:class_variables)", bind)
|
196
198
|
candidates += eval("class_variables", bind).collect(&:to_s)
|
197
199
|
end
|
198
|
-
candidates = (candidates|ReservedWords|custom_completions).grep(/^#{Regexp.quote(input)}/)
|
200
|
+
candidates = (candidates | ReservedWords | custom_completions).grep(/^#{Regexp.quote(input)}/)
|
199
201
|
candidates.collect(&path)
|
200
202
|
end
|
201
203
|
rescue Pry::RescuableException
|
@@ -220,7 +222,8 @@ class Pry::InputCompleter
|
|
220
222
|
# path is a proc that takes an input and builds a full path.
|
221
223
|
def build_path(input)
|
222
224
|
# check to see if the input is a regex
|
223
|
-
return proc {|i| i.to_s }, input if input[/\/\./]
|
225
|
+
return proc { |i| i.to_s }, input if input[/\/\./]
|
226
|
+
|
224
227
|
trailing_slash = input.end_with?('/')
|
225
228
|
contexts = input.chomp('/').split(/\//)
|
226
229
|
input = contexts[-1]
|
@@ -241,6 +244,7 @@ class Pry::InputCompleter
|
|
241
244
|
|
242
245
|
scanner = lambda do |m|
|
243
246
|
next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
|
247
|
+
|
244
248
|
s << m
|
245
249
|
m.constants(false).each do |c|
|
246
250
|
value = m.const_get(c)
|
@@ -251,6 +255,7 @@ class Pry::InputCompleter
|
|
251
255
|
# FIXME: Add Pry here as well?
|
252
256
|
[:IRB, :SLex, :RubyLex, :RubyToken].each do |module_name|
|
253
257
|
next unless Object.const_defined?(module_name)
|
258
|
+
|
254
259
|
scanner.call(Object.const_get(module_name))
|
255
260
|
end
|
256
261
|
|
data/lib/pry/input_lock.rb
CHANGED
data/lib/pry/last_exception.rb
CHANGED
data/lib/pry/method/disowned.rb
CHANGED
@@ -20,7 +20,7 @@ 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
25
|
@method = nil
|
26
26
|
end
|
@@ -47,6 +47,7 @@ class Pry
|
|
47
47
|
# Raise a more useful error message instead of trying to forward to nil.
|
48
48
|
def method_missing(meth_name, *args, &block)
|
49
49
|
raise "Cannot call '#{meth_name}' on an undef'd method." if method(:name).respond_to?(meth_name)
|
50
|
+
|
50
51
|
Object.instance_method(:method_missing).bind(self).call(meth_name, *args, &block)
|
51
52
|
end
|
52
53
|
end
|
data/lib/pry/method/patcher.rb
CHANGED
@@ -94,7 +94,7 @@ class Pry
|
|
94
94
|
def wrap_for_owner(source)
|
95
95
|
Pry.current[:pry_owner] = method.owner
|
96
96
|
owner_source = definition_for_owner(source)
|
97
|
-
visibility_fix = "#{method.visibility
|
97
|
+
visibility_fix = "#{method.visibility} #{method.name.to_sym.inspect}"
|
98
98
|
"Pry.current[:pry_owner].class_eval do; #{owner_source}\n#{visibility_fix}\nend"
|
99
99
|
end
|
100
100
|
|
@@ -113,7 +113,7 @@ class Pry
|
|
113
113
|
def wrap_for_nesting(source)
|
114
114
|
nesting = Pry::Code.from_file(method.source_file).nesting_at(method.source_line)
|
115
115
|
|
116
|
-
(nesting + [source] + nesting.map{ "end" } + [""]).join(";")
|
116
|
+
(nesting + [source] + nesting.map { "end" } + [""]).join(";")
|
117
117
|
rescue Pry::Indent::UnparseableNestingError
|
118
118
|
source
|
119
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
|
@@ -67,7 +65,7 @@ class Pry
|
|
67
65
|
|
68
66
|
def skip_superclass_search?
|
69
67
|
target_mod = @target.eval('self').class
|
70
|
-
target_mod.ancestors.take_while {|mod| mod != target_mod }.any?
|
68
|
+
target_mod.ancestors.take_while { |mod| mod != target_mod }.any?
|
71
69
|
end
|
72
70
|
|
73
71
|
def normal_method?(method)
|
@@ -100,8 +98,7 @@ class Pry
|
|
100
98
|
# __FILE__ and __LINE__ the binding is at, we can hope to disambiguate these cases.
|
101
99
|
#
|
102
100
|
# This obviously won't work if the source is unavaiable for some reason, or if both
|
103
|
-
# methods have the same __FILE__ and __LINE__
|
104
|
-
# is broken.
|
101
|
+
# methods have the same __FILE__ and __LINE__.
|
105
102
|
#
|
106
103
|
# @return [Pry::Method, nil] The Pry::Method representing the
|
107
104
|
# superclass method.
|
@@ -110,6 +107,7 @@ class Pry
|
|
110
107
|
if skip_superclass_search?
|
111
108
|
return guess
|
112
109
|
end
|
110
|
+
|
113
111
|
while guess
|
114
112
|
# needs rescue if this is a Disowned method or a C method or something...
|
115
113
|
# TODO: Fix up the exception handling so we don't need a bare rescue
|
@@ -122,9 +120,9 @@ class Pry
|
|
122
120
|
end
|
123
121
|
end
|
124
122
|
|
125
|
-
# Uhoh... none of the methods in the chain had the right __FILE__ and
|
126
|
-
#
|
127
|
-
#
|
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.
|
128
126
|
nil
|
129
127
|
end
|
130
128
|
|
@@ -136,6 +134,7 @@ class Pry
|
|
136
134
|
# renamed method
|
137
135
|
def find_renamed_method
|
138
136
|
return if !valid_file?(target_file)
|
137
|
+
|
139
138
|
alias_name = all_methods_for(target_self).find do |v|
|
140
139
|
expanded_source_location(target_self.method(v).source_location) == renamed_method_source_location
|
141
140
|
end
|
data/lib/pry/method.rb
CHANGED
@@ -39,7 +39,7 @@ class Pry
|
|
39
39
|
# contain any context.
|
40
40
|
# @return [Pry::Method, nil] A `Pry::Method` instance containing the requested
|
41
41
|
# method, or `nil` if name is `nil` or no method could be located matching the parameters.
|
42
|
-
def from_str(name, target=TOPLEVEL_BINDING, options={})
|
42
|
+
def from_str(name, target = TOPLEVEL_BINDING, options = {})
|
43
43
|
if name.nil?
|
44
44
|
nil
|
45
45
|
elsif name.to_s =~ /(.+)\#(\S+)\Z/
|
@@ -56,8 +56,8 @@ class Pry
|
|
56
56
|
elsif options[:methods]
|
57
57
|
from_obj(target.eval("self"), name, target)
|
58
58
|
else
|
59
|
-
from_str(name, target, :
|
60
|
-
from_str(name, target, :
|
59
|
+
from_str(name, target, instance: true) or
|
60
|
+
from_str(name, target, methods: true)
|
61
61
|
end
|
62
62
|
|
63
63
|
rescue Pry::RescuableException
|
@@ -101,7 +101,7 @@ class Pry
|
|
101
101
|
# @param [Symbol] method_type The type of method: :method or :instance_method
|
102
102
|
# @param [Binding] target The binding where the method is looked up.
|
103
103
|
# @return [Method, UnboundMethod] The 'refined' method object.
|
104
|
-
def lookup_method_via_binding(obj, method_name, method_type, target=TOPLEVEL_BINDING)
|
104
|
+
def lookup_method_via_binding(obj, method_name, method_type, target = TOPLEVEL_BINDING)
|
105
105
|
Pry.current[:obj] = obj
|
106
106
|
Pry.current[:name] = method_name
|
107
107
|
receiver = obj.is_a?(Module) ? "Module" : "Kernel"
|
@@ -118,7 +118,7 @@ class Pry
|
|
118
118
|
# @param [String] name
|
119
119
|
# @param [Binding] target The binding where the method is looked up.
|
120
120
|
# @return [Pry::Method, nil]
|
121
|
-
def from_class(klass, name, target=TOPLEVEL_BINDING)
|
121
|
+
def from_class(klass, name, target = TOPLEVEL_BINDING)
|
122
122
|
new(lookup_method_via_binding(klass, name, :instance_method, target)) rescue nil
|
123
123
|
end
|
124
124
|
alias from_module from_class
|
@@ -131,7 +131,7 @@ class Pry
|
|
131
131
|
# @param [String] name
|
132
132
|
# @param [Binding] target The binding where the method is looked up.
|
133
133
|
# @return [Pry::Method, nil]
|
134
|
-
def from_obj(obj, name, target=TOPLEVEL_BINDING)
|
134
|
+
def from_obj(obj, name, target = TOPLEVEL_BINDING)
|
135
135
|
new(lookup_method_via_binding(obj, name, :method, target)) rescue nil
|
136
136
|
end
|
137
137
|
|
@@ -139,10 +139,10 @@ class Pry
|
|
139
139
|
# @param [Class,Module] klass
|
140
140
|
# @param [Boolean] include_super Whether to include methods from ancestors.
|
141
141
|
# @return [Array[Pry::Method]]
|
142
|
-
def all_from_class(klass, include_super=true)
|
142
|
+
def all_from_class(klass, include_super = true)
|
143
143
|
%w(public protected private).flat_map do |visibility|
|
144
144
|
safe_send(klass, :"#{visibility}_instance_methods", include_super).map do |method_name|
|
145
|
-
new(safe_send(klass, :instance_method, method_name), :
|
145
|
+
new(safe_send(klass, :instance_method, method_name), visibility: visibility.to_sym)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
@@ -157,7 +157,7 @@ class Pry
|
|
157
157
|
#
|
158
158
|
# @return [Array[Pry::Method]]
|
159
159
|
#
|
160
|
-
def all_from_obj(obj, include_super=true)
|
160
|
+
def all_from_obj(obj, include_super = true)
|
161
161
|
all_from_class(singleton_class_of(obj), include_super)
|
162
162
|
end
|
163
163
|
|
@@ -166,7 +166,7 @@ class Pry
|
|
166
166
|
# please use {all_from_obj} instead.
|
167
167
|
# the `method_type` argument is ignored.
|
168
168
|
#
|
169
|
-
def all_from_common(obj,
|
169
|
+
def all_from_common(obj, _method_type = nil, include_super = true)
|
170
170
|
all_from_obj(obj, include_super)
|
171
171
|
end
|
172
172
|
|
@@ -233,7 +233,7 @@ class Pry
|
|
233
233
|
# @param [::Method, UnboundMethod, Proc] method
|
234
234
|
# @param [Hash] known_info Can be used to pre-cache expensive to compute stuff.
|
235
235
|
# @return [Pry::Method]
|
236
|
-
def initialize(method, known_info={})
|
236
|
+
def initialize(method, known_info = {})
|
237
237
|
@method = method
|
238
238
|
@visibility = known_info[:visibility]
|
239
239
|
end
|
@@ -298,7 +298,8 @@ class Pry
|
|
298
298
|
# @return [String, nil] The documentation for the method, or `nil` if it's
|
299
299
|
# unavailable.
|
300
300
|
def doc
|
301
|
-
@doc ||=
|
301
|
+
@doc ||=
|
302
|
+
case source_type
|
302
303
|
when :c
|
303
304
|
info = pry_doc_info
|
304
305
|
info.docstring if info
|
@@ -317,7 +318,7 @@ class Pry
|
|
317
318
|
# `nil` if the filename is unavailable.
|
318
319
|
def source_file
|
319
320
|
if source_location.nil?
|
320
|
-
if
|
321
|
+
if source_type == :c
|
321
322
|
info = pry_doc_info
|
322
323
|
info.file if info
|
323
324
|
end
|
@@ -354,20 +355,24 @@ class Pry
|
|
354
355
|
|
355
356
|
# @return [String] A representation of the method's signature, including its
|
356
357
|
# name and parameters. Optional and "rest" parameters are marked with `*`
|
357
|
-
# and block parameters with `&`.
|
358
|
-
# they're given numbered names instead.
|
358
|
+
# and block parameters with `&`. Keyword arguments are shown with `:`
|
359
|
+
# If the parameter names are unavailable, they're given numbered names instead.
|
359
360
|
# Paraphrased from `awesome_print` gem.
|
360
361
|
def signature
|
361
362
|
if respond_to?(:parameters)
|
362
|
-
args = parameters.inject([]) do |
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
363
|
+
args = parameters.inject([]) do |args_array, (arg_type, name)|
|
364
|
+
name ||= (arg_type == :block ? 'block' : "arg#{args_array.size + 1}")
|
365
|
+
args_array.push(
|
366
|
+
case arg_type
|
367
|
+
when :req then name.to_s
|
368
|
+
when :opt then "#{name}=?"
|
369
|
+
when :rest then "*#{name}"
|
370
|
+
when :block then "&#{name}"
|
371
|
+
when :key then "#{name}:?"
|
372
|
+
when :keyreq then "#{name}:"
|
373
|
+
else '?'
|
374
|
+
end
|
375
|
+
)
|
371
376
|
end
|
372
377
|
else
|
373
378
|
args = (1..arity.abs).map { |i| "arg#{i}" }
|
@@ -379,7 +384,7 @@ class Pry
|
|
379
384
|
|
380
385
|
# @return [Pry::Method, nil] The wrapped method that is called when you
|
381
386
|
# use "super" in the body of this method.
|
382
|
-
def super(times=1)
|
387
|
+
def super(times = 1)
|
383
388
|
if UnboundMethod === @method
|
384
389
|
sup = super_using_ancestors(Pry::Method.instance_resolution_order(owner), times)
|
385
390
|
else
|
@@ -393,6 +398,7 @@ class Pry
|
|
393
398
|
# before any aliasing, or `nil` if it can't be determined.
|
394
399
|
def original_name
|
395
400
|
return nil if source_type != :ruby
|
401
|
+
|
396
402
|
method_name_from_first_line(source.lines.first)
|
397
403
|
end
|
398
404
|
|
@@ -461,7 +467,7 @@ class Pry
|
|
461
467
|
|
462
468
|
# @param [String, Symbol] method_name
|
463
469
|
# @return [Boolean]
|
464
|
-
def respond_to?(method_name, include_all=false)
|
470
|
+
def respond_to?(method_name, include_all = false)
|
465
471
|
super or @method.respond_to?(method_name, include_all)
|
466
472
|
end
|
467
473
|
|
@@ -483,7 +489,7 @@ class Pry
|
|
483
489
|
Pry::MethodInfo.info_for(@method) or raise CommandError, "Cannot locate this method: #{name}. (source_location returns nil)"
|
484
490
|
else
|
485
491
|
fail_msg = "Cannot locate this method: #{name}."
|
486
|
-
if mri?
|
492
|
+
if Helpers::Platform.mri?
|
487
493
|
fail_msg += " Invoke the 'gem-install pry-doc' Pry command to get access to Ruby Core documentation.\n"
|
488
494
|
end
|
489
495
|
raise CommandError, fail_msg
|
@@ -492,7 +498,7 @@ class Pry
|
|
492
498
|
|
493
499
|
# @param [Class, Module] ancestors The ancestors to investigate
|
494
500
|
# @return [Method] The unwrapped super-method
|
495
|
-
def super_using_ancestors(ancestors, times=1)
|
501
|
+
def super_using_ancestors(ancestors, times = 1)
|
496
502
|
next_owner = self.owner
|
497
503
|
times.times do
|
498
504
|
i = ancestors.index(next_owner) + 1
|
@@ -529,9 +535,9 @@ class Pry
|
|
529
535
|
end
|
530
536
|
|
531
537
|
def ruby_source
|
532
|
-
#
|
533
|
-
# hacked version of source_location for
|
534
|
-
#
|
538
|
+
# Clone of `MethodSource.source_helper` that knows to use our
|
539
|
+
# hacked version of `source_location` for our input buffer for methods
|
540
|
+
# defined in `(pry)`.
|
535
541
|
file, line = *source_location
|
536
542
|
raise SourceNotFoundError, "Could not locate source for #{name_with_owner}!" unless file
|
537
543
|
|
data/lib/pry/object_path.rb
CHANGED
@@ -28,7 +28,7 @@ class Pry
|
|
28
28
|
stack = @current_stack.dup
|
29
29
|
|
30
30
|
begin
|
31
|
-
next_segment
|
31
|
+
next_segment = ""
|
32
32
|
|
33
33
|
loop do
|
34
34
|
# Scan for as long as we don't see a slash
|
@@ -74,9 +74,10 @@ class Pry
|
|
74
74
|
"Exception: #{err.inspect}"
|
75
75
|
].join("\n")
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
command_error = CommandError.new(msg)
|
78
|
+
command_error.set_backtrace(err.backtrace)
|
79
|
+
|
80
|
+
raise command_error
|
80
81
|
end
|
81
82
|
end
|
82
83
|
end
|
data/lib/pry/output.rb
CHANGED
@@ -8,8 +8,9 @@ class Pry::Output
|
|
8
8
|
|
9
9
|
def puts(*objs)
|
10
10
|
return print "\n" if objs.empty?
|
11
|
+
|
11
12
|
objs.each do |obj|
|
12
|
-
if ary = Array.try_convert(obj)
|
13
|
+
if (ary = Array.try_convert(obj))
|
13
14
|
puts(*ary)
|
14
15
|
else
|
15
16
|
print "#{obj.to_s.chomp}\n"
|
@@ -35,7 +36,7 @@ class Pry::Output
|
|
35
36
|
@boxed_io.__send__(name, *args, &block)
|
36
37
|
end
|
37
38
|
|
38
|
-
def respond_to_missing?(m, include_all=false)
|
39
|
+
def respond_to_missing?(m, include_all = false)
|
39
40
|
@boxed_io.respond_to?(m, include_all)
|
40
41
|
end
|
41
42
|
|