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.
Files changed (189) hide show
  1. data/.document +2 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +21 -0
  4. data/.yardopts +3 -0
  5. data/CHANGELOG +503 -0
  6. data/CONTRIBUTORS +55 -0
  7. data/Gemfile +9 -0
  8. data/Guardfile +62 -0
  9. data/LICENSE +2 -2
  10. data/{README.md → README.markdown} +31 -37
  11. data/Rakefile +144 -0
  12. data/TODO +117 -0
  13. data/lib/pry.rb +146 -33
  14. data/lib/pry/cli.rb +13 -35
  15. data/lib/pry/code.rb +63 -24
  16. data/lib/pry/code/loc.rb +2 -2
  17. data/lib/pry/code_object.rb +21 -40
  18. data/lib/pry/command.rb +6 -9
  19. data/lib/pry/command_set.rb +37 -80
  20. data/lib/pry/commands.rb +1 -1
  21. data/lib/pry/commands/amend_line.rb +1 -1
  22. data/lib/pry/commands/bang.rb +1 -1
  23. data/lib/pry/commands/cat.rb +2 -11
  24. data/lib/pry/commands/cat/abstract_formatter.rb +1 -1
  25. data/lib/pry/commands/cat/exception_formatter.rb +7 -6
  26. data/lib/pry/commands/cat/file_formatter.rb +32 -15
  27. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  28. data/lib/pry/commands/cd.rb +3 -14
  29. data/lib/pry/commands/code_collector.rb +4 -4
  30. data/lib/pry/commands/easter_eggs.rb +3 -3
  31. data/lib/pry/commands/edit.rb +22 -10
  32. data/lib/pry/commands/edit/exception_patcher.rb +1 -1
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +2 -0
  34. data/lib/pry/{method/patcher.rb → commands/edit/method_patcher.rb} +37 -40
  35. data/lib/pry/commands/find_method.rb +22 -16
  36. data/lib/pry/commands/gem_install.rb +2 -5
  37. data/lib/pry/commands/gem_open.rb +1 -1
  38. data/lib/pry/commands/gist.rb +11 -10
  39. data/lib/pry/commands/help.rb +14 -14
  40. data/lib/pry/commands/hist.rb +5 -24
  41. data/lib/pry/commands/ls.rb +287 -56
  42. data/lib/pry/commands/play.rb +10 -44
  43. data/lib/pry/commands/pry_backtrace.rb +2 -1
  44. data/lib/pry/commands/raise_up.rb +1 -1
  45. data/lib/pry/commands/reload_code.rb +15 -31
  46. data/lib/pry/commands/ri.rb +3 -7
  47. data/lib/pry/commands/shell_command.rb +12 -17
  48. data/lib/pry/commands/shell_mode.rb +2 -2
  49. data/lib/pry/commands/show_doc.rb +0 -5
  50. data/lib/pry/commands/show_info.rb +10 -11
  51. data/lib/pry/commands/show_source.rb +3 -15
  52. data/lib/pry/commands/simple_prompt.rb +1 -1
  53. data/lib/pry/commands/toggle_color.rb +4 -8
  54. data/lib/pry/commands/whereami.rb +10 -18
  55. data/lib/pry/completion.rb +293 -0
  56. data/lib/pry/config.rb +233 -20
  57. data/lib/pry/core_extensions.rb +19 -29
  58. data/lib/pry/custom_completions.rb +6 -0
  59. data/lib/pry/editor.rb +103 -109
  60. data/lib/pry/helpers/base_helpers.rb +109 -22
  61. data/lib/pry/helpers/command_helpers.rb +8 -10
  62. data/lib/pry/helpers/documentation_helpers.rb +2 -1
  63. data/lib/pry/helpers/text.rb +5 -4
  64. data/lib/pry/history.rb +10 -21
  65. data/lib/pry/history_array.rb +0 -5
  66. data/lib/pry/hooks.rb +29 -9
  67. data/lib/pry/indent.rb +10 -5
  68. data/lib/pry/method.rb +86 -81
  69. data/lib/pry/method/weird_method_locator.rb +2 -4
  70. data/lib/pry/module_candidate.rb +14 -5
  71. data/lib/pry/pager.rb +48 -193
  72. data/lib/pry/plugins.rb +2 -2
  73. data/lib/pry/pry_class.rb +193 -104
  74. data/lib/pry/pry_instance.rb +154 -152
  75. data/lib/pry/rbx_method.rb +13 -0
  76. data/lib/pry/rbx_path.rb +1 -1
  77. data/lib/pry/repl.rb +14 -17
  78. data/lib/pry/repl_file_loader.rb +3 -8
  79. data/lib/pry/rubygem.rb +3 -3
  80. data/lib/pry/terminal.rb +3 -4
  81. data/lib/pry/test/helper.rb +11 -6
  82. data/lib/pry/version.rb +1 -1
  83. data/lib/pry/wrapped_module.rb +56 -49
  84. data/man/pry.1 +195 -0
  85. data/man/pry.1.html +204 -0
  86. data/man/pry.1.ronn +141 -0
  87. data/pry.gemspec +31 -0
  88. data/spec/Procfile +3 -0
  89. data/spec/cli_spec.rb +78 -0
  90. data/spec/code_object_spec.rb +277 -0
  91. data/spec/code_spec.rb +219 -0
  92. data/spec/command_helpers_spec.rb +29 -0
  93. data/spec/command_integration_spec.rb +562 -0
  94. data/spec/command_set_spec.rb +627 -0
  95. data/spec/command_spec.rb +821 -0
  96. data/spec/commands/amend_line_spec.rb +247 -0
  97. data/spec/commands/bang_spec.rb +18 -0
  98. data/spec/commands/cat_spec.rb +164 -0
  99. data/spec/commands/cd_spec.rb +250 -0
  100. data/spec/commands/disable_pry_spec.rb +25 -0
  101. data/spec/commands/edit_spec.rb +725 -0
  102. data/spec/commands/exit_all_spec.rb +27 -0
  103. data/spec/commands/exit_program_spec.rb +19 -0
  104. data/spec/commands/exit_spec.rb +28 -0
  105. data/spec/commands/find_method_spec.rb +70 -0
  106. data/spec/commands/gem_list_spec.rb +26 -0
  107. data/spec/commands/gist_spec.rb +79 -0
  108. data/spec/commands/help_spec.rb +56 -0
  109. data/spec/commands/hist_spec.rb +172 -0
  110. data/spec/commands/jump_to_spec.rb +15 -0
  111. data/spec/commands/ls_spec.rb +189 -0
  112. data/spec/commands/play_spec.rb +136 -0
  113. data/spec/commands/raise_up_spec.rb +56 -0
  114. data/spec/commands/save_file_spec.rb +177 -0
  115. data/spec/commands/show_doc_spec.rb +488 -0
  116. data/spec/commands/show_input_spec.rb +17 -0
  117. data/spec/commands/show_source_spec.rb +760 -0
  118. data/spec/commands/whereami_spec.rb +203 -0
  119. data/spec/completion_spec.rb +221 -0
  120. data/spec/control_d_handler_spec.rb +62 -0
  121. data/spec/documentation_helper_spec.rb +73 -0
  122. data/spec/editor_spec.rb +79 -0
  123. data/spec/exception_whitelist_spec.rb +21 -0
  124. data/spec/fixtures/candidate_helper1.rb +11 -0
  125. data/spec/fixtures/candidate_helper2.rb +8 -0
  126. data/spec/fixtures/example.erb +5 -0
  127. data/spec/fixtures/example_nesting.rb +33 -0
  128. data/spec/fixtures/show_source_doc_examples.rb +15 -0
  129. data/spec/fixtures/testlinkrc +2 -0
  130. data/spec/fixtures/testrc +2 -0
  131. data/spec/fixtures/testrcbad +2 -0
  132. data/spec/fixtures/whereami_helper.rb +6 -0
  133. data/spec/helper.rb +35 -0
  134. data/spec/helpers/bacon.rb +86 -0
  135. data/spec/helpers/mock_pry.rb +44 -0
  136. data/spec/helpers/repl_tester.rb +112 -0
  137. data/spec/helpers/table_spec.rb +105 -0
  138. data/spec/history_array_spec.rb +67 -0
  139. data/spec/hooks_spec.rb +522 -0
  140. data/spec/indent_spec.rb +301 -0
  141. data/spec/method_spec.rb +482 -0
  142. data/spec/prompt_spec.rb +61 -0
  143. data/spec/pry_defaults_spec.rb +420 -0
  144. data/spec/pry_history_spec.rb +69 -0
  145. data/spec/pry_output_spec.rb +95 -0
  146. data/spec/pry_repl_spec.rb +86 -0
  147. data/spec/pry_spec.rb +394 -0
  148. data/spec/pryrc_spec.rb +97 -0
  149. data/spec/run_command_spec.rb +25 -0
  150. data/spec/sticky_locals_spec.rb +147 -0
  151. data/spec/syntax_checking_spec.rb +81 -0
  152. data/spec/wrapped_module_spec.rb +261 -0
  153. data/wiki/Customizing-pry.md +397 -0
  154. data/wiki/Home.md +4 -0
  155. metadata +272 -61
  156. checksums.yaml +0 -7
  157. data/CHANGELOG.md +0 -714
  158. data/lib/pry/code/code_file.rb +0 -103
  159. data/lib/pry/color_printer.rb +0 -55
  160. data/lib/pry/commands/change_inspector.rb +0 -27
  161. data/lib/pry/commands/change_prompt.rb +0 -26
  162. data/lib/pry/commands/list_inspectors.rb +0 -35
  163. data/lib/pry/commands/list_prompts.rb +0 -35
  164. data/lib/pry/commands/ls/constants.rb +0 -47
  165. data/lib/pry/commands/ls/formatter.rb +0 -49
  166. data/lib/pry/commands/ls/globals.rb +0 -48
  167. data/lib/pry/commands/ls/grep.rb +0 -21
  168. data/lib/pry/commands/ls/instance_vars.rb +0 -39
  169. data/lib/pry/commands/ls/interrogatable.rb +0 -18
  170. data/lib/pry/commands/ls/jruby_hacks.rb +0 -49
  171. data/lib/pry/commands/ls/local_names.rb +0 -35
  172. data/lib/pry/commands/ls/local_vars.rb +0 -39
  173. data/lib/pry/commands/ls/ls_entity.rb +0 -70
  174. data/lib/pry/commands/ls/methods.rb +0 -57
  175. data/lib/pry/commands/ls/methods_helper.rb +0 -46
  176. data/lib/pry/commands/ls/self_methods.rb +0 -32
  177. data/lib/pry/commands/watch_expression.rb +0 -105
  178. data/lib/pry/commands/watch_expression/expression.rb +0 -38
  179. data/lib/pry/config/behavior.rb +0 -139
  180. data/lib/pry/config/convenience.rb +0 -25
  181. data/lib/pry/config/default.rb +0 -161
  182. data/lib/pry/exceptions.rb +0 -78
  183. data/lib/pry/input_completer.rb +0 -242
  184. data/lib/pry/input_lock.rb +0 -132
  185. data/lib/pry/inspector.rb +0 -27
  186. data/lib/pry/last_exception.rb +0 -61
  187. data/lib/pry/object_path.rb +0 -82
  188. data/lib/pry/output.rb +0 -50
  189. data/lib/pry/prompt.rb +0 -26
