byebug 10.0.2 → 11.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,9 +34,7 @@ module Byebug
34
34
 
35
35
  def execute
36
36
  unless @match[1]
37
- if confirm(pr("break.confirmations.delete_all"))
38
- Byebug.breakpoints.clear
39
- end
37
+ Byebug.breakpoints.clear if confirm(pr("break.confirmations.delete_all"))
40
38
 
41
39
  return
42
40
  end
@@ -23,7 +23,7 @@ module Byebug
23
23
  dis[able][[ breakpoints| display)][ n1[ n2[ ...[ nn]]]]]
24
24
 
25
25
  #{short_description}
26
- DESCRIPTION
26
+ DESCRIPTION
27
27
  end
28
28
 
29
29
  def self.short_description
@@ -46,6 +46,7 @@ module Byebug
46
46
  if matched.nil?
47
47
  file = frame.file
48
48
  return errmsg(pr("edit.errors.state")) unless file
49
+
49
50
  line = frame.line
50
51
  elsif (@pos_match = /([^:]+)[:]([0-9]+)/.match(matched))
51
52
  file, line = @pos_match.captures
@@ -35,9 +35,7 @@ module Byebug
35
35
  if @match[1]
36
36
  indices = @match[1].split(/ +/).map(&:to_i)
37
37
  breakpoints = breakpoints.select { |b| indices.member?(b.id) }
38
- if breakpoints.empty?
39
- return errmsg("No breakpoints found among list given")
40
- end
38
+ return errmsg("No breakpoints found among list given") if breakpoints.empty?
41
39
  end
42
40
 
43
41
  puts "Num Enb What"
@@ -57,7 +55,7 @@ module Byebug
57
55
  )
58
56
  puts interp
59
57
  hits = brkpt.hit_count
60
- return unless hits > 0
58
+ return unless hits.positive?
61
59
 
62
60
  s = hits > 1 ? "s" : ""
63
61
  puts " breakpoint already hit #{hits} time#{s}"
@@ -28,9 +28,7 @@ module Byebug
28
28
  end
29
29
 
30
30
  def execute
31
- unless Byebug.displays.find { |d| d[0] }
32
- return puts("There are no auto-display expressions now.")
33
- end
31
+ return puts("There are no auto-display expressions now.") unless Byebug.displays.find { |d| d[0] }
34
32
 
35
33
  puts "Auto-display expressions now in effect:"
36
34
  puts "Num Enb Expression"
@@ -37,9 +37,7 @@ module Byebug
37
37
 
38
38
  def execute
39
39
  file = @match[1] || frame.file
40
- unless File.exist?(file)
41
- return errmsg(pr("info.errors.undefined_file", file: file))
42
- end
40
+ return errmsg(pr("info.errors.undefined_file", file: file)) unless File.exist?(file)
43
41
 
44
42
  puts prettify <<-RUBY
45
43
  File #{info_file_basic(file)}
@@ -28,9 +28,7 @@ module Byebug
28
28
  end
29
29
 
30
30
  def execute
31
- unless processor.interface.instance_of?(LocalInterface)
32
- return errmsg(pr("base.errors.only_local"))
33
- end
31
+ return errmsg(pr("base.errors.only_local")) unless processor.interface.instance_of?(LocalInterface)
34
32
 
35
33
  # @todo IRB tries to parse $ARGV so we must clear it (see #197). Add a
36
34
  # test case for it so we can remove this comment.
@@ -10,7 +10,7 @@ module Byebug
10
10
  self.allow_in_control = true
11
11
 
12
12
  def self.regexp
13
- /^\s* (?:kill) \s* (?:\s+(\S+))? \s*$/x
13
+ /^\s* kill \s* (?:\s+(\S+))? \s*$/x
14
14
  end
15
15
 
16
16
  def self.description
@@ -31,9 +31,7 @@ module Byebug
31
31
  if @match[1]
32
32
  signame = @match[1]
33
33
 
34
- unless Signal.list.member?(signame)
35
- return errmsg("signal name #{signame} is not a signal I know about\n")
36
- end
34
+ return errmsg("signal name #{signame} is not a signal I know about\n") unless Signal.list.member?(signame)
37
35
  else
38
36
  return unless confirm("Really kill? (y/n) ")
39
37
 
