pry 0.9.10pre1-i386-mswin32 → 0.9.11-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,15 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # define a local.
4
- a = "a local variable"
5
-
6
- # defing a top-level method.
7
- def hello
8
- puts "hello world!"
9
- end
10
-
11
- # Start pry session at top-level.
12
- # The local variable `a` and the `hello` method will
13
- # be accessible.
14
- puts __LINE__
15
- binding.pry
@@ -1,32 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Inherit standard command set, but tweak them by importing some and
4
- # overriding others.
5
- # Illustrates use of `command`, `run`, and `import_from` commands.
6
- class MyCommands < Pry::CommandBase
7
-
8
- # Override ls command
9
- command "ls", "An unhelpful ls" do
10
- output.puts "No, i refuse to display any useful information."
11
- end
12
-
13
- # bring in just the status command from Pry::Commands
14
- import_from Pry::Commands, "status"
15
-
16
- # analogy to Ruby's native alias_method idiom for decorating a method
17
- alias_command "old_status", "status"
18
-
19
- # Invoke one command from within another using `run`
20
- command "status", "Modified status." do |x|
21
- output.puts "About to show status, are you ready?"
22
- run "old_status", x
23
- output.puts "Finished showing status."
24
- end
25
-
26
- # bring in a few other commands
27
- import_from Pry::Commands, "quit", "show-method"
28
- end
29
-
30
- # Start a Pry session using the commands defined in MyCommands
31
- # Type 'help' in Pry to get a list of the commands and their descriptions
32
- Pry.start(TOPLEVEL_BINDING, :commands => MyCommands)
@@ -1,36 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- class MathCommands < Pry::CommandBase
4
- command "greet", "Greet a person, e.g: greet john" do |name|
5
- output.puts "Good afternoon #{name.capitalize}! Do you like Math?"
6
- end
7
-
8
- command "add", "Add a list of numbers together, e.g: add 1 2 3 4" do |*args|
9
- output.puts "Total: #{args.map(&:to_f).inject(&:+)}"
10
- end
11
-
12
- command "multiply", "Multiply a list of numbers together, e.g: multiply 1 2 3 4" do |*args|
13
- output.puts "Total: #{args.map(&:to_f).inject(&:*)}"
14
- end
15
-
16
- # Explicitly giving a description of "" to prevent command being
17
- # displayed in 'help'
18
- command "exit", "" do
19
- throw :breakout, 0
20
- end
21
-
22
- # Bring in the "!" method from Pry::Commands
23
- import_from Pry::Commands, "!"
24
- end
25
-
26
- # Since we provide math commands, let's have mathematical
27
- # before_session and after_session hooks, and a mathematical prompt
28
- math_prompt = [proc { "math> " }, proc { "math* " }]
29
- math_hooks = {
30
- :before_session => proc { |output, *| output.puts "Welcome! Let's do some math! Type 'help' for a list of commands." },
31
- :after_session => proc { |output, *| output.puts "Goodbye!" }
32
- }
33
-
34
- # Start a Pry session using the commands defined in MyCommands
35
- # Type 'help' in Pry to get a list of the commands and their descriptions
36
- Pry.start(TOPLEVEL_BINDING, :commands => MathCommands, :prompt => math_prompt, :hooks => math_hooks)
@@ -1,9 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- my_hooks = {
4
- :before_session => proc { |out, target| out.puts "Opening #{target.eval('self')}." },
5
- :after_session => proc { |out, target| out.puts "Closing #{target.eval('self')}." }
6
- }
7
-
8
- # Start a Pry session using the hooks hash defined in my_hooks
9
- Pry.start(TOPLEVEL_BINDING, :hooks => my_hooks)
@@ -1,67 +0,0 @@
1
- # Note: this requires you to have Gosu and TexPlay installed.
2
- # `gem install gosu`
3
- # `gem install texplay`
4
- #
5
- # Extra instructions for installing Gosu on Linux can be found here:
6
- # http://code.google.com/p/gosu/wiki/GettingStartedOnLinux
7
- #
8
- # Instructions for using TexPlay can be found here:
9
- # http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
10
- #
11
- # Have fun! :)
12
-
13
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
14
-
15
- WIDTH = 640
16
- HEIGHT = 480
17
-
18
- IMAGE_PROMPT = [ proc { "(image edit)> " }, proc { "(image edit)* " } ]
19
-
20
- class ImageCommands < Pry::CommandBase
21
- command "drawing_methods", "Show a list of TexPlay methods" do
22
- output.puts "#{Pry.view(TexPlay.public_instance_methods)}"
23
- end
24
-
25
- command "exit", "Exit the program." do
26
- output.puts "Thanks for dropping by!"
27
- exit
28
- end
29
-
30
- import_from Pry::Commands, "ls", "!"
31
- end
32
-
33
- class WinClass < Gosu::Window
34
-
35
- def initialize
36
- super(WIDTH, HEIGHT, false)
37
- @img = TexPlay.create_image(self, 200, 200).clear :color => :black
38
- @img.rect 0, 0, @img.width - 1, @img.height - 1
39
-
40
- @binding = Pry.binding_for(@img)
41
-
42
- @pry_instance = Pry.new(:commands => ImageCommands, :prompt => IMAGE_PROMPT)
43
- end
44
-
45
- def draw
46
- @img.draw_rot(WIDTH / 2, HEIGHT / 2, 1, 0, 0.5, 0.5)
47
- end
48
-
49
- def update
50
- exit if button_down?(Gosu::KbEscape)
51
-
52
- # We do not want a REPL session as the loop prevents the image
53
- # being updated; instead we do a REP session, and let the image
54
- # update each time the user presses enter. We maintain the same
55
- # binding object to keep locals between calls to `Pry#rep()`
56
- @pry_instance.rep(@binding)
57
- end
58
- end
59
-
60
- puts "Welcome to ImageEdit; type `help` for a list of commands and `drawing_methods` for a list of drawing methods available."
61
- puts "--"
62
- puts "Example: Try typing 'circle width/2, height/2, 95, :color => :blue, :fill => true'"
63
- puts "If you want to save your image, type: save(\"img.png\")"
64
-
65
- w = WinClass.new
66
- w.show
67
-
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Create a StringIO that contains the input data
4
- str_input = StringIO.new("puts 'hello world!'\nputs \"I am in \#{self}\"\nexit")
5
-
6
- # Start a Pry session on the Fixnum 5 using the input data in str_input
7
- Pry.start(5, :input => str_input)
@@ -1,29 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Create a StringIO that contains the input data for all the Pry objects
4
- cmds = <<-CMDS
5
- cd 1
6
- status
7
- puts 'hello from 1!!'
8
- cd 2
9
- nesting
10
- puts 'hello from 2!!'
11
- _pry_.parent.input = Readline
12
- back
13
- exit-all
14
- CMDS
15
-
16
- # create our StringIO object
17
- str_input = StringIO.new(cmds)
18
-
19
- # set global input to str_input, this means that all pry sessions
20
- # adopt this object as their input object.
21
- Pry.input = str_input
22
-
23
- # Start the session reading from str_input.
24
- # Note that because `Pry.input` is set to `str_input` all nested pry
25
- # sessions will read from `str_input` too. All pry sessions are there
26
- # for non-interactive, except for `pry(1)` which starts off
27
- # non-interactive but is set to be interactive by pry(2) (using
28
- # _pry_.parent.input = Readline)
29
- 0.pry
@@ -1,11 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Create a StringIO to contain the output data
4
- str_output = StringIO.new
5
-
6
- # Start a Pry session on the Fixnum 5 using str_output to store the
7
- # output (not writing to $stdout)
8
- Pry.start(5, :output => str_output)
9
-
10
- # Display all the output accumulated during the session
11
- puts str_output.string
@@ -1,6 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- my_print = proc { |out, value| out.puts "Output is: #{value.inspect}" }
4
-
5
- # Start a Pry session using the print object defined in my_print
6
- Pry.start(TOPLEVEL_BINDING, :print => my_print)
@@ -1,9 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Remember, first prompt in array is the main prompt, second is the wait
4
- # prompt (used for multiline input when more input is required)
5
- my_prompt = [ proc { |obj, *| "inside #{obj}> " },
6
- proc { |obj, *| "inside #{obj}* "} ]
7
-
8
- # Start a Pry session using the prompt defined in my_prompt
9
- Pry.start(TOPLEVEL_BINDING, :prompt => my_prompt)
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- unless Object.const_defined? 'Pry'
3
- $:.unshift File.expand_path '../../lib', __FILE__
4
- require 'pry'
5
- end
6
-
@@ -1,81 +0,0 @@
1
- class Pry
2
- module DefaultCommands
3
- Cd = Pry::CommandSet.new do
4
- create_command "cd" do
5
- group "Context"
6
- description "Move into a new context (object or scope)."
7
-
8
- banner <<-BANNER
9
- Usage: cd [OPTIONS] [--help]
10
-
11
- Move into new context (object or scope). As in unix shells use
12
- `cd ..` to go back, `cd /` to return to Pry top-level and `cd -`
13
- to toggle between last two scopes).
14
- Complex syntax (e.g `cd ../@x/y`) also supported.
15
-
16
- e.g: `cd @x`
17
- e.g: `cd ..`
18
- e.g: `cd /`
19
- e.g: `cd -`
20
-
21
- https://github.com/pry/pry/wiki/State-navigation#wiki-Changing_scope
22
- BANNER
23
-
24
- def process
25
- # Extract command arguments. Delete blank arguments like " ", but
26
- # don't delete empty strings like "".
27
- path = arg_string.split(/\//).delete_if { |a| a =~ /\A\s+\z/ }
28
- stack = _pry_.binding_stack.dup
29
- old_stack = state.old_stack || []
30
-
31
- # Special case when we only get a single "/", return to root.
32
- if path.empty?
33
- state.old_stack = stack.dup unless old_stack.empty?
34
- stack = [stack.first]
35
- end
36
-
37
- path.each_with_index do |context, i|
38
- begin
39
- case context.chomp
40
- when ""
41
- state.old_stack = stack.dup
42
- stack = [stack.first]
43
- when "::"
44
- state.old_stack = stack.dup
45
- stack.push(TOPLEVEL_BINDING)
46
- when "."
47
- next
48
- when ".."
49
- unless stack.size == 1
50
- # Don't rewrite old_stack if we're in complex expression
51
- # (e.g.: `cd 1/2/3/../4).
52
- state.old_stack = stack.dup if path.first == ".."
53
- stack.pop
54
- end
55
- when "-"
56
- unless old_stack.empty?
57
- # Interchange current stack and old stack with each other.
58
- stack, state.old_stack = state.old_stack, stack
59
- end
60
- else
61
- state.old_stack = stack.dup if i == 0
62
- stack.push(Pry.binding_for(stack.last.eval(context)))
63
- end
64
-
65
- rescue RescuableException => e
66
- # Restore old stack to its initial values.
67
- state.old_stack = old_stack
68
-
69
- output.puts "Bad object path: #{arg_string.chomp}. Failed trying to resolve: #{context}"
70
- output.puts e.inspect
71
- return
72
- end
73
- end
74
-
75
- _pry_.binding_stack = stack
76
- end
77
-
78
- end
79
- end
80
- end
81
- end
@@ -1,62 +0,0 @@
1
- class Pry
2
- module DefaultCommands
3
- Commands = Pry::CommandSet.new do
4
- create_command "import-set", "Import a command set" do
5
- group "Commands"
6
- def process(command_set_name)
7
- raise CommandError, "Provide a command set name" if command_set.nil?
8
-
9
- set = target.eval(arg_string)
10
- _pry_.commands.import set
11
- end
12
- end
13
-
14
- create_command "install-command", "Install a disabled command." do |name|
15
- group 'Commands'
16
-
17
- banner <<-BANNER
18
- Usage: install-command COMMAND
19
-
20
- Installs the gems necessary to run the given COMMAND. You will generally not
21
- need to run this unless told to by an error message.
22
- BANNER
23
-
24
- def process(name)
25
- require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
26
- command = find_command(name)
27
-
28
- if command_dependencies_met?(command.options)
29
- output.puts "Dependencies for #{command.name} are met. Nothing to do."
30
- return
31
- end
32
-
33
- output.puts "Attempting to install `#{name}` command..."
34
- gems_to_install = Array(command.options[:requires_gem])
35
-
36
- gems_to_install.each do |g|
37
- next if gem_installed?(g)
38
- output.puts "Installing `#{g}` gem..."
39
-
40
- begin
41
- Gem::DependencyInstaller.new.install(g)
42
- rescue Gem::GemNotFoundException
43
- raise CommandError, "Required Gem: `#{g}` not found. Aborting command installation."
44
- end
45
- end
46
-
47
- Gem.refresh
48
- gems_to_install.each do |g|
49
- begin
50
- require g
51
- rescue LoadError
52
- raise CommandError, "Required Gem: `#{g}` installed but not found?!. Aborting command installation."
53
- end
54
- end
55
-
56
- output.puts "Installation of `#{name}` successful! Type `help #{name}` for information"
57
- end
58
- end
59
- end
60
- end
61
- end
62
-
@@ -1,98 +0,0 @@
1
- require "pry/default_commands/ls"
2
- require "pry/default_commands/cd"
3
- require "pry/default_commands/find_method"
4
- require "pry/default_commands/whereami"
5
-
6
- class Pry
7
- module DefaultCommands
8
-
9
- Context = Pry::CommandSet.new do
10
- import Ls
11
- import Cd
12
- import FindMethod
13
- import Whereami
14
-
15
- create_command "pry-backtrace", "Show the backtrace for the Pry session." do
16
- banner <<-BANNER
17
- Usage: pry-backtrace [OPTIONS] [--help]
18
-
19
- Show the backtrace for the position in the code where Pry was started. This can be used to
20
- infer the behavior of the program immediately before it entered Pry, just like the backtrace
21
- property of an exception.
22
-
23
- (NOTE: if you are looking for the backtrace of the most recent exception raised,
24
- just type: `_ex_.backtrace` instead, see https://github.com/pry/pry/wiki/Special-Locals)
25
-
26
- e.g: pry-backtrace
27
- BANNER
28
-
29
- def process
30
- output.puts "\n#{text.bold('Backtrace:')}\n--\n"
31
- stagger_output _pry_.backtrace.join("\n")
32
- end
33
- end
34
-
35
- command "reset", "Reset the REPL to a clean state." do
36
- output.puts "Pry reset."
37
- exec "pry"
38
- end
39
-
40
- create_command(/wtf([?!]*)/, "Show the backtrace of the most recent exception") do
41
- options :listing => 'wtf?'
42
-
43
- banner <<-BANNER
44
- Show's a few lines of the backtrace of the most recent exception (also available
45
- as _ex_.backtrace).
46
-
47
- If you want to see more lines, add more question marks or exclamation marks:
48
-
49
- e.g.
50
- pry(main)> wtf?
51
- pry(main)> wtf?!???!?!?
52
-
53
- To see the entire backtrace, pass the -v/--verbose flag:
54
-
55
- e.g.
56
- pry(main)> wtf -v
57
- BANNER
58
-
59
- def options(opt)
60
- opt.on(:v, :verbose, "Show the full backtrace.")
61
- end
62
-
63
- def process
64
- raise Pry::CommandError, "No most-recent exception" unless _pry_.last_exception
65
-
66
- output.puts "#{text.bold('Exception:')} #{_pry_.last_exception.class}: #{_pry_.last_exception}\n--"
67
- if opts.verbose?
68
- output.puts Code.new(_pry_.last_exception.backtrace, 0, :text).with_line_numbers.to_s
69
- else
70
- output.puts Code.new(_pry_.last_exception.backtrace.first([captures[0].size, 0.5].max * 10), 0, :text).with_line_numbers.to_s
71
- end
72
- end
73
- end
74
-
75
- # N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
76
- create_command(/raise-up(!?\b.*)/, :listing => 'raise-up') do
77
- description "Raise an exception out of the current pry instance."
78
- banner <<-BANNER
79
- Raise up, like exit, allows you to quit pry. Instead of returning a value however, it raises an exception.
80
- If you don't provide the exception to be raised, it will use the most recent exception (in pry _ex_).
81
-
82
- e.g. `raise-up "get-me-out-of-here"` is equivalent to:
83
- `raise "get-me-out-of-here"
84
- raise-up`
85
-
86
- When called as raise-up! (with an exclamation mark), this command raises the exception through
87
- any nested prys you have created by "cd"ing into objects.
88
- BANNER
89
-
90
- def process
91
- return stagger_output help if captures[0] =~ /(-h|--help)\b/
92
- # Handle 'raise-up', 'raise-up "foo"', 'raise-up RuntimeError, 'farble' in a rubyesque manner
93
- target.eval("_pry_.raise_up#{captures[0]}")
94
- end
95
- end
96
- end
97
- end
98
- end