pry 0.9.5 → 0.9.6
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.
- data/CHANGELOG +21 -0
 - data/Gemfile +2 -0
 - data/README.markdown +15 -17
 - data/Rakefile +1 -1
 - data/bin/pry +8 -6
 - data/examples/example_command_override.rb +1 -1
 - data/lib/pry.rb +19 -4
 - data/lib/pry/command_context.rb +1 -0
 - data/lib/pry/command_processor.rb +1 -0
 - data/lib/pry/command_set.rb +2 -2
 - data/lib/pry/config.rb +15 -0
 - data/lib/pry/default_commands/context.rb +8 -4
 - data/lib/pry/default_commands/documentation.rb +18 -12
 - data/lib/pry/default_commands/input.rb +120 -67
 - data/lib/pry/default_commands/introspection.rb +112 -67
 - data/lib/pry/default_commands/shell.rb +28 -17
 - data/lib/pry/helpers/command_helpers.rb +73 -40
 - data/lib/pry/history_array.rb +4 -0
 - data/lib/pry/pry_class.rb +10 -6
 - data/lib/pry/pry_instance.rb +57 -25
 - data/lib/pry/version.rb +1 -1
 - data/pry.gemspec +8 -8
 - data/test/helper.rb +35 -1
 - data/test/test_command_set.rb +1 -1
 - data/test/test_default_commands/test_input.rb +30 -17
 - data/test/test_default_commands/test_introspection.rb +334 -1
 - data/test/test_default_commands/test_shell.rb +100 -5
 - data/test/test_exception_whitelist.rb +17 -0
 - data/test/test_input_stack.rb +70 -0
 - data/test/test_pry.rb +26 -22
 - data/test/test_pry_output.rb +2 -6
 - metadata +66 -67
 
    
        data/CHANGELOG
    CHANGED
    
    | 
         @@ -1,3 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            19/9/2011 version 0.9.6
         
     | 
| 
      
 2 
     | 
    
         
            +
            * restored previous behavior of command-line switches (allowing "-rfilename")
         
     | 
| 
      
 3 
     | 
    
         
            +
            * removed -p option (--play) from edit command
         
     | 
| 
      
 4 
     | 
    
         
            +
            * `edit` with no arguments now edits the current or most recent expression
         
     | 
| 
      
 5 
     | 
    
         
            +
            * `edit` auto-reloads .rb files (need to specify -n to suppress)
         
     | 
| 
      
 6 
     | 
    
         
            +
            * added -p option (--patch) to edit-method command, which allows
         
     | 
| 
      
 7 
     | 
    
         
            +
                monkeypatching methods without touching the original file
         
     | 
| 
      
 8 
     | 
    
         
            +
            * edit-method can now edit REPL-defined methods
         
     | 
| 
      
 9 
     | 
    
         
            +
            * cat --ex now works on exceptions in REPL-defined code
         
     | 
| 
      
 10 
     | 
    
         
            +
            * play -m now uses eval_string.replace()
         
     | 
| 
      
 11 
     | 
    
         
            +
            * play -m --open uses show-input to show play'd code
         
     | 
| 
      
 12 
     | 
    
         
            +
            * added "unindent" helper to make adding help to commands easier
         
     | 
| 
      
 13 
     | 
    
         
            +
            * local ./.pryrc now loaded after ~/.pryrc if it exists
         
     | 
| 
      
 14 
     | 
    
         
            +
            * cat --ex N and edit --ex N now can navigate through backtrace, where cat --ex (with no args) moves throuh successive levels of the backtrace automatically with state stored on the exceptino object itself
         
     | 
| 
      
 15 
     | 
    
         
            +
            * new option Pry.config.exception_window_size determines window size for cat --ex
         
     | 
| 
      
 16 
     | 
    
         
            +
            * input_stack now implemented - pushing objects onto a pry instance's input_stack causes the instance to read from those objects in turn as it encounters EOF on the previous object. On finishing the input_stack the input object for the pry instance is set back to Pry.config.input, if this fails, pry breaks out of the REPL (throw(:breakout)) with an error message
         
     | 
| 
      
 17 
     | 
    
         
            +
            * Pry.config.system() defines how pry runs system commands
         
     | 
| 
      
 18 
     | 
    
         
            +
            * now injecting target_self method into command scope
         
     | 
| 
      
 19 
     | 
    
         
            +
            * play now performs 'show-input' always unless eval_string contains a valid expression (i.e it's about to be eval'd)
         
     | 
| 
      
 20 
     | 
    
         
            +
            * play and hist --replay now push the current input object onto the input_stack before redirecting input to a StringIO (works much better with pry-remote now)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       1 
22 
     | 
    
         
             
            8/9/2011 version 0.9.5
         
     | 
| 
       2 
23 
     | 
    
         | 
| 
       3 
24 
     | 
    
         
             
            MAJOR NEW FEATURES:
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/README.markdown
    CHANGED
    
    | 
         @@ -1,16 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <center>
         
     | 
| 
       1 
