pry 0.9.12.2 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1141 -0
  3. data/LICENSE +2 -2
  4. data/README.md +466 -0
  5. data/bin/pry +4 -7
  6. data/lib/pry/basic_object.rb +10 -0
  7. data/lib/pry/block_command.rb +22 -0
  8. data/lib/pry/class_command.rb +194 -0
  9. data/lib/pry/cli.rb +97 -92
  10. data/lib/pry/code/code_file.rb +114 -0
  11. data/lib/pry/code/code_range.rb +7 -4
  12. data/lib/pry/code/loc.rb +27 -14
  13. data/lib/pry/code.rb +62 -90
  14. data/lib/pry/code_object.rb +83 -39
  15. data/lib/pry/color_printer.rb +66 -0
  16. data/lib/pry/command.rb +202 -371
  17. data/lib/pry/command_set.rb +151 -133
  18. data/lib/pry/command_state.rb +31 -0
  19. data/lib/pry/commands/amend_line.rb +86 -82
  20. data/lib/pry/commands/bang.rb +18 -14
  21. data/lib/pry/commands/bang_pry.rb +15 -11
  22. data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
  23. data/lib/pry/commands/cat/exception_formatter.rb +85 -73
  24. data/lib/pry/commands/cat/file_formatter.rb +56 -63
  25. data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
  26. data/lib/pry/commands/cat.rb +64 -47
  27. data/lib/pry/commands/cd.rb +42 -26
  28. data/lib/pry/commands/change_inspector.rb +34 -0
  29. data/lib/pry/commands/change_prompt.rb +51 -0
  30. data/lib/pry/commands/clear_screen.rb +20 -0
  31. data/lib/pry/commands/code_collector.rb +148 -131
  32. data/lib/pry/commands/disable_pry.rb +23 -19
  33. data/lib/pry/commands/easter_eggs.rb +23 -34
  34. data/lib/pry/commands/edit/exception_patcher.rb +21 -17
  35. data/lib/pry/commands/edit/file_and_line_locator.rb +33 -24
  36. data/lib/pry/commands/edit.rb +183 -167
  37. data/lib/pry/commands/exit.rb +40 -35
  38. data/lib/pry/commands/exit_all.rb +24 -20
  39. data/lib/pry/commands/exit_program.rb +20 -17
  40. data/lib/pry/commands/find_method.rb +167 -167
  41. data/lib/pry/commands/fix_indent.rb +16 -12
  42. data/lib/pry/commands/help.rb +140 -133
  43. data/lib/pry/commands/hist.rb +153 -132
  44. data/lib/pry/commands/import_set.rb +20 -15
  45. data/lib/pry/commands/jump_to.rb +25 -21
  46. data/lib/pry/commands/list_inspectors.rb +42 -0
  47. data/lib/pry/commands/ls/constants.rb +75 -0
  48. data/lib/pry/commands/ls/formatter.rb +55 -0
  49. data/lib/pry/commands/ls/globals.rb +50 -0
  50. data/lib/pry/commands/ls/grep.rb +23 -0
  51. data/lib/pry/commands/ls/instance_vars.rb +40 -0
  52. data/lib/pry/commands/ls/interrogatable.rb +24 -0
  53. data/lib/pry/commands/ls/jruby_hacks.rb +55 -0
  54. data/lib/pry/commands/ls/local_names.rb +37 -0
  55. data/lib/pry/commands/ls/local_vars.rb +47 -0
  56. data/lib/pry/commands/ls/ls_entity.rb +65 -0
  57. data/lib/pry/commands/ls/methods.rb +55 -0
  58. data/lib/pry/commands/ls/methods_helper.rb +50 -0
  59. data/lib/pry/commands/ls/self_methods.rb +34 -0
  60. data/lib/pry/commands/ls.rb +100 -303
  61. data/lib/pry/commands/nesting.rb +21 -17
  62. data/lib/pry/commands/play.rb +93 -49
  63. data/lib/pry/commands/pry_backtrace.rb +22 -18
  64. data/lib/pry/commands/pry_version.rb +15 -11
  65. data/lib/pry/commands/raise_up.rb +33 -27
  66. data/lib/pry/commands/reload_code.rb +57 -48
  67. data/lib/pry/commands/reset.rb +16 -12
  68. data/lib/pry/commands/ri.rb +57 -38
  69. data/lib/pry/commands/save_file.rb +45 -43
  70. data/lib/pry/commands/shell_command.rb +66 -34
  71. data/lib/pry/commands/shell_mode.rb +22 -20
  72. data/lib/pry/commands/show_doc.rb +80 -65
  73. data/lib/pry/commands/show_info.rb +193 -159
  74. data/lib/pry/commands/show_input.rb +16 -11
  75. data/lib/pry/commands/show_source.rb +113 -33
  76. data/lib/pry/commands/stat.rb +35 -31
  77. data/lib/pry/commands/switch_to.rb +21 -15
  78. data/lib/pry/commands/toggle_color.rb +21 -13
  79. data/lib/pry/commands/watch_expression/expression.rb +43 -0
  80. data/lib/pry/commands/watch_expression.rb +110 -0
  81. data/lib/pry/commands/whereami.rb +157 -134
  82. data/lib/pry/commands/wtf.rb +78 -40
  83. data/lib/pry/config/attributable.rb +22 -0
  84. data/lib/pry/config/lazy_value.rb +29 -0
  85. data/lib/pry/config/memoized_value.rb +34 -0
  86. data/lib/pry/config/value.rb +24 -0
  87. data/lib/pry/config.rb +290 -220
  88. data/lib/pry/control_d_handler.rb +28 -0
  89. data/lib/pry/core_extensions.rb +50 -27
  90. data/lib/pry/editor.rb +130 -102
  91. data/lib/pry/env.rb +18 -0
  92. data/lib/pry/exception_handler.rb +43 -0
  93. data/lib/pry/exceptions.rb +73 -0
  94. data/lib/pry/forwardable.rb +27 -0
  95. data/lib/pry/helpers/base_helpers.rb +22 -151
  96. data/lib/pry/helpers/command_helpers.rb +55 -63
  97. data/lib/pry/helpers/documentation_helpers.rb +21 -13
  98. data/lib/pry/helpers/options_helpers.rb +15 -8
  99. data/lib/pry/helpers/platform.rb +55 -0
  100. data/lib/pry/helpers/table.rb +44 -32
  101. data/lib/pry/helpers/text.rb +96 -86
  102. data/lib/pry/helpers.rb +3 -0
  103. data/lib/pry/history.rb +101 -70
  104. data/lib/pry/hooks.rb +67 -137
  105. data/lib/pry/indent.rb +79 -73
  106. data/lib/pry/input_completer.rb +283 -0
  107. data/lib/pry/input_lock.rb +129 -0
  108. data/lib/pry/inspector.rb +39 -0
  109. data/lib/pry/last_exception.rb +61 -0
  110. data/lib/pry/method/disowned.rb +19 -5
  111. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +51 -42
  112. data/lib/pry/method/weird_method_locator.rb +80 -44
  113. data/lib/pry/method.rb +225 -176
  114. data/lib/pry/object_path.rb +91 -0
  115. data/lib/pry/output.rb +136 -0
  116. data/lib/pry/pager.rb +227 -68
  117. data/lib/pry/prompt.rb +214 -0
  118. data/lib/pry/pry_class.rb +216 -289
  119. data/lib/pry/pry_instance.rb +438 -500
  120. data/lib/pry/repl.rb +256 -0
  121. data/lib/pry/repl_file_loader.rb +34 -35
  122. data/lib/pry/ring.rb +89 -0
  123. data/lib/pry/slop/LICENSE +20 -0
  124. data/lib/pry/slop/commands.rb +190 -0
  125. data/lib/pry/slop/option.rb +210 -0
  126. data/lib/pry/slop.rb +672 -0
  127. data/lib/pry/syntax_highlighter.rb +26 -0
  128. data/lib/pry/system_command_handler.rb +17 -0
  129. data/lib/pry/testable/evalable.rb +24 -0
  130. data/lib/pry/testable/mockable.rb +22 -0
  131. data/lib/pry/testable/pry_tester.rb +88 -0
  132. data/lib/pry/testable/utility.rb +34 -0
  133. data/lib/pry/testable/variables.rb +52 -0
  134. data/lib/pry/testable.rb +68 -0
  135. data/lib/pry/version.rb +3 -1
  136. data/lib/pry/warning.rb +20 -0
  137. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +36 -43
  138. data/lib/pry/wrapped_module.rb +102 -103
  139. data/lib/pry.rb +135 -261
  140. metadata +94 -283
  141. data/.document +0 -2
  142. data/.gitignore +0 -16
  143. data/.travis.yml +0 -21
  144. data/.yardopts +0 -1
  145. data/CHANGELOG +0 -534
  146. data/CONTRIBUTORS +0 -55
  147. data/Gemfile +0 -9
  148. data/Guardfile +0 -62
  149. data/README.markdown +0 -400
  150. data/Rakefile +0 -140
  151. data/TODO +0 -117
  152. data/lib/pry/commands/disabled_commands.rb +0 -2
  153. data/lib/pry/commands/gem_cd.rb +0 -26
  154. data/lib/pry/commands/gem_install.rb +0 -29
  155. data/lib/pry/commands/gem_list.rb +0 -33
  156. data/lib/pry/commands/gem_open.rb +0 -29
  157. data/lib/pry/commands/gist.rb +0 -102
  158. data/lib/pry/commands/install_command.rb +0 -51
  159. data/lib/pry/commands/simple_prompt.rb +0 -22
  160. data/lib/pry/commands.rb +0 -6
  161. data/lib/pry/completion.rb +0 -304
  162. data/lib/pry/custom_completions.rb +0 -6
  163. data/lib/pry/history_array.rb +0 -116
  164. data/lib/pry/plugins.rb +0 -103
  165. data/lib/pry/rbx_method.rb +0 -13
  166. data/lib/pry/rbx_path.rb +0 -22
  167. data/lib/pry/rubygem.rb +0 -74
  168. data/lib/pry/terminal.rb +0 -78
  169. data/lib/pry/test/helper.rb +0 -185
  170. data/man/pry.1 +0 -195
  171. data/man/pry.1.html +0 -204
  172. data/man/pry.1.ronn +0 -141
  173. data/pry.gemspec +0 -30
  174. data/spec/Procfile +0 -3
  175. data/spec/cli_spec.rb +0 -78
  176. data/spec/code_object_spec.rb +0 -277
  177. data/spec/code_spec.rb +0 -219
  178. data/spec/command_helpers_spec.rb +0 -29
  179. data/spec/command_integration_spec.rb +0 -644
  180. data/spec/command_set_spec.rb +0 -627
  181. data/spec/command_spec.rb +0 -821
  182. data/spec/commands/amend_line_spec.rb +0 -247
  183. data/spec/commands/bang_spec.rb +0 -19
  184. data/spec/commands/cat_spec.rb +0 -164
  185. data/spec/commands/cd_spec.rb +0 -250
  186. data/spec/commands/disable_pry_spec.rb +0 -25
  187. data/spec/commands/edit_spec.rb +0 -727
  188. data/spec/commands/exit_all_spec.rb +0 -34
  189. data/spec/commands/exit_program_spec.rb +0 -19
  190. data/spec/commands/exit_spec.rb +0 -34
  191. data/spec/commands/find_method_spec.rb +0 -70
  192. data/spec/commands/gem_list_spec.rb +0 -26
  193. data/spec/commands/gist_spec.rb +0 -79
  194. data/spec/commands/help_spec.rb +0 -56
  195. data/spec/commands/hist_spec.rb +0 -181
  196. data/spec/commands/jump_to_spec.rb +0 -15
  197. data/spec/commands/ls_spec.rb +0 -181
  198. data/spec/commands/play_spec.rb +0 -140
  199. data/spec/commands/raise_up_spec.rb +0 -56
  200. data/spec/commands/save_file_spec.rb +0 -177
  201. data/spec/commands/show_doc_spec.rb +0 -510
  202. data/spec/commands/show_input_spec.rb +0 -17
  203. data/spec/commands/show_source_spec.rb +0 -782
  204. data/spec/commands/whereami_spec.rb +0 -203
  205. data/spec/completion_spec.rb +0 -239
  206. data/spec/control_d_handler_spec.rb +0 -58
  207. data/spec/documentation_helper_spec.rb +0 -73
  208. data/spec/editor_spec.rb +0 -79
  209. data/spec/exception_whitelist_spec.rb +0 -21
  210. data/spec/fixtures/candidate_helper1.rb +0 -11
  211. data/spec/fixtures/candidate_helper2.rb +0 -8
  212. data/spec/fixtures/example.erb +0 -5
  213. data/spec/fixtures/example_nesting.rb +0 -33
  214. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  215. data/spec/fixtures/testrc +0 -2
  216. data/spec/fixtures/testrcbad +0 -2
  217. data/spec/fixtures/whereami_helper.rb +0 -6
  218. data/spec/helper.rb +0 -34
  219. data/spec/helpers/bacon.rb +0 -86
  220. data/spec/helpers/mock_pry.rb +0 -43
  221. data/spec/helpers/table_spec.rb +0 -105
  222. data/spec/history_array_spec.rb +0 -67
  223. data/spec/hooks_spec.rb +0 -522
  224. data/spec/indent_spec.rb +0 -301
  225. data/spec/input_stack_spec.rb +0 -90
  226. data/spec/method_spec.rb +0 -482
  227. data/spec/prompt_spec.rb +0 -60
  228. data/spec/pry_defaults_spec.rb +0 -419
  229. data/spec/pry_history_spec.rb +0 -99
  230. data/spec/pry_output_spec.rb +0 -95
  231. data/spec/pry_spec.rb +0 -504
  232. data/spec/run_command_spec.rb +0 -25
  233. data/spec/sticky_locals_spec.rb +0 -157
  234. data/spec/syntax_checking_spec.rb +0 -81
  235. data/spec/wrapped_module_spec.rb +0 -261
  236. data/wiki/Customizing-pry.md +0 -397
  237. data/wiki/Home.md +0 -4