@@ -27,9 +27,7 @@ module Byebug
27
27
  end
28
28
 
29
29
  def execute
30
- unless processor.interface.instance_of?(LocalInterface)
31
- return errmsg(pr("base.errors.only_local"))
32
- end
30
+ return errmsg(pr("base.errors.only_local")) unless processor.interface.instance_of?(LocalInterface)
33
31
 
34
32
  begin
35
33
  require "pry"
@@ -16,12 +16,12 @@ module Byebug
16
16
 
17
17
  def self.description
18
18
  <<-DESCRIPTION
19
- q[uit] [!|unconditionally]
19
+ q[uit][!| unconditionally]
20
20
 
21
21
  #{short_description}
22
22
 
23
- Normally we prompt before exiting. However if the parameter
24
- "unconditionally" is given or command is suffixed with !, we exit
23
+ Normally we prompt before exiting. However, if the parameter
24
+ "unconditionally" is given or command is suffixed with "!", we exit
25
25
  without asking further questions.
26
26
  DESCRIPTION
27
27
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/command"
4
+ require "byebug/helpers/parse"
5
+
6
+ module Byebug
7
+ #
8
+ # Allows the user to continue execution until the next breakpoint, as
9
+ # long as it is different from the current one
10
+ #
11
+ class SkipCommand < Command
12
+ include Helpers::ParseHelper
13
+
14
+ class << self
15
+ attr_writer :file_line, :file_path
16
+
17
+ def file_line
18
+ @file_line ||= 0
19
+ end
20
+
21
+ def file_path
22
+ @file_path ||= ""
23
+ end
24
+ end
25
+
26
+ def self.regexp
27
+ /^\s* sk(?:ip)? \s*$/x
28
+ end
29
+
30
+ def self.description
31
+ <<-DESCRIPTION
32
+ sk[ip]
33
+
34
+ #{short_description}
35
+ DESCRIPTION
36
+ end
37
+
38
+ def self.short_description
39
+ "Runs until the next breakpoint as long as it is different from the current one"
40
+ end
41
+
42
+ def initialize_attributes
43
+ self.class.always_run = 2
44
+ self.class.file_path = frame.file
45
+ self.class.file_line = frame.line
46
+ end
47
+
48
+ def keep_execution
49
+ [self.class.file_path, self.class.file_line] == [frame.file, frame.line]
50
+ end
51
+
52
+ def reset_attributes
53
+ self.class.always_run = 0
54
+ end
55
+
56
+ def auto_run
57
+ return false unless self.class.always_run == 2
58
+
59
+ keep_execution ? processor.proceed! : reset_attributes
60
+ true
61
+ end
62
+
63
+ def execute
64
+ return if auto_run
65
+
66
+ initialize_attributes
67
+ processor.proceed!
68
+ Byebug.stop if Byebug.stoppable?
69
+ end
70
+ end
71
+ end
@@ -32,9 +32,7 @@ module Byebug
32
32
  return puts(help) unless @match[1]
33
33
 
34
34
  file = File.expand_path(@match[1]).strip
35
- unless File.exist?(file)
36
- return errmsg(pr("source.errors.not_found", file: file))
37
- end
35
+ return errmsg(pr("source.errors.not_found", file: file)) unless File.exist?(file)
38
36
 
39
37
  processor.interface.read_file(file)
40
38
  end
@@ -35,9 +35,7 @@ module Byebug
35
35
  context, err = context_from_thread(@match[1])
36
36
  return errmsg(err) if err
37
37
 
38
- unless context.suspended?
39
- return errmsg(pr("thread.errors.already_running"))
40
- end
38
+ return errmsg(pr("thread.errors.already_running")) unless context.suspended?
41
39
 
42
40
  context.resume
43
41
  display_context(context)
@@ -32,10 +32,7 @@ module Byebug
32
32
  def execute
33
33
  var = @match[1]
34
34
  return errmsg(pr("trace.errors.needs_global_variable")) unless var
35
-
36
- unless global_variables.include?(:"#{var}")
37
- return errmsg(pr("trace.errors.var_is_not_global", name: var))
38
- end
35
+ return errmsg(pr("trace.errors.var_is_not_global", name: var)) unless global_variables.include?(:"#{var}")
39
36
 
40
37
  stop = @match[2] && @match[2] !~ /nostop/
41
38
 
