Class: Byebug::PryCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/repl.rb

Overview

Implements byebug’s “pry” command

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



151
152
153
154
155
# File 'lib/byebug/commands/repl.rb', line 151

def description
  %{
    pry[ -d]\tstarts a Pry session.
  }
end

.namesObject



147
148
149
# File 'lib/byebug/commands/repl.rb', line 147

def names
  %w(pry)
end

Instance Method Details

#executeObject



132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/byebug/commands/repl.rb', line 132

def execute
  unless @state.interface.kind_of?(LocalInterface)
    print "Command is available only in local mode.\n"
    throw :debug_error
  end

  add_debugging = @match.is_a?(MatchData) && '-d' == @match[1]
  $byebug_state = @state if add_debugging

  get_binding.pry

  $byebug_state = nil if add_debugging
end

#regexpObject



126
127
128
129
130
# File 'lib/byebug/commands/repl.rb', line 126

def regexp
  /^\s* pry
    (?:\s+(-d))?
    \s*$/x
end