data/README.markdown DELETED
@@ -1,400 +0,0 @@
1
- [![Build Status](https://secure.travis-ci.org/pry/pry.png)](http://travis-ci.org/pry/pry)
2
-
3
- <center>
4
- ![The Pry Logo](https://dl.dropbox.com/u/26521875/pry%20stuff/logo/pry_logo_350.png)
5
-
6
- © John Mair (banisterfiend) 2012<br>
7
-
8
- **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
-
10
- **Sponsors**
11
-
12
- [Atomic Object](http://www.atomicobject.com/)<br/>
13
- [Bendyworks](http://bendyworks.com/)<br/>
14
- [Intridea](http://intridea.com/)<br/>
15
- [Gaslight](http://gaslight.co/home)<br/>
16
-
17
- **Other Resources**
18
-
19
- [Skip to the website (recommended)](http://pry.github.com) <br />
20
- [Skip to the wiki](https://github.com/pry/pry/wiki)
21
- </center>
22
-
23
- Pry is a powerful alternative to the standard IRB shell for Ruby. It is
24
- written from scratch to provide a number of advanced features,
25
- including:
26
-
27
- * Source code browsing (including core C source with the pry-doc gem)
28
- * Documentation browsing
29
- * Live help system
30
- * Open methods in editors (`edit-method Class#method`)
31
- * Syntax highlighting
32
- * Command shell integration (start editors, run git, and rake from within Pry)
33
- * Gist integration
34
- * Navigation around state (`cd`, `ls` and friends)
35
- * Runtime invocation (use Pry as a developer console or debugger)
36
- * Exotic object support (BasicObject instances, IClasses, ...)
37
- * A Powerful and flexible command system
38
- * Ability to view and replay history
39
-
40
- * Many convenience commands inspired by IPython, Smalltalk and other advanced REPLs
41
- * A wide-range number of [plugins](https://github.com/pry/pry/wiki/Available-plugins) that provide remote sessions, full debugging functionality, and more.
42
-
43
- Pry also aims to be more than an IRB replacement; it is an
44
- attempt to bring REPL driven programming to the Ruby language. It is
45
- currently not as powerful as tools like [SLIME](http://en.wikipedia.org/wiki/SLIME) for lisp, but that is the
46
- general direction Pry is heading.
47
-
48
- Pry is also fairly flexible and allows significant user
49
- [customization](https://github.com/pry/pry/wiki/Customization-and-configuration)
50
- is trivial to set it to read from any object that has a `readline` method and write to any object that has a
51
- `puts` method - many other aspects of Pry are also configurable making
52
- it a good choice for implementing custom shells.
53
-
54
- Pry comes with an executable so it can be invoked at the command line.
55
- Just enter `pry` to start. A `.pryrc` file in the user's home directory will
56
- be loaded if it exists. Type `pry --help` at the command line for more
57
- information.
58
-
59
- Try `gem install pry-doc` for additional documentation on Ruby Core
60
- methods. The additional docs are accessed through the `show-doc` and
61
- `show-method` commands.
62
-
63
- * Install the [gem](https://rubygems.org/gems/pry): `gem install pry`
64
- * Browse the comprehensive [documentation at the official Pry wiki](https://github.com/pry/pry/wiki)
65
- * Read the [YARD API documentation](http://rdoc.info/github/pry/pry/master/file/README.markdown)
66
- * See the [source code](http://github.com/pry/pry)
67
-
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
- ### Commands
76
-
77
- Nearly every piece of functionality in a Pry session is implemented as
78
- a command. Commands are not methods and must start at the beginning of a line, with no
79
- whitespace in between. Commands support a flexible syntax and allow
80
- 'options' in the same way as shell commands, for example the following
81
- Pry command will show a list of all private instance methods (in
82
- scope) that begin with 'pa'
83
-
84
- pry(YARD::Parser::SourceParser):5> ls -Mp --grep ^pa
85
- YARD::Parser::SourceParser#methods: parse parser_class parser_type parser_type= parser_type_for_filename
86
-
87
- ### Navigating around state
88
-
89
- Pry allows us to pop in and out of different scopes (objects) using
90
- the `cd` command. This enables us to explore the run-time view of a
91
- program or library. To view which variables and methods are available
92
- within a particular scope we use the versatile [ls command.](https://gist.github.com/c0fc686ef923c8b87715)
93
-
94
- Here we will begin Pry at top-level, then Pry on a class and then on
95
- an instance variable inside that class:
96
-
97
- pry(main)> class Hello
98
- pry(main)* @x = 20
99
- pry(main)* end
100
- => 20
101
- pry(main)> cd Hello
102
- pry(Hello):1> ls -i
103
- instance variables: @x
104
- pry(Hello):1> cd @x
105
- pry(20:2)> self + 10
106
- => 30
107
- pry(20:2)> cd ..
108
- pry(Hello):1> cd ..
109
- pry(main)> cd ..
110
-
111
- The number after the `:` in the pry prompt indicates the nesting
112
- level. To display more information about nesting, use the `nesting`
113
- command. E.g
114
-
115
- pry("friend":3)> nesting
116
- Nesting status:
117
- 0. main (Pry top level)
118
- 1. Hello
119
- 2. 100
120
- 3. "friend"
121
- => nil
122
-
123
- We can then jump back to any of the previous nesting levels by using
124
- the `jump-to` command:
125
-
126
- pry("friend":3)> jump-to 1
127
- => 100
128
- pry(Hello):1>
129
-
130
- ### Runtime invocation
131
-
132
- Pry can be invoked in the middle of a running program. It opens a Pry
133
- session at the point it's called and makes all program state at that
134
- point available. It can be invoked on any object using the
135
- `my_object.pry` syntax or on the current binding (or any binding)
136
- using `binding.pry`. The Pry session will then begin within the scope
137
- of the object (or binding). When the session ends the program continues with any
138
- modifications you made to it.
139
-
140
- This functionality can be used for such things as: debugging,
141
- implementing developer consoles and applying hot patches.
142
-
143
- code:
144
-
145
- # test.rb
146
- require 'pry'
147
-
148
- class A
149
- def hello() puts "hello world!" end
150
- end
151
-
152
- a = A.new
153
-
154
- # start a REPL session
155
- binding.pry
156
-
157
- # program resumes here (after pry session)
158
- puts "program resumes here."
159
-
160
- Pry session:
161
-
162
- pry(main)> a.hello
163
- hello world!
164
- => nil
165
- pry(main)> def a.goodbye
166
- pry(main)* puts "goodbye cruel world!"
167
- pry(main)* end
168
- => nil
169
- pry(main)> a.goodbye
170
- goodbye cruel world!
171
- => nil
172
- pry(main)> exit
173
-
174
- program resumes here.
175
-
176
- ### Command Shell Integration
177
-
178
- A line of input that begins with a '.' will be forwarded to the
179
- command shell. This enables us to navigate the file system, spawn
180
- editors, and run git and rake directly from within Pry.
181
-
182
- Further, we can use the `shell-mode` command to incorporate the
183
- present working directory into the Pry prompt and bring in (limited at this stage, sorry) file name completion.
184
- We can also interpolate Ruby code directly into the shell by
185
- using the normal `#{}` string interpolation syntax.
186
-
187
- In the code below we're going to switch to `shell-mode` and edit the
188
- `.pryrc` file in the home directory. We'll then cat its contents and
189
- reload the file.
190
-
191
- pry(main)> shell-mode
192
- pry main:/home/john/ruby/projects/pry $ .cd ~
193
- pry main:/home/john $ .emacsclient .pryrc
194
- pry main:/home/john $ .cat .pryrc
195
- def hello_world
196
- puts "hello world!"
197
- end
198
- pry main:/home/john $ load ".pryrc"
199
- => true
200
- pry main:/home/john $ hello_world
201
- hello world!
202
-
203
- We can also interpolate Ruby code into the shell. In the
204
- example below we use the shell command `cat` on a random file from the
205
- current directory and count the number of lines in that file with
206
- `wc`:
207
-
208
- pry main:/home/john $ .cat #{Dir['*.*'].sample} | wc -l
209
- 44
210
-
211
- ### Code Browsing
212
-
213
- You can browse method source code with the `show-method` command. Nearly all Ruby methods (and some C methods, with the pry-doc
214
- gem) can have their source viewed. Code that is longer than a page is
215
- sent through a pager (such as less), and all code is properly syntax
216
- highlighted (even C code).
217
-
218
- The `show-method` command accepts two syntaxes, the typical ri
219
- `Class#method` syntax and also simply the name of a method that's in
220
- scope. You can optionally pass the `-l` option to show-method to
221
- include line numbers in the output.
222
-
223
- In the following example we will enter the `Pry` class, list the
224
- instance methods beginning with 're' and display the source code for the `rep` method:
225
-
226
- pry(main)> cd Pry
227
- pry(Pry)> ls -M --grep re
228
- Pry#methods: re readline refresh rep repl repl_epilogue repl_prologue retrieve_line
229
- pry(Pry):1> show-method rep -l
230
-
231
- From: /home/john/ruby/projects/pry/lib/pry/pry_instance.rb @ line 143:
232
- Number of lines: 6
233
-
234
- 143: def rep(target=TOPLEVEL_BINDING)
235
- 144: target = Pry.binding_for(target)
236
- 145: result = re(target)
237
- 146:
238
- 147: show_result(result) if should_print?
239
- 148: end
240
-
241
- Note that we can also view C methods (from Ruby Core) using the
242
- `pry-doc` plugin; we also show off the alternate syntax for
243
- `show-method`:
244
-
245
- pry(main)> show-method Array#select
246
-
247
- From: array.c in Ruby Core (C Method):
248
- Number of lines: 15
249
-
250
- static VALUE
251
- rb_ary_select(VALUE ary)
252
- {
253
- VALUE result;
254
- long i;
255
-
256
- RETURN_ENUMERATOR(ary, 0, 0);
257
- result = rb_ary_new2(RARRAY_LEN(ary));
258
- 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
- }
262
- }
263
- return result;
264
- }
265
-
266
- ### Documentation Browsing
267
-
268
- One use-case for Pry is to explore a program at run-time by `cd`-ing
269
- in and out of objects and viewing and invoking methods. In the course
270
- of exploring it may be useful to read the documentation for a
271
- specific method that you come across. Like `show-method` the `show-doc` command supports
272
- two syntaxes - the normal `ri` syntax as well as accepting the name of
273
- any method that is currently in scope.
274
-
275
- The Pry documentation system does not rely on pre-generated `rdoc` or
276
- `ri`, instead it grabs the comments directly above the method on
277
- demand. This results in speedier documentation retrieval and allows
278
- the Pry system to retrieve documentation for methods that would not be
279
- picked up by `rdoc`. Pry also has a basic understanding of both the
280
- rdoc and yard formats and will attempt to syntax highlight the
281
- documentation appropriately.
282
-
283
- Nonetheless, the `ri` functionality is very good and
284
- has an advantage over Pry's system in that it allows documentation
285
- lookup for classes as well as methods. Pry therefore has good
286
- integration with `ri` through the `ri` command. The syntax
287
- for the command is exactly as it would be in command-line -
288
- so it is not necessary to quote strings.
289
-
290
- In our example we will enter the `Gem` class and view the
291
- documentation for the `try_activate` method:
292
-
293
- pry(main)> cd Gem
294
- pry(Gem):1> show-doc try_activate
295
-
296
- From: /Users/john/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb @ line 201:
297
- Number of lines: 3
298
-
299
- Try to activate a gem containing path. Returns true if
300
- activation succeeded or wasn't needed because it was already
301
- activated. Returns false if it can't find the path in a gem.
302
- pry(Gem):1>
303
-
304
- We can also use `ri` in the normal way:
305
-
306
- pry(main) ri Array#each
307
- ----------------------------------------------------------- Array#each
308
- array.each {|item| block } -> array
309
- ------------------------------------------------------------------------
310
- Calls _block_ once for each element in _self_, passing that element
311
- as a parameter.
312
-
313
- a = [ "a", "b", "c" ]
314
- a.each {|x| print x, " -- " }
315
-
316
- produces:
317
-
318
- a -- b -- c --
319
-
320
- ### Gist integration
321
-
322
- If the `gist` gem is installed then method source or documentation can be gisted to github with the
323
- `gist` command. The `gist` command is capable of gisting [almost any REPL content](https://gist.github.com/cae143e4533416529726), including methods, documentation,
324
- input expressions, command source, and so on. In the example below we will gist the C source
325
- code for the `Symbol#to_proc` method to github:
326
-
327
- pry(main)> gist -m Symbol#to_proc
328
- Gist created at https://gist.github.com/5332c38afc46d902ce46 and added to clipboard.
329
- pry(main)>
330
-
331
- You can see the actual gist generated here: [https://gist.github.com/5332c38afc46d902ce46](https://gist.github.com/5332c38afc46d902ce46)
332
-
333
- ### Edit methods
334
-
335
- You can use `edit-method Class#method` or `edit-method my_method`
336
- (if the method is in scope) to open a method for editing directly in
337
- your favorite editor. Pry has knowledge of a few different editors and
338
- will attempt to open the file at the line the method is defined.
339
-
340
- You can set the editor to use by assigning to the `Pry.editor`
341
- accessor. `Pry.editor` will default to `$EDITOR` or failing that will
342
- use `nano` as the backup default. The file that is edited will be
343
- automatically reloaded after exiting the editor - reloading can be
344
- suppressed by passing the `--no-reload` option to `edit-method`
345
-
346
- In the example below we will set our default editor to "emacsclient"
347
- and open the `Pry#repl` method for editing:
348
-
349
- pry(main)> Pry.editor = "emacsclient"
350
- pry(main)> edit-method Pry#repl
351
-
352
- ### Live Help System
353
-
354
- Many other commands are available in Pry; to see the full list type
355
- `help` at the prompt. A short description of each command is provided
356
- with basic instructions for use; some commands have a more extensive
357
- help that can be accessed via typing `command_name --help`. A command
358
- will typically say in its description if the `--help` option is
359
- avaiable.
360
-
361
- ### Use Pry as your Rails Console
362
-
363
- pry -r ./config/environment
364
-
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.
366
-
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.
368
-
369
- ### Limitations:
370
-
371
- * Tab completion is currently a bit broken/limited this will have a
372
- major overhaul in a future version.
373
-
374
- ### Syntax Highlighting
375
-
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.
380
-
381
- ### Future Directions
382
-
383
- Many new features are planned such as:
384
-
385
- * Increase modularity (rely more on plugin system)
386
- * Much improved tab completion (using [Bond](http://github.com/cldwalker/bond))
387
- * Much improved documentation system, better support for YARD
388
- * Better support for code and method reloading and saving code
389
- * Extended and more sophisticated command system, allowing piping
390
- between commands and running commands in background
391
-
392
- ### Contact
393
-
394
- Problems or questions? file an issue at [github](https://github.com/pry/pry/issues)
395
-
396
- ### Contributors
397
-
398
- Pry is primarily the work of [John Mair (banisterfiend)](http://github.com/banister), for full list
399
- of contributors see the
400
- [CONTRIBUTORS](https://github.com/pry/pry/blob/master/CONTRIBUTORS) file.
data/Rakefile DELETED
@@ -1,140 +0,0 @@
1
- require 'rake/clean'
2
- require 'rubygems/package_task'
3
-
4
- $:.unshift 'lib'
5
- require 'pry/version'
6
-
7
- CLOBBER.include('**/*~', '**/*#*', '**/*.log')
8
- CLEAN.include('**/*#*', '**/*#*.*', '**/*_flymake*.*', '**/*_flymake', '**/*.rbc', '**/.#*.*')
9
-
10
- def check_dependencies
11
- require 'bundler'
12
- Bundler.definition.missing_specs
13
-
14
- eval('nil', TOPLEVEL_BINDING, '<main>') # workaround for issue #395
15
- rescue LoadError
16
- # if Bundler isn't installed, we'll just assume your setup is ok.
17
- rescue Bundler::GemNotFound
18
- raise RuntimeError, "You're missing one or more required gems. Run `bundle install` first."
19
- end
20
-
21
- desc "Set up and run tests"
22
- task :default => [:test]
23
-
24
- unless [].respond_to? :shuffle!
25
- class Array
26
- def shuffle!
27
- # TODO: fill this in if anyone cares
28
- self
29
- end
30
- end
31
- end
32
-
33
- def run_specs paths
34
- quiet = ENV['VERBOSE'] ? '' : '-q'
35
- exec "bacon -Ispec -rubygems #{quiet} #{paths.join ' '}"
36
- end
37
-
38
- desc "Run tests"
39
- task :test do
40
- check_dependencies unless ENV['SKIP_DEP_CHECK']
41
- paths =
42
- if explicit_list = ENV['run']
43
- explicit_list.split(',')
44
- else
45
- Dir['spec/**/*_spec.rb'].shuffle!
46
- end
47
- run_specs paths
48
- end
49
- task :spec => :test
50
-
51
- task :recspec do
52
- all = Dir['spec/**/*_spec.rb'].sort_by{|path| File.mtime(path)}.reverse
53
- warn "Running all, sorting by mtime: #{all[0..2].join(' ')} ...etc."
54
- run_specs all
55
- end
56
-
57
- desc "Run pry"
58
- task :pry do
59
- check_dependencies unless ENV['SKIP_DEP_CHECK']
60
- load 'bin/pry'
61
- end
62
-
63
- desc "Show pry version"
64
- task :version do
65
- puts "Pry version: #{Pry::VERSION}"
66
- end
67
-
68
- desc "Profile pry's startup time"
69
- task :profile do
70
- require 'profile'
71
- require 'pry'
72
- Pry.start(TOPLEVEL_BINDING, :input => StringIO.new('exit'))
73
- end
74
-
75
- def modify_base_gemspec
76
- eval(File.read('pry.gemspec')).tap { |s| yield s }
77
- end
78
-
79
- namespace :ruby do
80
- spec = modify_base_gemspec do |s|
81
- s.platform = Gem::Platform::RUBY
82
- end
83
-
84
- Gem::PackageTask.new(spec) do |pkg|
85
- pkg.need_zip = false
86
- pkg.need_tar = false
87
- end
88
- end
89
-
90
- namespace :jruby do
91
- spec = modify_base_gemspec do |s|
92
- s.add_dependency('spoon', '~> 0.0')
93
- s.platform = 'java'
94
- end
95
-
96
- Gem::PackageTask.new(spec) do |pkg|
97
- pkg.need_zip = false
98
- pkg.need_tar = false
99
- end
100
- end
101
-
102
-
103
- [:mingw32, :mswin32].each do |v|
104
- namespace v do
105
- spec = modify_base_gemspec do |s|
106
- s.add_dependency('win32console', '~> 1.3')
107
- s.platform = "i386-#{v}"
108
- end
109
-
110
- Gem::PackageTask.new(spec) do |pkg|
111
- pkg.need_zip = false
112
- pkg.need_tar = false
113
- end
114
- end
115
- end
116
-
117
- desc "build all platform gems at once"
118
- task :gems => [:clean, :rmgems, 'ruby:gem', 'mswin32:gem', 'mingw32:gem', 'jruby:gem']
119
-
120
- desc "remove all platform gems"
121
- task :rmgems => ['ruby:clobber_package']
122
- task :rm_gems => :rmgems
123
- task :rm_pkgs => :rmgems
124
-
125
- desc "reinstall gem"
126
- task :reinstall => :gems do
127
- sh "gem uninstall pry" rescue nil
128
- sh "gem install #{File.dirname(__FILE__)}/pkg/pry-#{Pry::VERSION}.gem"
129
- end
130
-
131
- task :install => :reinstall
132
-
133
- desc "build and push latest gems"
134
- task :pushgems => :gems do
135
- chdir("#{File.dirname(__FILE__)}/pkg") do
136
- Dir["*.gem"].each do |gemfile|
137
- sh "gem push #{gemfile}"
138
- end
139
- end
140
- end
data/TODO DELETED
@@ -1,117 +0,0 @@
1
- 0.9.5
2
- * include method visiblity in show-doc and stat output
3
- * tempfile should end in .rb (for edit -t)
4
- * ls output should not be in array format
5
- * exceptions should allow access to previous items in the backtrace
6
- * input should allow multiple objects which are switched to automatically when EOF is reached on the preceding one
7
- * pry -r should happen in pry
8
- * more plugin-related commands in pry - see installed ones, see activated ones, see available on rubygems
9
- * should also allow plugins be explicitly activated as a command line option
10
- * should not raise if plugin activation fails (should show warning instead)
11
- * more documentation on CommandContext, etc and also command helpers
12
- * fix history saving (should not save all of Readline::HISTORY, but only what changed)
13
- * prevent blank lines going to Readline::HISTORY
14
- * ensure that cat --ex emulates the `whereami` format - includes line numbers and formatted the same, etc
15
- * rename inp and out to _inp_ and _out_ otherwise than can overwrite locals by those names when debugging (not good)
16
- * add source file to stat command
17
- * make plugins use hash instead of array
18
- * ensure edit -t has 'edit' alias (no parameters) and dumps eval_string into buffer
19
- * whitelist exceptions
20
- * hooks system
21
- * jruby shell command support
22
-
23
- 0.9.3
24
- * hist command now excludes last line of input (the command invocation itself)
25
- * hist now has `history` alias
26
- * `pry -r` requires now happen after plugin loading (so as not to interfere with
27
- * new Pry.config.disable_auto_reload option, for turning off auto reloading by edit-method and related
28
- * add better error messages for `cd` command
29
- * add command_prefix
30
- * change some command names to include hyphen, e.g version => pry-version, install => install-command
31
- * do cat --ex and edit --ex
32
- * add reload-method
33
- * fixed exotic object regression - BasicObject.new etc now return "=> unknown"
34
- * converted: import => import-set, version => pry-version, install => install-command
35
- * fix show-doc bug for ruby 1.8 and Kernel.fork
36
- * edit -t (opens a temporary file and evals it in current context when closed)
37
-
38
- 0.9.0
39
- Major features
40
- --------------
41
- * Restructure command system and helpers (almost complete)
42
- * Delete unnecessary commands, add a couple of new ones (e.g amend-line)
43
- * Readline history
44
- * Plugin support
45
- * Support Rubinius core methods
46
- * in[] and out[] arrays
47
- * Improve test coverage (test some commands, etc)
48
-
49
- Minor changes
50
- -------------
51
- * improve edit-method support for various editors
52
- * ensure all commands have appropriate error handing and informative error messages
53
- * show-doc should include signature of method
54
-
55
- Optional
56
- --------
57
- * multi-line readline support
58
-
59
-
60
- 0.8.0
61
- * allow #{} interpolation of all commands
62
- * update documentation! new commands and features and change in behaviour of `run`
63
- * add ; at end of line to suppress return value output
64
- * Remove message spam (before/after hooks)
65
- * stop commands returning a value
66
- * use `redo` in the r() method when encounter a command
67
- * shell functionality should just use system(), but redirect in and
68
- out to Pry.input and Pry.output by reassining $stdin and $stdout
69
- for duration of block.
70
- * basicobject and no to_s/inspect support
71
- * fix documentation, support rdoc and yard properly
72
- * only load Ripper if 1.9 AND MRI (support jruby 1.9, using
73
- RubyParser)
74
- * shell commands invokable file .<command>
75
- * supercharge cat-file so it can syntax highlight sourcecode files
76
-
77
-
78
- 0.7.0
79
- * add pry-doc support with syntax highlighting for docs
80
- * add 'mj' option to ls (restrict to singleton methods)
81
- * add _ex_ local to hold last exception raised in an exception
82
-
83
- 0.6.8
84
- * add whereami command, a la the `ir_b` gem
85
- * make .pryrc be loaded by run-time pry sessions
86
-
87
- 0.6.7
88
- * color support
89
- * --simple-prompt for pry commandline
90
- * -I mode for pry commandline
91
- * --color mode for pry commandline
92
- * clean up requires (put them all in one place)
93
- * simple-prompt command and toggle-color commandd.
94
-
95
- 0.6.1
96
- * !@ command alias for exit_all
97
- * `cd /` for breaking out to pry top level (jump-to 0)
98
- * made `-e` option work in a more effective way for `pry` command line invocation
99
- * exit and exit-all commands now accept a parameter, this parameter becomes the return value of repl()
100
- * `command` method from CommandBase now accepts a :keep_retval arg that determines if command value is returned to pry session or just `nil` (`nil` was old behaviour)
101
- * tests for new :keep_retval and exit-all/exit behaviour; :keep_retval will remain undocumented.
102
-
103
- 0.5.0 release:
104
- * !!!! UPDATE DOCUMENTATION !!!!
105
- * Use clipped version of Pry.view() for large objects
106
- * Exit Pry session on ^d
107
- * Use Shellwords for breaking up parameters to pry commands
108
- * Use OptionParser to parse options for default pry commands
109
- * Add version command
110
- * Refactor 'status' command: add current method info
111
- * Add meth_name_from_binding utility lambda to commands.rb
112
- * Add -M, -m, -v(erbose), -a(ll), -s(uper), -l(ocals), -i(ivars), -k(klass vars) options to ls
113
- * add -i(nstance) option to show-method
114
- * add --help option to most commands
115
- * Get rid of ls_method and ls_imethods (subsumed by more powerful ls)
116
- * Get rid of show_idoc and show_imethod
117
- * Add special eval-file command that evals target file in current context
@@ -1,2 +0,0 @@
1
- Pry::Commands.disabled_command("edit-method", "Use `edit` instead.")
2
- Pry::Commands.disabled_command("show-command", "Use show-source [command_name] instead.")
@@ -1,26 +0,0 @@
1
- class Pry
2
- class Command::GemCd < Pry::ClassCommand
3
- match 'gem-cd'
4
- group 'Gems'
5
- description "Change working directory to specified gem's directory."
6
- command_options :argument_required => true
7
-
8
- banner <<-'BANNER'
9
- Usage: gem-cd GEM_NAME
10
-
11
- Change the current working directory to that in which the given gem is
12
- installed.
13
- BANNER
14
-
15
- def process(gem)
16
- Dir.chdir(Rubygem.spec(gem).full_gem_path)
17
- output.puts(Dir.pwd)
18
- end
19
-
20
- def complete(str)
21
- Rubygem.complete(str)
22
- end
23
- end
24
-
25
- Pry::Commands.add_command(Pry::Command::GemCd)
26
- end