Sha256: 3c22ff6f60981743f8d1ed7f7234fed37b696baff181125b89d5f15494d4e39a

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

class Pry
  # N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
  class Command::RaiseUp < Pry::ClassCommand
    match(/raise-up(!?\b.*)/)
    group 'Context'
    description 'Raise an exception out of the current pry instance.'
    command_options listing: 'raise-up'

    banner <<-BANNER
      Raise up, like exit, allows you to quit pry. Instead of returning a value
      however, it raises an exception. If you don't provide the exception to be
      raised, it will use the most recent exception (in pry `_ex_`).

      When called as raise-up! (with an exclamation mark), this command raises the
      exception through any nested prys you have created by "cd"ing into objects.

      raise-up "get-me-out-of-here"

      # This is equivalent to the command above.
      raise "get-me-out-of-here"
      raise-up
    BANNER

    def process
      return _pry.pager.page help if captures[0] =~ /(-h|--help)\b/

      # Handle 'raise-up', 'raise-up "foo"', 'raise-up RuntimeError, 'farble' in a rubyesque manner
      target.eval("_pry_.raise_up#{captures[0]}")
    end
  end

  Pry::Commands.add_command(Pry::Command::RaiseUp)
end

Version data entries

15 entries across 15 versions & 7 rubygems

Version Path
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
chess_engine-0.0.2 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
chess_engine-0.0.1 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/raise_up.rb
pry-0.12.2-java lib/pry/commands/raise_up.rb
pry-0.12.2 lib/pry/commands/raise_up.rb
pry-0.12.1 lib/pry/commands/raise_up.rb
pry-0.12.1-java lib/pry/commands/raise_up.rb
pry-0.12.0 lib/pry/commands/raise_up.rb
pry-0.12.0-java lib/pry/commands/raise_up.rb