Sha256: 4111e85474273c4db6ed00a3fe318eebf36e9b0e4c8fc604f35669432560bccb

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

require 'pry'

module PryNav
  Commands = Pry::CommandSet.new do
    block_command 'step', 'Step execution into the next line or method.' do |steps|
      check_file_context
      breakout_navigation :step, steps
    end

    block_command 'next', 'Execute the next line within the same stack frame.' do |lines|
      check_file_context
      breakout_navigation :next, lines
    end

    block_command 'continue', 'Continue program execution and end the Pry session.' do
      check_file_context
      run 'exit-all'
    end

    helpers do
      def breakout_navigation(action, times)
        _pry_.binding_stack.clear     # Clear the binding stack.
        throw :breakout_nav, {        # Break out of the REPL loop and
          :action => action,          #   signal the tracer.
          :times =>  times
        }
      end

      # Ensures that a command is executed in a local file context.
      def check_file_context
        unless PryNav.check_file_context(target)
          raise Pry::CommandError, 'Cannot find local context. Did you use `binding.pry`?'
        end
      end
    end
  end
end

Pry.commands.import PryNav::Commands

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
gameboard-3.1.0 vendor/bundle/ruby/2.3.0/gems/pry-nav-0.2.4/lib/pry-nav/commands.rb
gameboard-3.0.0 vendor/bundle/ruby/2.3.0/gems/pry-nav-0.2.4/lib/pry-nav/commands.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/commands.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/commands.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/commands.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/commands.rb
pry-nav-0.2.4 lib/pry-nav/commands.rb
pry-nav-0.2.3 lib/pry-nav/commands.rb
pry-nav-0.2.2 lib/pry-nav/commands.rb
pry-nav-0.2.1 lib/pry-nav/commands.rb
pry-nav-0.2.0 lib/pry-nav/commands.rb