pry 0.10.pre.1-i386-mingw32 → 0.10.0.pre3-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +702 -0
- data/LICENSE +2 -2
- data/{README.markdown → README.md} +41 -35
- data/lib/pry.rb +82 -139
- data/lib/pry/cli.rb +77 -30
- data/lib/pry/code.rb +122 -183
- data/lib/pry/code/code_file.rb +103 -0
- data/lib/pry/code/code_range.rb +71 -0
- data/lib/pry/code/loc.rb +92 -0
- data/lib/pry/code_object.rb +172 -0
- data/lib/pry/color_printer.rb +55 -0
- data/lib/pry/command.rb +184 -28
- data/lib/pry/command_set.rb +113 -59
- data/lib/pry/commands.rb +4 -27
- data/lib/pry/commands/amend_line.rb +99 -0
- data/lib/pry/commands/bang.rb +20 -0
- data/lib/pry/commands/bang_pry.rb +17 -0
- data/lib/pry/commands/cat.rb +62 -0
- data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
- data/lib/pry/commands/cat/exception_formatter.rb +77 -0
- data/lib/pry/commands/cat/file_formatter.rb +67 -0
- data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
- data/lib/pry/commands/cd.rb +41 -0
- data/lib/pry/commands/change_inspector.rb +27 -0
- data/lib/pry/commands/change_prompt.rb +26 -0
- data/lib/pry/commands/code_collector.rb +165 -0
- data/lib/pry/commands/disable_pry.rb +27 -0
- data/lib/pry/commands/disabled_commands.rb +2 -0
- data/lib/pry/commands/easter_eggs.rb +112 -0
- data/lib/pry/commands/edit.rb +195 -0
- data/lib/pry/commands/edit/exception_patcher.rb +25 -0
- data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
- data/lib/pry/commands/exit.rb +42 -0
- data/lib/pry/commands/exit_all.rb +29 -0
- data/lib/pry/commands/exit_program.rb +23 -0
- data/lib/pry/commands/find_method.rb +193 -0
- data/lib/pry/commands/fix_indent.rb +19 -0
- data/lib/pry/commands/gem_cd.rb +26 -0
- data/lib/pry/commands/gem_install.rb +32 -0
- data/lib/pry/commands/gem_list.rb +33 -0
- data/lib/pry/commands/gem_open.rb +29 -0
- data/lib/pry/commands/gist.rb +101 -0
- data/lib/pry/commands/help.rb +164 -0
- data/lib/pry/commands/hist.rb +180 -0
- data/lib/pry/commands/import_set.rb +22 -0
- data/lib/pry/commands/install_command.rb +53 -0
- data/lib/pry/commands/jump_to.rb +29 -0
- data/lib/pry/commands/list_inspectors.rb +35 -0
- data/lib/pry/commands/list_prompts.rb +35 -0
- data/lib/pry/commands/ls.rb +114 -0
- data/lib/pry/commands/ls/constants.rb +47 -0
- data/lib/pry/commands/ls/formatter.rb +49 -0
- data/lib/pry/commands/ls/globals.rb +48 -0
- data/lib/pry/commands/ls/grep.rb +21 -0
- data/lib/pry/commands/ls/instance_vars.rb +39 -0
- data/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/lib/pry/commands/ls/local_names.rb +35 -0
- data/lib/pry/commands/ls/local_vars.rb +39 -0
- data/lib/pry/commands/ls/ls_entity.rb +70 -0
- data/lib/pry/commands/ls/methods.rb +57 -0
- data/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/lib/pry/commands/ls/self_methods.rb +32 -0
- data/lib/pry/commands/nesting.rb +25 -0
- data/lib/pry/commands/play.rb +103 -0
- data/lib/pry/commands/pry_backtrace.rb +25 -0
- data/lib/pry/commands/pry_version.rb +17 -0
- data/lib/pry/commands/raise_up.rb +32 -0
- data/lib/pry/commands/reload_code.rb +62 -0
- data/lib/pry/commands/reset.rb +18 -0
- data/lib/pry/commands/ri.rb +60 -0
- data/lib/pry/commands/save_file.rb +61 -0
- data/lib/pry/commands/shell_command.rb +48 -0
- data/lib/pry/commands/shell_mode.rb +25 -0
- data/lib/pry/commands/show_doc.rb +83 -0
- data/lib/pry/commands/show_info.rb +195 -0
- data/lib/pry/commands/show_input.rb +17 -0
- data/lib/pry/commands/show_source.rb +50 -0
- data/lib/pry/commands/simple_prompt.rb +22 -0
- data/lib/pry/commands/stat.rb +40 -0
- data/lib/pry/commands/switch_to.rb +23 -0
- data/lib/pry/commands/toggle_color.rb +24 -0
- data/lib/pry/commands/watch_expression.rb +105 -0
- data/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/lib/pry/commands/whereami.rb +190 -0
- data/lib/pry/commands/wtf.rb +57 -0
- data/lib/pry/config.rb +20 -229
- data/lib/pry/config/behavior.rb +139 -0
- data/lib/pry/config/convenience.rb +26 -0
- data/lib/pry/config/default.rb +165 -0
- data/lib/pry/core_extensions.rb +59 -38
- data/lib/pry/editor.rb +133 -0
- data/lib/pry/exceptions.rb +77 -0
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/helpers/base_helpers.rb +40 -154
- data/lib/pry/helpers/command_helpers.rb +19 -130
- data/lib/pry/helpers/documentation_helpers.rb +21 -11
- data/lib/pry/helpers/table.rb +109 -0
- data/lib/pry/helpers/text.rb +8 -9
- data/lib/pry/history.rb +61 -45
- data/lib/pry/history_array.rb +11 -1
- data/lib/pry/hooks.rb +10 -32
- data/lib/pry/indent.rb +110 -38
- data/lib/pry/input_completer.rb +242 -0
- data/lib/pry/input_lock.rb +132 -0
- data/lib/pry/inspector.rb +27 -0
- data/lib/pry/last_exception.rb +61 -0
- data/lib/pry/method.rb +199 -200
- data/lib/pry/method/disowned.rb +53 -0
- data/lib/pry/method/patcher.rb +125 -0
- data/lib/pry/method/weird_method_locator.rb +186 -0
- data/lib/pry/module_candidate.rb +39 -33
- data/lib/pry/object_path.rb +82 -0
- data/lib/pry/output.rb +50 -0
- data/lib/pry/pager.rb +234 -0
- data/lib/pry/plugins.rb +4 -3
- data/lib/pry/prompt.rb +26 -0
- data/lib/pry/pry_class.rb +199 -227
- data/lib/pry/pry_instance.rb +344 -403
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +202 -0
- data/lib/pry/repl_file_loader.rb +20 -26
- data/lib/pry/rubygem.rb +82 -0
- data/lib/pry/terminal.rb +79 -0
- data/lib/pry/test/helper.rb +170 -0
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +133 -48
- metadata +132 -197
- data/.document +0 -2
- data/.gemtest +0 -0
- data/.gitignore +0 -16
- data/.travis.yml +0 -17
- data/.yardopts +0 -1
- data/CHANGELOG +0 -387
- data/CONTRIBUTORS +0 -36
- data/Gemfile +0 -2
- data/Rakefile +0 -137
- data/TODO +0 -117
- data/examples/example_basic.rb +0 -15
- data/examples/example_command_override.rb +0 -32
- data/examples/example_commands.rb +0 -36
- data/examples/example_hooks.rb +0 -9
- data/examples/example_image_edit.rb +0 -67
- data/examples/example_input.rb +0 -7
- data/examples/example_input2.rb +0 -29
- data/examples/example_output.rb +0 -11
- data/examples/example_print.rb +0 -6
- data/examples/example_prompt.rb +0 -9
- data/examples/helper.rb +0 -6
- data/lib/pry/completion.rb +0 -221
- data/lib/pry/custom_completions.rb +0 -6
- data/lib/pry/default_commands/cd.rb +0 -81
- data/lib/pry/default_commands/commands.rb +0 -62
- data/lib/pry/default_commands/context.rb +0 -98
- data/lib/pry/default_commands/easter_eggs.rb +0 -95
- data/lib/pry/default_commands/editing.rb +0 -420
- data/lib/pry/default_commands/find_method.rb +0 -169
- data/lib/pry/default_commands/gems.rb +0 -84
- data/lib/pry/default_commands/gist.rb +0 -187
- data/lib/pry/default_commands/help.rb +0 -127
- data/lib/pry/default_commands/hist.rb +0 -120
- data/lib/pry/default_commands/input_and_output.rb +0 -306
- data/lib/pry/default_commands/introspection.rb +0 -410
- data/lib/pry/default_commands/ls.rb +0 -272
- data/lib/pry/default_commands/misc.rb +0 -38
- data/lib/pry/default_commands/navigating_pry.rb +0 -110
- data/lib/pry/default_commands/whereami.rb +0 -92
- data/lib/pry/extended_commands/experimental.rb +0 -7
- data/lib/pry/rbx_method.rb +0 -13
- data/man/pry.1 +0 -195
- data/man/pry.1.html +0 -204
- data/man/pry.1.ronn +0 -141
- data/pry.gemspec +0 -46
- data/test/candidate_helper1.rb +0 -11
- data/test/candidate_helper2.rb +0 -8
- data/test/helper.rb +0 -223
- data/test/test_cli.rb +0 -78
- data/test/test_code.rb +0 -201
- data/test/test_command.rb +0 -712
- data/test/test_command_helpers.rb +0 -9
- data/test/test_command_integration.rb +0 -668
- data/test/test_command_set.rb +0 -610
- data/test/test_completion.rb +0 -62
- data/test/test_control_d_handler.rb +0 -45
- data/test/test_default_commands/example.erb +0 -5
- data/test/test_default_commands/test_cd.rb +0 -318
- data/test/test_default_commands/test_context.rb +0 -280
- data/test/test_default_commands/test_documentation.rb +0 -314
- data/test/test_default_commands/test_find_method.rb +0 -50
- data/test/test_default_commands/test_gems.rb +0 -18
- data/test/test_default_commands/test_help.rb +0 -57
- data/test/test_default_commands/test_input.rb +0 -428
- data/test/test_default_commands/test_introspection.rb +0 -511
- data/test/test_default_commands/test_ls.rb +0 -151
- data/test/test_default_commands/test_shell.rb +0 -343
- data/test/test_default_commands/test_show_source.rb +0 -432
- data/test/test_exception_whitelist.rb +0 -21
- data/test/test_history_array.rb +0 -65
- data/test/test_hooks.rb +0 -521
- data/test/test_indent.rb +0 -277
- data/test/test_input_stack.rb +0 -86
- data/test/test_method.rb +0 -401
- data/test/test_pry.rb +0 -463
- data/test/test_pry_defaults.rb +0 -419
- data/test/test_pry_history.rb +0 -84
- data/test/test_pry_output.rb +0 -41
- data/test/test_sticky_locals.rb +0 -155
- data/test/test_syntax_checking.rb +0 -65
- data/test/test_wrapped_module.rb +0 -174
- data/test/testrc +0 -2
- data/test/testrcbad +0 -2
- data/wiki/Customizing-pry.md +0 -397
- data/wiki/Home.md +0 -4
@@ -0,0 +1,38 @@
|
|
1
|
+
class Pry
|
2
|
+
class Command::WatchExpression
|
3
|
+
class Expression
|
4
|
+
attr_reader :target, :source, :value, :previous_value, :_pry_
|
5
|
+
|
6
|
+
def initialize(_pry_, target, source)
|
7
|
+
@_pry_ = _pry_
|
8
|
+
@target = target
|
9
|
+
@source = source.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
def eval!
|
13
|
+
@previous_value = @value
|
14
|
+
@value = Pry::ColorPrinter.pp(target_eval(target, source), "")
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"#{Code.new(source).strip} => #{value}"
|
19
|
+
end
|
20
|
+
|
21
|
+
# Has the value of the expression changed?
|
22
|
+
#
|
23
|
+
# We use the pretty-printed string represenation to detect differences
|
24
|
+
# as this avoids problems with dup (causes too many differences) and == (causes too few)
|
25
|
+
def changed?
|
26
|
+
(value != previous_value)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def target_eval(target, source)
|
32
|
+
target.eval(source)
|
33
|
+
rescue => e
|
34
|
+
e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
class Pry
|
2
|
+
class Command::Whereami < Pry::ClassCommand
|
3
|
+
|
4
|
+
class << self
|
5
|
+
attr_accessor :method_size_cutoff
|
6
|
+
end
|
7
|
+
|
8
|
+
@method_size_cutoff = 30
|
9
|
+
|
10
|
+
match 'whereami'
|
11
|
+
description 'Show code surrounding the current context.'
|
12
|
+
group 'Context'
|
13
|
+
|
14
|
+
banner <<-'BANNER'
|
15
|
+
Usage: whereami [-qn] [LINES]
|
16
|
+
|
17
|
+
Describe the current location. If you use `binding.pry` inside a method then
|
18
|
+
whereami will print out the source for that method.
|
19
|
+
|
20
|
+
If a number is passed, then LINES lines before and after the current line will be
|
21
|
+
shown instead of the method itself.
|
22
|
+
|
23
|
+
The `-q` flag can be used to suppress error messages in the case that there's
|
24
|
+
no code to show. This is used by pry in the default before_session hook to show
|
25
|
+
you when you arrive at a `binding.pry`.
|
26
|
+
|
27
|
+
The `-n` flag can be used to hide line numbers so that code can be copy/pasted
|
28
|
+
effectively.
|
29
|
+
|
30
|
+
When pry was started on an Object and there is no associated method, whereami
|
31
|
+
will instead output a brief description of the current object.
|
32
|
+
BANNER
|
33
|
+
|
34
|
+
def setup
|
35
|
+
@file = expand_path(target.eval('__FILE__'))
|
36
|
+
@line = target.eval('__LINE__')
|
37
|
+
@method = Pry::Method.from_binding(target)
|
38
|
+
end
|
39
|
+
|
40
|
+
def options(opt)
|
41
|
+
opt.on :q, :quiet, "Don't display anything in case of an error"
|
42
|
+
opt.on :n, :"no-line-numbers", "Do not display line numbers"
|
43
|
+
opt.on :m, :"method", "Show the complete source for the current method."
|
44
|
+
opt.on :c, :"class", "Show the complete source for the current class or module."
|
45
|
+
opt.on :f, :"file", "Show the complete source for the current file."
|
46
|
+
end
|
47
|
+
|
48
|
+
def code
|
49
|
+
@code ||= if opts.present?(:m)
|
50
|
+
method_code or raise CommandError, "Cannot find method code."
|
51
|
+
elsif opts.present?(:c)
|
52
|
+
class_code or raise CommandError, "Cannot find class code."
|
53
|
+
elsif opts.present?(:f)
|
54
|
+
Pry::Code.from_file(@file)
|
55
|
+
elsif args.any?
|
56
|
+
code_window
|
57
|
+
else
|
58
|
+
default_code
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def code?
|
63
|
+
!!code
|
64
|
+
rescue MethodSource::SourceNotFoundError
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
def bad_option_combination?
|
69
|
+
[opts.present?(:m), opts.present?(:f),
|
70
|
+
opts.present?(:c), args.any?].count(true) > 1
|
71
|
+
end
|
72
|
+
|
73
|
+
def location
|
74
|
+
"#{@file} @ line #{@line} #{@method && @method.name_with_owner}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def process
|
78
|
+
if bad_option_combination?
|
79
|
+
raise CommandError, "Only one of -m, -c, -f, and LINES may be specified."
|
80
|
+
end
|
81
|
+
|
82
|
+
if nothing_to_do?
|
83
|
+
return
|
84
|
+
elsif internal_binding?(target)
|
85
|
+
handle_internal_binding
|
86
|
+
return
|
87
|
+
end
|
88
|
+
|
89
|
+
set_file_and_dir_locals(@file)
|
90
|
+
|
91
|
+
out = "\n#{text.bold('From:')} #{location}:\n\n" <<
|
92
|
+
code.with_line_numbers(use_line_numbers?).with_marker(marker) << "\n"
|
93
|
+
|
94
|
+
_pry_.pager.page out
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def nothing_to_do?
|
100
|
+
opts.quiet? && (internal_binding?(target) || !code?)
|
101
|
+
end
|
102
|
+
|
103
|
+
def use_line_numbers?
|
104
|
+
!opts.present?(:n)
|
105
|
+
end
|
106
|
+
|
107
|
+
def marker
|
108
|
+
!opts.present?(:n) && @line
|
109
|
+
end
|
110
|
+
|
111
|
+
def top_level?
|
112
|
+
target_self == Pry.main
|
113
|
+
end
|
114
|
+
|
115
|
+
def handle_internal_binding
|
116
|
+
if top_level?
|
117
|
+
output.puts "At the top level."
|
118
|
+
else
|
119
|
+
output.puts "Inside #{Pry.view_clip(target_self)}."
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def small_method?
|
124
|
+
@method.source_range.count < self.class.method_size_cutoff
|
125
|
+
end
|
126
|
+
|
127
|
+
def default_code
|
128
|
+
if method_code && small_method?
|
129
|
+
method_code
|
130
|
+
else
|
131
|
+
code_window
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def code_window
|
136
|
+
Pry::Code.from_file(@file).around(@line, window_size)
|
137
|
+
end
|
138
|
+
|
139
|
+
def method_code
|
140
|
+
return @method_code if @method_code
|
141
|
+
|
142
|
+
if valid_method?
|
143
|
+
@method_code = Pry::Code.from_method(@method)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# This either returns the `target_self`
|
148
|
+
# or it returns the class of `target_self` if `target_self` is not a class.
|
149
|
+
# @return [Pry::WrappedModule]
|
150
|
+
def target_class
|
151
|
+
target_self.is_a?(Module) ? Pry::WrappedModule(target_self) :
|
152
|
+
Pry::WrappedModule(target_self.class)
|
153
|
+
end
|
154
|
+
|
155
|
+
def class_code
|
156
|
+
return @class_code if @class_code
|
157
|
+
|
158
|
+
mod = @method ? Pry::WrappedModule(@method.owner) : target_class
|
159
|
+
|
160
|
+
idx = mod.candidates.find_index { |v| expand_path(v.source_file) == @file }
|
161
|
+
@class_code = idx && Pry::Code.from_module(mod, idx)
|
162
|
+
end
|
163
|
+
|
164
|
+
def valid_method?
|
165
|
+
@method && @method.source? && expand_path(@method.source_file) == @file &&
|
166
|
+
@method.source_range.include?(@line)
|
167
|
+
end
|
168
|
+
|
169
|
+
def expand_path(f)
|
170
|
+
return if !f
|
171
|
+
|
172
|
+
if Pry.eval_path == f
|
173
|
+
f
|
174
|
+
else
|
175
|
+
File.expand_path(f)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def window_size
|
180
|
+
if args.empty?
|
181
|
+
_pry_.config.default_window_size
|
182
|
+
else
|
183
|
+
args.first.to_i
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
Pry::Commands.add_command(Pry::Command::Whereami)
|
189
|
+
Pry::Commands.alias_command '@', 'whereami'
|
190
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Pry
|
2
|
+
class Command::Wtf < Pry::ClassCommand
|
3
|
+
match(/wtf([?!]*)/)
|
4
|
+
group 'Context'
|
5
|
+
description 'Show the backtrace of the most recent exception.'
|
6
|
+
options :listing => 'wtf?'
|
7
|
+
|
8
|
+
banner <<-'BANNER'
|
9
|
+
Usage: wtf[?|!]
|
10
|
+
|
11
|
+
Show's a few lines of the backtrace of the most recent exception (also available
|
12
|
+
as `_ex_.backtrace`). If you want to see more lines, add more question marks or
|
13
|
+
exclamation marks.
|
14
|
+
|
15
|
+
wtf?
|
16
|
+
wtf?!???!?!?
|
17
|
+
|
18
|
+
# To see the entire backtrace, pass the `-v` or `--verbose` flag.
|
19
|
+
wtf -v
|
20
|
+
BANNER
|
21
|
+
|
22
|
+
def options(opt)
|
23
|
+
opt.on :v, :verbose, "Show the full backtrace"
|
24
|
+
end
|
25
|
+
|
26
|
+
def process
|
27
|
+
raise Pry::CommandError, "No most-recent exception" unless exception
|
28
|
+
|
29
|
+
output.puts "#{text.bold('Exception:')} #{exception.class}: #{exception}\n--"
|
30
|
+
if opts.verbose?
|
31
|
+
output.puts with_line_numbers(backtrace)
|
32
|
+
else
|
33
|
+
output.puts with_line_numbers(backtrace.first(size_of_backtrace))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def exception
|
40
|
+
_pry_.last_exception
|
41
|
+
end
|
42
|
+
|
43
|
+
def with_line_numbers(bt)
|
44
|
+
Pry::Code.new(bt, 0, :text).with_line_numbers.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def backtrace
|
48
|
+
exception.backtrace
|
49
|
+
end
|
50
|
+
|
51
|
+
def size_of_backtrace
|
52
|
+
[captures[0].size, 0.5].max * 10
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Pry::Commands.add_command(Pry::Command::Wtf)
|
57
|
+
end
|
data/lib/pry/config.rb
CHANGED
@@ -1,233 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# @return [#readline] The object to use for input by default by all
|
11
|
-
# Pry instances.
|
12
|
-
# @example
|
13
|
-
# Pry.config.input = StringIO.new("@x = 10\nexit")
|
14
|
-
attr_accessor :input
|
15
|
-
|
16
|
-
# Get/Set the object to use for output by default by all Pry instances.
|
17
|
-
# Pry.config.output is an option determining the output object - the object to which
|
18
|
-
# Pry writes its output. Pry accepts any object that implements the puts method. This
|
19
|
-
# includes IO objects, StringIO, File and custom objects.
|
20
|
-
# @return [#puts] The object to use for output by default by all
|
21
|
-
# Pry instances.
|
22
|
-
# @example
|
23
|
-
# Pry.config.output = StringIO.new
|
24
|
-
attr_accessor :output
|
25
|
-
|
26
|
-
# Get/Set the object to use for commands by default by all Pry instances.
|
27
|
-
# @return [Pry::CommandBase] The object to use for commands by default by all
|
28
|
-
# Pry instances.
|
29
|
-
# @example
|
30
|
-
# Pry.config.commands = Pry::CommandSet.new do
|
31
|
-
# import_from Pry::Commands, "ls"
|
32
|
-
#
|
33
|
-
# command "greet" do |name|
|
34
|
-
# output.puts "hello #{name}"
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
attr_accessor :commands
|
38
|
-
|
39
|
-
# Get/Set the Proc to use for printing by default by all Pry
|
40
|
-
# instances.
|
41
|
-
# Two parameters are passed to the print Proc: these are (1) the
|
42
|
-
# output object for the current session and (2) the expression value to print. It is important
|
43
|
-
# that you write to the output object instead of just stdout so that all Pry output can be redirected if necessary.
|
44
|
-
# This is the 'print' component of the REPL.
|
45
|
-
# @return [Proc] The Proc to use for printing by default by all
|
46
|
-
# Pry instances.
|
47
|
-
# @example
|
48
|
-
# Pry.config.print = proc { |output, value| output.puts "=> #{value.inspect}" }
|
49
|
-
attr_accessor :print
|
50
|
-
|
51
|
-
# Pry.config.exception_handler is an option determining the exception handler object - the
|
52
|
-
# Proc responsible for dealing with exceptions raised by user input to the REPL.
|
53
|
-
# Three parameters are passed to the exception handler Proc: these
|
54
|
-
# are (1) the output object for the current session, (2) the
|
55
|
-
# exception object that was raised inside the Pry session, and (3)
|
56
|
-
# a reference to the associated Pry instance.
|
57
|
-
# @return [Proc] The Proc to use for printing exceptions by default by all
|
58
|
-
# Pry instances.
|
59
|
-
# @example
|
60
|
-
# Pry.config.exception_handler = proc do |output, exception, _|
|
61
|
-
# output.puts "#{exception.class}: #{exception.message}"
|
62
|
-
# output.puts "from #{exception.backtrace.first}"
|
63
|
-
# end
|
64
|
-
attr_accessor :exception_handler
|
65
|
-
|
66
|
-
# @return [Array] The classes of exception that will not be caught by Pry.
|
67
|
-
# @example
|
68
|
-
# Pry.config.exception_whitelist = [SystemExit, SignalException]
|
69
|
-
attr_accessor :exception_whitelist
|
70
|
-
|
71
|
-
# @return [Fixnum] The number of lines of context to show before and after
|
72
|
-
# exceptions, etc.
|
73
|
-
# @example
|
74
|
-
# Pry.config.default_window_size = 10
|
75
|
-
attr_accessor :default_window_size
|
76
|
-
|
77
|
-
# Get/Set the `Pry::Hooks` instance that defines Pry hooks used by default by all Pry
|
78
|
-
# instances.
|
79
|
-
# @return [Pry::Hooks] The hooks used by default by all Pry instances.
|
80
|
-
# @example
|
81
|
-
# Pry.config.hooks = Pry::Hooks.new.add_hook(:before_session,
|
82
|
-
# :default) { |output, target, _pry_| output.puts "Good morning!" }
|
83
|
-
attr_reader :hooks
|
1
|
+
class Pry::Config
|
2
|
+
require_relative 'config/behavior'
|
3
|
+
require_relative 'config/default'
|
4
|
+
require_relative 'config/convenience'
|
5
|
+
include Pry::Config::Behavior
|
6
|
+
|
7
|
+
def self.shortcuts
|
8
|
+
Convenience::SHORTCUTS
|
9
|
+
end
|
84
10
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
11
|
+
#
|
12
|
+
# FIXME
|
13
|
+
# @param [Pry::Hooks] hooks
|
14
|
+
#
|
15
|
+
def hooks=(hooks)
|
16
|
+
if hooks.is_a?(Hash)
|
17
|
+
warn "Hash-based hooks are now deprecated! Use a `Pry::Hooks` object " \
|
18
|
+
"instead! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
|
19
|
+
self["hooks"] = Pry::Hooks.from_hash(hooks)
|
20
|
+
else
|
21
|
+
self["hooks"] = hooks
|
95
22
|
end
|
96
|
-
|
97
|
-
# Get/Set the stack of input objects that a Pry instance switches
|
98
|
-
# to when its current input object encounters EOF.
|
99
|
-
# @return [Array] The array of input objects.
|
100
|
-
# @example
|
101
|
-
# Pry.config.input_stack = [StringIO.new("puts 'hello world'\nexit")]
|
102
|
-
attr_accessor :input_stack
|
103
|
-
|
104
|
-
# Get the array of Procs (or single Proc) to be used for the prompts by default by
|
105
|
-
# all Pry instances.
|
106
|
-
# Three parameters are passed into the prompt procs, (1) the
|
107
|
-
# object that is the target of the session, (2) the current
|
108
|
-
# nesting level, and (3) a reference to the associated Pry instance. These objects can be used in the prompt, if desired.
|
109
|
-
# @return [Array<Proc>, Proc] The array of Procs to be used for the
|
110
|
-
# prompts by default by all Pry instances.
|
111
|
-
# @example
|
112
|
-
# Pry.config.prompt = proc { |obj, nest_level, _pry_| "#{obj}:#{nest_level}> " }
|
113
|
-
attr_accessor :prompt
|
114
|
-
|
115
|
-
# The default editor to use. Defaults to $VISUAL, $EDITOR, or a sensible fallback
|
116
|
-
# for the platform.
|
117
|
-
# If `editor` is a String then that string is used as the shell
|
118
|
-
# command to invoke the editor. If `editor` is callable (e.g a
|
119
|
-
# Proc) then `file`, `line`, and `reloading` are passed in as parameters and the
|
120
|
-
# return value of that callable invocation is used as the exact
|
121
|
-
# shell command to invoke the editor. `reloading` indicates whether Pry will be
|
122
|
-
# reloading code after the shell command returns. Any or all of these parameters
|
123
|
-
# can be omitted from the callable's signature.
|
124
|
-
# @example String
|
125
|
-
# Pry.config.editor = "emacsclient"
|
126
|
-
# @example Callable
|
127
|
-
# Pry.config.editor = proc { |file, line| "emacsclient #{file} +#{line}" }
|
128
|
-
# @example Callable waiting only if reloading
|
129
|
-
# Pry.config.editor = proc { |file, line, reloading| "subl #{'--wait' if reloading} #{file}:#{line}" }
|
130
|
-
# @return [String, #call]
|
131
|
-
attr_accessor :editor
|
132
|
-
|
133
|
-
# A string that must precede all Pry commands (e.g., if command_prefix is
|
134
|
-
# set to "%", the "cd" command must be invoked as "%cd").
|
135
|
-
# @return [String]
|
136
|
-
attr_accessor :command_prefix
|
137
|
-
|
138
|
-
# @return [Boolean] Toggle Pry color on and off.
|
139
|
-
attr_accessor :color
|
140
|
-
|
141
|
-
# @return [Boolean] Toggle paging on and off.
|
142
|
-
attr_accessor :pager
|
143
|
-
|
144
|
-
# Determines whether the rc file (~/.pryrc) should be loaded.
|
145
|
-
# @return [Boolean]
|
146
|
-
attr_accessor :should_load_rc
|
147
|
-
|
148
|
-
# Determines whether the local rc file (./.pryrc) should be loaded.
|
149
|
-
# @return [Boolean]
|
150
|
-
attr_accessor :should_load_local_rc
|
151
|
-
|
152
|
-
# Determines whether plugins should be loaded.
|
153
|
-
# @return [Boolean]
|
154
|
-
attr_accessor :should_load_plugins
|
155
|
-
|
156
|
-
# Determines whether to load files specified with the -r flag.
|
157
|
-
# @return [Boolean]
|
158
|
-
attr_accessor :should_load_requires
|
159
|
-
|
160
|
-
# Determines whether to disable edit-method's auto-reloading behavior.
|
161
|
-
# @return [Boolean]
|
162
|
-
attr_accessor :disable_auto_reload
|
163
|
-
|
164
|
-
# Determines whether Pry should trap SIGINT and cause it to raise an
|
165
|
-
# Interrupt exception. This is only useful on jruby, MRI does this
|
166
|
-
# for us.
|
167
|
-
# @return [Boolean]
|
168
|
-
attr_accessor :should_trap_interrupts
|
169
|
-
|
170
|
-
# Config option for history.
|
171
|
-
# sub-options include history.file, history.load, and history.save
|
172
|
-
# history.file is the file to save/load history to, e.g
|
173
|
-
# Pry.config.history.file = "~/.pry_history".
|
174
|
-
# history.should_load is a boolean that determines whether history will be
|
175
|
-
# loaded from history.file at session start.
|
176
|
-
# history.should_save is a boolean that determines whether history will be
|
177
|
-
# saved to history.file at session end.
|
178
|
-
# @return [OpenStruct]
|
179
|
-
attr_accessor :history
|
180
|
-
|
181
|
-
# Config option for plugins:
|
182
|
-
# sub-options include:
|
183
|
-
# `plugins.strict_loading` (Boolean) which toggles whether referring to a non-existent plugin should raise an exception (defaults to `false`)
|
184
|
-
# @return [OpenStruct]
|
185
|
-
attr_accessor :plugins
|
186
|
-
|
187
|
-
# @return [Array<String>] Ruby files to be required after loading any plugins.
|
188
|
-
attr_accessor :requires
|
189
|
-
|
190
|
-
# @return [Integer] Amount of results that will be stored into out
|
191
|
-
attr_accessor :memory_size
|
192
|
-
|
193
|
-
# @return [Proc] The proc that manages ^D presses in the REPL.
|
194
|
-
# The proc is passed the current eval_string and the current pry instance.
|
195
|
-
attr_accessor :control_d_handler
|
196
|
-
|
197
|
-
# @return [Proc] The proc that runs system commands
|
198
|
-
# The proc is passed the pry output object, the command string
|
199
|
-
# to eval, and a reference to the pry instance
|
200
|
-
attr_accessor :system
|
201
|
-
|
202
|
-
# @return [Boolean] Whether or not code should be indented
|
203
|
-
# using Pry::Indent.
|
204
|
-
attr_accessor :auto_indent
|
205
|
-
|
206
|
-
# @return [Boolean] Whether or not indentation should be corrected
|
207
|
-
# after hitting enter. This feature is not supported by all terminals.
|
208
|
-
attr_accessor :correct_indent
|
209
|
-
|
210
|
-
# @return [Boolean] Whether or not a warning will be displayed when
|
211
|
-
# a command name collides with a method/local in the current context.
|
212
|
-
attr_accessor :collision_warning
|
213
|
-
|
214
|
-
|
215
|
-
# Config option for gist.
|
216
|
-
# sub-options include `gist.inspecter`,
|
217
|
-
# `gist.inspecter` is a callable that defines how the expression output
|
218
|
-
# will be displayed when using the `gist -i` command.
|
219
|
-
# @example Pretty inspect output
|
220
|
-
# Pry.config.gist.inspecter = proc { |v| v.pretty_inspect }
|
221
|
-
# @example Regular inspect
|
222
|
-
# Pry.config.gist.inspecter = proc &:inspect
|
223
|
-
# @return [OpenStruct]
|
224
|
-
attr_accessor :gist
|
225
|
-
|
226
|
-
# @return [Hash] Additional sticky locals (to the standard ones) to use in Pry sessions.
|
227
|
-
# @example Inject `random_number` sticky local into Pry session
|
228
|
-
# Pry.config.extra_sticky_locals = { :random_number => proc {
|
229
|
-
# rand(10) } }
|
230
|
-
attr_accessor :extra_sticky_locals
|
231
23
|
end
|
232
24
|
end
|
233
|
-
|