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.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +41 -35
  5. data/lib/pry.rb +82 -139
  6. data/lib/pry/cli.rb +77 -30
  7. data/lib/pry/code.rb +122 -183
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +71 -0
  10. data/lib/pry/code/loc.rb +92 -0
  11. data/lib/pry/code_object.rb +172 -0
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +184 -28
  14. data/lib/pry/command_set.rb +113 -59
  15. data/lib/pry/commands.rb +4 -27
  16. data/lib/pry/commands/amend_line.rb +99 -0
  17. data/lib/pry/commands/bang.rb +20 -0
  18. data/lib/pry/commands/bang_pry.rb +17 -0
  19. data/lib/pry/commands/cat.rb +62 -0
  20. data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
  21. data/lib/pry/commands/cat/exception_formatter.rb +77 -0
  22. data/lib/pry/commands/cat/file_formatter.rb +67 -0
  23. data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
  24. data/lib/pry/commands/cd.rb +41 -0
  25. data/lib/pry/commands/change_inspector.rb +27 -0
  26. data/lib/pry/commands/change_prompt.rb +26 -0
  27. data/lib/pry/commands/code_collector.rb +165 -0
  28. data/lib/pry/commands/disable_pry.rb +27 -0
  29. data/lib/pry/commands/disabled_commands.rb +2 -0
  30. data/lib/pry/commands/easter_eggs.rb +112 -0
  31. data/lib/pry/commands/edit.rb +195 -0
  32. data/lib/pry/commands/edit/exception_patcher.rb +25 -0
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
  34. data/lib/pry/commands/exit.rb +42 -0
  35. data/lib/pry/commands/exit_all.rb +29 -0
  36. data/lib/pry/commands/exit_program.rb +23 -0
  37. data/lib/pry/commands/find_method.rb +193 -0
  38. data/lib/pry/commands/fix_indent.rb +19 -0
  39. data/lib/pry/commands/gem_cd.rb +26 -0
  40. data/lib/pry/commands/gem_install.rb +32 -0
  41. data/lib/pry/commands/gem_list.rb +33 -0
  42. data/lib/pry/commands/gem_open.rb +29 -0
  43. data/lib/pry/commands/gist.rb +101 -0
  44. data/lib/pry/commands/help.rb +164 -0
  45. data/lib/pry/commands/hist.rb +180 -0
  46. data/lib/pry/commands/import_set.rb +22 -0
  47. data/lib/pry/commands/install_command.rb +53 -0
  48. data/lib/pry/commands/jump_to.rb +29 -0
  49. data/lib/pry/commands/list_inspectors.rb +35 -0
  50. data/lib/pry/commands/list_prompts.rb +35 -0
  51. data/lib/pry/commands/ls.rb +114 -0
  52. data/lib/pry/commands/ls/constants.rb +47 -0
  53. data/lib/pry/commands/ls/formatter.rb +49 -0
  54. data/lib/pry/commands/ls/globals.rb +48 -0
  55. data/lib/pry/commands/ls/grep.rb +21 -0
  56. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  57. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  58. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  59. data/lib/pry/commands/ls/local_names.rb +35 -0
  60. data/lib/pry/commands/ls/local_vars.rb +39 -0
  61. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  62. data/lib/pry/commands/ls/methods.rb +57 -0
  63. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  64. data/lib/pry/commands/ls/self_methods.rb +32 -0
  65. data/lib/pry/commands/nesting.rb +25 -0
  66. data/lib/pry/commands/play.rb +103 -0
  67. data/lib/pry/commands/pry_backtrace.rb +25 -0
  68. data/lib/pry/commands/pry_version.rb +17 -0
  69. data/lib/pry/commands/raise_up.rb +32 -0
  70. data/lib/pry/commands/reload_code.rb +62 -0
  71. data/lib/pry/commands/reset.rb +18 -0
  72. data/lib/pry/commands/ri.rb +60 -0
  73. data/lib/pry/commands/save_file.rb +61 -0
  74. data/lib/pry/commands/shell_command.rb +48 -0
  75. data/lib/pry/commands/shell_mode.rb +25 -0
  76. data/lib/pry/commands/show_doc.rb +83 -0
  77. data/lib/pry/commands/show_info.rb +195 -0
  78. data/lib/pry/commands/show_input.rb +17 -0
  79. data/lib/pry/commands/show_source.rb +50 -0
  80. data/lib/pry/commands/simple_prompt.rb +22 -0
  81. data/lib/pry/commands/stat.rb +40 -0
  82. data/lib/pry/commands/switch_to.rb +23 -0
  83. data/lib/pry/commands/toggle_color.rb +24 -0
  84. data/lib/pry/commands/watch_expression.rb +105 -0
  85. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  86. data/lib/pry/commands/whereami.rb +190 -0
  87. data/lib/pry/commands/wtf.rb +57 -0
  88. data/lib/pry/config.rb +20 -229
  89. data/lib/pry/config/behavior.rb +139 -0
  90. data/lib/pry/config/convenience.rb +26 -0
  91. data/lib/pry/config/default.rb +165 -0
  92. data/lib/pry/core_extensions.rb +59 -38
  93. data/lib/pry/editor.rb +133 -0
  94. data/lib/pry/exceptions.rb +77 -0
  95. data/lib/pry/helpers.rb +1 -0
  96. data/lib/pry/helpers/base_helpers.rb +40 -154
  97. data/lib/pry/helpers/command_helpers.rb +19 -130
  98. data/lib/pry/helpers/documentation_helpers.rb +21 -11
  99. data/lib/pry/helpers/table.rb +109 -0
  100. data/lib/pry/helpers/text.rb +8 -9
  101. data/lib/pry/history.rb +61 -45
  102. data/lib/pry/history_array.rb +11 -1
  103. data/lib/pry/hooks.rb +10 -32
  104. data/lib/pry/indent.rb +110 -38
  105. data/lib/pry/input_completer.rb +242 -0
  106. data/lib/pry/input_lock.rb +132 -0
  107. data/lib/pry/inspector.rb +27 -0
  108. data/lib/pry/last_exception.rb +61 -0
  109. data/lib/pry/method.rb +199 -200
  110. data/lib/pry/method/disowned.rb +53 -0
  111. data/lib/pry/method/patcher.rb +125 -0
  112. data/lib/pry/method/weird_method_locator.rb +186 -0
  113. data/lib/pry/module_candidate.rb +39 -33
  114. data/lib/pry/object_path.rb +82 -0
  115. data/lib/pry/output.rb +50 -0
  116. data/lib/pry/pager.rb +234 -0
  117. data/lib/pry/plugins.rb +4 -3
  118. data/lib/pry/prompt.rb +26 -0
  119. data/lib/pry/pry_class.rb +199 -227
  120. data/lib/pry/pry_instance.rb +344 -403
  121. data/lib/pry/rbx_path.rb +1 -1
  122. data/lib/pry/repl.rb +202 -0
  123. data/lib/pry/repl_file_loader.rb +20 -26
  124. data/lib/pry/rubygem.rb +82 -0
  125. data/lib/pry/terminal.rb +79 -0
  126. data/lib/pry/test/helper.rb +170 -0
  127. data/lib/pry/version.rb +1 -1
  128. data/lib/pry/wrapped_module.rb +133 -48
  129. metadata +132 -197
  130. data/.document +0 -2
  131. data/.gemtest +0 -0
  132. data/.gitignore +0 -16
  133. data/.travis.yml +0 -17
  134. data/.yardopts +0 -1
  135. data/CHANGELOG +0 -387
  136. data/CONTRIBUTORS +0 -36
  137. data/Gemfile +0 -2
  138. data/Rakefile +0 -137
  139. data/TODO +0 -117
  140. data/examples/example_basic.rb +0 -15
  141. data/examples/example_command_override.rb +0 -32
  142. data/examples/example_commands.rb +0 -36
  143. data/examples/example_hooks.rb +0 -9
  144. data/examples/example_image_edit.rb +0 -67
  145. data/examples/example_input.rb +0 -7
  146. data/examples/example_input2.rb +0 -29
  147. data/examples/example_output.rb +0 -11
  148. data/examples/example_print.rb +0 -6
  149. data/examples/example_prompt.rb +0 -9
  150. data/examples/helper.rb +0 -6
  151. data/lib/pry/completion.rb +0 -221
  152. data/lib/pry/custom_completions.rb +0 -6
  153. data/lib/pry/default_commands/cd.rb +0 -81
  154. data/lib/pry/default_commands/commands.rb +0 -62
  155. data/lib/pry/default_commands/context.rb +0 -98
  156. data/lib/pry/default_commands/easter_eggs.rb +0 -95
  157. data/lib/pry/default_commands/editing.rb +0 -420
  158. data/lib/pry/default_commands/find_method.rb +0 -169
  159. data/lib/pry/default_commands/gems.rb +0 -84
  160. data/lib/pry/default_commands/gist.rb +0 -187
  161. data/lib/pry/default_commands/help.rb +0 -127
  162. data/lib/pry/default_commands/hist.rb +0 -120
  163. data/lib/pry/default_commands/input_and_output.rb +0 -306
  164. data/lib/pry/default_commands/introspection.rb +0 -410
  165. data/lib/pry/default_commands/ls.rb +0 -272
  166. data/lib/pry/default_commands/misc.rb +0 -38
  167. data/lib/pry/default_commands/navigating_pry.rb +0 -110
  168. data/lib/pry/default_commands/whereami.rb +0 -92
  169. data/lib/pry/extended_commands/experimental.rb +0 -7
  170. data/lib/pry/rbx_method.rb +0 -13
  171. data/man/pry.1 +0 -195
  172. data/man/pry.1.html +0 -204
  173. data/man/pry.1.ronn +0 -141
  174. data/pry.gemspec +0 -46
  175. data/test/candidate_helper1.rb +0 -11
  176. data/test/candidate_helper2.rb +0 -8
  177. data/test/helper.rb +0 -223
  178. data/test/test_cli.rb +0 -78
  179. data/test/test_code.rb +0 -201
  180. data/test/test_command.rb +0 -712
  181. data/test/test_command_helpers.rb +0 -9
  182. data/test/test_command_integration.rb +0 -668
  183. data/test/test_command_set.rb +0 -610
  184. data/test/test_completion.rb +0 -62
  185. data/test/test_control_d_handler.rb +0 -45
  186. data/test/test_default_commands/example.erb +0 -5
  187. data/test/test_default_commands/test_cd.rb +0 -318
  188. data/test/test_default_commands/test_context.rb +0 -280
  189. data/test/test_default_commands/test_documentation.rb +0 -314
  190. data/test/test_default_commands/test_find_method.rb +0 -50
  191. data/test/test_default_commands/test_gems.rb +0 -18
  192. data/test/test_default_commands/test_help.rb +0 -57
  193. data/test/test_default_commands/test_input.rb +0 -428
  194. data/test/test_default_commands/test_introspection.rb +0 -511
  195. data/test/test_default_commands/test_ls.rb +0 -151
  196. data/test/test_default_commands/test_shell.rb +0 -343
  197. data/test/test_default_commands/test_show_source.rb +0 -432
  198. data/test/test_exception_whitelist.rb +0 -21
  199. data/test/test_history_array.rb +0 -65
  200. data/test/test_hooks.rb +0 -521
  201. data/test/test_indent.rb +0 -277
  202. data/test/test_input_stack.rb +0 -86
  203. data/test/test_method.rb +0 -401
  204. data/test/test_pry.rb +0 -463
  205. data/test/test_pry_defaults.rb +0 -419
  206. data/test/test_pry_history.rb +0 -84
  207. data/test/test_pry_output.rb +0 -41
  208. data/test/test_sticky_locals.rb +0 -155
  209. data/test/test_syntax_checking.rb +0 -65
  210. data/test/test_wrapped_module.rb +0 -174
  211. data/test/testrc +0 -2
  212. data/test/testrcbad +0 -2
  213. data/wiki/Customizing-pry.md +0 -397
  214. data/wiki/Home.md +0 -4
