pry 0.10.2-i386-mswin32 → 1.0.0.pre1-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +2 -0
- data/.gitignore +16 -0
- data/.travis.yml +21 -0
- data/.yardopts +3 -0
- data/CHANGELOG +503 -0
- data/CONTRIBUTORS +55 -0
- data/Gemfile +9 -0
- data/Guardfile +62 -0
- data/LICENSE +2 -2
- data/{README.md → README.markdown} +31 -37
- data/Rakefile +144 -0
- data/TODO +117 -0
- data/lib/pry.rb +146 -33
- data/lib/pry/cli.rb +13 -35
- data/lib/pry/code.rb +63 -24
- data/lib/pry/code/loc.rb +2 -2
- data/lib/pry/code_object.rb +21 -40
- data/lib/pry/command.rb +6 -9
- data/lib/pry/command_set.rb +37 -80
- data/lib/pry/commands.rb +1 -1
- data/lib/pry/commands/amend_line.rb +1 -1
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat.rb +2 -11
- data/lib/pry/commands/cat/abstract_formatter.rb +1 -1
- data/lib/pry/commands/cat/exception_formatter.rb +7 -6
- data/lib/pry/commands/cat/file_formatter.rb +32 -15
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cd.rb +3 -14
- data/lib/pry/commands/code_collector.rb +4 -4
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +22 -10
- data/lib/pry/commands/edit/exception_patcher.rb +1 -1
- data/lib/pry/commands/edit/file_and_line_locator.rb +2 -0
- data/lib/pry/{method/patcher.rb → commands/edit/method_patcher.rb} +37 -40
- data/lib/pry/commands/find_method.rb +22 -16
- data/lib/pry/commands/gem_install.rb +2 -5
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gist.rb +11 -10
- data/lib/pry/commands/help.rb +14 -14
- data/lib/pry/commands/hist.rb +5 -24
- data/lib/pry/commands/ls.rb +287 -56
- data/lib/pry/commands/play.rb +10 -44
- data/lib/pry/commands/pry_backtrace.rb +2 -1
- data/lib/pry/commands/raise_up.rb +1 -1
- data/lib/pry/commands/reload_code.rb +15 -31
- data/lib/pry/commands/ri.rb +3 -7
- data/lib/pry/commands/shell_command.rb +12 -17
- data/lib/pry/commands/shell_mode.rb +2 -2
- data/lib/pry/commands/show_doc.rb +0 -5
- data/lib/pry/commands/show_info.rb +10 -11
- data/lib/pry/commands/show_source.rb +3 -15
- data/lib/pry/commands/simple_prompt.rb +1 -1
- data/lib/pry/commands/toggle_color.rb +4 -8
- data/lib/pry/commands/whereami.rb +10 -18
- data/lib/pry/completion.rb +293 -0
- data/lib/pry/config.rb +233 -20
- data/lib/pry/core_extensions.rb +19 -29
- data/lib/pry/custom_completions.rb +6 -0
- data/lib/pry/editor.rb +103 -109
- data/lib/pry/helpers/base_helpers.rb +109 -22
- data/lib/pry/helpers/command_helpers.rb +8 -10
- data/lib/pry/helpers/documentation_helpers.rb +2 -1
- data/lib/pry/helpers/text.rb +5 -4
- data/lib/pry/history.rb +10 -21
- data/lib/pry/history_array.rb +0 -5
- data/lib/pry/hooks.rb +29 -9
- data/lib/pry/indent.rb +10 -5
- data/lib/pry/method.rb +86 -81
- data/lib/pry/method/weird_method_locator.rb +2 -4
- data/lib/pry/module_candidate.rb +14 -5
- data/lib/pry/pager.rb +48 -193
- data/lib/pry/plugins.rb +2 -2
- data/lib/pry/pry_class.rb +193 -104
- data/lib/pry/pry_instance.rb +154 -152
- data/lib/pry/rbx_method.rb +13 -0
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +14 -17
- data/lib/pry/repl_file_loader.rb +3 -8
- data/lib/pry/rubygem.rb +3 -3
- data/lib/pry/terminal.rb +3 -4
- data/lib/pry/test/helper.rb +11 -6
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +56 -49
- data/man/pry.1 +195 -0
- data/man/pry.1.html +204 -0
- data/man/pry.1.ronn +141 -0
- data/pry.gemspec +31 -0
- data/spec/Procfile +3 -0
- data/spec/cli_spec.rb +78 -0
- data/spec/code_object_spec.rb +277 -0
- data/spec/code_spec.rb +219 -0
- data/spec/command_helpers_spec.rb +29 -0
- data/spec/command_integration_spec.rb +562 -0
- data/spec/command_set_spec.rb +627 -0
- data/spec/command_spec.rb +821 -0
- data/spec/commands/amend_line_spec.rb +247 -0
- data/spec/commands/bang_spec.rb +18 -0
- data/spec/commands/cat_spec.rb +164 -0
- data/spec/commands/cd_spec.rb +250 -0
- data/spec/commands/disable_pry_spec.rb +25 -0
- data/spec/commands/edit_spec.rb +725 -0
- data/spec/commands/exit_all_spec.rb +27 -0
- data/spec/commands/exit_program_spec.rb +19 -0
- data/spec/commands/exit_spec.rb +28 -0
- data/spec/commands/find_method_spec.rb +70 -0
- data/spec/commands/gem_list_spec.rb +26 -0
- data/spec/commands/gist_spec.rb +79 -0
- data/spec/commands/help_spec.rb +56 -0
- data/spec/commands/hist_spec.rb +172 -0
- data/spec/commands/jump_to_spec.rb +15 -0
- data/spec/commands/ls_spec.rb +189 -0
- data/spec/commands/play_spec.rb +136 -0
- data/spec/commands/raise_up_spec.rb +56 -0
- data/spec/commands/save_file_spec.rb +177 -0
- data/spec/commands/show_doc_spec.rb +488 -0
- data/spec/commands/show_input_spec.rb +17 -0
- data/spec/commands/show_source_spec.rb +760 -0
- data/spec/commands/whereami_spec.rb +203 -0
- data/spec/completion_spec.rb +221 -0
- data/spec/control_d_handler_spec.rb +62 -0
- data/spec/documentation_helper_spec.rb +73 -0
- data/spec/editor_spec.rb +79 -0
- data/spec/exception_whitelist_spec.rb +21 -0
- data/spec/fixtures/candidate_helper1.rb +11 -0
- data/spec/fixtures/candidate_helper2.rb +8 -0
- data/spec/fixtures/example.erb +5 -0
- data/spec/fixtures/example_nesting.rb +33 -0
- data/spec/fixtures/show_source_doc_examples.rb +15 -0
- data/spec/fixtures/testlinkrc +2 -0
- data/spec/fixtures/testrc +2 -0
- data/spec/fixtures/testrcbad +2 -0
- data/spec/fixtures/whereami_helper.rb +6 -0
- data/spec/helper.rb +35 -0
- data/spec/helpers/bacon.rb +86 -0
- data/spec/helpers/mock_pry.rb +44 -0
- data/spec/helpers/repl_tester.rb +112 -0
- data/spec/helpers/table_spec.rb +105 -0
- data/spec/history_array_spec.rb +67 -0
- data/spec/hooks_spec.rb +522 -0
- data/spec/indent_spec.rb +301 -0
- data/spec/method_spec.rb +482 -0
- data/spec/prompt_spec.rb +61 -0
- data/spec/pry_defaults_spec.rb +420 -0
- data/spec/pry_history_spec.rb +69 -0
- data/spec/pry_output_spec.rb +95 -0
- data/spec/pry_repl_spec.rb +86 -0
- data/spec/pry_spec.rb +394 -0
- data/spec/pryrc_spec.rb +97 -0
- data/spec/run_command_spec.rb +25 -0
- data/spec/sticky_locals_spec.rb +147 -0
- data/spec/syntax_checking_spec.rb +81 -0
- data/spec/wrapped_module_spec.rb +261 -0
- data/wiki/Customizing-pry.md +397 -0
- data/wiki/Home.md +4 -0
- metadata +272 -61
- checksums.yaml +0 -7
- data/CHANGELOG.md +0 -714
- data/lib/pry/code/code_file.rb +0 -103
- data/lib/pry/color_printer.rb +0 -55
- data/lib/pry/commands/change_inspector.rb +0 -27
- data/lib/pry/commands/change_prompt.rb +0 -26
- data/lib/pry/commands/list_inspectors.rb +0 -35
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/ls/constants.rb +0 -47
- data/lib/pry/commands/ls/formatter.rb +0 -49
- data/lib/pry/commands/ls/globals.rb +0 -48
- data/lib/pry/commands/ls/grep.rb +0 -21
- data/lib/pry/commands/ls/instance_vars.rb +0 -39
- data/lib/pry/commands/ls/interrogatable.rb +0 -18
- data/lib/pry/commands/ls/jruby_hacks.rb +0 -49
- data/lib/pry/commands/ls/local_names.rb +0 -35
- data/lib/pry/commands/ls/local_vars.rb +0 -39
- data/lib/pry/commands/ls/ls_entity.rb +0 -70
- data/lib/pry/commands/ls/methods.rb +0 -57
- data/lib/pry/commands/ls/methods_helper.rb +0 -46
- data/lib/pry/commands/ls/self_methods.rb +0 -32
- data/lib/pry/commands/watch_expression.rb +0 -105
- data/lib/pry/commands/watch_expression/expression.rb +0 -38
- data/lib/pry/config/behavior.rb +0 -139
- data/lib/pry/config/convenience.rb +0 -25
- data/lib/pry/config/default.rb +0 -161
- data/lib/pry/exceptions.rb +0 -78
- data/lib/pry/input_completer.rb +0 -242
- data/lib/pry/input_lock.rb +0 -132
- data/lib/pry/inspector.rb +0 -27
- data/lib/pry/last_exception.rb +0 -61
- data/lib/pry/object_path.rb +0 -82
- data/lib/pry/output.rb +0 -50
- data/lib/pry/prompt.rb +0 -26
@@ -0,0 +1,293 @@
|
|
1
|
+
# taken from irb
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
|
5
|
+
module BondCompleter
|
6
|
+
def self.call(input, options)
|
7
|
+
Pry.current[:pry] = options[:pry]
|
8
|
+
Bond.agent.call(input)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.start
|
12
|
+
Bond.start(:eval_binding => lambda{ Pry.current[:pry] && Pry.current[:pry].current_context })
|
13
|
+
Bond.complete(:on => /\A/) do |input|
|
14
|
+
Pry.commands.complete(input.line,
|
15
|
+
:pry_instance => Pry.current[:pry],
|
16
|
+
:target => Pry.current[:pry].current_context,
|
17
|
+
:command_set => Pry.current[:pry].commands)
|
18
|
+
end
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Implements tab completion for Readline in Pry
|
24
|
+
module InputCompleter
|
25
|
+
|
26
|
+
def self.start
|
27
|
+
if Readline.respond_to?("basic_word_break_characters=")
|
28
|
+
Readline.basic_word_break_characters = " \t\n\"\\'`><=;|&{("
|
29
|
+
end
|
30
|
+
|
31
|
+
Readline.completion_append_character = nil
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
ReservedWords = [
|
36
|
+
"BEGIN", "END",
|
37
|
+
"alias", "and",
|
38
|
+
"begin", "break",
|
39
|
+
"case", "class",
|
40
|
+
"def", "defined", "do",
|
41
|
+
"else", "elsif", "end", "ensure",
|
42
|
+
"false", "for",
|
43
|
+
"if", "in",
|
44
|
+
"module",
|
45
|
+
"next", "nil", "not",
|
46
|
+
"or",
|
47
|
+
"redo", "rescue", "retry", "return",
|
48
|
+
"self", "super",
|
49
|
+
"then", "true",
|
50
|
+
"undef", "unless", "until",
|
51
|
+
"when", "while",
|
52
|
+
"yield" ]
|
53
|
+
|
54
|
+
Operators = [
|
55
|
+
"%", "&", "*", "**", "+", "-", "/",
|
56
|
+
"<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
|
57
|
+
"[]", "[]=", "^", "!", "!=", "!~"
|
58
|
+
]
|
59
|
+
|
60
|
+
# Return a new completion proc for use by Readline.
|
61
|
+
# @param [Binding] target The current binding context.
|
62
|
+
# @param [Array<String>] commands The array of Pry commands.
|
63
|
+
def self.call(input, options)
|
64
|
+
|
65
|
+
custom_completions = options[:custom_completions] || []
|
66
|
+
|
67
|
+
# if there are multiple contexts e.g. cd 1/2/3
|
68
|
+
# get new target for 1/2 and find candidates for 3
|
69
|
+
path, input = build_path(input)
|
70
|
+
|
71
|
+
if path.call.empty?
|
72
|
+
target = options[:target]
|
73
|
+
else
|
74
|
+
target, _ = Pry::Helpers::BaseHelpers.context_from_object_path(path.call, options[:pry])
|
75
|
+
target = target.last
|
76
|
+
end
|
77
|
+
|
78
|
+
begin
|
79
|
+
bind = target
|
80
|
+
|
81
|
+
case input
|
82
|
+
|
83
|
+
|
84
|
+
# Complete stdlib symbols
|
85
|
+
|
86
|
+
when /^(\/[^\/]*\/)\.([^.]*)$/
|
87
|
+
# Regexp
|
88
|
+
receiver = $1
|
89
|
+
message = Regexp.quote($2)
|
90
|
+
|
91
|
+
candidates = Regexp.instance_methods.collect(&:to_s)
|
92
|
+
select_message(path, receiver, message, candidates)
|
93
|
+
|
94
|
+
when /^([^\]]*\])\.([^.]*)$/
|
95
|
+
# Array
|
96
|
+
receiver = $1
|
97
|
+
message = Regexp.quote($2)
|
98
|
+
|
99
|
+
candidates = Array.instance_methods.collect(&:to_s)
|
100
|
+
select_message(path, receiver, message, candidates)
|
101
|
+
|
102
|
+
when /^([^\}]*\})\.([^.]*)$/
|
103
|
+
# Proc or Hash
|
104
|
+
receiver = $1
|
105
|
+
message = Regexp.quote($2)
|
106
|
+
|
107
|
+
candidates = Proc.instance_methods.collect(&:to_s)
|
108
|
+
candidates |= Hash.instance_methods.collect(&:to_s)
|
109
|
+
select_message(path, receiver, message, candidates)
|
110
|
+
|
111
|
+
when /^(:[^:.]*)$/
|
112
|
+
# Symbol
|
113
|
+
if Symbol.respond_to?(:all_symbols)
|
114
|
+
sym = Regexp.quote($1)
|
115
|
+
candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
|
116
|
+
|
117
|
+
candidates.grep(/^#{sym}/)
|
118
|
+
else
|
119
|
+
[]
|
120
|
+
end
|
121
|
+
|
122
|
+
when /^::([A-Z][^:\.\(]*)$/
|
123
|
+
# Absolute Constant or class methods
|
124
|
+
receiver = $1
|
125
|
+
candidates = Object.constants.collect(&:to_s)
|
126
|
+
candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
|
127
|
+
|
128
|
+
|
129
|
+
# Complete target symbols
|
130
|
+
|
131
|
+
when /^([A-Z][A-Za-z0-9]*)$/
|
132
|
+
# Constant
|
133
|
+
message = $1
|
134
|
+
|
135
|
+
begin
|
136
|
+
context = target.eval("self")
|
137
|
+
context = context.class unless context.respond_to? :constants
|
138
|
+
candidates = context.constants.collect(&:to_s)
|
139
|
+
rescue
|
140
|
+
candidates = []
|
141
|
+
end
|
142
|
+
candidates = candidates.grep(/^#{message}/).collect(&path)
|
143
|
+
|
144
|
+
when /^([A-Z].*)::([^:.]*)$/
|
145
|
+
# Constant or class methods
|
146
|
+
receiver = $1
|
147
|
+
message = Regexp.quote($2)
|
148
|
+
begin
|
149
|
+
candidates = eval("#{receiver}.constants.collect(&:to_s)", bind)
|
150
|
+
candidates |= eval("#{receiver}.methods.collect(&:to_s)", bind)
|
151
|
+
rescue RescuableException
|
152
|
+
candidates = []
|
153
|
+
end
|
154
|
+
candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
|
155
|
+
|
156
|
+
when /^(:[^:.]+)\.([^.]*)$/
|
157
|
+
# Symbol
|
158
|
+
receiver = $1
|
159
|
+
message = Regexp.quote($2)
|
160
|
+
|
161
|
+
candidates = Symbol.instance_methods.collect(&:to_s)
|
162
|
+
select_message(path, receiver, message, candidates)
|
163
|
+
|
164
|
+
when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)\.([^.]*)$/
|
165
|
+
# Numeric
|
166
|
+
receiver = $1
|
167
|
+
message = Regexp.quote($5)
|
168
|
+
|
169
|
+
begin
|
170
|
+
candidates = eval(receiver, bind).methods.collect(&:to_s)
|
171
|
+
rescue RescuableException
|
172
|
+
candidates = []
|
173
|
+
end
|
174
|
+
select_message(path, receiver, message, candidates)
|
175
|
+
|
176
|
+
when /^(-?0x[0-9a-fA-F_]+)\.([^.]*)$/#
|
177
|
+
# Numeric(0xFFFF)
|
178
|
+
receiver = $1
|
179
|
+
message = Regexp.quote($2)
|
180
|
+
|
181
|
+
begin
|
182
|
+
candidates = eval(receiver, bind).methods.collect(&:to_s)
|
183
|
+
rescue RescuableException
|
184
|
+
candidates = []
|
185
|
+
end
|
186
|
+
select_message(path, receiver, message, candidates)
|
187
|
+
|
188
|
+
when /^(\$[^.]*)$/
|
189
|
+
# Global variables
|
190
|
+
regmessage = Regexp.new(Regexp.quote($1))
|
191
|
+
candidates = global_variables.collect(&:to_s).grep(regmessage)
|
192
|
+
|
193
|
+
when /^([^."].*)\.([^.]*)$/
|
194
|
+
# Variable
|
195
|
+
receiver = $1
|
196
|
+
message = Regexp.quote($2)
|
197
|
+
|
198
|
+
gv = eval("global_variables", bind).collect(&:to_s)
|
199
|
+
lv = eval("local_variables", bind).collect(&:to_s)
|
200
|
+
cv = eval("self.class.constants", bind).collect(&:to_s)
|
201
|
+
|
202
|
+
if (gv | lv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
|
203
|
+
# foo.func and foo is local var. OR
|
204
|
+
# Foo::Bar.func
|
205
|
+
begin
|
206
|
+
candidates = eval("#{receiver}.methods", bind).collect(&:to_s)
|
207
|
+
rescue RescuableException
|
208
|
+
candidates = []
|
209
|
+
end
|
210
|
+
else
|
211
|
+
# func1.func2
|
212
|
+
candidates = []
|
213
|
+
ObjectSpace.each_object(Module){|m|
|
214
|
+
begin
|
215
|
+
name = m.name.to_s
|
216
|
+
rescue RescuableException
|
217
|
+
name = ""
|
218
|
+
end
|
219
|
+
next if name != "IRB::Context" and
|
220
|
+
/^(IRB|SLex|RubyLex|RubyToken)/ =~ name
|
221
|
+
|
222
|
+
# jruby doesn't always provide #instance_methods() on each
|
223
|
+
# object.
|
224
|
+
if m.respond_to?(:instance_methods)
|
225
|
+
candidates.concat m.instance_methods(false).collect(&:to_s)
|
226
|
+
end
|
227
|
+
}
|
228
|
+
candidates.sort!
|
229
|
+
candidates.uniq!
|
230
|
+
end
|
231
|
+
select_message(path, receiver, message, candidates)
|
232
|
+
|
233
|
+
when /^\.([^.]*)$/
|
234
|
+
# Unknown(maybe String)
|
235
|
+
receiver = ""
|
236
|
+
message = Regexp.quote($1)
|
237
|
+
|
238
|
+
candidates = String.instance_methods(true).collect(&:to_s)
|
239
|
+
select_message(path, receiver, message, candidates)
|
240
|
+
|
241
|
+
else
|
242
|
+
|
243
|
+
candidates = eval(
|
244
|
+
"methods | private_methods | local_variables | " \
|
245
|
+
"self.class.constants | instance_variables",
|
246
|
+
bind
|
247
|
+
).collect(&:to_s)
|
248
|
+
|
249
|
+
if eval("respond_to?(:class_variables)", bind)
|
250
|
+
candidates += eval("class_variables", bind).collect(&:to_s)
|
251
|
+
end
|
252
|
+
candidates = (candidates|ReservedWords|custom_completions).grep(/^#{Regexp.quote(input)}/)
|
253
|
+
candidates.collect(&path)
|
254
|
+
end
|
255
|
+
rescue RescuableException
|
256
|
+
[]
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def self.select_message(path, receiver, message, candidates)
|
261
|
+
candidates.grep(/^#{message}/).collect { |e|
|
262
|
+
case e
|
263
|
+
when /^[a-zA-Z_]/
|
264
|
+
path.call(receiver + "." + e)
|
265
|
+
when /^[0-9]/
|
266
|
+
when *Operators
|
267
|
+
#receiver + " " + e
|
268
|
+
end
|
269
|
+
}.compact
|
270
|
+
end
|
271
|
+
|
272
|
+
# build_path seperates the input into two parts: path and input.
|
273
|
+
# input is the partial string that should be completed
|
274
|
+
# path is a proc that takes an input and builds a full path.
|
275
|
+
def self.build_path(input)
|
276
|
+
|
277
|
+
# check to see if the input is a regex
|
278
|
+
return proc {|i| i.to_s }, input if input[/\/\./]
|
279
|
+
|
280
|
+
trailing_slash = input.end_with?('/')
|
281
|
+
contexts = input.chomp('/').split(/\//)
|
282
|
+
input = contexts[-1]
|
283
|
+
|
284
|
+
path = proc do |i|
|
285
|
+
p = contexts[0..-2].push(i).join('/')
|
286
|
+
p += '/' if trailing_slash && !i.nil?
|
287
|
+
p
|
288
|
+
end
|
289
|
+
|
290
|
+
return path, input
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
data/lib/pry/config.rb
CHANGED
@@ -1,24 +1,237 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
class Config < OpenStruct
|
5
|
+
|
6
|
+
# Get/Set the object to use for input by default by all Pry instances.
|
7
|
+
# Pry.config.input is an option determining the input object - the object from
|
8
|
+
# which Pry retrieves its lines of input. Pry accepts any object that implements the readline method.
|
9
|
+
# This includes IO objects, StringIO, Readline, File and custom objects.
|
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
|
10
76
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
84
|
+
|
85
|
+
# FIXME:
|
86
|
+
# This is a hack to alert people of the new API.
|
87
|
+
# @param [Pry::Hooks] v Only accept `Pry::Hooks` now!
|
88
|
+
def hooks=(v)
|
89
|
+
if v.is_a?(Hash)
|
90
|
+
warn "Hash-based hooks are now deprecated! Use a `Pry::Hooks` object instead! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
|
91
|
+
@hooks = Pry::Hooks.from_hash(v)
|
92
|
+
else
|
93
|
+
@hooks = v
|
94
|
+
end
|
22
95
|
end
|
96
|
+
|
97
|
+
# Get the array of Procs (or single Proc) to be used for the prompts by default by
|
98
|
+
# all Pry instances.
|
99
|
+
# Three parameters are passed into the prompt procs, (1) the
|
100
|
+
# object that is the target of the session, (2) the current
|
101
|
+
# nesting level, and (3) a reference to the associated Pry instance. These objects can be used in the prompt, if desired.
|
102
|
+
# @return [Array<Proc>, Proc] The array of Procs to be used for the
|
103
|
+
# prompts by default by all Pry instances.
|
104
|
+
# @example
|
105
|
+
# Pry.config.prompt = proc { |obj, nest_level, _pry_| "#{obj}:#{nest_level}> " }
|
106
|
+
attr_accessor :prompt
|
107
|
+
|
108
|
+
# The display name that is part of the prompt. Default is 'pry'.
|
109
|
+
# You can set your own name so you can identify which project your current pry session
|
110
|
+
# is using. This is useful if you have a local pryrc file in a Rails project for example.
|
111
|
+
# @return [String]
|
112
|
+
# @example
|
113
|
+
# Pry.config.prompt_name = 'my_rails_project'
|
114
|
+
attr_accessor :prompt_name
|
115
|
+
|
116
|
+
# The default editor to use. Defaults to $VISUAL, $EDITOR, or a sensible fallback
|
117
|
+
# for the platform.
|
118
|
+
# If `editor` is a String then that string is used as the shell
|
119
|
+
# command to invoke the editor. If `editor` is callable (e.g a
|
120
|
+
# Proc) then `file`, `line`, and `reloading` are passed in as parameters and the
|
121
|
+
# return value of that callable invocation is used as the exact
|
122
|
+
# shell command to invoke the editor. `reloading` indicates whether Pry will be
|
123
|
+
# reloading code after the shell command returns. Any or all of these parameters
|
124
|
+
# can be omitted from the callable's signature.
|
125
|
+
# @example String
|
126
|
+
# Pry.config.editor = "emacsclient"
|
127
|
+
# @example Callable
|
128
|
+
# Pry.config.editor = proc { |file, line| "emacsclient #{file} +#{line}" }
|
129
|
+
# @example Callable waiting only if reloading
|
130
|
+
# Pry.config.editor = proc { |file, line, reloading| "subl #{'--wait' if reloading} #{file}:#{line}" }
|
131
|
+
# @return [String, #call]
|
132
|
+
attr_accessor :editor
|
133
|
+
|
134
|
+
# A string that must precede all Pry commands (e.g., if command_prefix is
|
135
|
+
# set to "%", the "cd" command must be invoked as "%cd").
|
136
|
+
# @return [String]
|
137
|
+
attr_accessor :command_prefix
|
138
|
+
|
139
|
+
# @return [Boolean] Toggle Pry color on and off.
|
140
|
+
attr_accessor :color
|
141
|
+
|
142
|
+
# @return [Boolean] Toggle paging on and off.
|
143
|
+
attr_accessor :pager
|
144
|
+
|
145
|
+
# Determines whether the rc file (~/.pryrc) should be loaded.
|
146
|
+
# @return [Boolean]
|
147
|
+
attr_accessor :should_load_rc
|
148
|
+
|
149
|
+
# Determines whether the local rc file (./.pryrc) should be loaded.
|
150
|
+
# @return [Boolean]
|
151
|
+
attr_accessor :should_load_local_rc
|
152
|
+
|
153
|
+
# Determines whether plugins should be loaded.
|
154
|
+
# @return [Boolean]
|
155
|
+
attr_accessor :should_load_plugins
|
156
|
+
|
157
|
+
# Determines whether to load files specified with the -r flag.
|
158
|
+
# @return [Boolean]
|
159
|
+
attr_accessor :should_load_requires
|
160
|
+
|
161
|
+
# Determines whether to disable edit-method's auto-reloading behavior.
|
162
|
+
# @return [Boolean]
|
163
|
+
attr_accessor :disable_auto_reload
|
164
|
+
|
165
|
+
# Determines whether Pry should trap SIGINT and cause it to raise an
|
166
|
+
# Interrupt exception. This is only useful on jruby, MRI does this
|
167
|
+
# for us.
|
168
|
+
# @return [Boolean]
|
169
|
+
attr_accessor :should_trap_interrupts
|
170
|
+
|
171
|
+
# Config option for history.
|
172
|
+
# sub-options include history.file, history.load, and history.save
|
173
|
+
# history.file is the file to save/load history to, e.g
|
174
|
+
# Pry.config.history.file = "~/.pry_history".
|
175
|
+
# history.should_load is a boolean that determines whether history will be
|
176
|
+
# loaded from history.file at session start.
|
177
|
+
# history.should_save is a boolean that determines whether history will be
|
178
|
+
# saved to history.file at session end.
|
179
|
+
# @return [OpenStruct]
|
180
|
+
attr_accessor :history
|
181
|
+
|
182
|
+
# Config option for plugins:
|
183
|
+
# sub-options include:
|
184
|
+
# `plugins.strict_loading` (Boolean) which toggles whether referring to a non-existent plugin should raise an exception (defaults to `false`)
|
185
|
+
# @return [OpenStruct]
|
186
|
+
attr_accessor :plugins
|
187
|
+
|
188
|
+
# @return [Array<String>] Ruby files to be required after loading any plugins.
|
189
|
+
attr_accessor :requires
|
190
|
+
|
191
|
+
# @return [Integer] Amount of results that will be stored into out
|
192
|
+
attr_accessor :memory_size
|
193
|
+
|
194
|
+
# @return [Proc] The proc that manages ^D presses in the REPL.
|
195
|
+
# The proc is passed the current eval_string and the current pry instance.
|
196
|
+
attr_accessor :control_d_handler
|
197
|
+
|
198
|
+
# @return [Proc] The proc that runs system commands
|
199
|
+
# The proc is passed the pry output object, the command string
|
200
|
+
# to eval, and a reference to the pry instance
|
201
|
+
attr_accessor :system
|
202
|
+
|
203
|
+
# @return [Boolean] Whether or not code should be indented
|
204
|
+
# using Pry::Indent.
|
205
|
+
attr_accessor :auto_indent
|
206
|
+
|
207
|
+
# @return [Boolean] Whether or not indentation should be corrected
|
208
|
+
# after hitting enter. This feature is not supported by all terminals.
|
209
|
+
attr_accessor :correct_indent
|
210
|
+
|
211
|
+
# @return [Boolean] Whether or not a warning will be displayed when
|
212
|
+
# a command name collides with a method/local in the current context.
|
213
|
+
attr_accessor :collision_warning
|
214
|
+
|
215
|
+
|
216
|
+
# Config option for gist.
|
217
|
+
# sub-options include `gist.inspecter`,
|
218
|
+
# `gist.inspecter` is a callable that defines how the expression output
|
219
|
+
# will be displayed when using the `gist -i` command.
|
220
|
+
# @example Pretty inspect output
|
221
|
+
# Pry.config.gist.inspecter = proc { |v| v.pretty_inspect }
|
222
|
+
# @example Regular inspect
|
223
|
+
# Pry.config.gist.inspecter = proc &:inspect
|
224
|
+
# @return [OpenStruct]
|
225
|
+
attr_accessor :gist
|
226
|
+
|
227
|
+
# @return [Hash] Additional sticky locals (to the standard ones) to use in Pry sessions.
|
228
|
+
# @example Inject `random_number` sticky local into Pry session
|
229
|
+
# Pry.config.extra_sticky_locals = { :random_number => proc {
|
230
|
+
# rand(10) } }
|
231
|
+
attr_accessor :extra_sticky_locals
|
232
|
+
|
233
|
+
# @return [#build_completion_proc] A completer to use.
|
234
|
+
attr_accessor :completer
|
23
235
|
end
|
24
236
|
end
|
237
|
+
|