@@ -0,0 +1,397 @@
1
+ Customizing Pry
2
+ ---------------
3
+
4
+ Pry supports customization of the input, the output, the commands,
5
+ the hooks, the prompt, and the 'print' object (the "P" in REPL).
6
+
7
+ Global customization, which applies to all Pry sessions, is done
8
+ through invoking class accessors on the `Pry` class, the accessors
9
+ are:
10
+
11
+ * `Pry.input=`
12
+ * `Pry.output=`
13
+ * `Pry.commands=`
14
+ * `Pry.hooks=`
15
+ * `Pry.prompt=`
16
+ * `Pry.print=`
17
+
18
+ Local customization (applied to a single Pry session) is done by
19
+ passing config hash options to `Pry.start()` or to `Pry.new()`; also the
20
+ same accessors as described above for the `Pry` class exist for a
21
+ Pry instance so that customization can occur at runtime.
22
+
23
+ ### Input
24
+
25
+ For input Pry accepts any object that implements the `readline` method. This
26
+ includes `IO` objects, `StringIO`, `Readline`, `File` and custom objects. Pry
27
+ initially defaults to using `Readline` for input.
28
+
29
+ #### Example: Setting global input
30
+
31
+ Setting Pry's global input causes all subsequent Pry instances to use
32
+ this input by default:
33
+
34
+ Pry.input = StringIO.new("@x = 10\nexit")
35
+ Object.pry
36
+
37
+ Object.instance_variable_get(:@x) #=> 10
38
+
39
+ The above will execute the code in the `StringIO`
40
+ non-interactively. It gets all the input it needs from the `StringIO`
41
+ and then exits the Pry session. Note it is important to end the
42
+ session with 'exit' if you are running non-interactively or the Pry
43
+ session will hang as it loops indefinitely awaiting new input.
44
+
45
+ #### Example: Setting input for a specific session
46
+
47
+ The settings for a specific session override the global settings
48
+ (discussed above). There are two ways to set input for a specific pry session: At the
49
+ point the session is started, or within the session itself (at runtime):
50
+
51
+ ##### At session start
52
+
53
+ Pry.start(Object, :input => StringIO.new("@x = 10\nexit"))
54
+ Object.instance_variable_get(:@x) #=> 10
55
+
56
+ ##### At runtime
57
+
58
+ If you want to set the input object within the session itself you use
59
+ the special `_pry_` local variable which represents the Pry instance
60
+ managing the current session; inside the session we type:
61
+
62
+ _pry_.input = StringIO.new("@x = 10\nexit")
63
+
64
+ Note we can also set the input object for the parent Pry session (if
65
+ the current session is nested) like so:
66
+
67
+ _pry_.parent.input = StringIO.new("@x = 10\nexit")
68
+
69
+ ### Output
70
+
71
+ For output Pry accepts any object that implements the `puts` method. This
72
+ includes `IO` objects, `StringIO`, `File` and custom objects. Pry initially
73
+ defaults to using `$stdout` for output.
74
+
75
+ #### Example: Setting global output
76
+
77
+ Setting Pry's global output causes all subsequent Pry instances to use
78
+ this output by default:
79
+
80
+ Pry.output = StringIO.new
81
+
82
+ #### Example: Setting output for a specific session
83
+
84
+ As per Input, given above, we set the local output as follows:
85
+
86
+ ##### At session start
87
+
88
+ Pry.start(Object, :output => StringIO.new("@x = 10\nexit"))
89
+
90
+ ##### At runtime
91
+
92
+ _pry_.output = StringIO.new
93
+
94
+ ### Commands
95
+
96
+ Pry commands are not methods; they are commands that are intercepted
97
+ and executed before a Ruby eval takes place. Pry comes with a default
98
+ command set (`Pry::Commands`), but these commands can be augmented or overriden by
99
+ user-specified ones.
100
+
101
+ The Pry command API is quite sophisticated supporting features such as:
102
+ command set inheritance, importing of specific commands from another
103
+ command set, deletion of commands, calling of commands within other
104
+ commands, and so on.
105
+
106
+ A valid Pry command object must inherit from
107
+ `Pry::CommandBase` (or one of its subclasses) and use the special command API:
108
+
109
+ #### Example: Defining a command object and setting it globally
110
+
111
+ class MyCommands < Pry::CommandBase
112
+ command "greet", "Greet the user." do |name, age|
113
+ output.puts "Hello #{name.capitalize}, how does it feel being #{age}?"
114
+ end
115
+ end
116
+
117
+ Pry.commands = MyCommands
118
+
119
+ Then inside a pry session:
120
+
121
+ pry(main)> greet john 9
122
+ Hello John, how does it feel being 9?
123
+ => nil
124
+
125
+ #### Example: Using a command object in a specific session
126
+
127
+ As in the case of `input` and `output`:
128
+
129
+ ##### At session start:
130
+
131
+ Pry.start(self, :commands => MyCommands)
132
+
133
+ ##### At runtime:
134
+
135
+ _pry_.commands = MyCommands
136
+
137
+ #### The command API
138
+
139
+ The command API is defined by the `Pry::CommandBase` class (hence why
140
+ all commands must inherit from it or a subclass). The API works as follows:
141
+
142
+ ##### `command` method
143
+
144
+ The `command` method defines a new command, its parameter is the
145
+ name of the command and an optional second parameter is a description of
146
+ the command.
147
+
148
+ The associated block defines the action to be performed. The number of
149
+ parameters in the block determine the number of parameters that will
150
+ be sent to the command (from the Pry prompt) when it is invoked. Note
151
+ that all parameters that are received will be strings; if a parameter
152
+ is not received it will be set to `nil`.
153
+
154
+ command "hello" do |x, y, z|
155
+ puts "hello there #{x}, #{y}, and #{z}!"
156
+ end
157
+
158
+ Command aliases can also be defined - simply use an array of strings
159
+ for the command name - all these strings will be valid names for the
160
+ command.
161
+
162
+ command ["ls", "dir"], "show a list of local vars" do
163
+ output.puts target.eval("local_variables")
164
+ end
165
+
166
+ ##### `delete` method
167
+
168
+ The `delete` method deletes a command or a group of commands. It
169
+ can be useful when inheriting from another command set and you wish
170
+ to keep only a portion of the inherited commands.
171
+
172
+ class MyCommands < Pry::Commands
173
+ delete "show_method", "show_imethod"
174
+ end
175
+
176
+ ##### `import_from` method
177
+
178
+ The `import_from` method enables you to specifically select which
179
+ commands will be copied across from another command set, useful when
180
+ you only want a small number of commands and so inheriting and then
181
+ deleting would be inefficient. The first parameter to `import_from`
182
+ is the class to import from and the other paramters are the names of
183
+ the commands to import:
184
+
185
+ class MyCommands < Pry::CommandBase
186
+ import_from Pry::Commands, "ls", "status", "!"
187
+ end
188
+
189
+ ##### `run` method
190
+
191
+ The `run` command invokes one command from within another.
192
+ The first parameter is the name of the command to invoke
193
+ and the remainder of the parameters will be passed on to the command
194
+ being invoked:
195
+
196
+ class MyCommands < Pry::Commands
197
+ command "ls_with_hello" do
198
+ output.puts "hello!"
199
+ run "ls"
200
+ end
201
+ end
202
+
203
+ ##### `alias_command` method
204
+
205
+ The `alias_command` method creates an alias of a command. The first
206
+ parameter is the name of the new command, the second parameter is the
207
+ name of the command to be aliased; an optional third parameter is the
208
+ description to use for the alias. If no description is provided then
209
+ the description of the original command is used.
210
+
211
+ class MyCommands < Pry::Commands
212
+ alias_command "help2", "help", "An alias of help"
213
+ end
214
+
215
+ ##### `desc` method
216
+
217
+ The `desc` method is used to give a command a new description. The
218
+ first parameter is the name of the command, the second parameter is
219
+ the description.
220
+
221
+ class MyCommands < Pry::Commands
222
+ desc "ls", "a new description"
223
+ end
224
+
225
+ #### Utility methods for commands
226
+
227
+ All commands can access the special `output` and `target` methods. The
228
+ `output` method returns the `output` object for the active pry session.
229
+ Ensuring that your commands invoke `puts` on this rather than using
230
+ the top-level `puts` will ensure that all your session output goes to
231
+ the same place.
232
+
233
+ The `target` method returns the `Binding` object the Pry session is currently
234
+ active on - useful when your commands need to manipulate or examine
235
+ the state of the object. E.g, the "ls" command is implemented as follows
236
+
237
+ command "ls" do
238
+ output.puts target.eval("local_variables + instance_variables").inspect
239
+ end
240
+
241
+ #### The opts hash
242
+
243
+ These are miscellaneous variables that may be useful to your commands:
244
+
245
+ * `opts[:val]` - The line of input that invoked the command.
246
+ * `opts[:eval_string]` - The cumulative lines of input for multi-line input.
247
+ * `opts[:nesting]` - Lowlevel session nesting information.
248
+ * `opts[:commands]` - Lowlevel data of all Pry commands.
249
+
250
+ (see commands.rb for examples of how some of these options are used)
251
+
252
+ #### The `help` command
253
+
254
+ The `Pry::CommandBase` class automatically defines a `help` command
255
+ for you. Typing `help` in a Pry session will show a list of commands
256
+ to the user followed by their descriptions. Passing a parameter to
257
+ `help` with the command name will just return the description of that
258
+ specific command. If a description is left out it will automatically
259
+ be given the description "No description.".
260
+
261
+ If the description is explicitly set to `""` then this command will
262
+ not be displayed in `help`.
263
+
264
+ ### Hooks
265
+
266
+ Currently Pry supports just two hooks: `before_session` and
267
+ `after_session`. These hooks are invoked before a Pry session starts
268
+ and after a session ends respectively. The default hooks used are
269
+ stored in the `Pry::DEFAULT_HOOKS` and just output the text `"Beginning
270
+ Pry session for <obj>"` and `"Ending Pry session for <obj>"`.
271
+
272
+ #### Example: Setting global hooks
273
+
274
+ All subsequent Pry instances will use these hooks as default:
275
+
276
+ Pry.hooks = {
277
+ :before_session => proc { |out, obj| out.puts "Opened #{obj}" },
278
+ :after_session => proc { |out, obj| out.puts "Closed #{obj}" }
279
+ }
280
+
281
+ 5.pry
282
+
283
+ Inside the session:
284
+
285
+ Opened 5
286
+ pry(5)> exit
287
+ Closed 5
288
+
289
+ Note that the `before_session` and `after_session` procs receive the
290
+ current session's output object and session receiver as parameters.
291
+
292
+ #### Example: Setting hooks for a specific session
293
+
294
+ Like all the other customization options, the global default (as
295
+ explained above) can be overriden for a specific session, either at
296
+ session start or during runtime.
297
+
298
+ ##### At session start
299
+
300
+ Pry.start(self, :hooks => { :before_session => proc { puts "hello world!" },
301
+ :after_session => proc { puts "goodbye world!" }
302
+ })
303
+
304
+ ##### At runtime
305
+
306
+ _pry_.hooks = { :before_session => proc { puts "puts "hello world!" } }
307
+
308
+ ### Prompts
309
+
310
+ The Pry prompt is used by `Readline` and other input objects that
311
+ accept a prompt. Pry can accept two prompt-types for every prompt; the
312
+ 'main prompt' and the 'wait prompt'. The main prompt is always used
313
+ for the first line of input; the wait prompt is used in multi-line
314
+ input to indicate that the current expression is incomplete and more lines of
315
+ input are required. The default Prompt used by Pry is stored in the
316
+ `Pry::DEFAULT_PROMPT` constant.
317
+
318
+ A valid Pry prompt is either a single `Proc` object or a two element
319
+ array of `Proc` objects. When an array is used the first element is
320
+ the 'main prompt' and the last element is the 'wait prompt'. When a
321
+ single `Proc` object is used it will be used for both the main prompt
322
+ and the wait prompt.
323
+
324
+ #### Example: Setting global prompt
325
+
326
+ The prompt `Proc` objects are passed the receiver of the Pry session
327
+ and the nesting level of that session as parameters (they can simply
328
+ ignore these if they do not need them).
329
+
330
+ # Using one proc for both main and wait prompts
331
+ Pry.prompt = proc { |obj, nest_level| "#{obj}:#{nest_level}> " }
332
+
333
+ # Alternatively, provide two procs; one for main and one for wait
334
+ Pry.prompt = [ proc { "ENTER INPUT> " }, proc { "MORE INPUT REQUIRED!* " }]
335
+
336
+ #### Example: Setting the prompt for a specific session
337
+
338
+ ##### At session start
339
+
340
+ Pry.start(self, :prompt => [proc { "ENTER INPUT> " },
341
+ proc { "MORE INPUT REQUIRED!* " }])
342
+
343
+ ##### At runtime
344
+
345
+ _pry_.prompt = [proc { "ENTER INPUT> " },
346
+ proc { "MORE INPUT REQUIRED!* " }]
347
+
348
+ ### Print
349
+
350
+ The Print phase of Pry's READ-EVAL-PRINT-LOOP can be customized. The
351
+ default action is stored in the `Pry::DEFAULT_PRINT` constant and it
352
+ simply outputs the value of the current expression preceded by a `=>` (or the first
353
+ line of the backtrace if the value is an `Exception` object.)
354
+
355
+ The print object should be a `Proc` and the parameters passed to the
356
+ `Proc` are the output object for the current session and the 'value'
357
+ returned by the current expression.
358
+
359
+ #### Example: Setting global print object
360
+
361
+ Let's define a print object that displays the full backtrace of any
362
+ exception and precedes the output of a value by the text `"Output is: "`:
363
+
364
+ Pry.print = proc do |output, value|
365
+ case value
366
+ when Exception
367
+ output.puts value.backtrace
368
+ else
369
+ output.puts "Output is: #{value}"
370
+ end
371
+ end
372
+
373
+ #### Example: Setting the print object for a specific session
374
+
375
+ ##### At session start
376
+
377
+ Pry.start(self, :print => proc do |output, value|
378
+ case value
379
+ when Exception
380
+ output.puts value.backtrace
381
+ else
382
+ output.puts "Output is: #{value.inspect}"
383
+ end
384
+ end)
385
+
386
+ ##### At runtime
387
+
388
+ _pry_.print = proc do |output, value|
389
+ case value
390
+ when Exception
391
+ output.puts value.backtrace
392
+ else
393
+ output.puts "Output is: #{value.inspect}"
394
+ end
395
+ end
396
+
397
+ [Back to front page of documentation](http://rdoc.info/github/banister/pry/master/file/README.markdown)
@@ -0,0 +1,4 @@
1
+ Further documentation on Pry can be found here:
2
+
3
+ * [Customizing Pry](https://github.com/banister/pry/wiki/Customizing-pry)
4
+ * [Blog post: Turning IRB on its head with Pry](http://banisterfiend.wordpress.com/2011/01/27/turning-irb-on-its-head-with-pry/)
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ prerelease: 6
5
+ version: 1.0.0.pre1
5
6
  platform: i386-mswin32
6
7
  authors:
7
8
  - John Mair (banisterfiend)
@@ -10,74 +11,164 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-09-25 00:00:00.000000000 Z
14
+ date: 2013-03-09 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
17
+ type: :runtime
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.5
16
24
  name: coderay
25
+ prerelease: false
17
26
  requirement: !ruby/object:Gem::Requirement
27
+ none: false
18
28
  requirements:
19
29
  - - ~>
20
30
  - !ruby/object:Gem::Version
21
- version: 1.1.0
31
+ version: 1.0.5
32
+ - !ruby/object:Gem::Dependency
22
33
  type: :runtime
23
- prerelease: false
24
34
  version_requirements: !ruby/object:Gem::Requirement
35
+ none: false
25
36
  requirements:
26
37
  - - ~>
27
38
  - !ruby/object:Gem::Version
28
- version: 1.1.0
29
- - !ruby/object:Gem::Dependency
39
+ version: '3.4'
30
40
  name: slop
41
+ prerelease: false
31
42
  requirement: !ruby/object:Gem::Requirement
43
+ none: false
32
44
  requirements:
33
45
  - - ~>
34
46
  - !ruby/object:Gem::Version
35
47
  version: '3.4'
48
+ - !ruby/object:Gem::Dependency
36
49
  type: :runtime
37
- prerelease: false
38
50
  version_requirements: !ruby/object:Gem::Requirement
51
+ none: false
39
52
  requirements:
40
53
  - - ~>
41
54
  - !ruby/object:Gem::Version
42
- version: '3.4'
43
- - !ruby/object:Gem::Dependency
55
+ version: '0.8'
44
56
  name: method_source
57
+ prerelease: false
45
58
  requirement: !ruby/object:Gem::Requirement
59
+ none: false
46
60
  requirements:
47
61
  - - ~>
48
62
  - !ruby/object:Gem::Version
49
- version: 0.8.1
50
- type: :runtime
63
+ version: '0.8'
64
+ - !ruby/object:Gem::Dependency
65
+ type: :development
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '1.2'
72
+ name: bacon
51
73
  prerelease: false
74
+ requirement: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '1.2'
80
+ - !ruby/object:Gem::Dependency
81
+ type: :development
52
82
  version_requirements: !ruby/object:Gem::Requirement
83
+ none: false
53
84
  requirements:
54
85
  - - ~>
55
86
  - !ruby/object:Gem::Version
56
- version: 0.8.1
87
+ version: '1.3'
88
+ name: open4
89
+ prerelease: false
90
+ requirement: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '1.3'
57
96
  - !ruby/object:Gem::Dependency
58
- name: bundler
97
+ type: :development
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ name: rake
105
+ prerelease: false
59
106
  requirement: !ruby/object:Gem::Requirement
107
+ none: false
60
108
  requirements:
61
109
  - - ~>
62
110
  - !ruby/object:Gem::Version
63
- version: '1.0'
111
+ version: '0.9'
112
+ - !ruby/object:Gem::Dependency
64
113
  type: :development
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ~>
118
+ - !ruby/object:Gem::Version
119
+ version: 1.3.2
120
+ name: guard
65
121
  prerelease: false
122
+ requirement: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ~>
126
+ - !ruby/object:Gem::Version
127
+ version: 1.3.2
128
+ - !ruby/object:Gem::Dependency
129
+ type: :development
66
130
  version_requirements: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ~>
134
+ - !ruby/object:Gem::Version
135
+ version: 0.13.1
136
+ name: mocha
137
+ prerelease: false
138
+ requirement: !ruby/object:Gem::Requirement
139
+ none: false
67
140
  requirements:
68
141
  - - ~>
69
142
  - !ruby/object:Gem::Version
70
- version: '1.0'
143
+ version: 0.13.1
71
144
  - !ruby/object:Gem::Dependency
72
- name: win32console
145
+ type: :development
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ~>
150
+ - !ruby/object:Gem::Version
151
+ version: 0.4.2
152
+ name: bond
153
+ prerelease: false
73
154
  requirement: !ruby/object:Gem::Requirement
155
+ none: false
74
156
  requirements:
75
157
  - - ~>
76
158
  - !ruby/object:Gem::Version
77
- version: '1.3'
159
+ version: 0.4.2
160
+ - !ruby/object:Gem::Dependency
78
161
  type: :runtime
79
- prerelease: false
80
162
  version_requirements: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ~>
166
+ - !ruby/object:Gem::Version
167
+ version: '1.3'
168
+ name: win32console
169
+ prerelease: false
170
+ requirement: !ruby/object:Gem::Requirement
171
+ none: false
81
172
  requirements:
82
173
  - - ~>
83
174
  - !ruby/object:Gem::Version
@@ -92,18 +183,25 @@ executables:
92
183
  extensions: []
93
184
  extra_rdoc_files: []
94
185
  files:
95
- - CHANGELOG.md
186
+ - .document
187
+ - .gitignore
188
+ - .travis.yml
189
+ - .yardopts
190
+ - CHANGELOG
191
+ - CONTRIBUTORS
192
+ - Gemfile
193
+ - Guardfile
96
194
  - LICENSE
97
- - README.md
195
+ - README.markdown
196
+ - Rakefile
197
+ - TODO
98
198
  - bin/pry
99
199
  - lib/pry.rb
100
200
  - lib/pry/cli.rb
101
201
  - lib/pry/code.rb
102
- - lib/pry/code/code_file.rb
103
202
  - lib/pry/code/code_range.rb
104
203
  - lib/pry/code/loc.rb
105
204
  - lib/pry/code_object.rb
106
- - lib/pry/color_printer.rb
107
205
  - lib/pry/command.rb
108
206
  - lib/pry/command_set.rb
109
207
  - lib/pry/commands.rb
@@ -116,8 +214,6 @@ files:
116
214
  - lib/pry/commands/cat/file_formatter.rb
117
215
  - lib/pry/commands/cat/input_expression_formatter.rb
118
216
  - lib/pry/commands/cd.rb
119
- - lib/pry/commands/change_inspector.rb
120
- - lib/pry/commands/change_prompt.rb
121
217
  - lib/pry/commands/code_collector.rb
122
218
  - lib/pry/commands/disable_pry.rb
123
219
  - lib/pry/commands/disabled_commands.rb
@@ -125,6 +221,7 @@ files:
125
221
  - lib/pry/commands/edit.rb
126
222
  - lib/pry/commands/edit/exception_patcher.rb
127
223
  - lib/pry/commands/edit/file_and_line_locator.rb
224
+ - lib/pry/commands/edit/method_patcher.rb
128
225
  - lib/pry/commands/exit.rb
129
226
  - lib/pry/commands/exit_all.rb
130
227
  - lib/pry/commands/exit_program.rb
@@ -140,22 +237,7 @@ files:
140
237
  - lib/pry/commands/import_set.rb
141
238
  - lib/pry/commands/install_command.rb
142
239
  - lib/pry/commands/jump_to.rb
143
- - lib/pry/commands/list_inspectors.rb
144
- - lib/pry/commands/list_prompts.rb
145
240
  - lib/pry/commands/ls.rb
146
- - lib/pry/commands/ls/constants.rb
147
- - lib/pry/commands/ls/formatter.rb
148
- - lib/pry/commands/ls/globals.rb
149
- - lib/pry/commands/ls/grep.rb
150
- - lib/pry/commands/ls/instance_vars.rb
151
- - lib/pry/commands/ls/interrogatable.rb
152
- - lib/pry/commands/ls/jruby_hacks.rb
153
- - lib/pry/commands/ls/local_names.rb
154
- - lib/pry/commands/ls/local_vars.rb
155
- - lib/pry/commands/ls/ls_entity.rb
156
- - lib/pry/commands/ls/methods.rb
157
- - lib/pry/commands/ls/methods_helper.rb
158
- - lib/pry/commands/ls/self_methods.rb
159
241
  - lib/pry/commands/nesting.rb
160
242
  - lib/pry/commands/play.rb
161
243
  - lib/pry/commands/pry_backtrace.rb
@@ -175,17 +257,13 @@ files:
175
257
  - lib/pry/commands/stat.rb
176
258
  - lib/pry/commands/switch_to.rb
177
259
  - lib/pry/commands/toggle_color.rb
178
- - lib/pry/commands/watch_expression.rb
179
- - lib/pry/commands/watch_expression/expression.rb
180
260
  - lib/pry/commands/whereami.rb
181
261
  - lib/pry/commands/wtf.rb
262
+ - lib/pry/completion.rb
182
263
  - lib/pry/config.rb
183
- - lib/pry/config/behavior.rb
184
- - lib/pry/config/convenience.rb
185
- - lib/pry/config/default.rb
186
264
  - lib/pry/core_extensions.rb
265
+ - lib/pry/custom_completions.rb
187
266
  - lib/pry/editor.rb
188
- - lib/pry/exceptions.rb
189
267
  - lib/pry/helpers.rb
190
268
  - lib/pry/helpers/base_helpers.rb
191
269
  - lib/pry/helpers/command_helpers.rb
@@ -197,22 +275,15 @@ files:
197
275
  - lib/pry/history_array.rb
198
276
  - lib/pry/hooks.rb
199
277
  - lib/pry/indent.rb
200
- - lib/pry/input_completer.rb
201
- - lib/pry/input_lock.rb
202
- - lib/pry/inspector.rb
203
- - lib/pry/last_exception.rb
204
278
  - lib/pry/method.rb
205
279
  - lib/pry/method/disowned.rb
206
- - lib/pry/method/patcher.rb
207
280
  - lib/pry/method/weird_method_locator.rb
208
281
  - lib/pry/module_candidate.rb
209
- - lib/pry/object_path.rb
210
- - lib/pry/output.rb
211
282
  - lib/pry/pager.rb
212
283
  - lib/pry/plugins.rb
213
- - lib/pry/prompt.rb
214
284
  - lib/pry/pry_class.rb
215
285
  - lib/pry/pry_instance.rb
286
+ - lib/pry/rbx_method.rb
216
287
  - lib/pry/rbx_path.rb
217
288
  - lib/pry/repl.rb
218
289
  - lib/pry/repl_file_loader.rb
@@ -221,28 +292,168 @@ files:
221
292
  - lib/pry/test/helper.rb
222
293
  - lib/pry/version.rb
223
294
  - lib/pry/wrapped_module.rb
224
- homepage: http://pryrepl.org
295
+ - man/pry.1
296
+ - man/pry.1.html
297
+ - man/pry.1.ronn
298
+ - pry.gemspec
299
+ - spec/Procfile
300
+ - spec/cli_spec.rb
301
+ - spec/code_object_spec.rb
302
+ - spec/code_spec.rb
303
+ - spec/command_helpers_spec.rb
304
+ - spec/command_integration_spec.rb
305
+ - spec/command_set_spec.rb
306
+ - spec/command_spec.rb
307
+ - spec/commands/amend_line_spec.rb
308
+ - spec/commands/bang_spec.rb
309
+ - spec/commands/cat_spec.rb
310
+ - spec/commands/cd_spec.rb
311
+ - spec/commands/disable_pry_spec.rb
312
+ - spec/commands/edit_spec.rb
313
+ - spec/commands/exit_all_spec.rb
314
+ - spec/commands/exit_program_spec.rb
315
+ - spec/commands/exit_spec.rb
316
+ - spec/commands/find_method_spec.rb
317
+ - spec/commands/gem_list_spec.rb
318
+ - spec/commands/gist_spec.rb
319
+ - spec/commands/help_spec.rb
320
+ - spec/commands/hist_spec.rb
321
+ - spec/commands/jump_to_spec.rb
322
+ - spec/commands/ls_spec.rb
323
+ - spec/commands/play_spec.rb
324
+ - spec/commands/raise_up_spec.rb
325
+ - spec/commands/save_file_spec.rb
326
+ - spec/commands/show_doc_spec.rb
327
+ - spec/commands/show_input_spec.rb
328
+ - spec/commands/show_source_spec.rb
329
+ - spec/commands/whereami_spec.rb
330
+ - spec/completion_spec.rb
331
+ - spec/control_d_handler_spec.rb
332
+ - spec/documentation_helper_spec.rb
333
+ - spec/editor_spec.rb
334
+ - spec/exception_whitelist_spec.rb
335
+ - spec/fixtures/candidate_helper1.rb
336
+ - spec/fixtures/candidate_helper2.rb
337
+ - spec/fixtures/example.erb
338
+ - spec/fixtures/example_nesting.rb
339
+ - spec/fixtures/show_source_doc_examples.rb
340
+ - spec/fixtures/testlinkrc
341
+ - spec/fixtures/testrc
342
+ - spec/fixtures/testrcbad
343
+ - spec/fixtures/whereami_helper.rb
344
+ - spec/helper.rb
345
+ - spec/helpers/bacon.rb
346
+ - spec/helpers/mock_pry.rb
347
+ - spec/helpers/repl_tester.rb
348
+ - spec/helpers/table_spec.rb
349
+ - spec/history_array_spec.rb
350
+ - spec/hooks_spec.rb
351
+ - spec/indent_spec.rb
352
+ - spec/method_spec.rb
353
+ - spec/prompt_spec.rb
354
+ - spec/pry_defaults_spec.rb
355
+ - spec/pry_history_spec.rb
356
+ - spec/pry_output_spec.rb
357
+ - spec/pry_repl_spec.rb
358
+ - spec/pry_spec.rb
359
+ - spec/pryrc_spec.rb
360
+ - spec/run_command_spec.rb
361
+ - spec/sticky_locals_spec.rb
362
+ - spec/syntax_checking_spec.rb
363
+ - spec/wrapped_module_spec.rb
364
+ - wiki/Customizing-pry.md
365
+ - wiki/Home.md
366
+ homepage: http://pry.github.com
225
367
  licenses:
226
368
  - MIT
227
- metadata: {}
228
369
  post_install_message:
229
370
  rdoc_options: []
230
371
  require_paths:
231
372
  - lib
232
373
  required_ruby_version: !ruby/object:Gem::Requirement
374
+ none: false
233
375
  requirements:
234
- - - '>='
376
+ - - ! '>='
235
377
  - !ruby/object:Gem::Version
378
+ segments:
379
+ - 0
380
+ hash: -1068142609689603056
236
381
  version: '0'
237
382
  required_rubygems_version: !ruby/object:Gem::Requirement
383
+ none: false
238
384
  requirements:
239
- - - '>='
385
+ - - ! '>'
240
386
  - !ruby/object:Gem::Version
241
- version: '0'
387
+ version: 1.3.1
242
388
  requirements: []
243
389
  rubyforge_project:
244
- rubygems_version: 2.4.6
390
+ rubygems_version: 1.8.25
245
391
  signing_key:
246
- specification_version: 4
392
+ specification_version: 3
247
393
  summary: An IRB alternative and runtime developer console
248
- test_files: []
394
+ test_files:
395
+ - spec/Procfile
396
+ - spec/cli_spec.rb
397
+ - spec/code_object_spec.rb
398
+ - spec/code_spec.rb
399
+ - spec/command_helpers_spec.rb
400
+ - spec/command_integration_spec.rb
401
+ - spec/command_set_spec.rb
402
+ - spec/command_spec.rb
403
+ - spec/commands/amend_line_spec.rb
404
+ - spec/commands/bang_spec.rb
405
+ - spec/commands/cat_spec.rb
406
+ - spec/commands/cd_spec.rb
407
+ - spec/commands/disable_pry_spec.rb
408
+ - spec/commands/edit_spec.rb
409
+ - spec/commands/exit_all_spec.rb
410
+ - spec/commands/exit_program_spec.rb
411
+ - spec/commands/exit_spec.rb
412
+ - spec/commands/find_method_spec.rb
413
+ - spec/commands/gem_list_spec.rb
414
+ - spec/commands/gist_spec.rb
415
+ - spec/commands/help_spec.rb
416
+ - spec/commands/hist_spec.rb
417
+ - spec/commands/jump_to_spec.rb
418
+ - spec/commands/ls_spec.rb
419
+ - spec/commands/play_spec.rb
420
+ - spec/commands/raise_up_spec.rb
421
+ - spec/commands/save_file_spec.rb
422
+ - spec/commands/show_doc_spec.rb
423
+ - spec/commands/show_input_spec.rb
424
+ - spec/commands/show_source_spec.rb
425
+ - spec/commands/whereami_spec.rb
426
+ - spec/completion_spec.rb
427
+ - spec/control_d_handler_spec.rb
428
+ - spec/documentation_helper_spec.rb
429
+ - spec/editor_spec.rb
430
+ - spec/exception_whitelist_spec.rb
431
+ - spec/fixtures/candidate_helper1.rb
432
+ - spec/fixtures/candidate_helper2.rb
433
+ - spec/fixtures/example.erb
434
+ - spec/fixtures/example_nesting.rb
435
+ - spec/fixtures/show_source_doc_examples.rb
436
+ - spec/fixtures/testlinkrc
437
+ - spec/fixtures/testrc
438
+ - spec/fixtures/testrcbad
439
+ - spec/fixtures/whereami_helper.rb
440
+ - spec/helper.rb
441
+ - spec/helpers/bacon.rb
442
+ - spec/helpers/mock_pry.rb
443
+ - spec/helpers/repl_tester.rb
444
+ - spec/helpers/table_spec.rb
445
+ - spec/history_array_spec.rb
446
+ - spec/hooks_spec.rb
447
+ - spec/indent_spec.rb
448
+ - spec/method_spec.rb
449
+ - spec/prompt_spec.rb
450
+ - spec/pry_defaults_spec.rb
451
+ - spec/pry_history_spec.rb
452
+ - spec/pry_output_spec.rb
453
+ - spec/pry_repl_spec.rb
454
+ - spec/pry_spec.rb
455
+ - spec/pryrc_spec.rb
456
+ - spec/run_command_spec.rb
457
+ - spec/sticky_locals_spec.rb
458
+ - spec/syntax_checking_spec.rb
459
+ - spec/wrapped_module_spec.rb