pry 0.11.3-java → 0.12.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +139 -1
- data/LICENSE +1 -1
- data/README.md +13 -30
- data/bin/pry +0 -4
- data/lib/pry.rb +17 -47
- data/lib/pry/cli.rb +17 -24
- data/lib/pry/code.rb +6 -6
- 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_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.rb +7 -6
- 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/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.rb +27 -30
- 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/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.rb +33 -9
- 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/core_extensions.rb +4 -3
- data/lib/pry/editor.rb +5 -12
- data/lib/pry/exceptions.rb +0 -2
- data/lib/pry/helpers.rb +1 -0
- 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/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.rb +37 -31
- 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/object_path.rb +5 -4
- data/lib/pry/output.rb +3 -2
- data/lib/pry/pager.rb +4 -3
- 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.rb +17 -17
- data/lib/pry/slop/commands.rb +3 -4
- data/lib/pry/slop/option.rb +19 -21
- 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.rb +15 -15
- data/lib/pry/wrapped_module/candidate.rb +2 -2
- metadata +19 -31
- 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/commands/wtf.rb
CHANGED
@@ -3,7 +3,7 @@ class Pry
|
|
3
3
|
match(/wtf([?!]*)/)
|
4
4
|
group 'Context'
|
5
5
|
description 'Show the backtrace of the most recent exception.'
|
6
|
-
options :
|
6
|
+
options listing: 'wtf?'
|
7
7
|
|
8
8
|
banner <<-'BANNER'
|
9
9
|
Usage: wtf[?|!]
|
@@ -26,12 +26,25 @@ class Pry
|
|
26
26
|
def process
|
27
27
|
raise Pry::CommandError, "No most-recent exception" unless exception
|
28
28
|
|
29
|
-
output.puts "#{
|
29
|
+
output.puts "#{bold('Exception:')} #{exception.class}: #{exception}\n--"
|
30
30
|
if opts.verbose?
|
31
31
|
output.puts with_line_numbers(backtrace)
|
32
32
|
else
|
33
33
|
output.puts with_line_numbers(backtrace.first(size_of_backtrace))
|
34
34
|
end
|
35
|
+
|
36
|
+
if exception.respond_to? :cause
|
37
|
+
cause = exception.cause
|
38
|
+
while cause
|
39
|
+
output.puts "#{text.bold('Caused by:')} #{cause.class}: #{cause}\n--"
|
40
|
+
if opts.verbose?
|
41
|
+
output.puts with_line_numbers(cause.backtrace)
|
42
|
+
else
|
43
|
+
output.puts with_line_numbers(cause.backtrace.first(size_of_backtrace))
|
44
|
+
end
|
45
|
+
cause = cause.cause
|
46
|
+
end
|
47
|
+
end
|
35
48
|
end
|
36
49
|
|
37
50
|
private
|
data/lib/pry/config.rb
CHANGED
@@ -1,11 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
class Pry
|
2
|
+
# The Pry config.
|
3
|
+
# @api public
|
4
|
+
class Config < Pry::BasicObject
|
5
|
+
# Wraps a block so it can have a name.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# proc1 = proc {}
|
9
|
+
# proc2 = Pry::Config::Lazy.new(&proc {})
|
10
|
+
#
|
11
|
+
# proc1.is_a?(Pry::Config::Lazy)
|
12
|
+
# #=> false
|
13
|
+
# proc2.is_a?(Pry::Config::Lazy)
|
14
|
+
# #=> true
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
# @since v0.12.0
|
18
|
+
class Lazy
|
19
|
+
def initialize(&block)
|
20
|
+
@block = block
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Object]
|
24
|
+
def call
|
25
|
+
@block.call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
include Behavior
|
30
|
+
|
31
|
+
def self.shortcuts
|
32
|
+
Convenience::SHORTCUTS
|
33
|
+
end
|
10
34
|
end
|
11
35
|
end
|
data/lib/pry/config/behavior.rb
CHANGED
@@ -1,231 +1,255 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
class Pry
|
2
|
+
class Config < Pry::BasicObject
|
3
|
+
module Behavior
|
4
|
+
ASSIGNMENT = "=".freeze
|
5
|
+
NODUP = [TrueClass, FalseClass, NilClass, Symbol, Numeric, Module, Proc].freeze
|
6
|
+
INSPECT_REGEXP = /#{Regexp.escape "default=#<"}/
|
7
|
+
ReservedKeyError = Class.new(RuntimeError)
|
8
|
+
|
9
|
+
module Builder
|
10
|
+
#
|
11
|
+
# Returns a new Behavior, non-recursively (unlike {#from_hash}).
|
12
|
+
#
|
13
|
+
# @param
|
14
|
+
# (see #from_hash)
|
15
|
+
#
|
16
|
+
# @return
|
17
|
+
# (see #from_hash)
|
18
|
+
#
|
19
|
+
def assign(attributes, default = nil)
|
20
|
+
new(default).tap do |behavior|
|
21
|
+
behavior.merge!(attributes)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Returns a new Behavior, recursively walking attributes.
|
27
|
+
#
|
28
|
+
# @param [Hash] attributes
|
29
|
+
# a hash to initialize an instance of self with.
|
30
|
+
#
|
31
|
+
# @param [Pry::Config, nil] default
|
32
|
+
# a default, or nil for none.
|
33
|
+
#
|
34
|
+
# @return [Pry::Config]
|
35
|
+
# returns an instance of self.
|
36
|
+
#
|
37
|
+
def from_hash(attributes, default = nil)
|
38
|
+
new(default).tap do |config|
|
39
|
+
attributes.each do |key,value|
|
40
|
+
config[key] = Hash === value ? from_hash(value, nil) : value
|
41
|
+
end
|
42
|
+
end
|
22
43
|
end
|
23
44
|
end
|
24
|
-
end
|
25
|
-
end
|
26
45
|
|
27
|
-
|
28
|
-
|
29
|
-
|
46
|
+
def self.included(klass)
|
47
|
+
klass.extend(Builder)
|
48
|
+
end
|
30
49
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
50
|
+
def initialize(default = Pry.config)
|
51
|
+
@default = default
|
52
|
+
@lookup = {}
|
53
|
+
@reserved_keys = methods.map(&:to_s).freeze
|
54
|
+
end
|
36
55
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
56
|
+
#
|
57
|
+
# @return [Pry::Config::Behavior]
|
58
|
+
# returns the default used incase a key isn't found in self.
|
59
|
+
#
|
60
|
+
def default
|
61
|
+
@default
|
62
|
+
end
|
44
63
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
#
|
65
|
+
# @param [String] key
|
66
|
+
# a key (as a String)
|
67
|
+
#
|
68
|
+
# @return [Object, BasicObject]
|
69
|
+
# returns an object from self or one of its defaults.
|
70
|
+
#
|
71
|
+
def [](key)
|
72
|
+
key = key.to_s
|
73
|
+
key?(key) ? @lookup[key] : (@default and @default[key])
|
74
|
+
end
|
56
75
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
__push(key,value)
|
75
|
-
end
|
76
|
+
#
|
77
|
+
# Add a key and value pair to self.
|
78
|
+
#
|
79
|
+
# @param [String] key
|
80
|
+
# a key (as a String).
|
81
|
+
#
|
82
|
+
# @param [Object,BasicObject] value
|
83
|
+
# a value.
|
84
|
+
#
|
85
|
+
# @raise [Pry::Config::ReservedKeyError]
|
86
|
+
# when 'key' is a reserved key name.
|
87
|
+
#
|
88
|
+
def []=(key, value)
|
89
|
+
key = key.to_s
|
90
|
+
if @reserved_keys.include?(key)
|
91
|
+
raise ReservedKeyError, "It is not possible to use '#{key}' as a key name, please choose a different key name."
|
92
|
+
end
|
76
93
|
|
77
|
-
|
78
|
-
|
79
|
-
#
|
80
|
-
# @param [String] key
|
81
|
-
# a key (as a String)
|
82
|
-
#
|
83
|
-
# @return [void]
|
84
|
-
#
|
85
|
-
def forget(key)
|
86
|
-
key = key.to_s
|
87
|
-
__remove(key)
|
88
|
-
end
|
94
|
+
__push(key,value)
|
95
|
+
end
|
89
96
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
97
|
+
#
|
98
|
+
# Removes a key from self.
|
99
|
+
#
|
100
|
+
# @param [String] key
|
101
|
+
# a key (as a String)
|
102
|
+
#
|
103
|
+
# @return [void]
|
104
|
+
#
|
105
|
+
def forget(key)
|
106
|
+
key = key.to_s
|
107
|
+
__remove(key)
|
108
|
+
end
|
103
109
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
# returns true when "key" is a member of self.
|
119
|
-
#
|
120
|
-
def key?(key)
|
121
|
-
key = key.to_s
|
122
|
-
@lookup.key?(key)
|
123
|
-
end
|
110
|
+
#
|
111
|
+
# @param [Hash, #to_h, #to_hash] other
|
112
|
+
# a hash to merge into self.
|
113
|
+
#
|
114
|
+
# @return [void]
|
115
|
+
#
|
116
|
+
def merge!(other)
|
117
|
+
other = __try_convert_to_hash(other)
|
118
|
+
raise TypeError, "unable to convert argument into a Hash" unless other
|
119
|
+
|
120
|
+
other.each do |key, value|
|
121
|
+
self[key] = value
|
122
|
+
end
|
123
|
+
end
|
124
124
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
125
|
+
#
|
126
|
+
# @param [Hash, #to_h, #to_hash] other
|
127
|
+
# a hash to compare against the lookup table of self.
|
128
|
+
#
|
129
|
+
def ==(other)
|
130
|
+
@lookup == __try_convert_to_hash(other)
|
131
|
+
end
|
132
|
+
alias_method :eql?, :==
|
133
|
+
|
134
|
+
#
|
135
|
+
# @param [String] key
|
136
|
+
# a key (as a String)
|
137
|
+
#
|
138
|
+
# @return [Boolean]
|
139
|
+
# returns true when "key" is a member of self.
|
140
|
+
#
|
141
|
+
def key?(key)
|
142
|
+
key = key.to_s
|
143
|
+
@lookup.key?(key)
|
144
|
+
end
|
134
145
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
146
|
+
#
|
147
|
+
# Clear the lookup table of self.
|
148
|
+
#
|
149
|
+
# @return [void]
|
150
|
+
#
|
151
|
+
def clear
|
152
|
+
@lookup.clear
|
153
|
+
true
|
154
|
+
end
|
142
155
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
156
|
+
#
|
157
|
+
# @return [Array<String>]
|
158
|
+
# returns an array of keys in self.
|
159
|
+
#
|
160
|
+
def keys
|
161
|
+
@lookup.keys
|
162
|
+
end
|
150
163
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
164
|
+
def eager_load!
|
165
|
+
default = @default
|
166
|
+
while default
|
167
|
+
default.memoized_methods.each { |method| self[key] = default.public_send(key) } if default.respond_to?(:memoized_methods)
|
168
|
+
default = @default.default
|
169
|
+
end
|
170
|
+
end
|
156
171
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
@lookup.dup
|
163
|
-
end
|
164
|
-
alias_method :to_h, :to_hash
|
172
|
+
def last_default
|
173
|
+
last = @default
|
174
|
+
last = last.default while last and last.default
|
175
|
+
last
|
176
|
+
end
|
165
177
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
178
|
+
#
|
179
|
+
# @return [Hash]
|
180
|
+
# returns a duplicate copy of the lookup table used by self.
|
181
|
+
#
|
182
|
+
def to_hash
|
183
|
+
@lookup.dup
|
184
|
+
end
|
185
|
+
alias_method :to_h, :to_hash
|
170
186
|
|
171
|
-
|
172
|
-
|
173
|
-
|
187
|
+
def inspect
|
188
|
+
key_str = keys.map { |key| "'#{key}'" }.join(",")
|
189
|
+
"#<#{__clip_inspect(self)} keys=[#{key_str}] default=#{@default.inspect}>"
|
190
|
+
end
|
174
191
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
short_key = key[0..-2]
|
179
|
-
self[short_key] = args[0]
|
180
|
-
elsif key?(key)
|
181
|
-
self[key]
|
182
|
-
elsif @default.respond_to?(name)
|
183
|
-
value = @default.public_send(name, *args, &block)
|
184
|
-
self[key] = __dup(value)
|
185
|
-
else
|
186
|
-
nil
|
187
|
-
end
|
188
|
-
end
|
192
|
+
def pretty_print(q)
|
193
|
+
q.text inspect[1..-1].gsub(INSPECT_REGEXP, "default=<")
|
194
|
+
end
|
189
195
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
196
|
+
def method_missing(name, *args, &block)
|
197
|
+
key = name.to_s
|
198
|
+
if key[-1] == ASSIGNMENT
|
199
|
+
short_key = key[0..-2]
|
200
|
+
self[short_key] = args[0]
|
201
|
+
elsif key?(key)
|
202
|
+
self[key]
|
203
|
+
elsif @default.respond_to?(name)
|
204
|
+
value = @default.public_send(name, *args, &block)
|
205
|
+
self[key] = __dup(value)
|
206
|
+
else
|
207
|
+
nil
|
208
|
+
end
|
209
|
+
end
|
194
210
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
211
|
+
def respond_to_missing?(key, include_all = false)
|
212
|
+
key = key.to_s.chomp(ASSIGNMENT)
|
213
|
+
key?(key) or @default.respond_to?(key) or super(key, include_all)
|
214
|
+
end
|
199
215
|
|
200
|
-
|
201
|
-
if Hash === obj
|
202
|
-
obj
|
203
|
-
elsif obj.respond_to?(:to_h)
|
204
|
-
obj.to_h
|
205
|
-
elsif obj.respond_to?(:to_hash)
|
206
|
-
obj.to_hash
|
207
|
-
else
|
208
|
-
nil
|
209
|
-
end
|
210
|
-
end
|
216
|
+
private
|
211
217
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
else
|
216
|
-
value.dup
|
217
|
-
end
|
218
|
-
end
|
218
|
+
def __clip_inspect(obj)
|
219
|
+
"#{obj.class}:0x%x" % obj.object_id
|
220
|
+
end
|
219
221
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
222
|
+
def __try_convert_to_hash(obj)
|
223
|
+
if Hash === obj
|
224
|
+
obj
|
225
|
+
elsif obj.respond_to?(:to_h)
|
226
|
+
obj.to_h
|
227
|
+
elsif obj.respond_to?(:to_hash)
|
228
|
+
obj.to_hash
|
229
|
+
else
|
230
|
+
nil
|
231
|
+
end
|
232
|
+
end
|
227
233
|
|
228
|
-
|
229
|
-
|
234
|
+
def __dup(value)
|
235
|
+
if NODUP.any? { |klass| klass === value }
|
236
|
+
value
|
237
|
+
else
|
238
|
+
value.dup
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def __push(key,value)
|
243
|
+
unless singleton_class.method_defined? key
|
244
|
+
define_singleton_method(key) { self[key] }
|
245
|
+
define_singleton_method("#{key}=") { |val| @lookup[key] = val }
|
246
|
+
end
|
247
|
+
@lookup[key] = value
|
248
|
+
end
|
249
|
+
|
250
|
+
def __remove(key)
|
251
|
+
@lookup.delete(key)
|
252
|
+
end
|
253
|
+
end
|
230
254
|
end
|
231
255
|
end
|