2 
     | 
    
         
             
            
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            (C) John Mair (banisterfiend) 2011
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            _Get to the code_
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            ** 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            **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!
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            **Sponsors**
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            [Atomic Object](http://www.atomicobject.com/)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            **Other Resources**
         
     | 
| 
       11 
14 
     | 
    
         | 
| 
       12 
15 
     | 
    
         
             
            [Skip to the website (recommended)](http://pry.github.com) <br />
         
     | 
| 
       13 
16 
     | 
    
         
             
            [Skip to the wiki](https://github.com/pry/pry/wiki)
         
     | 
| 
      
 17 
     | 
    
         
            +
            </center>
         
     | 
| 
       14 
18 
     | 
    
         | 
| 
       15 
19 
     | 
    
         
             
            Pry is a powerful alternative to the standard IRB shell for Ruby. It is
         
     | 
| 
       16 
20 
     | 
    
         
             
            written from scratch to provide a number of advanced features, some of
         
     | 
| 
         @@ -28,11 +32,11 @@ these include: 
     | 
|
| 
       28 
32 
     | 
    
         
             
            * Exotic object support (BasicObject instances, IClasses, ...)
         
     | 
| 
       29 
33 
     | 
    
         
             
            * A Powerful and flexible command system
         
     | 
| 
       30 
34 
     | 
    
         
             
            * Ability to view and replay history
         
     | 
| 
       31 
     | 
    
         
            -
            * Many convenience commands inspired by IPython and other advanced REPLs
         
     | 
| 
      
 35 
     | 
    
         
            +
            * Many convenience commands inspired by IPython, Smalltalk and other advanced REPLs
         
     | 
| 
       32 
36 
     | 
    
         | 
| 
       33 
37 
     | 
    
         
             
            Pry also aims to be more than an IRB replacement; it is an
         
     | 
| 
       34 
38 
     | 
    
         
             
            attempt to bring REPL driven programming to the Ruby language. It is
         
     | 
| 
       35 
     | 
    
         
            -
            currently not  
     | 
| 
      
 39 
     | 
    
         
            +
            currently not as powerful as tools like [SLIME](http://en.wikipedia.org/wiki/SLIME) for lisp, but that is the
         
     | 
| 
       36 
40 
     | 
    
         
             
            general direction Pry is heading.
         
     | 
| 
       37 
41 
     | 
    
         | 
| 
       38 
42 
     | 
    
         
             
            Pry is also fairly flexible and allows significant user
         
     | 
| 
         @@ -352,14 +356,12 @@ avaiable. 
     | 
|
| 
       352 
356 
     | 
    
         | 
| 
       353 
357 
     | 
    
         
             
            ### Use Pry as your Rails Console
         
     | 
| 
       354 
358 
     | 
    
         | 
| 
       355 
     | 
    
         
            -
                pry -r./config/environment
         
     | 
| 
      
 359 
     | 
    
         
            +
                pry -r ./config/environment
         
     | 
| 
       356 
360 
     | 
    
         | 
| 
       357 
361 
     | 
    
         
             
            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.
         
     | 
| 
       358 
362 
     | 
    
         | 
| 
       359 
363 
     | 
    
         
             
            ### Limitations:
         
     | 
| 
       360 
364 
     | 
    
         | 
| 
       361 
     | 
    
         
            -
            * JRuby not officially supported due to currently too many quirks and
         
     | 
| 
       362 
     | 
    
         
            -
             strange behaviour. This will be fixed soon.
         
     | 
| 
       363 
365 
     | 
    
         
             
            * Tab completion is currently a bit broken/limited this will have a
         
     | 
| 
       364 
366 
     | 
    
         
             
              major overhaul in a future version.
         
     | 
| 
       365 
367 
     | 
    
         | 
| 
         @@ -376,7 +378,6 @@ Many new features are planned such as: 
     | 
|
| 
       376 
378 
     | 
    
         | 
| 
       377 
379 
     | 
    
         
             
            * Increase modularity (rely more on plugin system)
         
     | 
| 
       378 
380 
     | 
    
         
             
            * Much improved tab completion (using [Bond](http://github.com/cldwalker/bond))
         
     | 
| 
       379 
     | 
    
         
            -
            * Improved JRuby support
         
     | 
| 
       380 
381 
     | 
    
         
             
            * Much improved documentation system, better support for YARD
         
     | 
| 
       381 
382 
     | 
    
         
             
            * Better support for code and method reloading and saving code
         
     | 
| 
       382 
383 
     | 
    
         
             
            * Extended and more sophisticated command system, allowing piping
         
     | 
| 
         @@ -388,9 +389,6 @@ Problems or questions contact me at [github](http://github.com/banister) 
     | 
|
| 
       388 
389 
     | 
    
         | 
| 
       389 
390 
     | 
    
         
             
            ### Contributors
         
     | 
| 
       390 
391 
     | 
    
         | 
| 
       391 
     | 
    
         
            -
             
     | 
| 
       392 
     | 
    
         
            -
             
     | 
| 
       393 
     | 
    
         
            -
             
     | 
| 
       394 
     | 
    
         
            -
            * [Rob Gleeson](https://github.com/robgleeson)
         
     | 
| 
       395 
     | 
    
         
            -
            * [Mon_Ouie](http://github.com/mon-ouie)
         
     | 
| 
       396 
     | 
    
         
            -
            * [injekt](http://github.com/injekt)
         
     | 
| 
      
 392 
     | 
    
         
            +
            Pry is primarily the work of [John Mair (banisterfiend)]((http://github.com/banister)), for full list
         
     | 
| 
      
 393 
     | 
    
         
            +
            of contributors see the
         
     | 
| 
      
 394 
     | 
    
         
            +
            [CONTRIBUTORS](https://github.com/pry/pry/blob/master/CONTRIBUTORS) file.
         
     | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/bin/pry
    CHANGED
    
    | 
         @@ -12,7 +12,7 @@ rescue LoadError 
     | 
|
| 
       12 
12 
     | 
    
         
             
              require 'pry'
         
     | 
| 
       13 
13 
     | 
    
         
             
            end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
            opts = Slop.parse(:help => true) do
         
     | 
| 
      
 15 
     | 
    
         
            +
            opts = Slop.parse(:help => true, :multiple_switches => false) do
         
     | 
| 
       16 
16 
     | 
    
         
             
              banner %{Usage: pry [OPTIONS]
         
     | 
| 
       17 
17 
     | 
    
         
             
            Start a Pry session.
         
     | 
| 
       18 
18 
     | 
    
         
             
            See: `https://github.com/banister` for more information.
         
     | 
| 
         @@ -80,10 +80,12 @@ Pry.cli = true 
     | 
|
| 
       80 
80 
     | 
    
         
             
            # create the actual context
         
     | 
| 
       81 
81 
     | 
    
         
             
            context = Pry.binding_for(eval(opts[:context]))
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
      
 83 
     | 
    
         
            +
            if opts[:exec]
         
     | 
| 
      
 84 
     | 
    
         
            +
              exec_string = opts[:exec] + "\n"
         
     | 
| 
      
 85 
     | 
    
         
            +
            else
         
     | 
| 
      
 86 
     | 
    
         
            +
              exec_string = ""
         
     | 
| 
       86 
87 
     | 
    
         
             
            end
         
     | 
| 
       87 
88 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
            #  
     | 
| 
       89 
     | 
    
         
            -
            context. 
     | 
| 
      
 89 
     | 
    
         
            +
            # Start the session (running any code passed with -e, if there is any)
         
     | 
| 
      
 90 
     | 
    
         
            +
            Pry.start(context, :input => StringIO.new(exec_string), :input_stack => [Readline])
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
         @@ -14,7 +14,7 @@ class MyCommands < Pry::CommandBase 
     | 
|
| 
       14 
14 
     | 
    
         
             
              import_from Pry::Commands, "status"
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              # analogy to Ruby's native alias_method idiom for decorating a method
         
     | 
| 
       17 
     | 
    
         
            -
              alias_command "old_status", "status" 
     | 
| 
      
 17 
     | 
    
         
            +
              alias_command "old_status", "status"
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              # Invoke one command from within another using `run`
         
     | 
| 
       20 
20 
     | 
    
         
             
              command "status", "Modified status."  do |x|
         
     | 
    
        data/lib/pry.rb
    CHANGED
    
    | 
         @@ -21,7 +21,7 @@ class Pry 
     | 
|
| 
       21 
21 
     | 
    
         
             
              DEFAULT_PRINT = proc do |output, value|
         
     | 
| 
       22 
22 
     | 
    
         
             
                stringified = begin
         
     | 
| 
       23 
23 
     | 
    
         
             
                                value.pretty_inspect
         
     | 
| 
       24 
     | 
    
         
            -
                              rescue RescuableException 
     | 
| 
      
 24 
     | 
    
         
            +
                              rescue RescuableException
         
     | 
| 
       25 
25 
     | 
    
         
             
                                nil
         
     | 
| 
       26 
26 
     | 
    
         
             
                              end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
         @@ -29,7 +29,6 @@ class Pry 
     | 
|
| 
       29 
29 
     | 
    
         
             
                  # Read the class name off of the singleton class to provide a default inspect.
         
     | 
| 
       30 
30 
     | 
    
         
             
                  klass = (class << value; self; end).ancestors.first
         
     | 
| 
       31 
31 
     | 
    
         
             
                  stringified = "#<#{klass}:0x#{value.__id__.to_s(16)}>"
         
     | 
| 
       32 
     | 
    
         
            -
                  Helpers::BaseHelpers.stagger_output("output error: #{ex.inspect}", output) if ex
         
     | 
| 
       33 
32 
     | 
    
         
             
                end
         
     | 
| 
       34 
33 
     | 
    
         | 
| 
       35 
34 
     | 
    
         
             
                Helpers::BaseHelpers.stagger_output("=> #{Helpers::BaseHelpers.colorize_code(stringified)}", output)
         
     | 
| 
         @@ -51,11 +50,14 @@ class Pry 
     | 
|
| 
       51 
50 
     | 
    
         
             
              end
         
     | 
| 
       52 
51 
     | 
    
         | 
| 
       53 
52 
     | 
    
         
             
              # Will only show the first line of the backtrace
         
     | 
| 
       54 
     | 
    
         
            -
              DEFAULT_EXCEPTION_HANDLER = proc do |output, exception|
         
     | 
| 
      
 53 
     | 
    
         
            +
              DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _|
         
     | 
| 
       55 
54 
     | 
    
         
             
                output.puts "#{exception.class}: #{exception.message}"
         
     | 
| 
       56 
55 
     | 
    
         
             
                output.puts "from #{exception.backtrace.first}"
         
     | 
| 
       57 
56 
     | 
    
         
             
              end
         
     | 
| 
       58 
57 
     | 
    
         | 
| 
      
 58 
     | 
    
         
            +
              # Don't catch these exceptions
         
     | 
| 
      
 59 
     | 
    
         
            +
              DEFAULT_EXCEPTION_WHITELIST = [SystemExit, SignalException]
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
       59 
61 
     | 
    
         
             
              # The default prompt; includes the target and nesting level
         
     | 
| 
       60 
62 
     | 
    
         
             
              DEFAULT_PROMPT = [
         
     | 
| 
       61 
63 
     | 
    
         
             
                                proc { |target_self, nest_level, _|
         
     | 
| 
         @@ -115,6 +117,11 @@ class Pry 
     | 
|
| 
       115 
117 
     | 
    
         
             
                            end,
         
     | 
| 
       116 
118 
     | 
    
         
             
                           ]
         
     | 
| 
       117 
119 
     | 
    
         | 
| 
      
 120 
     | 
    
         
            +
              DEFAULT_SYSTEM = proc do |output, cmd, _|
         
     | 
| 
      
 121 
     | 
    
         
            +
                if !system(cmd)
         
     | 
| 
      
 122 
     | 
    
         
            +
                  output.puts "Error: there was a problem executing system command: #{cmd}"
         
     | 
| 
      
 123 
     | 
    
         
            +
                end
         
     | 
| 
      
 124 
     | 
    
         
            +
              end
         
     | 
| 
       118 
125 
     | 
    
         | 
| 
       119 
126 
     | 
    
         
             
              # As a REPL, we often want to catch any unexpected exceptions that may have
         
     | 
| 
       120 
127 
     | 
    
         
             
              # been raised; however we don't want to go overboard and prevent the user
         
     | 
| 
         @@ -128,7 +135,7 @@ class Pry 
     | 
|
| 
       128 
135 
     | 
    
         
             
                    true
         
     | 
| 
       129 
136 
     | 
    
         
             
                    # Don't catch signals (particularly not SIGTERM) as these are unlikely to be
         
     | 
| 
       130 
137 
     | 
    
         
             
                    # intended for pry itself. We should also make sure that Kernel#exit works.
         
     | 
| 
       131 
     | 
    
         
            -
                  when  
     | 
| 
      
 138 
     | 
    
         
            +
                  when *Pry.config.exception_whitelist
         
     | 
| 
       132 
139 
     | 
    
         
             
                    false
         
     | 
| 
       133 
140 
     | 
    
         
             
                    # All other exceptions will be caught.
         
     | 
| 
       134 
141 
     | 
    
         
             
                  else
         
     | 
| 
         @@ -148,6 +155,14 @@ require "optparse" 
     | 
|
| 
       148 
155 
     | 
    
         
             
            require "slop"
         
     | 
| 
       149 
156 
     | 
    
         
             
            require "rubygems/dependency_installer"
         
     | 
| 
       150 
157 
     | 
    
         | 
| 
      
 158 
     | 
    
         
            +
            if RUBY_PLATFORM =~ /jruby/
         
     | 
| 
      
 159 
     | 
    
         
            +
              begin
         
     | 
| 
      
 160 
     | 
    
         
            +
                require 'ffi'
         
     | 
| 
      
 161 
     | 
    
         
            +
              rescue LoadError
         
     | 
| 
      
 162 
     | 
    
         
            +
                $stderr.puts "Need to `gem install ffi`"
         
     | 
| 
      
 163 
     | 
    
         
            +
              end
         
     | 
| 
      
 164 
     | 
    
         
            +
            end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
       151 
166 
     | 
    
         
             
            if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
         
     | 
| 
       152 
167 
     | 
    
         
             
              begin
         
     | 
| 
       153 
168 
     | 
    
         
             
                require 'win32console'
         
     | 
    
        data/lib/pry/command_context.rb
    CHANGED
    
    
| 
         @@ -154,6 +154,7 @@ class Pry 
     | 
|
| 
       154 
154 
     | 
    
         
             
                  # set some useful methods to be used by the action blocks
         
     | 
| 
       155 
155 
     | 
    
         
             
                  context.opts        = options
         
     | 
| 
       156 
156 
     | 
    
         
             
                  context.target      = target
         
     | 
| 
      
 157 
     | 
    
         
            +
                  context.target_self = target.eval('self')
         
     | 
| 
       157 
158 
     | 
    
         
             
                  context.output      = output
         
     | 
| 
       158 
159 
     | 
    
         
             
                  context.captures    = options[:captures]
         
     | 
| 
       159 
160 
     | 
    
         
             
                  context.eval_string = options[:eval_string]
         
     | 
    
        data/lib/pry/command_set.rb
    CHANGED
    
    | 
         @@ -168,10 +168,10 @@ class Pry 
     | 
|
| 
       168 
168 
     | 
    
         
             
                # @param [String] new_name New name of the command.
         
     | 
| 
       169 
169 
     | 
    
         
             
                # @param [String] old_name Old name of the command.
         
     | 
| 
       170 
170 
     | 
    
         
             
                # @param [String, nil] desc New description of the command.
         
     | 
| 
       171 
     | 
    
         
            -
                def alias_command(new_name, old_name, desc 
     | 
| 
      
 171 
     | 
    
         
            +
                def alias_command(new_name, old_name, desc="")
         
     | 
| 
       172 
172 
     | 
    
         
             
                  commands[new_name] = commands[old_name].dup
         
     | 
| 
       173 
173 
     | 
    
         
             
                  commands[new_name].name = new_name
         
     | 
| 
       174 
     | 
    
         
            -
                  commands[new_name].description = desc 
     | 
| 
      
 174 
     | 
    
         
            +
                  commands[new_name].description = desc
         
     | 
| 
       175 
175 
     | 
    
         
             
                end
         
     | 
| 
       176 
176 
     | 
    
         | 
| 
       177 
177 
     | 
    
         
             
                # Runs a command.
         
     | 
    
        data/lib/pry/config.rb
    CHANGED
    
    | 
         @@ -29,6 +29,9 @@ class Pry 
     | 
|
| 
       29 
29 
     | 
    
         
             
                #   Pry instances.
         
     | 
| 
       30 
30 
     | 
    
         
             
                attr_accessor :exception_handler
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
      
 32 
     | 
    
         
            +
                # @return [Array] The classes of exception that will not be caught by Pry.
         
     | 
| 
      
 33 
     | 
    
         
            +
                attr_accessor :exception_whitelist
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       32 
35 
     | 
    
         
             
                # Get/Set the Hash that defines Pry hooks used by default by all Pry
         
     | 
| 
       33 
36 
     | 
    
         
             
                # instances.
         
     | 
| 
       34 
37 
     | 
    
         
             
                # @return [Hash] The hooks used by default by all Pry instances.
         
     | 
| 
         @@ -37,6 +40,13 @@ class Pry 
     | 
|
| 
       37 
40 
     | 
    
         
             
                #     :after_session => proc { puts "goodbye" }
         
     | 
| 
       38 
41 
     | 
    
         
             
                attr_accessor :hooks
         
     | 
| 
       39 
42 
     | 
    
         | 
| 
      
 43 
     | 
    
         
            +
                # Get/Set the stack of input objects that a Pry instance switches
         
     | 
| 
      
 44 
     | 
    
         
            +
                # to when its current input object encounters EOF.
         
     | 
| 
      
 45 
     | 
    
         
            +
                # @return [Array] The array of input objects.
         
     | 
| 
      
 46 
     | 
    
         
            +
                # @example
         
     | 
| 
      
 47 
     | 
    
         
            +
                #   Pry.config.input_stack = [StringIO.new("puts 'hello world'\nexit")]
         
     | 
| 
      
 48 
     | 
    
         
            +
                attr_accessor :input_stack
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       40 
50 
     | 
    
         
             
                # Get the array of Procs to be used for the prompts by default by
         
     | 
| 
       41 
51 
     | 
    
         
             
                # all Pry instances.
         
     | 
| 
       42 
52 
     | 
    
         
             
                # @return [Array<Proc>] The array of Procs to be used for the
         
     | 
| 
         @@ -111,6 +121,11 @@ class Pry 
     | 
|
| 
       111 
121 
     | 
    
         
             
                # @return [Proc] The proc that manages ^D presses in the REPL.
         
     | 
| 
       112 
122 
     | 
    
         
             
                #   The proc is passed the current eval_string and the current pry instance.
         
     | 
| 
       113 
123 
     | 
    
         
             
                attr_accessor :control_d_handler
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                # @return [Proc] The proc that runs system commands
         
     | 
| 
      
 126 
     | 
    
         
            +
                #   The proc is passed the pry output object, the command string
         
     | 
| 
      
 127 
     | 
    
         
            +
                #   to eval, and a reference to the pry instance
         
     | 
| 
      
 128 
     | 
    
         
            +
                attr_accessor :system
         
     | 
| 
       114 
129 
     | 
    
         
             
              end
         
     | 
| 
       115 
130 
     | 
    
         
             
            end
         
     | 
| 
       116 
131 
     | 
    
         | 
| 
         @@ -91,7 +91,7 @@ class Pry 
     | 
|
| 
       91 
91 
     | 
    
         
             
                    throw(:breakout, target.eval(arg_string))
         
     | 
| 
       92 
92 
     | 
    
         
             
                  end
         
     | 
| 
       93 
93 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
                  alias_command "!!@", "exit-all" 
     | 
| 
      
 94 
     | 
    
         
            +
                  alias_command "!!@", "exit-all"
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
       96 
96 
     | 
    
         
             
                  command "exit", "Pop the current binding and return to the one immediately prior. Note this does NOT exit the program. Aliases: quit", :keep_retval => true do
         
     | 
| 
       97 
97 
     | 
    
         
             
                    if _pry_.binding_stack.one?
         
     | 
| 
         @@ -111,15 +111,15 @@ class Pry 
     | 
|
| 
       111 
111 
     | 
    
         
             
                    end
         
     | 
| 
       112 
112 
     | 
    
         
             
                  end
         
     | 
| 
       113 
113 
     | 
    
         | 
| 
       114 
     | 
    
         
            -
                  alias_command "quit", "exit" 
     | 
| 
      
 114 
     | 
    
         
            +
                  alias_command "quit", "exit"
         
     | 
| 
       115 
115 
     | 
    
         | 
| 
       116 
116 
     | 
    
         
             
                  command "exit-program", "End the current program. Aliases: quit-program, !!!" do
         
     | 
| 
       117 
117 
     | 
    
         
             
                    Pry.save_history if Pry.config.history.should_save
         
     | 
| 
       118 
118 
     | 
    
         
             
                    Kernel.exit target.eval(arg_string).to_i
         
     | 
| 
       119 
119 
     | 
    
         
             
                  end
         
     | 
| 
       120 
120 
     | 
    
         | 
| 
       121 
     | 
    
         
            -
                  alias_command "quit-program", "exit-program" 
     | 
| 
       122 
     | 
    
         
            -
                  alias_command "!!!", "exit-program" 
     | 
| 
      
 121 
     | 
    
         
            +
                  alias_command "quit-program", "exit-program"
         
     | 
| 
      
 122 
     | 
    
         
            +
                  alias_command "!!!", "exit-program"
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
       124 
124 
     | 
    
         
             
                  command "!pry", "Start a Pry session on current self; this even works mid multi-line expression." do
         
     | 
| 
       125 
125 
     | 
    
         
             
                    target.pry
         
     | 
| 
         @@ -147,6 +147,10 @@ class Pry 
     | 
|
| 
       147 
147 
     | 
    
         
             
                    set_file_and_dir_locals(file)
         
     | 
| 
       148 
148 
     | 
    
         
             
                    output.puts "\n#{text.bold('From:')} #{file} @ line #{line_num} in #{klass}##{meth_name}:\n\n"
         
     | 
| 
       149 
149 
     | 
    
         | 
| 
      
 150 
     | 
    
         
            +
                    unless File.readable?(file)
         
     | 
| 
      
 151 
     | 
    
         
            +
                      output.puts "Cannot open #{file.inspect} for reading."
         
     | 
| 
      
 152 
     | 
    
         
            +
                      next
         
     | 
| 
      
 153 
     | 
    
         
            +
                    end
         
     | 
| 
       150 
154 
     | 
    
         | 
| 
       151 
155 
     | 
    
         
             
                    # This method inspired by http://rubygems.org/gems/ir_b
         
     | 
| 
       152 
156 
     | 
    
         
             
                    File.open(file).each_with_index do |line, index|
         
     | 
| 
         @@ -11,9 +11,11 @@ class Pry 
     | 
|
| 
       11 
11 
     | 
    
         
             
                    target = target()
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                    opts = Slop.parse!(args) do |opt|
         
     | 
| 
       14 
     | 
    
         
            -
                      opt.banner  
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
                      opt.banner unindent <<-USAGE
         
     | 
| 
      
 15 
     | 
    
         
            +
                        Usage: show-doc [OPTIONS] [METH 1] [METH 2] [METH N]
         
     | 
| 
      
 16 
     | 
    
         
            +
                        Show the comments above method METH. Tries instance methods first and then methods by default.
         
     | 
| 
      
 17 
     | 
    
         
            +
                        e.g show-doc hello_method
         
     | 
| 
      
 18 
     | 
    
         
            +
                      USAGE
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
                      opt.on :M, "instance-methods", "Operate on instance methods."
         
     | 
| 
       19 
21 
     | 
    
         
             
                      opt.on :m, :methods, "Operate on methods."
         
     | 
| 
         @@ -50,15 +52,17 @@ class Pry 
     | 
|
| 
       50 
52 
     | 
    
         
             
                    end
         
     | 
| 
       51 
53 
     | 
    
         
             
                  end
         
     | 
| 
       52 
54 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                  alias_command "?", "show-doc" 
     | 
| 
      
 55 
     | 
    
         
            +
                  alias_command "?", "show-doc"
         
     | 
| 
       54 
56 
     | 
    
         | 
| 
       55 
57 
     | 
    
         
             
                  command "stat", "View method information and set _file_ and _dir_ locals. Type `stat --help` for more info." do |*args|
         
     | 
| 
       56 
58 
     | 
    
         
             
                    target = target()
         
     | 
| 
       57 
59 
     | 
    
         | 
| 
       58 
60 
     | 
    
         
             
                    opts = Slop.parse!(args) do |opt|
         
     | 
| 
       59 
     | 
    
         
            -
                      opt.banner  
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
                      opt.banner unindent <<-USAGE
         
     | 
| 
      
 62 
     | 
    
         
            +
                        Usage: stat [OPTIONS] [METH]
         
     | 
| 
      
 63 
     | 
    
         
            +
                        Show method information for method METH and set _file_ and _dir_ locals.
         
     | 
| 
      
 64 
     | 
    
         
            +
                        e.g: stat hello_method
         
     | 
| 
      
 65 
     | 
    
         
            +
                      USAGE
         
     | 
| 
       62 
66 
     | 
    
         | 
| 
       63 
67 
     | 
    
         
             
                      opt.on :M, "instance-methods", "Operate on instance methods."
         
     | 
| 
       64 
68 
     | 
    
         
             
                      opt.on :m, :methods, "Operate on methods."
         
     | 
| 
         @@ -100,11 +104,13 @@ class Pry 
     | 
|
| 
       100 
104 
     | 
    
         
             
                    target = target()
         
     | 
| 
       101 
105 
     | 
    
         | 
| 
       102 
106 
     | 
    
         
             
                    opts = Slop.parse!(args) do |opt|
         
     | 
| 
       103 
     | 
    
         
            -
                      opt.banner  
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
      
 107 
     | 
    
         
            +
                      opt.banner unindent <<-USAGE
         
     | 
| 
      
 108 
     | 
    
         
            +
                        Usage: gist-method [OPTIONS] [METH]
         
     | 
| 
      
 109 
     | 
    
         
            +
                        Gist the method (doc or source) to github.
         
     | 
| 
      
 110 
     | 
    
         
            +
                        Ensure the `gist` gem is properly working before use. http://github.com/defunkt/gist for instructions.
         
     | 
| 
      
 111 
     | 
    
         
            +
                        e.g: gist -m my_method
         
     | 
| 
      
 112 
     | 
    
         
            +
                        e.g: gist -d my_method
         
     | 
| 
      
 113 
     | 
    
         
            +
                      USAGE
         
     | 
| 
       108 
114 
     | 
    
         | 
| 
       109 
115 
     | 
    
         
             
                      opt.on :m, :method, "Gist a method's source."
         
     | 
| 
       110 
116 
     | 
    
         
             
                      opt.on :d, :doc, "Gist a method's documentation."
         
     | 
| 
         @@ -17,14 +17,16 @@ class Pry 
     | 
|
| 
       17 
17 
     | 
    
         
             
                    start_line_number, end_line_number, replacement_line = *args
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                    opts = Slop.parse!(args.compact) do |opt|
         
     | 
| 
       20 
     | 
    
         
            -
                      opt.banner  
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            e.g amend-line 1 
     | 
| 
       25 
     | 
    
         
            -
            e.g amend-line  
     | 
| 
       26 
     | 
    
         
            -
            e.g amend-line puts ' 
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
                      opt.banner unindent <<-USAGE
         
     | 
| 
      
 21 
     | 
    
         
            +
                        Amend a line of input in multi-line mode. `amend-line N`, where the N in `amend-line N` represents line to replace.
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                        Can also specify a range of lines using `amend-line N..M` syntax. Passing '!' as replacement content deletes the line(s) instead. Aliases: %N
         
     | 
| 
      
 24 
     | 
    
         
            +
                        e.g amend-line 1 puts 'hello world! # replace line 1'
         
     | 
| 
      
 25 
     | 
    
         
            +
                        e.g amend-line 1..4 !               # delete lines 1..4
         
     | 
| 
      
 26 
     | 
    
         
            +
                        e.g amend-line 3 >puts 'goodbye'    # insert before line 3
         
     | 
| 
      
 27 
     | 
    
         
            +
                        e.g amend-line puts 'hello again'   # no line number modifies immediately preceding line
         
     | 
| 
      
 28 
     | 
    
         
            +
                      USAGE
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       28 
30 
     | 
    
         
             
                      opt.on :h, :help, "This message." do
         
     | 
| 
       29 
31 
     | 
    
         
             
                        output.puts opt
         
     | 
| 
       30 
32 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -52,11 +54,17 @@ e.g amend-line puts 'hello again'   # no line number modifies immediately preced 
     | 
|
| 
       52 
54 
     | 
    
         
             
                    run "show-input"
         
     | 
| 
       53 
55 
     | 
    
         
             
                  end
         
     | 
| 
       54 
56 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
                  alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?) 
     | 
| 
      
 57 
     | 
    
         
            +
                  alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/)
         
     | 
| 
       56 
58 
     | 
    
         | 
| 
       57 
59 
     | 
    
         
             
                  command "play", "Play back a string variable or a method or a file as input. Type `play --help` for more information." do |*args|
         
     | 
| 
       58 
60 
     | 
    
         
             
                    opts = Slop.parse!(args) do |opt|
         
     | 
| 
       59 
     | 
    
         
            -
                      opt.banner  
     | 
| 
      
 61 
     | 
    
         
            +
                      opt.banner unindent <<-USAGE
         
     | 
| 
      
 62 
     | 
    
         
            +
                        Usage: play [OPTIONS] [--help]
         
     | 
| 
      
 63 
     | 
    
         
            +
                        Default action (no options) is to play the provided string variable
         
     | 
| 
      
 64 
     | 
    
         
            +
                        e.g `play _in_[20] --lines 1..3`
         
     | 
| 
      
 65 
     | 
    
         
            +
                        e.g `play -m Pry#repl --lines 1..-1`
         
     | 
| 
      
 66 
     | 
    
         
            +
                        e.g `play -f Rakefile --lines 5`
         
     | 
| 
      
 67 
     | 
    
         
            +
                      USAGE
         
     | 
| 
       60 
68 
     | 
    
         | 
| 
       61 
69 
     | 
    
         
             
                      opt.on :l, :lines, 'The line (or range of lines) to replay.', true, :as => Range
         
     | 
| 
       62 
70 
     | 
    
         
             
                      opt.on :m, :method, 'Play a method.', true
         
     | 
| 
         @@ -79,7 +87,7 @@ e.g amend-line puts 'hello again'   # no line number modifies immediately preced 
     | 
|
| 
       79 
87 
     | 
    
         
             
                      range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
         
     | 
| 
       80 
88 
     | 
    
         
             
                      range = (0..-2) if opts.o?
         
     | 
| 
       81 
89 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
                       
     | 
| 
      
 90 
     | 
    
         
            +
                      eval_string << Array(code.each_line.to_a[range]).join
         
     | 
| 
       83 
91 
     | 
    
         
             
                    elsif opts.f?
         
     | 
| 
       84 
92 
     | 
    
         
             
                      file_name = File.expand_path(opts[:f])
         
     | 
| 
       85 
93 
     | 
    
         
             
                      next output.puts "No such file: #{opts[:f]}" if !File.exists?(file_name)
         
     | 
| 
         @@ -87,6 +95,7 @@ e.g amend-line puts 'hello again'   # no line number modifies immediately preced 
     | 
|
| 
       87 
95 
     | 
    
         
             
                      range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
         
     | 
| 
       88 
96 
     | 
    
         
             
                      range = (0..-2) if opts.o?
         
     | 
| 
       89 
97 
     | 
    
         | 
| 
      
 98 
     | 
    
         
            +
                      _pry_.input_stack << _pry_.input
         
     | 
| 
       90 
99 
     | 
    
         
             
                      _pry_.input = StringIO.new(Array(text_array[range]).join)
         
     | 
| 
       91 
100 
     | 
    
         
             
                    else
         
     | 
| 
       92 
101 
     | 
    
         
             
                      next output.puts "Error: no input to play command" if !args.first
         
     | 
| 
         @@ -97,6 +106,8 @@ e.g amend-line puts 'hello again'   # no line number modifies immediately preced 
     | 
|
| 
       97 
106 
     | 
    
         | 
| 
       98 
107 
     | 
    
         
             
                      eval_string << Array(code.each_line.to_a[range]).join
         
     | 
| 
       99 
108 
     | 
    
         
             
                    end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                    run "show-input" if !_pry_.valid_expression?(eval_string)
         
     | 
| 
       100 
111 
     | 
    
         
             
                  end
         
     | 
| 
       101 
112 
     | 
    
         | 
| 
       102 
113 
     | 
    
         
             
                  command "hist", "Show and replay Readline history. Type `hist --help` for more info. Aliases: history" do |*args|
         
     | 
| 
         @@ -106,86 +117,121 @@ e.g amend-line puts 'hello again'   # no line number modifies immediately preced 
     | 
|
| 
       106 
117 
     | 
    
         
             
                    opts = Slop.parse!(args) do |opt|
         
     | 
| 
       107 
118 
     | 
    
         
             
                      opt.banner "Usage: hist [--replay START..END] [--clear] [--grep PATTERN] [--head N] [--tail N] [--help] [--save [START..END] file.txt]\n"
         
     | 
| 
       108 
119 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
                      opt.on : 
     | 
| 
       110 
     | 
    
         
            -
                        pattern = Regexp.new arg_string.strip.split(/ /, 2).last.strip
         
     | 
| 
       111 
     | 
    
         
            -
                        history.pop
         
     | 
| 
      
 120 
     | 
    
         
            +
                      opt.on :n, 'no-numbers', 'Omit line numbers.'
         
     | 
| 
       112 
121 
     | 
    
         | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                          if element =~ pattern
         
     | 
| 
       115 
     | 
    
         
            -
                            "#{text.blue index}: #{element}"
         
     | 
| 
       116 
     | 
    
         
            -
                          end
         
     | 
| 
       117 
     | 
    
         
            -
                        end
         
     | 
| 
      
 122 
     | 
    
         
            +
                      opt.on :g, :grep, 'A pattern to match against the history.', true
         
     | 
| 
       118 
123 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
      
 124 
     | 
    
         
            +
                      opt.on :head, 'Display the first N items of history.',
         
     | 
| 
      
 125 
     | 
    
         
            +
                             :optional => true,
         
     | 
| 
      
 126 
     | 
    
         
            +
                             :as       => Integer
         
     | 
| 
       121 
127 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
                      opt.on : 
     | 
| 
      
 128 
     | 
    
         
            +
                      opt.on :t, :tail, 'Display the last N items of history.',
         
     | 
| 
       123 
129 
     | 
    
         
             
                             :optional => true,
         
     | 
| 
       124 
     | 
    
         
            -
                             :as       => Integer 
     | 
| 
       125 
     | 
    
         
            -
                             :unless   => :grep do |limit|
         
     | 
| 
      
 130 
     | 
    
         
            +
                             :as       => Integer
         
     | 
| 
       126 
131 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
                        stagger_output lines
         
     | 
| 
       131 
     | 
    
         
            -
                      end
         
     | 
| 
      
 132 
     | 
    
         
            +
                      opt.on :s, :show, 'Show the history corresponding to the history line (or range of lines).',
         
     | 
| 
      
 133 
     | 
    
         
            +
                             :optional => true,
         
     | 
| 
      
 134 
     | 
    
         
            +
                             :as       => Range
         
     | 
| 
       132 
135 
     | 
    
         | 
| 
       133 
     | 
    
         
            -
                      opt.on : 
     | 
| 
       134 
     | 
    
         
            -
                                 :optional => true,
         
     | 
| 
       135 
     | 
    
         
            -
                                 :as       => Integer,
         
     | 
| 
       136 
     | 
    
         
            -
                                 :unless   => :grep do |limit|
         
     | 
| 
      
 136 
     | 
    
         
            +
                      opt.on :e, :exclude, 'Exclude pry commands from the history.'
         
     | 
| 
       137 
137 
     | 
    
         | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
                        offset = offset < 0 ? 0 : offset
         
     | 
| 
      
 138 
     | 
    
         
            +
                      opt.on :r, :replay, 'The line (or range of lines) to replay.', true,
         
     | 
| 
      
 139 
     | 
    
         
            +
                             :as => Range
         
     | 
| 
       141 
140 
     | 
    
         | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
                        stagger_output lines
         
     | 
| 
       145 
     | 
    
         
            -
                      end
         
     | 
| 
      
 141 
     | 
    
         
            +
                      opt.on "save", "Save history to a file. --save [start..end] output.txt. Pry commands are excluded from saved history.", true,
         
     | 
| 
      
 142 
     | 
    
         
            +
                             :as => Range
         
     | 
| 
       146 
143 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
                      opt.on : 
     | 
| 
       148 
     | 
    
         
            -
                             true,
         
     | 
| 
       149 
     | 
    
         
            -
                             :as     => Range,
         
     | 
| 
       150 
     | 
    
         
            -
                             :unless => :grep do |range|
         
     | 
| 
      
 144 
     | 
    
         
            +
                      opt.on :c, :clear, 'Clear the history.', :unless => :grep
         
     | 
| 
       151 
145 
     | 
    
         | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
                         
     | 
| 
       154 
     | 
    
         
            -
                        stagger_output lines
         
     | 
| 
      
 146 
     | 
    
         
            +
                      opt.on :h, :help, 'Show this message.', :tail => true, :unless => :grep do
         
     | 
| 
      
 147 
     | 
    
         
            +
                        output.puts opt.help
         
     | 
| 
       155 
148 
     | 
    
         
             
                      end
         
     | 
| 
      
 149 
     | 
    
         
            +
                    end
         
     | 
| 
      
 150 
     | 
    
         
            +
                    next if opts.help?
         
     | 
| 
       156 
151 
     | 
    
         | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
      
 152 
     | 
    
         
            +
                    if opts.grep?
         
     | 
| 
      
 153 
     | 
    
         
            +
                      pattern = Regexp.new(arg_string.strip.split(/ /, 2).last.strip)
         
     | 
| 
      
 154 
     | 
    
         
            +
                      history.pop
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
                      history.map!.with_index do |element, index|
         
     | 
| 
      
 157 
     | 
    
         
            +
                        if element =~ pattern
         
     | 
| 
      
 158 
     | 
    
         
            +
                          if opts.n?
         
     | 
| 
      
 159 
     | 
    
         
            +
                            element
         
     | 
| 
      
 160 
     | 
    
         
            +
                          else
         
     | 
| 
       160 
161 
     | 
    
         
             
                            "#{text.blue index}: #{element}"
         
     | 
| 
       161 
162 
     | 
    
         
             
                          end
         
     | 
| 
       162 
163 
     | 
    
         
             
                        end
         
     | 
| 
       163 
     | 
    
         
            -
                        stagger_output history.compact.join "\n"
         
     | 
| 
       164 
164 
     | 
    
         
             
                      end
         
     | 
| 
       165 
165 
     | 
    
         | 
| 
       166 
     | 
    
         
            -
                       
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
      
 166 
     | 
    
         
            +
                      stagger_output history.compact.join "\n"
         
     | 
| 
      
 167 
     | 
    
         
            +
                      next
         
     | 
| 
      
 168 
     | 
    
         
            +
                    end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                    if opts.head?
         
     | 
| 
      
 171 
     | 
    
         
            +
                      limit = opts['head'] || 10
         
     | 
| 
      
 172 
     | 
    
         
            +
                      list  = history.first limit
         
     | 
| 
      
 173 
     | 
    
         
            +
                      lines = list.join("\n")
         
     | 
| 
      
 174 
     | 
    
         
            +
                      if opts.n?
         
     | 
| 
      
 175 
     | 
    
         
            +
                        stagger_output lines
         
     | 
| 
      
 176 
     | 
    
         
            +
                      else
         
     | 
| 
      
 177 
     | 
    
         
            +
                        stagger_output text.with_line_numbers(lines, 0)
         
     | 
| 
       172 
178 
     | 
    
         
             
                      end
         
     | 
| 
      
 179 
     | 
    
         
            +
                      next
         
     | 
| 
      
 180 
     | 
    
         
            +
                    end
         
     | 
| 
       173 
181 
     | 
    
         | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
      
 182 
     | 
    
         
            +
                    if opts.tail?
         
     | 
| 
      
 183 
     | 
    
         
            +
                      limit = opts['tail'] || 10
         
     | 
| 
      
 184 
     | 
    
         
            +
                      offset = history.size - limit
         
     | 
| 
      
 185 
     | 
    
         
            +
                      offset = offset < 0 ? 0 : offset
         
     | 
| 
       175 
186 
     | 
    
         | 
| 
       176 
     | 
    
         
            -
                       
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
      
 187 
     | 
    
         
            +
                      list  = history.last limit
         
     | 
| 
      
 188 
     | 
    
         
            +
                      lines = list.join("\n")
         
     | 
| 
      
 189 
     | 
    
         
            +
                      if opts.n?
         
     | 
| 
      
 190 
     | 
    
         
            +
                        stagger_output lines
         
     | 
| 
      
 191 
     | 
    
         
            +
                      else
         
     | 
| 
      
 192 
     | 
    
         
            +
                        stagger_output text.with_line_numbers(lines, offset)
         
     | 
| 
       179 
193 
     | 
    
         
             
                      end
         
     | 
| 
      
 194 
     | 
    
         
            +
                      next
         
     | 
| 
      
 195 
     | 
    
         
            +
                    end
         
     | 
| 
       180 
196 
     | 
    
         | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
      
 197 
     | 
    
         
            +
                    if opts.show?
         
     | 
| 
      
 198 
     | 
    
         
            +
                      range = opts['show']
         
     | 
| 
      
 199 
     | 
    
         
            +
                      start_line = range.is_a?(Range) ? range.first : range
         
     | 
| 
      
 200 
     | 
    
         
            +
                      lines = Array(history[range]).join("\n")
         
     | 
| 
      
 201 
     | 
    
         
            +
                      if opts.n?
         
     | 
| 
      
 202 
     | 
    
         
            +
                        stagger_output lines
         
     | 
| 
      
 203 
     | 
    
         
            +
                      else
         
     | 
| 
      
 204 
     | 
    
         
            +
                        stagger_output text.with_line_numbers(lines, start_line)
         
     | 
| 
       183 
205 
     | 
    
         
             
                      end
         
     | 
| 
      
 206 
     | 
    
         
            +
                      next
         
     | 
| 
      
 207 
     | 
    
         
            +
                    end
         
     | 
| 
       184 
208 
     | 
    
         | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
                         
     | 
| 
      
 209 
     | 
    
         
            +
                    if opts.exclude?
         
     | 
| 
      
 210 
     | 
    
         
            +
                      history.map!.with_index do |element, index|
         
     | 
| 
      
 211 
     | 
    
         
            +
                        unless command_processor.valid_command? element
         
     | 
| 
      
 212 
     | 
    
         
            +
                          if opts.n?
         
     | 
| 
      
 213 
     | 
    
         
            +
                            element
         
     | 
| 
      
 214 
     | 
    
         
            +
                          else
         
     | 
| 
      
 215 
     | 
    
         
            +
                            "#{text.blue index}: #{element}"
         
     | 
| 
      
 216 
     | 
    
         
            +
                          end
         
     | 
| 
      
 217 
     | 
    
         
            +
                        end
         
     | 
| 
       188 
218 
     | 
    
         
             
                      end
         
     | 
| 
      
 219 
     | 
    
         
            +
                      stagger_output history.compact.join "\n"
         
     | 
| 
      
 220 
     | 
    
         
            +
                      next
         
     | 
| 
      
 221 
     | 
    
         
            +
                    end
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                    if opts.replay?
         
     | 
| 
      
 224 
     | 
    
         
            +
                      range = opts['replay']
         
     | 
| 
      
 225 
     | 
    
         
            +
                      actions = Array(history[range]).join("\n") + "\n"
         
     | 
| 
      
 226 
     | 
    
         
            +
                      _pry_.input_stack << _pry_.input
         
     | 
| 
      
 227 
     | 
    
         
            +
                      _pry_.input = StringIO.new(actions)
         
     | 
| 
      
 228 
     | 
    
         
            +
                      next
         
     | 
| 
      
 229 
     | 
    
         
            +
                    end
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
                    if opts.clear?
         
     | 
| 
      
 232 
     | 
    
         
            +
                      Pry.history.clear
         
     | 
| 
      
 233 
     | 
    
         
            +
                      output.puts 'History cleared.'
         
     | 
| 
      
 234 
     | 
    
         
            +
                      next
         
     | 
| 
       189 
235 
     | 
    
         
             
                    end
         
     | 
| 
       190 
236 
     | 
    
         | 
| 
       191 
237 
     | 
    
         
             
                    # FIXME: hack to save history (this must be refactored)
         
     | 
| 
         @@ -214,11 +260,18 @@ e.g amend-line puts 'hello again'   # no line number modifies immediately preced 
     | 
|
| 
       214 
260 
     | 
    
         
             
                      end
         
     | 
| 
       215 
261 
     | 
    
         | 
| 
       216 
262 
     | 
    
         
             
                      output.puts "... history saved."
         
     | 
| 
      
 263 
     | 
    
         
            +
                      next
         
     | 
| 
       217 
264 
     | 
    
         
             
                    end
         
     | 
| 
       218 
265 
     | 
    
         | 
| 
      
 266 
     | 
    
         
            +
                    lines = history.join("\n")
         
     | 
| 
      
 267 
     | 
    
         
            +
                    if opts.n?
         
     | 
| 
      
 268 
     | 
    
         
            +
                      stagger_output lines
         
     | 
| 
      
 269 
     | 
    
         
            +
                    else
         
     | 
| 
      
 270 
     | 
    
         
            +
                      stagger_output text.with_line_numbers(lines, 0)
         
     | 
| 
      
 271 
     | 
    
         
            +
                    end
         
     | 
| 
       219 
272 
     | 
    
         
             
                  end
         
     | 
| 
       220 
273 
     | 
    
         | 
| 
       221 
     | 
    
         
            -
                  alias_command "history", "hist" 
     | 
| 
      
 274 
     | 
    
         
            +
                  alias_command "history", "hist"
         
     | 
| 
       222 
275 
     | 
    
         | 
| 
       223 
276 
     | 
    
         
             
                  helpers do
         
     | 
| 
       224 
277 
     | 
    
         
             
                    def one_index_number(line_number)
         
     |