@@ -37,11 +37,10 @@ module Byebug
37
37
  pos, err = get_int(@match[1], "Undisplay", 1, Byebug.displays.size)
38
38
  return errmsg(err) unless err.nil?
39
39
 
40
- unless Byebug.displays[pos - 1]
41
- return errmsg(pr("display.errors.undefined", expr: pos))
42
- end
40
+ last_display = Byebug.displays[pos - 1]
41
+ return errmsg(pr("display.errors.undefined", expr: pos)) unless last_display
43
42
 
44
- Byebug.displays[pos - 1][0] = nil
43
+ last_display[0] = nil
45
44
  else
46
45
  return unless confirm(pr("display.confirmations.clear_all"))
47
46
 
@@ -33,9 +33,7 @@ module Byebug
33
33
 
34
34
  def execute
35
35
  obj = warning_eval(str_obj)
36
- unless obj.is_a?(Module)
37
- return errmsg(pr("variable.errors.not_module", object: str_obj))
38
- end
36
+ return errmsg(pr("variable.errors.not_module", object: str_obj)) unless obj.is_a?(Module)
39
37
 
40
38
  constants = warning_eval("#{str_obj}.constants")
41
39
  puts prv(constants.sort.map { |c| [c, obj.const_get(c)] }, "constant")
@@ -21,7 +21,7 @@ module Byebug
21
21
 
22
22
  def adjust_frame(new_frame)
23
23
  return frame_err("too_low") if new_frame >= context.stack_size
24
- return frame_err("too_high") if new_frame < 0
24
+ return frame_err("too_high") if new_frame.negative?
25
25
 
26
26
  context.frame = new_frame
27
27
  processor.prev_line = nil
@@ -15,9 +15,7 @@ module Byebug
15
15
  # purpose.
16
16
  #
17
17
  def get_int(str, cmd, min = nil, max = nil)
18
- if str !~ /\A-?[0-9]+\z/
19
- return nil, pr("parse.errors.int.not_number", cmd: cmd, str: str)
20
- end
18
+ return nil, pr("parse.errors.int.not_number", cmd: cmd, str: str) if str !~ /\A-?[0-9]+\z/
21
19
 
22
20
  int = str.to_i
23
21
  if min && int < min
@@ -25,9 +25,6 @@ module Byebug
25
25
  #
26
26
  # Removes a number of leading whitespace for each input line.
27
27
  #
28
- # @note Might be unnecessary when Ruby 2.2 support is dropped and we can
29
- # use squiggly heredoc's.
30
- #
31
28
  def deindent(str, leading_spaces: 6)
