pry 0.9.10pre1-i386-mingw32 → 0.9.11-i386-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. data/.travis.yml +3 -1
  2. data/CHANGELOG +63 -2
  3. data/CONTRIBUTORS +43 -25
  4. data/Gemfile +7 -0
  5. data/Guardfile +62 -0
  6. data/README.markdown +4 -4
  7. data/Rakefile +34 -35
  8. data/lib/pry.rb +107 -54
  9. data/lib/pry/cli.rb +34 -11
  10. data/lib/pry/code.rb +165 -182
  11. data/lib/pry/code/code_range.rb +70 -0
  12. data/lib/pry/code/loc.rb +92 -0
  13. data/lib/pry/code_object.rb +153 -0
  14. data/lib/pry/command.rb +160 -22
  15. data/lib/pry/command_set.rb +37 -26
  16. data/lib/pry/commands.rb +4 -27
  17. data/lib/pry/commands/amend_line.rb +99 -0
  18. data/lib/pry/commands/bang.rb +20 -0
  19. data/lib/pry/commands/bang_pry.rb +17 -0
  20. data/lib/pry/commands/cat.rb +53 -0
  21. data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
  22. data/lib/pry/commands/cat/exception_formatter.rb +78 -0
  23. data/lib/pry/commands/cat/file_formatter.rb +84 -0
  24. data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
  25. data/lib/pry/commands/cd.rb +30 -0
  26. data/lib/pry/commands/code_collector.rb +165 -0
  27. data/lib/pry/commands/deprecated_commands.rb +2 -0
  28. data/lib/pry/commands/disable_pry.rb +27 -0
  29. data/lib/pry/commands/easter_eggs.rb +112 -0
  30. data/lib/pry/commands/edit.rb +206 -0
  31. data/lib/pry/commands/edit/exception_patcher.rb +25 -0
  32. data/lib/pry/commands/edit/file_and_line_locator.rb +38 -0
  33. data/lib/pry/commands/edit/method_patcher.rb +122 -0
  34. data/lib/pry/commands/exit.rb +42 -0
  35. data/lib/pry/commands/exit_all.rb +29 -0
  36. data/lib/pry/commands/exit_program.rb +24 -0
  37. data/lib/pry/commands/find_method.rb +199 -0
  38. data/lib/pry/commands/fix_indent.rb +19 -0
  39. data/lib/pry/commands/gem_cd.rb +26 -0
  40. data/lib/pry/commands/gem_install.rb +29 -0
  41. data/lib/pry/commands/gem_list.rb +33 -0
  42. data/lib/pry/commands/gem_open.rb +29 -0
  43. data/lib/pry/commands/gist.rb +95 -0
  44. data/lib/pry/commands/help.rb +164 -0
  45. data/lib/pry/commands/hist.rb +161 -0
  46. data/lib/pry/commands/import_set.rb +22 -0
  47. data/lib/pry/commands/install_command.rb +51 -0
  48. data/lib/pry/commands/jump_to.rb +29 -0
  49. data/lib/pry/commands/ls.rb +339 -0
  50. data/lib/pry/commands/nesting.rb +25 -0
  51. data/lib/pry/commands/play.rb +69 -0
  52. data/lib/pry/commands/pry_backtrace.rb +26 -0
  53. data/lib/pry/commands/pry_version.rb +17 -0
  54. data/lib/pry/commands/raise_up.rb +32 -0
  55. data/lib/pry/commands/reload_code.rb +39 -0
  56. data/lib/pry/commands/reset.rb +18 -0
  57. data/lib/pry/commands/ri.rb +56 -0
  58. data/lib/pry/commands/save_file.rb +61 -0
  59. data/lib/pry/commands/shell_command.rb +43 -0
  60. data/lib/pry/commands/shell_mode.rb +27 -0
  61. data/lib/pry/commands/show_doc.rb +78 -0
  62. data/lib/pry/commands/show_info.rb +139 -0
  63. data/lib/pry/commands/show_input.rb +17 -0
  64. data/lib/pry/commands/show_source.rb +37 -0
  65. data/lib/pry/commands/simple_prompt.rb +22 -0
  66. data/lib/pry/commands/stat.rb +40 -0
  67. data/lib/pry/commands/switch_to.rb +23 -0
  68. data/lib/pry/commands/toggle_color.rb +20 -0
  69. data/lib/pry/commands/whereami.rb +114 -0
  70. data/lib/pry/commands/wtf.rb +57 -0
  71. data/lib/pry/completion.rb +120 -46
  72. data/lib/pry/config.rb +11 -0
  73. data/lib/pry/core_extensions.rb +30 -19
  74. data/lib/pry/editor.rb +129 -0
  75. data/lib/pry/helpers.rb +1 -0
  76. data/lib/pry/helpers/base_helpers.rb +89 -119
  77. data/lib/pry/helpers/command_helpers.rb +7 -122
  78. data/lib/pry/helpers/table.rb +100 -0
  79. data/lib/pry/helpers/text.rb +4 -4
  80. data/lib/pry/history_array.rb +5 -0
  81. data/lib/pry/hooks.rb +1 -3
  82. data/lib/pry/indent.rb +104 -30
  83. data/lib/pry/method.rb +66 -22
  84. data/lib/pry/module_candidate.rb +26 -15
  85. data/lib/pry/pager.rb +70 -0
  86. data/lib/pry/plugins.rb +1 -2
  87. data/lib/pry/pry_class.rb +63 -22
  88. data/lib/pry/pry_instance.rb +58 -37
  89. data/lib/pry/rubygem.rb +74 -0
  90. data/lib/pry/terminal_info.rb +43 -0
  91. data/lib/pry/test/helper.rb +185 -0
  92. data/lib/pry/version.rb +1 -1
  93. data/lib/pry/wrapped_module.rb +58 -24
  94. data/pry.gemspec +21 -37
  95. data/{test/test_cli.rb → spec/cli_spec.rb} +0 -0
  96. data/spec/code_object_spec.rb +277 -0
  97. data/{test/test_code.rb → spec/code_spec.rb} +19 -1
  98. data/{test/test_command_helpers.rb → spec/command_helpers_spec.rb} +0 -0
  99. data/{test/test_command_integration.rb → spec/command_integration_spec.rb} +38 -46
  100. data/{test/test_command_set.rb → spec/command_set_spec.rb} +18 -1
  101. data/{test/test_command.rb → spec/command_spec.rb} +250 -149
  102. data/spec/commands/amend_line_spec.rb +247 -0
  103. data/spec/commands/bang_spec.rb +19 -0
  104. data/spec/commands/cat_spec.rb +164 -0
  105. data/spec/commands/cd_spec.rb +250 -0
  106. data/spec/commands/disable_pry_spec.rb +25 -0
  107. data/spec/commands/edit_spec.rb +727 -0
  108. data/spec/commands/exit_all_spec.rb +34 -0
  109. data/spec/commands/exit_program_spec.rb +19 -0
  110. data/spec/commands/exit_spec.rb +34 -0
  111. data/{test/test_default_commands/test_find_method.rb → spec/commands/find_method_spec.rb} +27 -7
  112. data/spec/commands/gem_list_spec.rb +26 -0
  113. data/spec/commands/gist_spec.rb +75 -0
  114. data/{test/test_default_commands/test_help.rb → spec/commands/help_spec.rb} +8 -9
  115. data/spec/commands/hist_spec.rb +181 -0
  116. data/spec/commands/jump_to_spec.rb +15 -0
  117. data/spec/commands/ls_spec.rb +177 -0
  118. data/spec/commands/play_spec.rb +140 -0
  119. data/spec/commands/raise_up_spec.rb +56 -0
  120. data/spec/commands/save_file_spec.rb +177 -0
  121. data/spec/commands/show_doc_spec.rb +378 -0
  122. data/spec/commands/show_input_spec.rb +17 -0
  123. data/spec/commands/show_source_spec.rb +597 -0
  124. data/spec/commands/whereami_spec.rb +154 -0
  125. data/spec/completion_spec.rb +233 -0
  126. data/spec/control_d_handler_spec.rb +58 -0
  127. data/spec/editor_spec.rb +79 -0
  128. data/{test/test_exception_whitelist.rb → spec/exception_whitelist_spec.rb} +0 -0
  129. data/{test → spec/fixtures}/candidate_helper1.rb +0 -0
  130. data/{test → spec/fixtures}/candidate_helper2.rb +0 -0
  131. data/{test/test_default_commands → spec/fixtures}/example.erb +0 -0
  132. data/spec/fixtures/example_nesting.rb +33 -0
  133. data/spec/fixtures/show_source_doc_examples.rb +15 -0
  134. data/{test → spec/fixtures}/testrc +0 -0
  135. data/{test → spec/fixtures}/testrcbad +0 -0
  136. data/spec/helper.rb +34 -0
  137. data/spec/helpers/bacon.rb +86 -0
  138. data/spec/helpers/mock_pry.rb +43 -0
  139. data/spec/helpers/table_spec.rb +83 -0
  140. data/{test/test_history_array.rb → spec/history_array_spec.rb} +21 -19
  141. data/{test/test_hooks.rb → spec/hooks_spec.rb} +0 -0
  142. data/{test/test_indent.rb → spec/indent_spec.rb} +24 -0
  143. data/{test/test_input_stack.rb → spec/input_stack_spec.rb} +4 -0
  144. data/{test/test_method.rb → spec/method_spec.rb} +65 -1
  145. data/{test/test_prompt.rb → spec/prompt_spec.rb} +0 -0
  146. data/{test/test_pry_defaults.rb → spec/pry_defaults_spec.rb} +14 -14
  147. data/{test/test_pry_history.rb → spec/pry_history_spec.rb} +15 -0
  148. data/spec/pry_output_spec.rb +95 -0
  149. data/{test/test_pry.rb → spec/pry_spec.rb} +74 -32
  150. data/{test/test_sticky_locals.rb → spec/sticky_locals_spec.rb} +27 -25
  151. data/{test/test_syntax_checking.rb → spec/syntax_checking_spec.rb} +17 -1
  152. data/{test/test_wrapped_module.rb → spec/wrapped_module_spec.rb} +92 -5
  153. metadata +239 -115
  154. data/examples/example_basic.rb +0 -15
  155. data/examples/example_command_override.rb +0 -32
  156. data/examples/example_commands.rb +0 -36
  157. data/examples/example_hooks.rb +0 -9
  158. data/examples/example_image_edit.rb +0 -67
  159. data/examples/example_input.rb +0 -7
  160. data/examples/example_input2.rb +0 -29
  161. data/examples/example_output.rb +0 -11
  162. data/examples/example_print.rb +0 -6
  163. data/examples/example_prompt.rb +0 -9
  164. data/examples/helper.rb +0 -6
  165. data/lib/pry/default_commands/cd.rb +0 -81
  166. data/lib/pry/default_commands/commands.rb +0 -62
  167. data/lib/pry/default_commands/context.rb +0 -98
  168. data/lib/pry/default_commands/easter_eggs.rb +0 -95
  169. data/lib/pry/default_commands/editing.rb +0 -420
  170. data/lib/pry/default_commands/find_method.rb +0 -169
  171. data/lib/pry/default_commands/gems.rb +0 -84
  172. data/lib/pry/default_commands/gist.rb +0 -187
  173. data/lib/pry/default_commands/help.rb +0 -127
  174. data/lib/pry/default_commands/hist.rb +0 -120
  175. data/lib/pry/default_commands/input_and_output.rb +0 -306
  176. data/lib/pry/default_commands/introspection.rb +0 -410
  177. data/lib/pry/default_commands/ls.rb +0 -272
  178. data/lib/pry/default_commands/misc.rb +0 -38
  179. data/lib/pry/default_commands/navigating_pry.rb +0 -110
  180. data/lib/pry/default_commands/whereami.rb +0 -92
  181. data/lib/pry/extended_commands/experimental.rb +0 -7
  182. data/test/helper.rb +0 -223
  183. data/test/test_completion.rb +0 -62
  184. data/test/test_control_d_handler.rb +0 -45
  185. data/test/test_default_commands/test_cd.rb +0 -321
  186. data/test/test_default_commands/test_context.rb +0 -288
  187. data/test/test_default_commands/test_documentation.rb +0 -315
  188. data/test/test_default_commands/test_gems.rb +0 -18
  189. data/test/test_default_commands/test_input.rb +0 -428
  190. data/test/test_default_commands/test_introspection.rb +0 -511
  191. data/test/test_default_commands/test_ls.rb +0 -151
  192. data/test/test_default_commands/test_shell.rb +0 -343
  193. data/test/test_default_commands/test_show_source.rb +0 -432
  194. data/test/test_pry_output.rb +0 -41
