pry 0.10.pre.1-java → 0.10.0.pre2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +702 -0
- data/LICENSE +2 -2
- data/{README.markdown → README.md} +41 -35
- data/lib/pry.rb +82 -139
- data/lib/pry/cli.rb +77 -30
- data/lib/pry/code.rb +126 -182
- data/lib/pry/code/code_file.rb +103 -0
- data/lib/pry/code/code_range.rb +71 -0
- data/lib/pry/code/loc.rb +92 -0
- data/lib/pry/code_object.rb +172 -0
- data/lib/pry/color_printer.rb +55 -0
- data/lib/pry/command.rb +184 -28
- data/lib/pry/command_set.rb +113 -59
- data/lib/pry/commands.rb +4 -27
- data/lib/pry/commands/amend_line.rb +99 -0
- data/lib/pry/commands/bang.rb +20 -0
- data/lib/pry/commands/bang_pry.rb +17 -0
- data/lib/pry/commands/cat.rb +62 -0
- data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
- data/lib/pry/commands/cat/exception_formatter.rb +77 -0
- data/lib/pry/commands/cat/file_formatter.rb +67 -0
- data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
- data/lib/pry/commands/cd.rb +41 -0
- data/lib/pry/commands/change_inspector.rb +27 -0
- data/lib/pry/commands/change_prompt.rb +26 -0
- data/lib/pry/commands/code_collector.rb +165 -0
- data/lib/pry/commands/disable_pry.rb +27 -0
- data/lib/pry/commands/disabled_commands.rb +2 -0
- data/lib/pry/commands/easter_eggs.rb +112 -0
- data/lib/pry/commands/edit.rb +195 -0
- data/lib/pry/commands/edit/exception_patcher.rb +25 -0
- data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
- data/lib/pry/commands/exit.rb +42 -0
- data/lib/pry/commands/exit_all.rb +29 -0
- data/lib/pry/commands/exit_program.rb +23 -0
- data/lib/pry/commands/find_method.rb +193 -0
- data/lib/pry/commands/fix_indent.rb +19 -0
- data/lib/pry/commands/gem_cd.rb +26 -0
- data/lib/pry/commands/gem_install.rb +32 -0
- data/lib/pry/commands/gem_list.rb +33 -0
- data/lib/pry/commands/gem_open.rb +29 -0
- data/lib/pry/commands/gist.rb +101 -0
- data/lib/pry/commands/help.rb +164 -0
- data/lib/pry/commands/hist.rb +180 -0
- data/lib/pry/commands/import_set.rb +22 -0
- data/lib/pry/commands/install_command.rb +53 -0
- data/lib/pry/commands/jump_to.rb +29 -0
- data/lib/pry/commands/list_inspectors.rb +35 -0
- data/lib/pry/commands/list_prompts.rb +35 -0
- data/lib/pry/commands/ls.rb +114 -0
- data/lib/pry/commands/ls/constants.rb +47 -0
- data/lib/pry/commands/ls/formatter.rb +49 -0
- data/lib/pry/commands/ls/globals.rb +48 -0
- data/lib/pry/commands/ls/grep.rb +21 -0
- data/lib/pry/commands/ls/instance_vars.rb +39 -0
- data/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/lib/pry/commands/ls/local_names.rb +35 -0
- data/lib/pry/commands/ls/local_vars.rb +39 -0
- data/lib/pry/commands/ls/ls_entity.rb +70 -0
- data/lib/pry/commands/ls/methods.rb +57 -0
- data/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/lib/pry/commands/ls/self_methods.rb +32 -0
- data/lib/pry/commands/nesting.rb +25 -0
- data/lib/pry/commands/play.rb +103 -0
- data/lib/pry/commands/pry_backtrace.rb +25 -0
- data/lib/pry/commands/pry_version.rb +17 -0
- data/lib/pry/commands/raise_up.rb +32 -0
- data/lib/pry/commands/reload_code.rb +62 -0
- data/lib/pry/commands/reset.rb +18 -0
- data/lib/pry/commands/ri.rb +60 -0
- data/lib/pry/commands/save_file.rb +61 -0
- data/lib/pry/commands/shell_command.rb +48 -0
- data/lib/pry/commands/shell_mode.rb +25 -0
- data/lib/pry/commands/show_doc.rb +83 -0
- data/lib/pry/commands/show_info.rb +195 -0
- data/lib/pry/commands/show_input.rb +17 -0
- data/lib/pry/commands/show_source.rb +50 -0
- data/lib/pry/commands/simple_prompt.rb +22 -0
- data/lib/pry/commands/stat.rb +40 -0
- data/lib/pry/commands/switch_to.rb +23 -0
- data/lib/pry/commands/toggle_color.rb +24 -0
- data/lib/pry/commands/watch_expression.rb +105 -0
- data/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/lib/pry/commands/whereami.rb +190 -0
- data/lib/pry/commands/wtf.rb +57 -0
- data/lib/pry/config.rb +20 -229
- data/lib/pry/config/behavior.rb +139 -0
- data/lib/pry/config/convenience.rb +26 -0
- data/lib/pry/config/default.rb +165 -0
- data/lib/pry/core_extensions.rb +59 -38
- data/lib/pry/editor.rb +133 -0
- data/lib/pry/exceptions.rb +77 -0
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/helpers/base_helpers.rb +40 -154
- data/lib/pry/helpers/command_helpers.rb +19 -130
- data/lib/pry/helpers/documentation_helpers.rb +21 -11
- data/lib/pry/helpers/table.rb +109 -0
- data/lib/pry/helpers/text.rb +8 -9
- data/lib/pry/history.rb +61 -45
- data/lib/pry/history_array.rb +11 -1
- data/lib/pry/hooks.rb +10 -32
- data/lib/pry/indent.rb +110 -38
- data/lib/pry/input_completer.rb +242 -0
- data/lib/pry/input_lock.rb +132 -0
- data/lib/pry/inspector.rb +27 -0
- data/lib/pry/last_exception.rb +61 -0
- data/lib/pry/method.rb +199 -200
- data/lib/pry/method/disowned.rb +53 -0
- data/lib/pry/method/patcher.rb +125 -0
- data/lib/pry/method/weird_method_locator.rb +186 -0
- data/lib/pry/module_candidate.rb +39 -33
- data/lib/pry/object_path.rb +82 -0
- data/lib/pry/output.rb +50 -0
- data/lib/pry/pager.rb +234 -0
- data/lib/pry/plugins.rb +4 -3
- data/lib/pry/prompt.rb +26 -0
- data/lib/pry/pry_class.rb +199 -227
- data/lib/pry/pry_instance.rb +344 -403
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +202 -0
- data/lib/pry/repl_file_loader.rb +20 -26
- data/lib/pry/rubygem.rb +82 -0
- data/lib/pry/terminal.rb +79 -0
- data/lib/pry/test/helper.rb +170 -0
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +133 -48
- metadata +132 -197
- data/.document +0 -2
- data/.gemtest +0 -0
- data/.gitignore +0 -16
- data/.travis.yml +0 -17
- data/.yardopts +0 -1
- data/CHANGELOG +0 -387
- data/CONTRIBUTORS +0 -36
- data/Gemfile +0 -2
- data/Rakefile +0 -137
- data/TODO +0 -117
- data/examples/example_basic.rb +0 -15
- data/examples/example_command_override.rb +0 -32
- data/examples/example_commands.rb +0 -36
- data/examples/example_hooks.rb +0 -9
- data/examples/example_image_edit.rb +0 -67
- data/examples/example_input.rb +0 -7
- data/examples/example_input2.rb +0 -29
- data/examples/example_output.rb +0 -11
- data/examples/example_print.rb +0 -6
- data/examples/example_prompt.rb +0 -9
- data/examples/helper.rb +0 -6
- data/lib/pry/completion.rb +0 -221
- data/lib/pry/custom_completions.rb +0 -6
- data/lib/pry/default_commands/cd.rb +0 -81
- data/lib/pry/default_commands/commands.rb +0 -62
- data/lib/pry/default_commands/context.rb +0 -98
- data/lib/pry/default_commands/easter_eggs.rb +0 -95
- data/lib/pry/default_commands/editing.rb +0 -420
- data/lib/pry/default_commands/find_method.rb +0 -169
- data/lib/pry/default_commands/gems.rb +0 -84
- data/lib/pry/default_commands/gist.rb +0 -187
- data/lib/pry/default_commands/help.rb +0 -127
- data/lib/pry/default_commands/hist.rb +0 -120
- data/lib/pry/default_commands/input_and_output.rb +0 -306
- data/lib/pry/default_commands/introspection.rb +0 -410
- data/lib/pry/default_commands/ls.rb +0 -272
- data/lib/pry/default_commands/misc.rb +0 -38
- data/lib/pry/default_commands/navigating_pry.rb +0 -110
- data/lib/pry/default_commands/whereami.rb +0 -92
- data/lib/pry/extended_commands/experimental.rb +0 -7
- data/lib/pry/rbx_method.rb +0 -13
- data/man/pry.1 +0 -195
- data/man/pry.1.html +0 -204
- data/man/pry.1.ronn +0 -141
- data/pry.gemspec +0 -46
- data/test/candidate_helper1.rb +0 -11
- data/test/candidate_helper2.rb +0 -8
- data/test/helper.rb +0 -223
- data/test/test_cli.rb +0 -78
- data/test/test_code.rb +0 -201
- data/test/test_command.rb +0 -712
- data/test/test_command_helpers.rb +0 -9
- data/test/test_command_integration.rb +0 -668
- data/test/test_command_set.rb +0 -610
- data/test/test_completion.rb +0 -62
- data/test/test_control_d_handler.rb +0 -45
- data/test/test_default_commands/example.erb +0 -5
- data/test/test_default_commands/test_cd.rb +0 -318
- data/test/test_default_commands/test_context.rb +0 -280
- data/test/test_default_commands/test_documentation.rb +0 -314
- data/test/test_default_commands/test_find_method.rb +0 -50
- data/test/test_default_commands/test_gems.rb +0 -18
- data/test/test_default_commands/test_help.rb +0 -57
- data/test/test_default_commands/test_input.rb +0 -428
- data/test/test_default_commands/test_introspection.rb +0 -511
- data/test/test_default_commands/test_ls.rb +0 -151
- data/test/test_default_commands/test_shell.rb +0 -343
- data/test/test_default_commands/test_show_source.rb +0 -432
- data/test/test_exception_whitelist.rb +0 -21
- data/test/test_history_array.rb +0 -65
- data/test/test_hooks.rb +0 -521
- data/test/test_indent.rb +0 -277
- data/test/test_input_stack.rb +0 -86
- data/test/test_method.rb +0 -401
- data/test/test_pry.rb +0 -463
- data/test/test_pry_defaults.rb +0 -419
- data/test/test_pry_history.rb +0 -84
- data/test/test_pry_output.rb +0 -41
- data/test/test_sticky_locals.rb +0 -155
- data/test/test_syntax_checking.rb +0 -65
- data/test/test_wrapped_module.rb +0 -174
- data/test/testrc +0 -2
- data/test/testrcbad +0 -2
- data/wiki/Customizing-pry.md +0 -397
- data/wiki/Home.md +0 -4
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)
|
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://
|
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
|
-
![
|
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
|
-
[
|
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
|
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
|
100
|
+
pry(20):2> self + 10
|
106
101
|
=> 30
|
107
|
-
pry(20:2
|
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
|
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
|
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
|
-
|
260
|
-
|
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
|
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
|
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
|
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
|
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
|
-
|
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
|
-
|
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)
|
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.
|
377
|
-
|
378
|
-
|
379
|
-
|
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)](
|
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)
|
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"
|
16
|
+
_pry_.run_command("whereami --quiet")
|
14
17
|
end
|
15
18
|
|
16
19
|
# The default print
|
17
|
-
DEFAULT_PRINT = proc do |output, value|
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
31
|
+
output.puts value.inspect
|
45
32
|
rescue RescuableException
|
46
|
-
output.puts "
|
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
|
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
|
-
|
58
|
-
|
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
|
-
|
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, _,
|
80
|
-
proc { |target_self, _,
|
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 |_,
|
87
|
-
tree =
|
88
|
-
"[#{
|
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 |_,
|
91
|
-
tree =
|
92
|
-
"[#{
|
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
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
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"].
|
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
|
-
#
|
124
|
-
#
|
125
|
-
|
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
|
-
|
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
|
168
|
-
require
|
169
|
-
require
|
170
|
-
require
|
171
|
-
require
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
require "pry/
|
201
|
-
require
|
202
|
-
require
|
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'
|