32
29
  str.gsub(/^ {#{leading_spaces}}/, "")
33
30
  end
@@ -15,9 +15,7 @@ module Byebug
15
15
 
16
16
  select_breakpoints(is_enable, args).each do |b|
17
17
  enabled = (is_enable == "enable")
18
- if enabled && !syntax_valid?(b.expr)
19
- raise pr("toggle.errors.expression", expr: b.expr)
20
- end
18
+ raise pr("toggle.errors.expression", expr: b.expr) if enabled && !syntax_valid?(b.expr)
21
19
 
22
20
  puts pr("toggle.messages.toggled", bpnum: b.id,
23
21
  endis: enabled ? "en" : "dis")
@@ -5,7 +5,7 @@ module Byebug
5
5
  # Interface class for standard byebug use.
6
6
  #
7
7
  class LocalInterface < Interface
8
- EOF_ALIAS = "continue".freeze
8
+ EOF_ALIAS = "continue"
9
9
 
10
10
  def initialize
11
11
  super()
@@ -25,6 +25,7 @@ module Byebug
25
25
  while (result = input.gets)
26
26
  output.puts "+ #{result}" if @verbose
27
27
  next if result =~ /^\s*#/
28
+
28
29
  return result.chomp
29
30
  end
30
31
  end
@@ -11,7 +11,7 @@ module Byebug
11
11
  class MissedPath < StandardError; end
12
12
  class MissedArgument < StandardError; end
13
13
 
14
- SEPARATOR = ".".freeze
14
+ SEPARATOR = "."
15
15
 
16
16
  def type
17
17
  self.class.name.split("::").last.downcase
@@ -23,11 +23,12 @@ module Byebug
23
23
  result = nil
24
24
  contents.each_value do |contents|
25
25
  result = parts(path).reduce(contents) do |r, part|
26
- r && r.key?(part) ? r[part] : nil
26
+ r&.key?(part) ? r[part] : nil
27
27
  end
28
28
  break if result
29
29
  end
30
30
  raise MissedPath, "Can't find part path '#{path}'" unless result
31
+
31
32
  result
32
33
  end
33
34
 
@@ -35,9 +36,7 @@ module Byebug
35
36
  # they may contain #{} string interpolation
36
37
  string.gsub(/\|\w+$/, "").gsub(/([^#]?){([^}]*)}/) do
37
38
  key = Regexp.last_match[2].to_s
38
- unless args.key?(key.to_sym)
39
- raise MissedArgument, "Missed argument #{key} for '#{string}'"
40
- end
39
+ raise MissedArgument, "Missed argument #{key} for '#{string}'" unless args.key?(key.to_sym)
41
40
 
42
41
  "#{Regexp.last_match[1]}#{args[key.to_sym]}"
43
42
  end
@@ -26,10 +26,12 @@ module Byebug
26
26
  when /^PROMPT (.*)$/
27
27
  input = interface.read_command(Regexp.last_match[1])
28
28
  break unless input
29
+
29
30
  socket.puts input
30
31
  when /^CONFIRM (.*)$/
31
32
  input = interface.readline(Regexp.last_match[1])
32
33
  break unless input
34
+
33
35
  socket.puts input
34
36
  else
35
37
  interface.puts line
@@ -7,7 +7,7 @@ module Byebug
7
7
  # Setting to customize the verbosity level for stack frames.
8
8
  #
9
9
  class CallstyleSetting < Setting
10
- DEFAULT = "long".freeze
10
+ DEFAULT = "long"
11
11
 
12
12
  def banner
13
13
  "Set how you want method call parameters to be displayed"
@@ -4,5 +4,5 @@
4
4
  # Reopen main module to define the library version
5
5
  #
6
6
  module Byebug
7
- VERSION = "10.0.2".freeze
7
+ VERSION = "11.0.0"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.2
4
+ version: 11.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-03-30 00:00:00.000000000 Z
13
+ date: 2019-02-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -18,21 +18,21 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.7'
21
+ version: '2.0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '1.7'
28
+ version: '2.0'
29
29
  description: |-
30
30
  Byebug is a Ruby debugger. It's implemented using the
31
31
  TracePoint C API for execution control and the Debug Inspector C API for
32
32
  call stack navigation. The core component provides support that front-ends
33
33
  can build on. It provides breakpoint handling and bindings for stack frames
34
34
  among other things and it comes with an easy to use command line interface.
35
- email: deivid.rodriguez@mail.com
35
+ email: deivid.rodriguez@riseup.net
36
36
  executables:
37
37
  - byebug
38
38
  extensions:
@@ -99,6 +99,7 @@ files:
99
99
  - lib/byebug/commands/save.rb
100
100
  - lib/byebug/commands/set.rb
101
101
  - lib/byebug/commands/show.rb
102
+ - lib/byebug/commands/skip.rb
102
103
  - lib/byebug/commands/source.rb
103
104
  - lib/byebug/commands/step.rb
104
105
  - lib/byebug/commands/thread.rb
@@ -172,7 +173,7 @@ files:
172
173
  - lib/byebug/source_file_formatter.rb
173
174
  - lib/byebug/subcommands.rb
174
175
  - lib/byebug/version.rb
175
- homepage: http://github.com/deivid-rodriguez/byebug
176
+ homepage: https://github.com/deivid-rodriguez/byebug
176
177
  licenses:
177
178
  - BSD-2-Clause
178
179
  metadata: {}
@@ -184,15 +185,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
185
  requirements:
185
186
  - - ">="
186
187
  - !ruby/object:Gem::Version
187
- version: 2.2.0
188
+ version: 2.3.0
188
189
  required_rubygems_version: !ruby/object:Gem::Requirement
189
190
  requirements:
190
191
  - - ">="
191
192
  - !ruby/object:Gem::Version
192
193
  version: '0'
193
194
  requirements: []
194
- rubyforge_project:
195
- rubygems_version: 2.7.6
195
+ rubygems_version: 3.0.1
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Ruby fast debugger - base + CLI