data/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
1
  License
2
2
  -------
3
3
 
4
- (The MIT License)
4
+ (The MIT License)
5
5
 
6
- Copyright (c) 2011 John Mair (banisterfiend)
6
+ Copyright (c) 2013 John Mair (banisterfiend)
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining
9
9
  a copy of this software and associated documentation files (the
@@ -1,18 +1,21 @@
1
- [![Build Status](https://secure.travis-ci.org/pry/pry.png)](http://travis-ci.org/pry/pry)
1
+ [![Build Status](https://img.shields.io/travis/pry/pry.svg)](https://travis-ci.org/pry/pry)
2
+ [![Code Climate](https://img.shields.io/codeclimate/github/pry/pry.svg)](https://codeclimate.com/github/pry/pry)
3
+ [![Inline docs](http://inch-pages.github.io/github/pry/pry.svg)](http://inch-pages.github.io/github/pry/pry)
2
4
 
3
5
  <center>
4
- ![Alt text](http://dl.dropbox.com/u/26521875/pry_logo_350.png)
5
-
6
- (C) John Mair (banisterfiend) 2011<br>
6
+ ![The Pry Logo](https://dl.dropbox.com/u/26521875/pry%20stuff/logo/pry_logo_350.png)
7
7
 
8
+ © John Mair ([banisterfiend](https://twitter.com/banisterfiend)) 2013<br>
8
9
 
9
10
  **Please** [DONATE](http://www.pledgie.com/campaigns/15899) to the Pry project - Pry was a **huge** amount of work and every donation received is encouraging and supports Pry's continued development!
10
11
 
11
12
  **Sponsors**
12
13
 
14
+ [Tealeaf Academy](www.gotealeaf.com)<br/>
13
15
  [Atomic Object](http://www.atomicobject.com/)<br/>
14
- [Bendyworks](http://bendyworks.com/)<br/>
16
+ [Hashrocket](http://hashrocket.com/)<br/>
15
17
  [Intridea](http://intridea.com/)<br/>
18
+ [Gaslight](http://gaslight.co/home)<br/>
16
19
 
17
20
  **Other Resources**
18
21
 
@@ -27,7 +30,7 @@ including:
27
30
  * Source code browsing (including core C source with the pry-doc gem)
28
31
  * Documentation browsing
29
32
  * Live help system
30
- * Open methods in editors (`edit-method Class#method`)
33
+ * Open methods in editors (`edit Class#method`)
31
34
  * Syntax highlighting
32
35
  * Command shell integration (start editors, run git, and rake from within Pry)
33
36
  * Gist integration
@@ -36,7 +39,6 @@ including:
36
39
  * Exotic object support (BasicObject instances, IClasses, ...)
37
40
  * A Powerful and flexible command system
38
41
  * Ability to view and replay history
39
-
40
42
  * Many convenience commands inspired by IPython, Smalltalk and other advanced REPLs
41
43
  * A wide-range number of [plugins](https://github.com/pry/pry/wiki/Available-plugins) that provide remote sessions, full debugging functionality, and more.
42
44
 
@@ -65,13 +67,6 @@ methods. The additional docs are accessed through the `show-doc` and
65
67
  * Read the [YARD API documentation](http://rdoc.info/github/pry/pry/master/file/README.markdown)
66
68
  * See the [source code](http://github.com/pry/pry)
67
69
 
68
- Pry also has `rubygems-test` support; to participate, first install
69
- Pry, then:
70
-
71
- 1. Install rubygems-test: `gem install rubygems-test`
72
- 2. Run the test: `gem test pry`
73
- 3. Finally choose 'Yes' to upload the results.
74
-
75
70
  ### Commands
76
71
 
77
72
  Nearly every piece of functionality in a Pry session is implemented as
@@ -102,9 +97,9 @@ an instance variable inside that class:
102
97
  pry(Hello):1> ls -i
103
98
  instance variables: @x
104
99
  pry(Hello):1> cd @x
105
- pry(20:2)> self + 10
100
+ pry(20):2> self + 10
106
101
  => 30
107
- pry(20:2)> cd ..
102
+ pry(20):2> cd ..
108
103
  pry(Hello):1> cd ..
109
104
  pry(main)> cd ..
110
105
 
@@ -112,7 +107,7 @@ The number after the `:` in the pry prompt indicates the nesting
112
107
  level. To display more information about nesting, use the `nesting`
113
108
  command. E.g
114
109
 
115
- pry("friend":3)> nesting
110
+ pry("friend"):3> nesting
116
111
  Nesting status:
117
112
  0. main (Pry top level)
118
113
  1. Hello
@@ -123,7 +118,7 @@ command. E.g
123
118
  We can then jump back to any of the previous nesting levels by using
124
119
  the `jump-to` command:
125
120
 
126
- pry("friend":3)> jump-to 1
121
+ pry("friend"):3> jump-to 1
127
122
  => 100
128
123
  pry(Hello):1>
129
124
 
@@ -224,7 +219,7 @@ In the following example we will enter the `Pry` class, list the
224
219
  instance methods beginning with 're' and display the source code for the `rep` method:
225
220
 
226
221
  pry(main)> cd Pry
227
- pry(Pry)> ls -M --grep re
222
+ pry(Pry):1> ls -M --grep re
228
223
  Pry#methods: re readline refresh rep repl repl_epilogue repl_prologue retrieve_line
229
224
  pry(Pry):1> show-method rep -l
230
225
 
@@ -256,9 +251,9 @@ Note that we can also view C methods (from Ruby Core) using the
256
251
  RETURN_ENUMERATOR(ary, 0, 0);
257
252
  result = rb_ary_new2(RARRAY_LEN(ary));
258
253
  for (i = 0; i < RARRAY_LEN(ary); i++) {
259
- if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
260
- rb_ary_push(result, rb_ary_elt(ary, i));
261
- }
254
+ if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
255
+ rb_ary_push(result, rb_ary_elt(ary, i));
256
+ }
262
257
  }
263
258
  return result;
264
259
  }
@@ -280,7 +275,7 @@ picked up by `rdoc`. Pry also has a basic understanding of both the
280
275
  rdoc and yard formats and will attempt to syntax highlight the
281
276
  documentation appropriately.
282
277
 
283
- Nonetheless The `ri` functionality is very good and
278
+ Nonetheless, the `ri` functionality is very good and
284
279
  has an advantage over Pry's system in that it allows documentation
285
280
  lookup for classes as well as methods. Pry therefore has good
286
281
  integration with `ri` through the `ri` command. The syntax
@@ -332,7 +327,7 @@ You can see the actual gist generated here: [https://gist.github.com/5332c38afc4
332
327
 
333
328
  ### Edit methods
334
329
 
335
- You can use `edit-method Class#method` or `edit-method my_method`
330
+ You can use `edit Class#method` or `edit my_method`
336
331
  (if the method is in scope) to open a method for editing directly in
337
332
  your favorite editor. Pry has knowledge of a few different editors and
338
333
  will attempt to open the file at the line the method is defined.
@@ -341,13 +336,13 @@ You can set the editor to use by assigning to the `Pry.editor`
341
336
  accessor. `Pry.editor` will default to `$EDITOR` or failing that will
342
337
  use `nano` as the backup default. The file that is edited will be
343
338
  automatically reloaded after exiting the editor - reloading can be
344
- suppressed by passing the `--no-reload` option to `edit-method`
339
+ suppressed by passing the `--no-reload` option to `edit`
345
340
 
346
341
  In the example below we will set our default editor to "emacsclient"
347
342
  and open the `Pry#repl` method for editing:
348
343
 
349
344
  pry(main)> Pry.editor = "emacsclient"
350
- pry(main)> edit-method Pry#repl
345
+ pry(main)> edit Pry#repl
351
346
 
352
347
  ### Live Help System
353
348
 
@@ -360,11 +355,19 @@ avaiable.
360
355
 
361
356
  ### Use Pry as your Rails Console
362
357
 
363
- pry -r ./config/environment
358
+ The recommended way to use Pry as your Rails console is to add
359
+ [the `pry-rails` gem](https://github.com/rweng/pry-rails) to
360
+ your Gemfile. This replaces the default console with Pry, in
361
+ addition to loading the Rails console helpers and adding some
362
+ useful Rails-specific commands.
363
+
364
+ If you don't want to change your Gemfile, you can still run a Pry
365
+ console in your app's environment using Pry's `-r` flag:
364
366
 
365
- MyArtChannel has kindly provided a hack to replace the `rails console` command in Rails 3: [https://gist.github.com/941174](https://gist.github.com/941174) This is not recommended for code bases with multiple developers, as they may not all want to use Pry.
367
+ pry -r ./config/environment
366
368
 
367
- Also check out the [wiki](https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry) for other strategies on integrating Pry with rails, notably the [pry-rails](https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry#wiki-pry_rails) plugin.
369
+ Also check out the [wiki](https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry)
370
+ for more information about integrating Pry with Rails.
368
371
 
369
372
  ### Limitations:
370
373
 
@@ -373,17 +376,20 @@ Also check out the [wiki](https://github.com/pry/pry/wiki/Setting-up-Rails-or-He
373
376
 
374
377
  ### Syntax Highlighting
375
378
 
376
- Syntax highlighting is on by default in Pry. You can toggle it on and
377
- off in a session by using the `toggle-color` command. Alternatively,
378
- you can turn it off permanently by putting the line `Pry.color =
379
- false` in your `~/.pryrc` file.
379
+ Syntax highlighting is on by default in Pry. If you want to change
380
+ the colors, check out the [pry-theme](https://github.com/kyrylo/pry-theme)
381
+ gem.
382
+
383
+ You can toggle the syntax highlighting on and off in a session by
384
+ using the `toggle-color` command. Alternatively, you can turn it off
385
+ permanently by putting the line `Pry.color = false` in your `~/.pryrc`
386
+ file.
380
387
 
381
388
  ### Future Directions
382
389
 
383
390
  Many new features are planned such as:
384
391
 
385
392
  * Increase modularity (rely more on plugin system)
386
- * Much improved tab completion (using [Bond](http://github.com/cldwalker/bond))
387
393
  * Much improved documentation system, better support for YARD
388
394
  * Better support for code and method reloading and saving code
389
395
  * Extended and more sophisticated command system, allowing piping
@@ -395,6 +401,6 @@ Problems or questions? file an issue at [github](https://github.com/pry/pry/issu
395
401
 
396
402
  ### Contributors
397
403
 
398
- Pry is primarily the work of [John Mair (banisterfiend)]((http://github.com/banister)), for full list
404
+ Pry is primarily the work of [John Mair (banisterfiend)](http://github.com/banister), for full list
399
405
  of contributors see the
400
406
  [CONTRIBUTORS](https://github.com/pry/pry/blob/master/CONTRIBUTORS) file.
data/lib/pry.rb CHANGED
@@ -1,115 +1,107 @@
1
- # (C) John Mair (banisterfiend) 2011
1
+ # (C) John Mair (banisterfiend) 2013
2
2
  # MIT License
3
3
  #
4
-
5
4
  require 'pp'
5
+
6
+ require 'pry/input_lock'
7
+ require 'pry/exceptions'
6
8
  require 'pry/helpers/base_helpers'
7
9
  require 'pry/hooks'
10
+ require 'forwardable'
8
11
 
9
12
  class Pry
10
13
  # The default hooks - display messages when beginning and ending Pry sessions.
11
14
  DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |out, target, _pry_|
12
15
  next if _pry_.quiet?
13
- _pry_.run_command("whereami --quiet", "", target)
16
+ _pry_.run_command("whereami --quiet")
14
17
  end
15
18
 
16
19
  # The default print
17
- DEFAULT_PRINT = proc do |output, value|
18
- stringified = begin
19
- value.pretty_inspect
20
- rescue RescuableException
21
- nil
22
- end
23
-
24
- unless String === stringified
25
- # Read the class name off of the singleton class to provide a default inspect.
26
- klass = (class << value; self; end).ancestors.first
27
- stringified = "#<#{klass}:0x#{value.__id__.to_s(16)}>"
20
+ DEFAULT_PRINT = proc do |output, value, _pry_|
21
+ _pry_.pager.open do |pager|
22
+ pager.print _pry_.config.output_prefix
23
+ Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
28
24
  end
29
-
30
- nonce = rand(0x100000000).to_s(16) # whatever
31
-
32
- colorized = Helpers::BaseHelpers.colorize_code(stringified.gsub(/#</, "%<#{nonce}"))
33
-
34
- # avoid colour-leak from CodeRay and any of the users' previous output
35
- colorized = colorized.sub(/(\n*)$/, "\e[0m\\1") if Pry.color
36
-
37
- Helpers::BaseHelpers.stagger_output("=> #{colorized.gsub(/%<(.*?)#{nonce}/, '#<\1')}", output)
38
25
  end
39
26
 
40
27
  # may be convenient when working with enormous objects and
41
28
  # pretty_print is too slow
42
29
  SIMPLE_PRINT = proc do |output, value|
43
30
  begin
44
- output.puts "=> #{value.inspect}"
31
+ output.puts value.inspect
45
32
  rescue RescuableException
46
- output.puts "=> unknown"
33
+ output.puts "unknown"
47
34
  end
48
35
  end
49
36
 
50
37
  # useful when playing with truly enormous objects
51
38
  CLIPPED_PRINT = proc do |output, value|
52
- output.puts "=> #{Pry.view_clip(value)}"
39
+ output.puts Pry.view_clip(value, id: true)
53
40
  end
54
41
 
55
42
  # Will only show the first line of the backtrace
56
43
  DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _|
57
- output.puts "#{exception.class}: #{exception.message}"
58
- output.puts "from #{exception.backtrace.first}"
44
+ if UserError === exception && SyntaxError === exception
45
+ output.puts "SyntaxError: #{exception.message.sub(/.*syntax error, */m, '')}"
46
+ else
47
+ output.puts "#{exception.class}: #{exception.message}"
48
+ output.puts "from #{exception.backtrace.first}"
49
+ end
59
50
  end
60
51
 
61
- # Don't catch these exceptions
62
- DEFAULT_EXCEPTION_WHITELIST = [SystemExit, SignalException]
52
+ DEFAULT_PROMPT_NAME = 'pry'
63
53
 
64
54
  # The default prompt; includes the target and nesting level
65
55
  DEFAULT_PROMPT = [
66
56
  proc { |target_self, nest_level, pry|
67
- "[#{pry.input_array.size}] pry(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
57
+ "[#{pry.input_array.size}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
68
58
  },
69
59
 
70
60
  proc { |target_self, nest_level, pry|
71
- "[#{pry.input_array.size}] pry(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
61
+ "[#{pry.input_array.size}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
72
62
  }
73
63
  ]
74
64
 
65
+ DEFAULT_PROMPT_SAFE_OBJECTS = [String, Numeric, Symbol, nil, true, false]
66
+
75
67
  # A simple prompt - doesn't display target or nesting level
76
68
  SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
77
69
 
70
+ NO_PROMPT = [proc { '' }, proc { '' }]
71
+
78
72
  SHELL_PROMPT = [
79
- proc { |target_self, _, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
80
- proc { |target_self, _, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
73
+ proc { |target_self, _, _pry_| "#{_pry_.config.prompt_name} #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
74
+ proc { |target_self, _, _pry_| "#{_pry_.config.prompt_name} #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
81
75
  ]
82
76
 
83
77
  # A prompt that includes the full object path as well as
84
78
  # input/output (_in_ and _out_) information. Good for navigation.
85
79
  NAV_PROMPT = [
86
- proc do |_, level, pry|
87
- tree = pry.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
88
- "[#{pry.input_array.size}] (pry) #{tree}: #{level}> "
80
+ proc do |_, _, _pry_|
81
+ tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
82
+ "[#{_pry_.input_array.count}] (#{_pry_.config.prompt_name}) #{tree}: #{_pry_.binding_stack.size - 1}> "
89
83
  end,
90
- proc do |_, level, pry|
91
- tree = pry.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
92
- "[#{pry.input_array.size}] (pry) #{tree}: #{level}* "
84
+ proc do |_, _, _pry_|
85
+ tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
86
+ "[#{_pry_.input_array.count}] (#{ _pry_.config.prompt_name}) #{tree}: #{_pry_.binding_stack.size - 1}* "
93
87
  end,
94
88
  ]
95
89
 
96
- # Deal with the ^D key being pressed, different behaviour in
97
- # different cases:
98
- # 1) In an expression - behave like `!` command (clear input buffer)
99
- # 2) At top-level session - behave like `exit command (break out of repl loop)
100
- # 3) In a nested session - behave like `cd ..` (pop a binding)
90
+ # Deal with the ^D key being pressed. Different behaviour in different cases:
91
+ # 1. In an expression behave like `!` command.
92
+ # 2. At top-level session behave like `exit` command.
93
+ # 3. In a nested session behave like `cd ..`.
101
94
  DEFAULT_CONTROL_D_HANDLER = proc do |eval_string, _pry_|
102
95
  if !eval_string.empty?
103
- # Clear input buffer.
104
- eval_string.replace("")
96
+ eval_string.replace('') # Clear input buffer.
105
97
  elsif _pry_.binding_stack.one?
106
- # ^D at top-level breaks out of a REPL loop.
107
98
  _pry_.binding_stack.clear
108
99
  throw(:breakout)
109
100
  else
110
101
  # Otherwise, saves current binding stack as old stack and pops last
111
102
  # binding out of binding stack (the old stack still has that binding).
112
- _pry_.command_state["cd"].old_stack = _pry_.binding_stack.dup
103
+ _pry_.command_state["cd"] ||= Pry::Config.from_hash({}) # FIXME
104
+ _pry_.command_state['cd'].old_stack = _pry_.binding_stack.dup
113
105
  _pry_.binding_stack.pop
114
106
  end
115
107
  end
@@ -120,99 +112,50 @@ class Pry
120
112
  end
121
113
  end
122
114
 
123
- # As a REPL, we often want to catch any unexpected exceptions that may have
124
- # been raised; however we don't want to go overboard and prevent the user
125
- # from exiting Pry when they want to.
126
- module RescuableException
127
- def self.===(exception)
128
- case exception
129
- # Catch when the user hits ^C (Interrupt < SignalException), and assume
130
- # that they just wanted to stop the in-progress command (just like bash etc.)
131
- when Interrupt
132
- true
133
- # Don't catch signals (particularly not SIGTERM) as these are unlikely to be
134
- # intended for pry itself. We should also make sure that Kernel#exit works.
135
- when *Pry.config.exception_whitelist
136
- false
137
- # All other exceptions will be caught.
138
- else
139
- true
140
- end
141
- end
142
- end
143
-
144
- # CommandErrors are caught by the REPL loop and displayed to the user. They
145
- # indicate an exceptional condition that's fatal to the current command.
146
- class CommandError < StandardError; end
147
- class NonMethodContextError < CommandError; end
148
-
149
- # indicates obsolete API
150
- class ObsoleteError < StandardError; end
115
+ # Store the current working directory. This allows show-source etc. to work if
116
+ # your process has changed directory since boot. [Issue #675]
117
+ INITIAL_PWD = Dir.pwd
151
118
 
152
119
  # This is to keep from breaking under Rails 3.2 for people who are doing that
153
120
  # IRB = Pry thing.
154
- module ExtendCommandBundle
155
- end
121
+ module ExtendCommandBundle; end
156
122
  end
157
123
 
158
- if Pry::Helpers::BaseHelpers.mri_18?
159
- begin
160
- require 'ruby18_source_location'
161
- rescue LoadError
162
- end
163
- end
164
-
165
- require "method_source"
124
+ require 'method_source'
166
125
  require 'shellwords'
167
- require "stringio"
168
- require "coderay"
169
- require "optparse"
170
- require "slop"
171
- require "rbconfig"
172
-
173
- begin
174
- require 'readline'
175
- rescue LoadError
176
- warn "You're running a version of ruby with no Readline support"
177
- warn "Please `gem install rb-readline` or recompile ruby --with-readline."
178
- exit!
179
- end
180
-
181
- if Pry::Helpers::BaseHelpers.jruby?
182
- begin
183
- require 'ffi'
184
- rescue LoadError
185
- warn "Need to `gem install ffi`"
186
- end
187
- end
188
-
189
- if Pry::Helpers::BaseHelpers.windows? && !Pry::Helpers::BaseHelpers.windows_ansi?
190
- begin
191
- require 'win32console'
192
- # The mswin and mingw versions of pry require win32console, so this should
193
- # only fail on jruby (where win32console doesn't work).
194
- # Instead we'll recommend ansicon, which does.
195
- rescue LoadError
196
- warn "For a better pry experience, please use ansicon: http://adoxa.3eeweb.com/ansicon/"
197
- end
198
- end
199
-
200
- require "pry/version"
201
- require "pry/rbx_method"
202
- require "pry/rbx_path"
203
- require "pry/code"
204
- require "pry/method"
205
- require "pry/wrapped_module"
206
- require "pry/history_array"
207
- require "pry/helpers"
208
- require "pry/history"
209
- require "pry/command"
210
- require "pry/command_set"
211
- require "pry/commands"
212
- require "pry/custom_completions"
213
- require "pry/completion"
214
- require "pry/plugins"
215
- require "pry/core_extensions"
216
- require "pry/pry_class"
217
- require "pry/pry_instance"
218
- require "pry/cli"
126
+ require 'stringio'
127
+ require 'coderay'
128
+ require 'slop'
129
+ require 'rbconfig'
130
+ require 'tempfile'
131
+ require 'pathname'
132
+
133
+ require 'pry/version'
134
+ require 'pry/repl'
135
+ require 'pry/rbx_path'
136
+ require 'pry/code'
137
+ require 'pry/history_array'
138
+ require 'pry/helpers'
139
+ require 'pry/code_object'
140
+ require 'pry/method'
141
+ require 'pry/wrapped_module'
142
+ require 'pry/history'
143
+ require 'pry/command'
144
+ require 'pry/command_set'
145
+ require 'pry/commands'
146
+ require 'pry/plugins'
147
+ require 'pry/core_extensions'
148
+ require 'pry/pry_class'
149
+ require 'pry/pry_instance'
150
+ require 'pry/cli'
151
+ require 'pry/color_printer'
152
+ require 'pry/pager'
153
+ require 'pry/terminal'
154
+ require 'pry/editor'
155
+ require 'pry/rubygem'
156
+ require "pry/indent"
157
+ require "pry/last_exception"
158
+ require "pry/prompt"
159
+ require "pry/inspector"
160
+ require 'pry/object_path'
161
+ require 'pry/output'