pry 0.9.12.6-java → 0.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +37 -31
  5. data/lib/pry.rb +38 -151
  6. data/lib/pry/cli.rb +35 -17
  7. data/lib/pry/code.rb +19 -63
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +2 -1
  10. data/lib/pry/code/loc.rb +2 -2
  11. data/lib/pry/code_object.rb +40 -21
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +12 -9
  14. data/lib/pry/command_set.rb +81 -38
  15. data/lib/pry/commands.rb +1 -1
  16. data/lib/pry/commands/amend_line.rb +2 -2
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat.rb +11 -2
  19. data/lib/pry/commands/cat/exception_formatter.rb +6 -7
  20. data/lib/pry/commands/cat/file_formatter.rb +15 -32
  21. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  22. data/lib/pry/commands/cd.rb +14 -3
  23. data/lib/pry/commands/change_inspector.rb +27 -0
  24. data/lib/pry/commands/change_prompt.rb +26 -0
  25. data/lib/pry/commands/code_collector.rb +4 -4
  26. data/lib/pry/commands/easter_eggs.rb +3 -3
  27. data/lib/pry/commands/edit.rb +10 -22
  28. data/lib/pry/commands/edit/exception_patcher.rb +2 -2
  29. data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
  30. data/lib/pry/commands/exit_program.rb +0 -1
  31. data/lib/pry/commands/find_method.rb +16 -22
  32. data/lib/pry/commands/gem_install.rb +5 -2
  33. data/lib/pry/commands/gem_open.rb +1 -1
  34. data/lib/pry/commands/gist.rb +10 -11
  35. data/lib/pry/commands/help.rb +14 -14
  36. data/lib/pry/commands/hist.rb +27 -8
  37. data/lib/pry/commands/install_command.rb +14 -12
  38. data/lib/pry/commands/list_inspectors.rb +35 -0
  39. data/lib/pry/commands/list_prompts.rb +35 -0
  40. data/lib/pry/commands/ls.rb +72 -296
  41. data/lib/pry/commands/ls/constants.rb +47 -0
  42. data/lib/pry/commands/ls/formatter.rb +49 -0
  43. data/lib/pry/commands/ls/globals.rb +48 -0
  44. data/lib/pry/commands/ls/grep.rb +21 -0
  45. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  46. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  47. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  48. data/lib/pry/commands/ls/local_names.rb +35 -0
  49. data/lib/pry/commands/ls/local_vars.rb +39 -0
  50. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  51. data/lib/pry/commands/ls/methods.rb +57 -0
  52. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  53. data/lib/pry/commands/ls/self_methods.rb +32 -0
  54. data/lib/pry/commands/play.rb +44 -10
  55. data/lib/pry/commands/pry_backtrace.rb +1 -2
  56. data/lib/pry/commands/raise_up.rb +2 -2
  57. data/lib/pry/commands/reload_code.rb +16 -19
  58. data/lib/pry/commands/ri.rb +7 -3
  59. data/lib/pry/commands/shell_command.rb +18 -13
  60. data/lib/pry/commands/shell_mode.rb +2 -4
  61. data/lib/pry/commands/show_doc.rb +5 -0
  62. data/lib/pry/commands/show_info.rb +8 -13
  63. data/lib/pry/commands/show_source.rb +15 -3
  64. data/lib/pry/commands/simple_prompt.rb +1 -1
  65. data/lib/pry/commands/toggle_color.rb +8 -4
  66. data/lib/pry/commands/watch_expression.rb +105 -0
  67. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  68. data/lib/pry/commands/whereami.rb +18 -10
  69. data/lib/pry/commands/wtf.rb +3 -3
  70. data/lib/pry/config.rb +20 -254
  71. data/lib/pry/config/behavior.rb +139 -0
  72. data/lib/pry/config/convenience.rb +26 -0
  73. data/lib/pry/config/default.rb +165 -0
  74. data/lib/pry/core_extensions.rb +31 -21
  75. data/lib/pry/editor.rb +107 -103
  76. data/lib/pry/exceptions.rb +77 -0
  77. data/lib/pry/helpers/base_helpers.rb +22 -109
  78. data/lib/pry/helpers/command_helpers.rb +10 -8
  79. data/lib/pry/helpers/documentation_helpers.rb +1 -2
  80. data/lib/pry/helpers/text.rb +4 -5
  81. data/lib/pry/history.rb +46 -45
  82. data/lib/pry/history_array.rb +6 -1
  83. data/lib/pry/hooks.rb +9 -29
  84. data/lib/pry/indent.rb +6 -6
  85. data/lib/pry/input_completer.rb +242 -0
  86. data/lib/pry/input_lock.rb +132 -0
  87. data/lib/pry/inspector.rb +27 -0
  88. data/lib/pry/last_exception.rb +61 -0
  89. data/lib/pry/method.rb +82 -87
  90. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
  91. data/lib/pry/module_candidate.rb +4 -14
  92. data/lib/pry/object_path.rb +82 -0
  93. data/lib/pry/output.rb +50 -0
  94. data/lib/pry/pager.rb +193 -48
  95. data/lib/pry/plugins.rb +1 -1
  96. data/lib/pry/prompt.rb +26 -0
  97. data/lib/pry/pry_class.rb +149 -230
  98. data/lib/pry/pry_instance.rb +302 -413
  99. data/lib/pry/rbx_path.rb +1 -1
  100. data/lib/pry/repl.rb +202 -0
  101. data/lib/pry/repl_file_loader.rb +20 -26
  102. data/lib/pry/rubygem.rb +13 -5
  103. data/lib/pry/terminal.rb +2 -1
  104. data/lib/pry/test/helper.rb +26 -41
  105. data/lib/pry/version.rb +1 -1
  106. data/lib/pry/wrapped_module.rb +45 -59
  107. metadata +62 -225
  108. data/.document +0 -2
  109. data/.gitignore +0 -16
  110. data/.travis.yml +0 -25
  111. data/.yardopts +0 -1
  112. data/CHANGELOG +0 -534
  113. data/CONTRIBUTORS +0 -55
  114. data/Gemfile +0 -12
  115. data/Rakefile +0 -140
  116. data/TODO +0 -117
  117. data/lib/pry/completion.rb +0 -321
  118. data/lib/pry/custom_completions.rb +0 -6
  119. data/lib/pry/rbx_method.rb +0 -13
  120. data/man/pry.1 +0 -195
  121. data/man/pry.1.html +0 -204
  122. data/man/pry.1.ronn +0 -141
  123. data/pry.gemspec +0 -29
  124. data/spec/Procfile +0 -3
  125. data/spec/cli_spec.rb +0 -78
  126. data/spec/code_object_spec.rb +0 -277
  127. data/spec/code_spec.rb +0 -219
  128. data/spec/command_helpers_spec.rb +0 -29
  129. data/spec/command_integration_spec.rb +0 -644
  130. data/spec/command_set_spec.rb +0 -627
  131. data/spec/command_spec.rb +0 -821
  132. data/spec/commands/amend_line_spec.rb +0 -247
  133. data/spec/commands/bang_spec.rb +0 -19
  134. data/spec/commands/cat_spec.rb +0 -164
  135. data/spec/commands/cd_spec.rb +0 -250
  136. data/spec/commands/disable_pry_spec.rb +0 -25
  137. data/spec/commands/edit_spec.rb +0 -727
  138. data/spec/commands/exit_all_spec.rb +0 -34
  139. data/spec/commands/exit_program_spec.rb +0 -19
  140. data/spec/commands/exit_spec.rb +0 -34
  141. data/spec/commands/find_method_spec.rb +0 -70
  142. data/spec/commands/gem_list_spec.rb +0 -26
  143. data/spec/commands/gist_spec.rb +0 -79
  144. data/spec/commands/help_spec.rb +0 -56
  145. data/spec/commands/hist_spec.rb +0 -181
  146. data/spec/commands/jump_to_spec.rb +0 -15
  147. data/spec/commands/ls_spec.rb +0 -181
  148. data/spec/commands/play_spec.rb +0 -140
  149. data/spec/commands/raise_up_spec.rb +0 -56
  150. data/spec/commands/save_file_spec.rb +0 -177
  151. data/spec/commands/show_doc_spec.rb +0 -510
  152. data/spec/commands/show_input_spec.rb +0 -17
  153. data/spec/commands/show_source_spec.rb +0 -782
  154. data/spec/commands/whereami_spec.rb +0 -203
  155. data/spec/completion_spec.rb +0 -241
  156. data/spec/control_d_handler_spec.rb +0 -58
  157. data/spec/documentation_helper_spec.rb +0 -73
  158. data/spec/editor_spec.rb +0 -79
  159. data/spec/exception_whitelist_spec.rb +0 -21
  160. data/spec/fixtures/candidate_helper1.rb +0 -11
  161. data/spec/fixtures/candidate_helper2.rb +0 -8
  162. data/spec/fixtures/example.erb +0 -5
  163. data/spec/fixtures/example_nesting.rb +0 -33
  164. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  165. data/spec/fixtures/testrc +0 -2
  166. data/spec/fixtures/testrcbad +0 -2
  167. data/spec/fixtures/whereami_helper.rb +0 -6
  168. data/spec/helper.rb +0 -34
  169. data/spec/helpers/bacon.rb +0 -86
  170. data/spec/helpers/mock_pry.rb +0 -43
  171. data/spec/helpers/table_spec.rb +0 -105
  172. data/spec/history_array_spec.rb +0 -67
  173. data/spec/hooks_spec.rb +0 -522
  174. data/spec/indent_spec.rb +0 -301
  175. data/spec/input_stack_spec.rb +0 -90
  176. data/spec/method_spec.rb +0 -482
  177. data/spec/prompt_spec.rb +0 -60
  178. data/spec/pry_defaults_spec.rb +0 -419
  179. data/spec/pry_history_spec.rb +0 -99
  180. data/spec/pry_output_spec.rb +0 -95
  181. data/spec/pry_spec.rb +0 -515
  182. data/spec/run_command_spec.rb +0 -25
  183. data/spec/sticky_locals_spec.rb +0 -157
  184. data/spec/syntax_checking_spec.rb +0 -81
  185. data/spec/wrapped_module_spec.rb +0 -261
  186. data/wiki/Customizing-pry.md +0 -397
  187. 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,16 +1,19 @@
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
6
  ![The Pry Logo](https://dl.dropbox.com/u/26521875/pry%20stuff/logo/pry_logo_350.png)
5
7
 
6
- © John Mair (banisterfiend) 2012<br>
8
+ © John Mair ([banisterfiend](https://twitter.com/banisterfiend)) 2013<br>
7
9
 
8
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!
9
11
 
10
12
  **Sponsors**
11
13
 
14
+ [Tealeaf Academy](http://www.gotealeaf.com)<br/>
12
15
  [Atomic Object](http://www.atomicobject.com/)<br/>
13
- [Bendyworks](http://bendyworks.com/)<br/>
16
+ [Hashrocket](http://hashrocket.com/)<br/>
14
17
  [Intridea](http://intridea.com/)<br/>
15
18
  [Gaslight](http://gaslight.co/home)<br/>
16
19
 
@@ -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
  }
@@ -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
data/lib/pry.rb CHANGED
@@ -1,53 +1,27 @@
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
- output_with_default_format(output, value, :hashrocket => true)
19
- end
20
-
21
- def self.output_with_default_format(output, value, options = {})
22
- stringified = begin
23
- value.pretty_inspect
24
- rescue RescuableException
25
- nil
26
- end
27
-
28
- unless String === stringified
29
- # Read the class name off of the singleton class to provide a default
30
- # inspect.
31
- klass = (class << value; self; end).ancestors.first
32
- 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)
33
24
  end
34
-
35
- nonce = rand(0x100000000).to_s(16) # whatever
36
-
37
- stringified.gsub!(/#</, "%<#{nonce}")
38
- # Don't recolorize output with color (for cucumber, looksee, etc.) [Issue #751]
39
- colorized = if stringified =~ /\e\[/
40
- stringified
41
- else
42
- Helpers::BaseHelpers.colorize_code(stringified)
43
- end
44
-
45
- # avoid colour-leak from CodeRay and any of the users' previous output
46
- colorized = colorized.sub(/(\n*)\z/, "\e[0m\\1") if Pry.color
47
-
48
- result = colorized.gsub(/%<(.*?)#{nonce}/, '#<\1')
49
- result = "=> #{result}"if options[:hashrocket]
50
- Helpers::BaseHelpers.stagger_output(result, output)
51
25
  end
52
26
 
53
27
  # may be convenient when working with enormous objects and
@@ -62,7 +36,7 @@ class Pry
62
36
 
63
37
  # useful when playing with truly enormous objects
64
38
  CLIPPED_PRINT = proc do |output, value|
65
- output.puts Pry.view_clip(value)
39
+ output.puts Pry.view_clip(value, id: true)
66
40
  end
67
41
 
68
42
  # Will only show the first line of the backtrace
@@ -80,32 +54,36 @@ class Pry
80
54
  # The default prompt; includes the target and nesting level
81
55
  DEFAULT_PROMPT = [
82
56
  proc { |target_self, nest_level, pry|
83
- "[#{pry.input_array.size}] #{Pry.config.prompt_name}(#{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?}> "
84
58
  },
85
59
 
86
60
  proc { |target_self, nest_level, pry|
87
- "[#{pry.input_array.size}] #{Pry.config.prompt_name}(#{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?}* "
88
62
  }
89
63
  ]
90
64
 
65
+ DEFAULT_PROMPT_SAFE_OBJECTS = [String, Numeric, Symbol, nil, true, false]
66
+
91
67
  # A simple prompt - doesn't display target or nesting level
92
68
  SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
93
69
 
70
+ NO_PROMPT = [proc { '' }, proc { '' }]
71
+
94
72
  SHELL_PROMPT = [
95
- proc { |target_self, _, _| "#{Pry.config.prompt_name} #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
96
- proc { |target_self, _, _| "#{Pry.config.prompt_name} #{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} * " }
97
75
  ]
98
76
 
99
77
  # A prompt that includes the full object path as well as
100
78
  # input/output (_in_ and _out_) information. Good for navigation.
101
79
  NAV_PROMPT = [
102
- proc do |conf|
103
- tree = conf.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
104
- "[#{conf.expr_number}] (#{Pry.config.prompt_name}) #{tree}: #{conf.nesting_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}> "
105
83
  end,
106
- proc do |conf|
107
- tree = conf.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
108
- "[#{conf.expr_number}] (#{ Pry.config.prompt_name}) #{tree}: #{conf.nesting_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}* "
109
87
  end,
110
88
  ]
111
89
 
@@ -120,10 +98,9 @@ class Pry
120
98
  _pry_.binding_stack.clear
121
99
  throw(:breakout)
122
100
  else
123
- # Store the entire binding stack before popping. Useful for `cd -`.
124
- if _pry_.command_state['cd'].nil?
125
- _pry_.command_state['cd'] = OpenStruct.new
126
- end
101
+ # Otherwise, saves current binding stack as old stack and pops last
102
+ # binding out of binding stack (the old stack still has that binding).
103
+ _pry_.command_state["cd"] ||= Pry::Config.from_hash({}) # FIXME
127
104
  _pry_.command_state['cd'].old_stack = _pry_.binding_stack.dup
128
105
  _pry_.binding_stack.pop
129
106
  end
@@ -139,80 +116,9 @@ class Pry
139
116
  # your process has changed directory since boot. [Issue #675]
140
117
  INITIAL_PWD = Dir.pwd
141
118
 
142
- # As a REPL, we often want to catch any unexpected exceptions that may have
143
- # been raised; however we don't want to go overboard and prevent the user
144
- # from exiting Pry when they want to.
145
- module RescuableException
146
- def self.===(exception)
147
- case exception
148
- # Catch when the user hits ^C (Interrupt < SignalException), and assume
149
- # that they just wanted to stop the in-progress command (just like bash etc.)
150
- when Interrupt
151
- true
152
- # Don't catch signals (particularly not SIGTERM) as these are unlikely to be
153
- # intended for pry itself. We should also make sure that Kernel#exit works.
154
- when *Pry.config.exception_whitelist
155
- false
156
- # All other exceptions will be caught.
157
- else
158
- true
159
- end
160
- end
161
- end
162
-
163
- # An Exception Tag (cf. Exceptional Ruby) that instructs Pry to show the error in
164
- # a more user-friendly manner. This should be used when the exception happens within
165
- # Pry itself as a direct consequence of the user typing something wrong.
166
- #
167
- # This allows us to distinguish between the user typing:
168
- #
169
- # pry(main)> def )
170
- # SyntaxError: unexpected )
171
- #
172
- # pry(main)> method_that_evals("def )")
173
- # SyntaxError: (eval):1: syntax error, unexpected ')'
174
- # from ./a.rb:2 in `eval'
175
- module UserError; end
176
-
177
- # Catches SecurityErrors if $SAFE is set
178
- module TooSafeException
179
- def self.===(exception)
180
- $SAFE > 0 && SecurityError === exception
181
- end
182
- end
183
-
184
- # Don't catch these exceptions
185
- DEFAULT_EXCEPTION_WHITELIST = [SystemExit, SignalException, Pry::TooSafeException]
186
-
187
- # CommandErrors are caught by the REPL loop and displayed to the user. They
188
- # indicate an exceptional condition that's fatal to the current command.
189
- class CommandError < StandardError; end
190
- class MethodNotFound < CommandError; end
191
-
192
- # indicates obsolete API
193
- class ObsoleteError < StandardError; end
194
-
195
119
  # This is to keep from breaking under Rails 3.2 for people who are doing that
196
120
  # IRB = Pry thing.
197
- module ExtendCommandBundle
198
- end
199
-
200
- def self.require_readline
201
- return false if @required_readline
202
- require 'readline'
203
- @required_readline = true
204
- rescue LoadError
205
- warn "Sorry, you can't use Pry without Readline or a compatible library."
206
- warn "Please `gem install rb-readline` or recompile Ruby --with-readline."
207
- raise
208
- end
209
- end
210
-
211
- if Pry::Helpers::BaseHelpers.mri_18?
212
- begin
213
- require 'ruby18_source_location'
214
- rescue LoadError
215
- end
121
+ module ExtendCommandBundle; end
216
122
  end
217
123
 
218
124
  require 'method_source'
@@ -222,34 +128,10 @@ require 'coderay'
222
128
  require 'slop'
223
129
  require 'rbconfig'
224
130
  require 'tempfile'
225
-
226
- if Pry::Helpers::BaseHelpers.jruby?
227
- begin
228
- require 'ffi'
229
- rescue LoadError
230
- warn "For a better Pry experience on JRuby, please `gem install ffi`."
231
- end
232
- end
233
-
234
- if Pry::Helpers::BaseHelpers.windows? && !Pry::Helpers::BaseHelpers.windows_ansi?
235
- begin
236
- require 'win32console'
237
- # The mswin and mingw versions of pry require win32console, so this should
238
- # only fail on jruby (where win32console doesn't work).
239
- # Instead we'll recommend ansicon, which does.
240
- rescue LoadError
241
- warn "For a better Pry experience on Windows, please use ansicon:"
242
- warn " http://adoxa.3eeweb.com/ansicon/"
243
- end
244
- end
245
-
246
- begin
247
- require 'bond'
248
- rescue LoadError
249
- end
131
+ require 'pathname'
250
132
 
251
133
  require 'pry/version'
252
- require 'pry/rbx_method'
134
+ require 'pry/repl'
253
135
  require 'pry/rbx_path'
254
136
  require 'pry/code'
255
137
  require 'pry/history_array'
@@ -261,14 +143,19 @@ require 'pry/history'
261
143
  require 'pry/command'
262
144
  require 'pry/command_set'
263
145
  require 'pry/commands'
264
- require 'pry/custom_completions'
265
- require 'pry/completion'
266
146
  require 'pry/plugins'
267
147
  require 'pry/core_extensions'
268
148
  require 'pry/pry_class'
269
149
  require 'pry/pry_instance'
270
150
  require 'pry/cli'
151
+ require 'pry/color_printer'
271
152
  require 'pry/pager'
272
153
  require 'pry/terminal'
273
154
  require 'pry/editor'
274
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'