Class: Byebug::SkipCommand

Inherits:
Command
  • Object
show all
Includes:
Helpers::ParseHelper
Defined in:
lib/byebug/commands/skip.rb

Overview

Allows the user to continue execution until the next breakpoint, as long as it is different from the current one

Class Attribute Summary collapse

Attributes inherited from Command

#processor

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::ParseHelper

#get_int, #parse_steps, #syntax_valid?

Methods inherited from Command

#arguments, columnize, #context, #frame, help, #initialize, match, to_s

Methods included from Helpers::StringHelper

#camelize, #deindent, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Attribute Details

.file_lineObject



18
19
20
# File 'lib/byebug/commands/skip.rb', line 18

def file_line
  @file_line ||= 0
end

.file_pathObject



22
23
24
# File 'lib/byebug/commands/skip.rb', line 22

def file_path
  @file_path ||= ""
end

.previous_autolistObject (readonly)

Returns the value of attribute previous_autolist.



16
17
18
# File 'lib/byebug/commands/skip.rb', line 16

def previous_autolist
  @previous_autolist
end

Class Method Details

.descriptionObject



41
42
43
44
45
46
47
# File 'lib/byebug/commands/skip.rb', line 41

def self.description
  <<-DESCRIPTION
    sk[ip]

    #{short_description}
  DESCRIPTION
end

.regexpObject



37
38
39
# File 'lib/byebug/commands/skip.rb', line 37

def self.regexp
  /^\s* sk(?:ip)? \s*$/x
end

.restore_autolistObject



31
32
33
34
# File 'lib/byebug/commands/skip.rb', line 31

def restore_autolist
  ListCommand.always_run = @previous_autolist
  @previous_autolist = nil
end

.setup_autolist(value) ⇒ Object



26
27
28
29
# File 'lib/byebug/commands/skip.rb', line 26

def setup_autolist(value)
  @previous_autolist = ListCommand.always_run
  ListCommand.always_run = value
end

.short_descriptionObject



49
50
51
# File 'lib/byebug/commands/skip.rb', line 49

def self.short_description
  "Runs until the next breakpoint as long as it is different from the current one"
end

Instance Method Details

#auto_runObject



70
71
72
73
74
75
# File 'lib/byebug/commands/skip.rb', line 70

def auto_run
  return false unless self.class.always_run == 2

  keep_execution ? processor.proceed! : reset_attributes
  true
end

#executeObject



77
78
79
80
81
82
83
# File 'lib/byebug/commands/skip.rb', line 77

def execute
  return if auto_run

  initialize_attributes
  processor.proceed!
  Byebug.stop if Byebug.stoppable?
end

#initialize_attributesObject



53
54
55
56
57
58
# File 'lib/byebug/commands/skip.rb', line 53

def initialize_attributes
  self.class.always_run = 2
  self.class.setup_autolist(0)
  self.class.file_path = frame.file
  self.class.file_line = frame.line
end

#keep_executionObject



60
61
62
# File 'lib/byebug/commands/skip.rb', line 60

def keep_execution
  [self.class.file_path, self.class.file_line] == [frame.file, frame.line]
end

#reset_attributesObject



64
65
66
67
68
# File 'lib/byebug/commands/skip.rb', line 64

def reset_attributes
  self.class.always_run = 0
  ListCommand.new(processor).execute if self.class.previous_autolist == 1
  self.class.restore_autolist
end