@@ -5,7 +5,9 @@ rvm:
5
5
  - ree
6
6
  - rbx-18mode
7
7
  - rbx-19mode
8
- - jruby
8
+ - jruby-18mode
9
+ - jruby-19mode
10
+ - jruby-head
9
11
 
10
12
  notifications:
11
13
  irc: "irc.freenode.org#pry"
data/CHANGELOG CHANGED
@@ -1,4 +1,64 @@
1
- 06/07/2012 version 0.10.pre.1
1
+ 16/01/2013 version 0.9.11
2
+ dependency changes:
3
+ * upgrade the slop gem to version ~> 3.4
4
+ * new optional dependency: Bond (you'll need to perform `gem install bond`). It enables autocompletion if you use Readline. Does not support work for Editline (more info: https://github.com/pry/pry/wiki/FAQ#wiki-readline). Big thanks to cldwalker.
5
+
6
+ new features:
7
+ * #738 basic Ruby 2.0 support
8
+ * #732 JRuby 1.7.0+ support
9
+ * added bond tabcompletion, much more powerful than standard tab
10
+ completion. However, it requires a real 'readline' to work,
11
+ so will not work on standard osx setup (since it uses Editline)
12
+ * show-source can now extract source for classes, methods, procs,
13
+ pry commands, and arbitrary objects (it shows the source for the class of
14
+ the object). As a result, show-command is now deprecated
15
+ * gist/play/save-file now infer object type without requiring flags,
16
+ e.g play MyClass, play my_file.rb, play my_method
17
+ * edit command can now edit most things, including: files, methods,
18
+ classes, commands. As a result the 'edit-method' command is now
19
+ deprecatd.
20
+ e.g edit my_file.rb, edit my_method, edit MyClass
21
+ * removed "edit-method", now merged with 'edit'
22
+ * amend-line and play now properly indent code added to input buffer.
23
+ * #674 added support for require switches chaining (`pry -rubygems -r./a.rb`)
24
+ * #695 added ability to customize the name displayed in the prompt
25
+ * #716 added `--patch` switch for `edit --ex` command
26
+ * #736 respect the `$PAGER` environment variable
27
+ * #497 added `disable-pry` command
28
+ * removed "show-command" command; use "show-source" command instead
29
+ * exec switch chaining (`pry -e ':one' -e ':two'`)
30
+ * added two new hooks: "before_eval" and "after_eval"
31
+ * added tabcompletion for "show-source", "show-doc" commands and "Array#<tab>" cases
32
+ * immediately require gems after gem-install
33
+ * added `-l` switch for `ls` command (displays local variables)
34
+ * added "gem-open" command
35
+ * added "fix-indent" command
36
+ * added subcommands API
37
+ * exposed the test API for plugin writers (d1489a)
38
+ * tablifed ls output
39
+ * added `--no-line-numbers` switch for "whereami" command
40
+ * added `--lines` switch for "play" command
41
+
42
+ bug fixes:
43
+ * #652 find-method uses single escape instead of double
44
+ * #657 fixed blank string delimiters
45
+ * #622 fixed "unwanted 'binding_impl_method' local now exists in scratch bindings"
46
+ * #645 fixed "edit-method -p changes constant lookup"
47
+ * #682 fixed ".pryrc" loading twice when invoked from `$HOME` directory
48
+ * #675 fixed pry not remembering initial "pwd"
49
+ * #717 fixed multiline object coloring
50
+ * #719 fixed "show-method" not supporting `String::new` notation
51
+ * #754 fixed "whereami" command not showing correct line numbers
52
+ * #751 fixed buggy Cucumber AST output
53
+ * #787 fixed `while/until do` loops indentation
54
+ * #526 fixed buggy `--no-plugins` switch of pry
55
+ * #774 ensure all errors go to the error handler
56
+ * fixed ".pryrc" loading with wrong `__FILE__`
57
+ * fixed bug when pager doesn't work if "less" is not available on system
58
+ * fixed "Control-D" press in nested REPL
59
+ * many small improvements of unclear error messages and formatting of documentation
60
+
61
+ 14/07/2012 version 0.9.10
2
62
  dependency changes:
3
63
  * #561 upgrade the slop gem to version 3
4
64
  * #590 move to the jist gem from gist.
@@ -14,6 +74,7 @@ new features:
14
74
  * allow running a file of pry input with pry <file>
15
75
  * support colours in "ri" command
16
76
  * add before_eval hook
77
+ * prompt now gets a lot more data when proc arity is 1
17
78
 
18
79
  bug fixes &c.
19
80
  * #554 removed the "req" command
@@ -29,6 +90,7 @@ bug fixes &c.
29
90
  * #620 improve whereami command when not in a binding.pry
30
91
  * #622 support embedded documents (=begin ... =end)
31
92
  * #627 support editing files with spaces in the name
93
+ * changed __binding_impl__ to __pry__
32
94
  * support for absolute paths in $EDITOR
33
95
  * fix "cat" command on files with unknown extensions
34
96
  * many many internal refactorings and tidyings
@@ -419,4 +481,3 @@ complete CHANGELOG:
419
481
  * now rescuing SyntaxError as well as Racc::Parser error in valid_expression?
420
482
  8/12/2010 version 0.1.0
421
483
  * release!
422
-
@@ -1,37 +1,55 @@
1
- 938 banisterfiend
2
- 290 cirwin
3
- 140 ryanf
4
- 93 robgleeson
5
- 51 injekt
6
- 49 Mon_Ouie
7
- 39 envygeeks
8
- 28 yorickpeterse
1
+ 1068 John Mair
2
+ 372 Conrad Irwin
3
+ 215 Ryan Fitzgerald
4
+ 108 Kyrylo Silin
5
+ 92 Rob Gleeson
6
+ 54 Mon ouïe
7
+ 51 Lee Jarvis
8
+ 47 ☈king
9
+ 40 Jordon Bedwell
10
+ 28 Yorick Peterse
9
11
  18 David Palm
12
+ 18 Robert Gleeson
10
13
  15 epitron
11
- 15 kyrylo
12
- 10 swarley
13
- 8 rue
14
- 3 Darrick Wiebe
15
- 3 fowl
14
+ 12 Andrew Vos
15
+ 11 Reginald Tan
16
+ 10 Matt Carey
17
+ 8 Eero Saynatkari
18
+ 8 Trey Lawrence
19
+ 6 Jason Laster
16
20
  3 misfo
17
- 2 Ben Langfeld
18
- 2 Eric Christopherson
21
+ 3 fowlmouth
22
+ 3 Darrick Wiebe
19
23
  2 Kelsey Judson
24
+ 2 Ben Langfeld
25
+ 2 Bram Swenson
26
+ 2 Erik Michaels-Ober
27
+ 2 Ingrid
28
+ 2 Vít Ondruch
20
29
  2 Xavier Shay
21
- 2 sferic
22
- 2 shadowshell
23
- 1 Gerbert Olivé
24
- 1 Gosha Arinich
30
+ 2 Jonathan Soeder
31
+ 2 Eric Christopherson
32
+ 2 robgleeson
33
+ 1 Ben Pickles
34
+ 1 Zeh Rizzatti
35
+ 1 shirmung
36
+ 1 sonnym
37
+ 1 Shawn Anderson
25
38
  1 Joe Peduto
39
+ 1 Greg Stearns
26
40
  1 Jonathan Jackson
27
- 1 Jonathan Soeder
28
41
  1 Jordan Running
42
+ 1 Gosha Arinich
29
43
  1 Josh Cheek
30
- 1 KL-7
44
+ 1 Kirill Lashuk
45
+ 1 Gerbert Olivé
46
+ 1 Larry Gilbert
31
47
  1 Lars Haugseth
32
- 1 Reginald Tan
48
+ 1 Loic Nageleisen
49
+ 1 Matthew Carey
50
+ 1 Michael Bensoussan
33
51
  1 Renato Mascarenhas
34
- 1 Shawn Anderson
52
+ 1 Havenwood
35
53
  1 Sherin C
36
- 1 sonnym
37
- 1 tpope
54
+ 1 Sonali Sridhar
55
+ 1 Tim Pope
data/Gemfile CHANGED
@@ -1,2 +1,9 @@
1
1
  source :rubygems
2
2
  gemspec
3
+
4
+ # For Guard
5
+ group :development do
6
+ gem 'jist'
7
+ gem 'rb-inotify', :require => 'false'
8
+ gem 'rb-fsevent', :require => 'false'
9
+ end
@@ -0,0 +1,62 @@
1
+ require 'guard/guard'
2
+
3
+ module ::Guard
4
+ class Bacon < Guard
5
+ def run_all
6
+ system "rake spec"
7
+ puts
8
+ true
9
+ end
10
+
11
+ def run_on_changes(paths)
12
+ paths.delete('some_lib')
13
+ puts "Running: #{paths.join ' '}"
14
+ if paths.size.zero?
15
+ warn 'Running all tests'
16
+ system 'rake recspec'
17
+ else
18
+ paths.each do |path|
19
+ warn "Running #{path}"
20
+ system "rake spec run=#{path}" or return
21
+ warn "\e[32;1mNice!!\e[0m Now running all specs, just to be sure."
22
+ run_all
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ guard 'bacon' do
30
+ def deduce_spec_from(token)
31
+ %W(
32
+ spec/#{token}_spec.rb
33
+ spec/pry_#{token}_spec.rb
34
+ spec/commands/#{token}_spec.rb
35
+ ).each do |e|
36
+ return e if File.exists? e
37
+ end
38
+ nil
39
+ end
40
+
41
+ Dir['lib/pry/**/*.rb'].each do |rb|
42
+ rb[%r(lib/pry/(.+)\.rb$)]
43
+ spec_rb = deduce_spec_from($1)
44
+ if spec_rb
45
+ # run as 'bundle exec guard -d' to see these.
46
+ ::Guard::UI.debug "'#{rb}' maps to '#{spec_rb}'"
47
+ else
48
+ ::Guard::UI.debug "No map, so run all for: '#{rb}'"
49
+ end
50
+ next unless spec_rb
51
+ watch(rb) do |m| spec_rb end
52
+ end
53
+
54
+ watch(%r{^lib/.+\.rb$}) do |m|
55
+ return if deduce_spec_from(m[0])
56
+ 'some_lib'
57
+ end
58
+
59
+ watch(%r{^spec/.+\.rb$}) do |m| m end
60
+ end
61
+
62
+ # vim:ft=ruby
@@ -1,10 +1,9 @@
1
1
  [![Build Status](https://secure.travis-ci.org/pry/pry.png)](http://travis-ci.org/pry/pry)
2
2
 
3
3
  <center>
4
- ![Alt text](http://dl.dropbox.com/u/26521875/pry_logo_350.png)
5
-
6
- (C) John Mair (banisterfiend) 2011<br>
4
+ ![The Pry Logo](https://dl.dropbox.com/u/26521875/pry%20stuff/logo/pry_logo_350.png)
7
5
 
6
+ © John Mair (banisterfiend) 2012<br>
8
7
 
9
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!
10
9
 
@@ -13,6 +12,7 @@
13
12
  [Atomic Object](http://www.atomicobject.com/)<br/>
14
13
  [Bendyworks](http://bendyworks.com/)<br/>
15
14
  [Intridea](http://intridea.com/)<br/>
15
+ [Gaslight](http://gaslight.co/home)<br/>
16
16
 
17
17
  **Other Resources**
18
18
 
@@ -395,6 +395,6 @@ Problems or questions? file an issue at [github](https://github.com/pry/pry/issu
395
395
 
396
396
  ### Contributors
397
397
 
398
- Pry is primarily the work of [John Mair (banisterfiend)]((http://github.com/banister)), for full list
398
+ Pry is primarily the work of [John Mair (banisterfiend)](http://github.com/banister), for full list
399
399
  of contributors see the
400
400
  [CONTRIBUTORS](https://github.com/pry/pry/blob/master/CONTRIBUTORS) file.
data/Rakefile CHANGED
@@ -7,26 +7,6 @@ require 'pry/version'
7
7
  CLOBBER.include('**/*~', '**/*#*', '**/*.log')
8
8
  CLEAN.include('**/*#*', '**/*#*.*', '**/*_flymake*.*', '**/*_flymake', '**/*.rbc', '**/.#*.*')
9
9
 
10
- def apply_spec_defaults(s)
11
- s.name = 'pry'
12
- s.summary = "An IRB alternative and runtime developer console"
13
- s.version = Pry::VERSION
14
- s.date = Time.now.strftime '%Y-%m-%d'
15
- s.authors = ["John Mair (banisterfiend)", "Conrad Irwin"]
16
- s.email = ['jrmair@gmail.com', 'conrad.irwin@gmail.com']
17
- s.description = s.summary
18
- s.homepage = 'http://pry.github.com'
19
- s.executables = ['pry']
20
- s.files = `git ls-files`.split("\n")
21
- s.test_files = `git ls-files -- test/*`.split("\n")
22
- s.add_dependency('coderay', '~> 1.0.5')
23
- s.add_dependency('slop', ['~> 3.3.1'])
24
- s.add_dependency('method_source','~> 0.8')
25
- s.add_development_dependency('bacon', '~> 1.1')
26
- s.add_development_dependency('open4', '~> 1.3')
27
- s.add_development_dependency('rake', '~> 0.9')
28
- end
29
-
30
10
  def check_dependencies
31
11
  require 'bundler'
32
12
  Bundler.definition.missing_specs
@@ -41,10 +21,37 @@ end
41
21
  desc "Set up and run tests"
42
22
  task :default => [:test]
43
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
+
44
38
  desc "Run tests"
45
39
  task :test do
46
40
  check_dependencies unless ENV['SKIP_DEP_CHECK']
47
- sh "bacon -Itest -rubygems -a -q"
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
48
55
  end
49
56
 
50
57
  desc "Run pry"
@@ -65,12 +72,12 @@ task :profile do
65
72
  Pry.start(TOPLEVEL_BINDING, :input => StringIO.new('exit'))
66
73
  end
67
74
 
68
- desc "Build the gemspec file"
69
- task :gemspec => "ruby:gemspec"
75
+ def modify_base_gemspec
76
+ eval(File.read('pry.gemspec')).tap { |s| yield s }
77
+ end
70
78
 
71
79
  namespace :ruby do
72
- spec = Gem::Specification.new do |s|
73
- apply_spec_defaults(s)
80
+ spec = modify_base_gemspec do |s|
74
81
  s.platform = Gem::Platform::RUBY
75
82
  end
76
83
 
@@ -78,17 +85,10 @@ namespace :ruby do
78
85
  pkg.need_zip = false
79
86
  pkg.need_tar = false
80
87
  end
81
-
82
- task :gemspec do
83
- File.open("#{spec.name}.gemspec", "w") do |f|
84
- f << spec.to_ruby
85
- end
86
- end
87
88
  end
88
89
 
89
90
  namespace :jruby do
90
- spec = Gem::Specification.new do |s|
91
- apply_spec_defaults(s)
91
+ spec = modify_base_gemspec do |s|
92
92
  s.add_dependency('spoon', '~> 0.0')
93
93
  s.platform = 'java'
94
94
  end
@@ -102,8 +102,7 @@ end
102
102
 
103
103
  [:mingw32, :mswin32].each do |v|
104
104
  namespace v do
105
- spec = Gem::Specification.new do |s|
106
- apply_spec_defaults(s)
105
+ spec = modify_base_gemspec do |s|
107
106
  s.add_dependency('win32console', '~> 1.3')
108
107
  s.platform = "i386-#{v}"
109
108
  end
data/lib/pry.rb CHANGED
@@ -15,6 +15,10 @@ class Pry
15
15
 
16
16
  # The default print
17
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 = {})
18
22
  stringified = begin
19
23
  value.pretty_inspect
20
24
  rescue RescuableException
@@ -22,53 +26,65 @@ class Pry
22
26
  end
23
27
 
24
28
  unless String === stringified
25
- # Read the class name off of the singleton class to provide a default inspect.
29
+ # Read the class name off of the singleton class to provide a default
30
+ # inspect.
26
31
  klass = (class << value; self; end).ancestors.first
27
32
  stringified = "#<#{klass}:0x#{value.__id__.to_s(16)}>"
28
33
  end
29
34
 
30
35
  nonce = rand(0x100000000).to_s(16) # whatever
31
36
 
32
- colorized = Helpers::BaseHelpers.colorize_code(stringified.gsub(/#</, "%<#{nonce}"))
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
33
44
 
34
45
  # avoid colour-leak from CodeRay and any of the users' previous output
35
- colorized = colorized.sub(/(\n*)$/, "\e[0m\\1") if Pry.color
46
+ colorized = colorized.sub(/(\n*)\z/, "\e[0m\\1") if Pry.color
36
47
 
37
- Helpers::BaseHelpers.stagger_output("=> #{colorized.gsub(/%<(.*?)#{nonce}/, '#<\1')}", output)
48
+ result = colorized.gsub(/%<(.*?)#{nonce}/, '#<\1')
49
+ result = "=> #{result}"if options[:hashrocket]
50
+ Helpers::BaseHelpers.stagger_output(result, output)
38
51
  end
39
52
 
40
53
  # may be convenient when working with enormous objects and
41
54
  # pretty_print is too slow
42
55
  SIMPLE_PRINT = proc do |output, value|
43
56
  begin
44
- output.puts "=> #{value.inspect}"
57
+ output.puts value.inspect
45
58
  rescue RescuableException
46
- output.puts "=> unknown"
59
+ output.puts "unknown"
47
60
  end
48
61
  end
49
62
 
50
63
  # useful when playing with truly enormous objects
51
64
  CLIPPED_PRINT = proc do |output, value|
52
- output.puts "=> #{Pry.view_clip(value)}"
65
+ output.puts Pry.view_clip(value)
53
66
  end
54
67
 
55
68
  # Will only show the first line of the backtrace
56
69
  DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _|
57
- output.puts "#{exception.class}: #{exception.message}"
58
- output.puts "from #{exception.backtrace.first}"
70
+ if UserError === exception && SyntaxError === exception
71
+ output.puts "SyntaxError: #{exception.message.sub(/.*syntax error, */m, '')}"
72
+ else
73
+ output.puts "#{exception.class}: #{exception.message}"
74
+ output.puts "from #{exception.backtrace.first}"
75
+ end
59
76
  end
60
77
 
61
- # Don't catch these exceptions
62
- DEFAULT_EXCEPTION_WHITELIST = [SystemExit, SignalException]
78
+ DEFAULT_PROMPT_NAME = 'pry'
63
79
 
64
80
  # The default prompt; includes the target and nesting level
65
81
  DEFAULT_PROMPT = [
66
82
  proc { |target_self, nest_level, pry|
67
- "[#{pry.input_array.size}] pry(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
83
+ "[#{pry.input_array.size}] #{Pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
68
84
  },
69
85
 
70
86
  proc { |target_self, nest_level, pry|
71
- "[#{pry.input_array.size}] pry(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
87
+ "[#{pry.input_array.size}] #{Pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
72
88
  }
73
89
  ]
74
90
 
@@ -76,8 +92,8 @@ class Pry
76
92
  SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
77
93
 
78
94
  SHELL_PROMPT = [
79
- proc { |target_self, _, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
80
- proc { |target_self, _, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
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} * " }
81
97
  ]
82
98
 
83
99
  # A prompt that includes the full object path as well as
@@ -85,31 +101,30 @@ class Pry
85
101
  NAV_PROMPT = [
86
102
  proc do |conf|
87
103
  tree = conf.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
88
- "[#{conf.expr_number}] (pry) #{tree}: #{conf.nesting_level}> "
104
+ "[#{conf.expr_number}] (#{Pry.config.prompt_name}) #{tree}: #{conf.nesting_level}> "
89
105
  end,
90
106
  proc do |conf|
91
107
  tree = conf.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
92
- "[#{conf.expr_number}] (pry) #{tree}: #{conf.nesting_level}* "
108
+ "[#{conf.expr_number}] (#{ Pry.config.prompt_name}) #{tree}: #{conf.nesting_level}* "
93
109
  end,
94
110
  ]
95
111
 
96
- # Deal with the ^D key being pressed, different behaviour in
97
- # different cases:
98
- # 1) In an expression - behave like `!` command (clear input buffer)
99
- # 2) At top-level session - behave like `exit command (break out of repl loop)
100
- # 3) In a nested session - behave like `cd ..` (pop a binding)
112
+ # Deal with the ^D key being pressed. Different behaviour in different cases:
113
+ # 1. In an expression behave like `!` command.
114
+ # 2. At top-level session behave like `exit` command.
115
+ # 3. In a nested session behave like `cd ..`.
101
116
  DEFAULT_CONTROL_D_HANDLER = proc do |eval_string, _pry_|
102
117
  if !eval_string.empty?
103
- # Clear input buffer.
104
- eval_string.replace("")
118
+ eval_string.replace('') # Clear input buffer.
105
119
  elsif _pry_.binding_stack.one?
106
- # ^D at top-level breaks out of a REPL loop.
107
120
  _pry_.binding_stack.clear
108
121
  throw(:breakout)
109
122
  else
110
- # Otherwise, saves current binding stack as old stack and pops last
111
- # binding out of binding stack (the old stack still has that binding).
112
- _pry_.command_state["cd"].old_stack = _pry_.binding_stack.dup
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
127
+ _pry_.command_state['cd'].old_stack = _pry_.binding_stack.dup
113
128
  _pry_.binding_stack.pop
114
129
  end
115
130
  end
@@ -120,6 +135,10 @@ class Pry
120
135
  end
121
136
  end
122
137
 
138
+ # Store the current working directory. This allows show-source etc. to work if
139
+ # your process has changed directory since boot. [Issue #675]
140
+ INITIAL_PWD = Dir.pwd
141
+
123
142
  # As a REPL, we often want to catch any unexpected exceptions that may have
124
143
  # been raised; however we don't want to go overboard and prevent the user
125
144
  # from exiting Pry when they want to.
@@ -141,10 +160,34 @@ class Pry
141
160
  end
142
161
  end
143
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
+
144
187
  # CommandErrors are caught by the REPL loop and displayed to the user. They
145
188
  # indicate an exceptional condition that's fatal to the current command.
146
189
  class CommandError < StandardError; end
147
- class NonMethodContextError < CommandError; end
190
+ class MethodNotFound < CommandError; end
148
191
 
149
192
  # indicates obsolete API
150
193
  class ObsoleteError < StandardError; end
@@ -162,13 +205,13 @@ if Pry::Helpers::BaseHelpers.mri_18?
162
205
  end
163
206
  end
164
207
 
165
- require "method_source"
208
+ require 'method_source'
166
209
  require 'shellwords'
167
- require "stringio"
168
- require "coderay"
169
- require "optparse"
170
- require "slop"
171
- require "rbconfig"
210
+ require 'stringio'
211
+ require 'coderay'
212
+ require 'slop'
213
+ require 'rbconfig'
214
+ require 'tempfile'
172
215
 
173
216
  begin
174
217
  require 'readline'
@@ -197,22 +240,32 @@ if Pry::Helpers::BaseHelpers.windows? && !Pry::Helpers::BaseHelpers.windows_ansi
197
240
  end
198
241
  end
199
242
 
200
- require "pry/version"
201
- require "pry/rbx_method"
202
- require "pry/rbx_path"
203
- require "pry/code"
204
- require "pry/method"
205
- require "pry/wrapped_module"
206
- require "pry/history_array"
207
- require "pry/helpers"
208
- require "pry/history"
209
- require "pry/command"
210
- require "pry/command_set"
211
- require "pry/commands"
212
- require "pry/custom_completions"
213
- require "pry/completion"
214
- require "pry/plugins"
215
- require "pry/core_extensions"
216
- require "pry/pry_class"
217
- require "pry/pry_instance"
218
- require "pry/cli"
243
+ begin
244
+ require 'bond'
245
+ rescue LoadError
246
+ end
247
+
248
+ require 'pry/version'
249
+ require 'pry/rbx_method'
250
+ require 'pry/rbx_path'
251
+ require 'pry/code'
252
+ require 'pry/history_array'
253
+ require 'pry/helpers'
254
+ require 'pry/code_object'
255
+ require 'pry/method'
256
+ require 'pry/wrapped_module'
257
+ require 'pry/history'
258
+ require 'pry/command'
259
+ require 'pry/command_set'
260
+ require 'pry/commands'
261
+ require 'pry/custom_completions'
262
+ require 'pry/completion'
263
+ require 'pry/plugins'
264
+ require 'pry/core_extensions'
265
+ require 'pry/pry_class'
266
+ require 'pry/pry_instance'
267
+ require 'pry/cli'
268
+ require 'pry/pager'
269
+ require 'pry/terminal_info'
270
+ require 'pry/editor'
271
+ require 'pry/rubygem'