pry 0.11.3 → 0.12.0
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 +17 -29
- 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
@@ -1,25 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
class Pry
|
2
|
+
class Config < Pry::BasicObject
|
3
|
+
module Convenience
|
4
|
+
SHORTCUTS = [
|
5
|
+
:input,
|
6
|
+
:output,
|
7
|
+
:commands,
|
8
|
+
:print,
|
9
|
+
:exception_handler,
|
10
|
+
:hooks,
|
11
|
+
:color,
|
12
|
+
:pager,
|
13
|
+
:editor,
|
14
|
+
:memory_size,
|
15
|
+
:extra_sticky_locals
|
16
|
+
]
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def config_shortcut(*names)
|
19
|
+
names.each do |name|
|
20
|
+
reader = name
|
21
|
+
setter = "#{name}="
|
22
|
+
define_method(reader) { config.public_send(name) }
|
23
|
+
define_method(setter) { |value| config.public_send(setter, value) }
|
24
|
+
end
|
25
|
+
end
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
data/lib/pry/config/default.rb
CHANGED
@@ -1,149 +1,159 @@
|
|
1
|
-
class Pry
|
2
|
-
|
3
|
-
|
1
|
+
class Pry
|
2
|
+
class Config < Pry::BasicObject
|
3
|
+
class Default
|
4
|
+
include Config::Behavior
|
5
|
+
include Config::Memoization
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
7
|
+
def_memoized({
|
8
|
+
input: proc {
|
9
|
+
lazy_readline
|
10
|
+
},
|
11
|
+
output: proc {
|
12
|
+
$stdout.tap { |out| out.sync = true }
|
13
|
+
},
|
14
|
+
commands: proc {
|
15
|
+
Pry::Commands
|
16
|
+
},
|
17
|
+
prompt_name: proc {
|
18
|
+
Pry::Prompt::DEFAULT_NAME
|
19
|
+
},
|
20
|
+
prompt: proc {
|
21
|
+
Pry::Prompt[:default][:value]
|
22
|
+
},
|
23
|
+
prompt_safe_contexts: proc {
|
24
|
+
Pry::Prompt::SAFE_CONTEXTS
|
25
|
+
},
|
26
|
+
print: proc {
|
27
|
+
Pry::DEFAULT_PRINT
|
28
|
+
},
|
29
|
+
quiet: proc {
|
30
|
+
false
|
31
|
+
},
|
32
|
+
exception_handler: proc {
|
33
|
+
Pry::DEFAULT_EXCEPTION_HANDLER
|
34
|
+
},
|
35
|
+
exception_whitelist: proc {
|
36
|
+
Pry::DEFAULT_EXCEPTION_WHITELIST
|
37
|
+
},
|
38
|
+
hooks: proc {
|
39
|
+
Pry::DEFAULT_HOOKS
|
40
|
+
},
|
41
|
+
pager: proc {
|
42
|
+
true
|
43
|
+
},
|
44
|
+
system: proc {
|
45
|
+
Pry::DEFAULT_SYSTEM
|
46
|
+
},
|
47
|
+
color: proc {
|
48
|
+
Pry::Helpers::BaseHelpers.use_ansi_codes?
|
49
|
+
},
|
50
|
+
default_window_size: proc {
|
51
|
+
5
|
52
|
+
},
|
53
|
+
editor: proc {
|
54
|
+
Pry.default_editor_for_platform
|
55
|
+
},
|
56
|
+
should_load_rc: proc {
|
57
|
+
true
|
58
|
+
},
|
59
|
+
should_load_local_rc: proc {
|
60
|
+
true
|
61
|
+
},
|
62
|
+
should_trap_interrupts: proc {
|
63
|
+
Pry::Helpers::Platform.jruby?
|
64
|
+
},
|
65
|
+
disable_auto_reload: proc {
|
66
|
+
false
|
67
|
+
},
|
68
|
+
command_prefix: proc {
|
69
|
+
""
|
70
|
+
},
|
71
|
+
auto_indent: proc {
|
72
|
+
Pry::Helpers::BaseHelpers.use_ansi_codes?
|
73
|
+
},
|
74
|
+
correct_indent: proc {
|
75
|
+
true
|
76
|
+
},
|
77
|
+
collision_warning: proc {
|
78
|
+
false
|
79
|
+
},
|
80
|
+
output_prefix: proc {
|
81
|
+
"=> "
|
82
|
+
},
|
83
|
+
requires: proc {
|
84
|
+
[]
|
85
|
+
},
|
86
|
+
should_load_requires: proc {
|
87
|
+
true
|
88
|
+
},
|
89
|
+
should_load_plugins: proc {
|
90
|
+
true
|
91
|
+
},
|
92
|
+
windows_console_warning: proc {
|
93
|
+
true
|
94
|
+
},
|
95
|
+
control_d_handler: proc {
|
96
|
+
Pry::DEFAULT_CONTROL_D_HANDLER
|
97
|
+
},
|
98
|
+
memory_size: proc {
|
99
|
+
100
|
100
|
+
},
|
101
|
+
extra_sticky_locals: proc {
|
102
|
+
{}
|
103
|
+
},
|
104
|
+
command_completions: proc {
|
105
|
+
proc { commands.keys }
|
106
|
+
},
|
107
|
+
file_completions: proc {
|
108
|
+
proc { Dir["."] }
|
109
|
+
},
|
110
|
+
ls: proc {
|
111
|
+
Pry::Config.from_hash(Pry::Command::Ls::DEFAULT_OPTIONS)
|
112
|
+
},
|
113
|
+
completer: proc {
|
114
|
+
require "pry/input_completer"
|
115
|
+
Pry::InputCompleter
|
116
|
+
},
|
117
|
+
gist: proc {
|
118
|
+
Pry::Config.from_hash({inspecter: proc(&:pretty_inspect)}, nil)
|
119
|
+
},
|
120
|
+
history: proc {
|
121
|
+
Pry::Config.from_hash({should_save: true, should_load: true}, nil).tap do |history|
|
122
|
+
history_file =
|
123
|
+
if File.exist?(File.expand_path('~/.pry_history'))
|
124
|
+
'~/.pry_history'
|
125
|
+
elsif ENV.key?('XDG_DATA_HOME') && ENV['XDG_DATA_HOME'] != ''
|
126
|
+
# See XDG Base Directory Specification at
|
127
|
+
# https://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
|
128
|
+
ENV['XDG_DATA_HOME'] + '/pry/pry_history'
|
129
|
+
else
|
130
|
+
'~/.local/share/pry/pry_history'
|
131
|
+
end
|
132
|
+
history.file = File.expand_path(history_file)
|
133
|
+
end
|
134
|
+
},
|
135
|
+
exec_string: proc {
|
136
|
+
""
|
137
|
+
}
|
138
|
+
})
|
139
|
+
|
140
|
+
def initialize
|
141
|
+
super(nil)
|
126
142
|
end
|
127
|
-
},
|
128
|
-
exec_string: proc {
|
129
|
-
""
|
130
|
-
}
|
131
|
-
})
|
132
143
|
|
133
|
-
|
134
|
-
super(nil)
|
135
|
-
end
|
144
|
+
private
|
136
145
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
146
|
+
def lazy_readline
|
147
|
+
require 'readline'
|
148
|
+
Readline
|
149
|
+
rescue LoadError
|
150
|
+
warn "Sorry, you can't use Pry without Readline or a compatible library."
|
151
|
+
warn "Possible solutions:"
|
152
|
+
warn " * Rebuild Ruby with Readline support using `--with-readline`"
|
153
|
+
warn " * Use the rb-readline gem, which is a pure-Ruby port of Readline"
|
154
|
+
warn " * Use the pry-coolline gem, a pure-ruby alternative to Readline"
|
155
|
+
raise
|
156
|
+
end
|
157
|
+
end
|
148
158
|
end
|
149
159
|
end
|
@@ -1,44 +1,48 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
class Pry
|
2
|
+
class Config < Pry::BasicObject
|
3
|
+
module Memoization
|
4
|
+
MEMOIZED_METHODS = Hash.new { |h,k| h[k] = [] }
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
module ClassMethods
|
7
|
+
#
|
8
|
+
# Defines one or more methods who return a constant value after being
|
9
|
+
# called once.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# class Foo
|
13
|
+
# include Pry::Config::Memoization
|
14
|
+
# def_memoized({
|
15
|
+
# foo: proc {1+10},
|
16
|
+
# bar: proc{"aaa"<<"a"}
|
17
|
+
# })
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# @param [{String => Proc}] method_table
|
21
|
+
#
|
22
|
+
# @return [void]
|
23
|
+
#
|
24
|
+
def def_memoized(method_table)
|
25
|
+
method_table.each do |method_name, method|
|
26
|
+
define_method(method_name) do
|
27
|
+
method_table[method_name] = instance_eval(&method) if method_table[method_name].equal? method
|
28
|
+
method_table[method_name]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
MEMOIZED_METHODS[self] |= method_table.keys
|
27
32
|
end
|
28
33
|
end
|
29
|
-
MEMOIZED_METHODS[self] |= method_table.keys
|
30
|
-
end
|
31
|
-
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
def self.included(mod)
|
36
|
+
mod.extend(ClassMethods)
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
#
|
40
|
+
# @return [Array<Symbol>]
|
41
|
+
# Returns the names of methods that have been defined by {ClassMethods#def_memoized}.
|
42
|
+
#
|
43
|
+
def memoized_methods
|
44
|
+
MEMOIZED_METHODS[self.class]
|
45
|
+
end
|
46
|
+
end
|
43
47
|
end
|
44
48
|
end
|
data/lib/pry/core_extensions.rb
CHANGED
@@ -38,7 +38,7 @@ class Object
|
|
38
38
|
# end
|
39
39
|
# my_method()
|
40
40
|
# @see Pry.start
|
41
|
-
def pry(object=nil, hash={})
|
41
|
+
def pry(object = nil, hash = {})
|
42
42
|
if object.nil? || Hash === object
|
43
43
|
Pry.start(self, object || {})
|
44
44
|
else
|
@@ -81,12 +81,13 @@ class Object
|
|
81
81
|
# This fixes the following two spec failures, at https://travis-ci.org/pry/pry/jobs/274470002
|
82
82
|
# 1) ./spec/pry_spec.rb:360:in `block in (root)'
|
83
83
|
# 2) ./spec/pry_spec.rb:366:in `block in (root)'
|
84
|
-
return class_eval {binding} if Pry::Helpers::
|
84
|
+
return class_eval { binding } if Pry::Helpers::Platform.jruby? and self.name == nil
|
85
|
+
|
85
86
|
# class_eval sets both self and the default definee to this class.
|
86
87
|
return class_eval("binding")
|
87
88
|
end
|
88
89
|
|
89
|
-
unless
|
90
|
+
unless self.class.method_defined?(:__pry__)
|
90
91
|
# The easiest way to check whether an object has a working singleton class
|
91
92
|
# is to try and define a method on it. (just checking for the presence of
|
92
93
|
# the singleton class gives false positives for `true` and `false`).
|