byebug 9.0.6 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0efdc94aba70c68b5b35988a7f295775c1571a76
4
- data.tar.gz: 8fb665c2f83ef93ced0be46b22f1b49742831928
3
+ metadata.gz: d998c99367586ad5a7f29f3bd5e22b2836f1d7c8
4
+ data.tar.gz: 32cf7615ad42d875e78c103e48c9a40dcde502be
5
5
  SHA512:
6
- metadata.gz: 52cd6fb114e28b5e6e3f1217441bed7516d351385fc02f5cc2eb8b65909222e511531bb81fbdb40e8898fb73aa12c7617bf90605c0a74bc3c40da090e8e0124e
7
- data.tar.gz: cb91790897351bc489f189f32e438cf24e087ace5c7542acf3932b7eb64fccb74e2950d2e663822579ba7ece77f5c1faed2070200ef3158b059f55b1895b4aab
6
+ metadata.gz: 2f5f3f1aec38feaa4a83fd97b9b09313a97ea5dd25daee3e9319d602e7268ca8fa6ade3995c8d8ccd4d68d5369e2f6511a3d8710562bc3204866bbc5ab20452b
7
+ data.tar.gz: 570436e9f4263fdc9191c666337e5a726854427932fa995fa4819417414a6160830d27ffa3d0a3acf9c1e23fa4d387ee8d6f0d4e50e4b6b583626443e31b2bd9
@@ -2,6 +2,23 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 9.1.0 - 2016-08-22
6
+
7
+ ### Added
8
+
9
+ * Better UI messages for breakpoint management.
10
+
11
+ ### Fixed
12
+
13
+ * `where` command failing on instance_exec block stack frames.
14
+ * `restart` command crashing in certain cases because of a missing `require 'English'` (#321, @akaneko3).
15
+ * `restart` command crashing when debugged script is not executable or has no shebang (#321, @akaneko3).
16
+
17
+ ### Removed
18
+
19
+ * Ruby 2.0 and Ruby 2.1 official & unofficial support. Byebug no longer installs
20
+ on these platforms.
21
+
5
22
  ## 9.0.6 - 2016-09-29
6
23
 
7
24
  ### Fixed
data/GUIDE.md CHANGED
@@ -186,7 +186,21 @@ end
186
186
 
187
187
  n_args = $ARGV.length
188
188
 
189
- fail('*** Need number of disks or no parameter') if n_args > 1
189
+ raise('*** Need number of disks or no parameter') if n_args > 1
190
+
191
+ n = 3
192
+
193
+ if n_args > 0
194
+ begin
195
+ n = $ARGV[0].to_i
196
+ rescue ValueError
197
+ raise("*** Expecting an integer, got: #{$ARGV[0]}")
198
+ end
199
+ end
200
+
201
+ raise('*** Number of disks should be between 1 and 100') if n < 1 || n > 100
202
+
203
+ hanoi(n, :a, :b, :c)
190
204
  ```
191
205
 
192
206
  Recall in the first section it was stated that before the `def` is run, the
@@ -316,7 +330,7 @@ Now let's see what happens after stepping:
316
330
  11:
317
331
  => 12: n_args = $ARGV.length
318
332
  13:
319
- 14: fail('*** Need number of disks or no parameter') if n_args > 1
333
+ 14: raise('*** Need number of disks or no parameter') if n_args > 1
320
334
  (byebug) private_methods.member?(:hanoi)
321
335
  true
322
336
  (byebug)
@@ -442,15 +456,15 @@ NameError Exception: undefined local variable or method `n_args' for main:Object
442
456
  19: begin
443
457
  20: n = $ARGV[0].to_i
444
458
  21: rescue ValueError
445
- 22: raise("** Expecting an integer, got: #{$ARGV[0]}")
459
+ 22: raise("*** Expecting an integer, got: #{$ARGV[0]}")
446
460
  23: end
447
461
  24: end
448
462
  25:
449
- 26: fail('*** Number of disks should be between 1 and 100') if n < 1 || n > 100
463
+ 26: raise('*** Number of disks should be between 1 and 100') if n < 1 || n > 100
450
464
  27:
451
465
  => 28: hanoi(n, :a, :b, :c)
452
466
  (byebug) n_args
453
- 0
467
+ 1
454
468
  (byebug) eval n
455
469
  3
456
470
  (byebug) down 2
data/README.md CHANGED
@@ -18,10 +18,10 @@
18
18
  [tip_url]: https://gratipay.com/byebug
19
19
  [irc_url]: https://gitter.im/deivid-rodriguez/byebug
20
20
 
21
- Byebug is a simple to use, feature rich debugger for Ruby 2. It uses the new
22
- TracePoint API for execution control and the new Debug Inspector API for call
23
- stack navigation, so it doesn't depend on internal core sources. It's developed
24
- as a C extension, so it's fast. And it has a full test suite so it's reliable.
21
+ Byebug is a simple to use, feature rich debugger for Ruby. It uses the
22
+ TracePoint API for execution control and the Debug Inspector API for call stack
23
+ navigation, so it doesn't depend on internal core sources. It's developed as a C
24
+ extension, so it's fast. And it has a full test suite so it's reliable.
25
25
 
26
26
  It allows you to see what is going on _inside_ a Ruby program while it executes
27
27
  and offers many of the traditional debugging features such as:
@@ -48,12 +48,10 @@ Windows [![Vey][vey]][vey_url]
48
48
 
49
49
  ## Requirements
50
50
 
51
- * Required: MRI 2.0.0 or higher. For debugging ruby 1.9.3 or older, use
52
- [debugger].
53
51
  * Recommended:
54
- * MRI 2.1.8 or higher.
55
52
  * MRI 2.2.4 or higher.
56
53
  * MRI 2.3.0 or higher.
54
+ * MRI 2.4.0 or higher.
57
55
 
58
56
  ## Install
59
57
 
@@ -63,6 +61,8 @@ gem install byebug
63
61
 
64
62
  ## Usage
65
63
 
64
+ ### From within the Ruby code
65
+
66
66
  Simply drop
67
67
 
68
68
  byebug
@@ -74,6 +74,7 @@ If you were debugging Rails, for example, you would add `byebug` to your code.
74
74
  def index
75
75
  byebug
76
76
  @articles = Article.find_recent
77
+ end
77
78
  ```
78
79
 
79
80
  And then start a Rails server.
@@ -84,6 +85,14 @@ bin/rails s
84
85
 
85
86
  Once the execution gets to your `byebug` command you will get a debugging prompt.
86
87
 
88
+ ### From the command line
89
+
90
+ If you want to debug a Ruby script without editing it, you can invoke byebug from the command line.
91
+
92
+ ```shell
93
+ byebug myscript.rb
94
+ ```
95
+
87
96
  ## Byebug's commands
88
97
 
89
98
  Command | Aliases | Subcommands
@@ -145,6 +154,7 @@ started. Proper documentation will be eventually written.
145
154
  connected.
146
155
  * [minitest-byebug] starts a byebug session on minitest failures.
147
156
  * [sublime_debugger] provides a plugin for ruby debugging on Sublime Text.
157
+ * [atom-byebug] provides integration with the Atom editor [EXPERIMENTAL].
148
158
 
149
159
  ## Contribute
150
160
 
@@ -168,3 +178,4 @@ software, especially:
168
178
  [ruby-debug-passenger]: https://github.com/davejamesmiller/ruby-debug-passenger
169
179
  [minitest-byebug]: https://github.com/kaspth/minitest-byebug
170
180
  [sublime_debugger]: https://github.com/shuky19/sublime_debugger
181
+ [atom-byebug]: https://github.com/izaera/atom-byebug
data/bin/byebug CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
3
+ bin_dir = File.dirname(File.realpath(__FILE__))
4
+
5
+ $LOAD_PATH.unshift(File.expand_path(File.join('..', 'lib'), bin_dir))
4
6
 
5
7
  require 'byebug/runner'
6
8
 
@@ -81,7 +81,7 @@ module Byebug
81
81
  # Prints all information associated to the breakpoint
82
82
  #
83
83
  def inspect
84
- meths = %w(id pos source expr hit_condition hit_count hit_value enabled?)
84
+ meths = %w[id pos source expr hit_condition hit_count hit_value enabled?]
85
85
  values = meths.map { |field| "#{field}: #{send(field)}" }.join(', ')
86
86
  "#<Byebug::Breakpoint #{values}>"
87
87
  end
@@ -36,7 +36,7 @@ module Byebug
36
36
  def execute
37
37
  return info unless @match[1]
38
38
 
39
- return 'off' == @match[1] ? clear : add(@match[1]) unless @match[2]
39
+ return @match[1] == 'off' ? clear : add(@match[1]) unless @match[2]
40
40
 
41
41
  return errmsg pr('catch.errors.off', off: cmd) unless @match[2] == 'off'
42
42
 
@@ -44,8 +44,10 @@ module Byebug
44
44
 
45
45
  return errmsg(err) unless pos
46
46
 
47
- unless Breakpoint.remove(pos)
48
- return errmsg(pr('break.errors.no_breakpoint_delete', pos: pos))
47
+ if Breakpoint.remove(pos)
48
+ puts(pr('break.messages.breakpoint_deleted', pos: pos))
49
+ else
50
+ errmsg(pr('break.errors.no_breakpoint_delete', pos: pos))
49
51
  end
50
52
  end
51
53
  end
@@ -29,7 +29,7 @@ module Byebug
29
29
  end
30
30
 
31
31
  def self.short_description
32
- 'Disable all or specific breakpoints'
32
+ 'Enable all or specific breakpoints'
33
33
  end
34
34
 
35
35
  def execute
@@ -10,6 +10,7 @@ module Byebug
10
10
  #
11
11
  class FileCommand < Command
12
12
  include Helpers::FileHelper
13
+ include Helpers::StringHelper
13
14
 
14
15
  self.allow_in_post_mortem = true
15
16
 
@@ -38,8 +39,7 @@ module Byebug
38
39
  return errmsg(pr('info.errors.undefined_file', file: file))
39
40
  end
40
41
 
41
- puts <<-EOC.gsub(/^ {6}/, '')
42
-
42
+ puts prettify <<-EOC
43
43
  File #{info_file_basic(file)}
44
44
 
45
45
  Breakpoint line numbers: #{info_file_breakpoints(file)}
@@ -47,7 +47,6 @@ module Byebug
47
47
  Modification time: #{info_file_mtime(file)}
48
48
 
49
49
  Sha1 Signature: #{info_file_sha1(file)}
50
-
51
50
  EOC
52
51
  end
53
52
 
@@ -1,5 +1,6 @@
1
1
  require 'byebug/command'
2
2
  require 'irb'
3
+ require 'English'
3
4
 
4
5
  module Byebug
5
6
  #
@@ -29,7 +30,7 @@ module Byebug
29
30
  return errmsg(pr('base.errors.only_local'))
30
31
  end
31
32
 
32
- # @todo IRB tries to parse ARGV so we must clear it (see #197). Add a
33
+ # @todo IRB tries to parse $ARGV so we must clear it (see #197). Add a
33
34
  # test case for it so we can remove this comment.
34
35
  with_clean_argv { IRB.start }
35
36
  end
@@ -37,12 +38,12 @@ module Byebug
37
38
  private
38
39
 
39
40
  def with_clean_argv
40
- saved_argv = ARGV.dup
41
- ARGV.clear
41
+ saved_argv = $ARGV.dup
42
+ $ARGV.clear
42
43
  begin
43
44
  yield
44
45
  ensure
45
- ARGV.concat(saved_argv)
46
+ $ARGV.concat(saved_argv)
46
47
  end
47
48
  end
48
49
  end
@@ -38,7 +38,7 @@ module Byebug
38
38
  signame = 'KILL'
39
39
  end
40
40
 
41
- processor.interface.close if 'KILL' == signame
41
+ processor.interface.close if signame == 'KILL'
42
42
  Process.kill(signame, Process.pid)
43
43
  end
44
44
  end
@@ -1,12 +1,16 @@
1
1
  require 'byebug/command'
2
+ require 'byebug/helpers/bin'
2
3
  require 'byebug/helpers/path'
3
4
  require 'shellwords'
5
+ require 'English'
6
+ require 'rbconfig'
4
7
 
5
8
  module Byebug
6
9
  #
7
10
  # Restart debugged program from within byebug.
8
11
  #
9
12
  class RestartCommand < Command
13
+ include Helpers::BinHelper
10
14
  include Helpers::PathHelper
11
15
 
12
16
  self.allow_in_control = true
@@ -32,14 +36,27 @@ module Byebug
32
36
  end
33
37
 
34
38
  def execute
35
- argv = [$PROGRAM_NAME]
39
+ cmd = [$PROGRAM_NAME]
36
40
 
37
- argv.unshift(bin_file) if Byebug.mode == :standalone
41
+ cmd = prepend_byebug_bin(cmd)
42
+ cmd = prepend_ruby_bin(cmd)
38
43
 
39
- argv += (@match[:args] ? @match[:args].shellsplit : $ARGV.compact)
44
+ cmd += (@match[:args] ? @match[:args].shellsplit : $ARGV)
40
45
 
41
- puts pr('restart.success', cmd: argv.shelljoin)
42
- Kernel.exec(*argv)
46
+ puts pr('restart.success', cmd: cmd.shelljoin)
47
+ Kernel.exec(*cmd)
48
+ end
49
+
50
+ private
51
+
52
+ def prepend_byebug_bin(cmd)
53
+ cmd.unshift(bin_file) if Byebug.mode == :standalone
54
+ cmd
55
+ end
56
+
57
+ def prepend_ruby_bin(cmd)
58
+ cmd.unshift(RbConfig.ruby) if which('ruby') != which(cmd.first)
59
+ cmd
43
60
  end
44
61
  end
45
62
  end
@@ -62,7 +62,7 @@ module Byebug
62
62
  end
63
63
 
64
64
  def save_settings(file)
65
- %w(autoirb autolist basename).each do |setting|
65
+ %w[autoirb autolist basename].each do |setting|
66
66
  file.puts "set #{setting} #{Setting[setting.to_sym]}"
67
67
  end
68
68
  end
@@ -51,7 +51,7 @@ module Byebug
51
51
  end
52
52
 
53
53
  def self.load_settings
54
- Dir.glob(File.expand_path('../settings/*.rb', __FILE__)).each do |file|
54
+ Dir.glob(File.join(__dir__, 'settings', '*.rb')).each do |file|
55
55
  require file
56
56
  end
57
57
 
@@ -47,13 +47,10 @@ module Byebug
47
47
  #
48
48
  # Gets local variables for the frame.
49
49
  #
50
- # @todo Use `Binding#local_variables` directly once we drop 2.1 support
51
- # since it's a public method since ruby 2.2
52
- #
53
50
  def locals
54
51
  return [] unless _binding
55
52
 
56
- _binding.eval('local_variables').each_with_object({}) do |e, a|
53
+ _binding.local_variables.each_with_object({}) do |e, a|
57
54
  a[e] = _binding.local_variable_get(e)
58
55
  a
59
56
  end
@@ -161,14 +158,14 @@ module Byebug
161
158
  def c_args
162
159
  return [] unless _self.to_s != 'main'
163
160
 
164
- _self.method(_method).parameters
161
+ _class.instance_method(_method).parameters
165
162
  end
166
163
 
167
164
  def ruby_args
168
165
  meth_name = _binding.eval('__method__')
169
166
  return [] unless meth_name
170
167
 
171
- meth_obj = _self.method(meth_name)
168
+ meth_obj = _class.instance_method(meth_name)
172
169
  return [] unless meth_obj
173
170
 
174
171
  meth_obj.parameters
@@ -0,0 +1,26 @@
1
+ module Byebug
2
+ module Helpers
3
+ #
4
+ # Utilities for interaction with executables
5
+ #
6
+ module BinHelper
7
+ #
8
+ # Cross-platform way of finding an executable in the $PATH.
9
+ # Borrowed from: http://stackoverflow.com/questions/2108727
10
+ #
11
+ def which(cmd)
12
+ return File.expand_path(cmd) if File.exist?(cmd)
13
+
14
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
15
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
16
+ exts.each do |ext|
17
+ exe = File.join(path, "#{cmd}#{ext}")
18
+ return exe if File.executable?(exe) && !File.directory?(exe)
19
+ end
20
+ end
21
+
22
+ nil
23
+ end
24
+ end
25
+ end
26
+ end
@@ -8,7 +8,7 @@ module Byebug
8
8
  # Reads lines of source file +filename+ into an array
9
9
  #
10
10
  def get_lines(filename)
11
- File.foreach(filename).reduce([]) { |a, e| a << e.chomp }
11
+ File.foreach(filename).reduce([]) { |acc, elem| acc << elem.chomp }
12
12
  end
13
13
 
14
14
  #
@@ -26,7 +26,7 @@ module Byebug
26
26
  # one-line-at-a-time way.
27
27
  #
28
28
  def n_lines(filename)
29
- File.foreach(filename).reduce(0) { |a, _e| a + 1 }
29
+ File.foreach(filename).reduce(0) { |acc, _elem| acc + 1 }
30
30
  end
31
31
 
32
32
  #
@@ -5,27 +5,23 @@ module Byebug
5
5
  #
6
6
  module PathHelper
7
7
  def bin_file
8
- @bin_file ||= Gem.bin_path('byebug', 'byebug')
8
+ @bin_file ||= File.join(root_path, 'bin', 'byebug')
9
9
  end
10
10
 
11
11
  def root_path
12
- @root_path ||= File.expand_path('../..', bin_file)
12
+ @root_path ||= File.expand_path(File.join('..', '..', '..'), __dir__)
13
13
  end
14
14
 
15
15
  def lib_files
16
- @lib_files ||= expand_from_root('lib/**/*.{rb,yml}')
17
- end
18
-
19
- def ext_files
20
- @ext_files ||= expand_from_root('ext/**/*.{c,h,rb}')
16
+ @lib_files ||= glob_for('lib')
21
17
  end
22
18
 
23
19
  def test_files
24
- @test_files ||= expand_from_root('test/**/*.rb')
20
+ @test_files ||= glob_for('test')
25
21
  end
26
22
 
27
23
  def gem_files
28
- @gem_files ||= [bin_file] + lib_files + ext_files
24
+ @gem_files ||= [bin_file] + lib_files
29
25
  end
30
26
 
31
27
  def all_files
@@ -34,8 +30,8 @@ module Byebug
34
30
 
35
31
  private
36
32
 
37
- def expand_from_root(glob)
38
- Dir.glob(File.expand_path(glob, root_path))
33
+ def glob_for(dir)
34
+ Dir.glob(File.join(root_path, dir, '**', '*.rb'))
39
35
  end
40
36
  end
41
37
  end
@@ -17,7 +17,17 @@ module Byebug
17
17
  # command prompt.
18
18
  #
19
19
  def prettify(str)
20
- "\n" + str.gsub(/^ {6}/, '') + "\n"
20
+ "\n" + deindent(str) + "\n"
21
+ end
22
+
23
+ #
24
+ # Removes a number of leading whitespace for each input line.
25
+ #
26
+ # @note Might be unnecessary when Ruby 2.2 support is dropped and we can
27
+ # use squiggly heredoc's.
28
+ #
29
+ def deindent(str, leading_spaces: 6)
30
+ str.gsub(/^ {#{leading_spaces}}/, '')
21
31
  end
22
32
  end
23
33
  end
@@ -9,50 +9,51 @@ module Byebug
9
9
  include ParseHelper
10
10
 
11
11
  def enable_disable_breakpoints(is_enable, args)
12
- return errmsg(pr('toggle.errors.no_breakpoints')) if Breakpoint.none?
12
+ raise pr('toggle.errors.no_breakpoints') if Breakpoint.none?
13
13
 
14
- all_breakpoints = Byebug.breakpoints.sort_by(&:id)
15
- if args.nil?
16
- selected_breakpoints = all_breakpoints
17
- else
18
- selected_ids = []
19
- args.split(/ +/).each do |pos|
20
- last_id = all_breakpoints.last.id
21
- pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id)
22
- return errmsg(err) unless pos
23
-
24
- selected_ids << pos
25
- end
26
- selected_breakpoints = all_breakpoints.select do |b|
27
- selected_ids.include?(b.id)
28
- end
29
- end
30
-
31
- selected_breakpoints.each do |b|
32
- enabled = ('enable' == is_enable)
14
+ select_breakpoints(is_enable, args).each do |b|
15
+ enabled = (is_enable == 'enable')
33
16
  if enabled && !syntax_valid?(b.expr)
34
- return errmsg(pr('toggle.errors.expression', expr: b.expr))
17
+ raise pr('toggle.errors.expression', expr: b.expr)
35
18
  end
36
19
 
20
+ puts pr('toggle.messages.toggled', bpnum: b.id,
21
+ endis: enabled ? 'en' : 'dis')
37
22
  b.enabled = enabled
38
23
  end
39
24
  end
40
25
 
41
26
  def enable_disable_display(is_enable, args)
42
- return errmsg(pr('toggle.errors.no_display')) if n_displays.zero?
27
+ raise pr('toggle.errors.no_display') if n_displays.zero?
43
28
 
44
29
  selected_displays = args ? args.split(/ +/) : [1..n_displays + 1]
45
30
 
46
31
  selected_displays.each do |pos|
47
32
  pos, err = get_int(pos, "#{is_enable} display", 1, n_displays)
48
- return errmsg(err) unless err.nil?
33
+ raise err unless err.nil?
49
34
 
50
- Byebug.displays[pos - 1][0] = ('enable' == is_enable)
35
+ Byebug.displays[pos - 1][0] = (is_enable == 'enable')
51
36
  end
52
37
  end
53
38
 
54
39
  private
55
40
 
41
+ def select_breakpoints(is_enable, args)
42
+ all_breakpoints = Byebug.breakpoints.sort_by(&:id)
43
+ return all_breakpoints if args.nil?
44
+
45
+ selected_ids = []
46
+ args.split(/ +/).each do |pos|
47
+ last_id = all_breakpoints.last.id
48
+ pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id)
49
+ raise(ArgumentError, err) unless pos
50
+
51
+ selected_ids << pos
52
+ end
53
+
54
+ all_breakpoints.select { |b| selected_ids.include?(b.id) }
55
+ end
56
+
56
57
  def n_displays
57
58
  Byebug.displays.size
58
59
  end
@@ -18,7 +18,7 @@ module Byebug
18
18
 
19
19
  def var_global
20
20
  globals = global_variables.reject do |v|
21
- [:$IGNORECASE, :$=, :$KCODE, :$-K, :$binding].include?(v)
21
+ %i[$IGNORECASE $= $KCODE $-K $binding].include?(v)
22
22
  end
23
23
 
24
24
  var_list(globals)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Byebug
3
4
  #
4
5
  # Interface class for standard byebug use.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'yaml'
3
4
 
4
5
  module Byebug
@@ -61,7 +62,7 @@ module Byebug
61
62
  end
62
63
 
63
64
  def contents_files
64
- [File.expand_path(File.join('..', 'texts', 'base.yml'), __FILE__)]
65
+ [File.join(__dir__, 'texts', 'base.yml')]
65
66
  end
66
67
  end
67
68
  end
@@ -35,8 +35,7 @@ module Byebug
35
35
  private
36
36
 
37
37
  def contents_files
38
- [File.expand_path(File.join('..', 'texts', 'plain.yml'), __FILE__)] +
39
- super
38
+ [File.join(__dir__, 'texts', 'plain.yml')] + super
40
39
  end
41
40
  end
42
41
  end
@@ -16,6 +16,8 @@ break:
16
16
  not_changed: "Incorrect expression \"{expr}\", breakpoint not changed"
17
17
  confirmations:
18
18
  delete_all: "Delete all breakpoints?"
19
+ messages:
20
+ breakpoint_deleted: "Deleted breakpoint {pos}"
19
21
 
20
22
  catch:
21
23
  added: "Catching exception {exception}."
@@ -97,6 +99,8 @@ toggle:
97
99
  no_display: "No display expressions have been set"
98
100
  syntax: "\"{toggle}\" must be followed by \"display\", \"breakpoints\" or breakpoint ids"
99
101
  expression: "Expression \"{expr}\" syntactically incorrect; breakpoint remains disabled."
102
+ messages:
103
+ toggled: "Breakpoint {bpnum} {endis}abled"
100
104
 
101
105
  parse:
102
106
  errors:
@@ -1,5 +1,5 @@
1
1
  break:
2
- created: "Successfully created breakpoint with id {id}"
2
+ created: "Created breakpoint {id} at {file}:{line}"
3
3
 
4
4
  display:
5
5
  result: "{n}: {exp} = {result}"
@@ -2,7 +2,9 @@ require 'optparse'
2
2
  require 'English'
3
3
  require 'byebug/core'
4
4
  require 'byebug/version'
5
+ require 'byebug/helpers/bin'
5
6
  require 'byebug/helpers/parse'
7
+ require 'byebug/helpers/string'
6
8
  require 'byebug/option_setter'
7
9
  require 'byebug/processors/control_processor'
8
10
 
@@ -11,7 +13,9 @@ module Byebug
11
13
  # Responsible for starting the debugger when started from the command line.
12
14
  #
13
15
  class Runner
16
+ include Helpers::BinHelper
14
17
  include Helpers::ParseHelper
18
+ include Helpers::StringHelper
15
19
 
16
20
  #
17
21
  # Special working modes that don't actually start the debugger.
@@ -71,12 +75,10 @@ module Byebug
71
75
  # Usage banner.
72
76
  #
73
77
  def banner
74
- <<-EOB.gsub(/^ {6}/, '')
75
-
78
+ prettify <<-EOB
76
79
  byebug #{Byebug::VERSION}
77
80
 
78
81
  Usage: byebug [options] <script.rb> -- <script.rb parameters>
79
-
80
82
  EOB
81
83
  end
82
84
 
@@ -84,9 +86,13 @@ module Byebug
84
86
  # Starts byebug to debug a program.
85
87
  #
86
88
  def run
89
+ Byebug.mode = :standalone
90
+
87
91
  option_parser.order!($ARGV)
88
92
  return if non_script_option? || error_in_script?
89
93
 
94
+ $PROGRAM_NAME = program
95
+
90
96
  Byebug.run_init_script if init_script
91
97
 
92
98
  loop do
@@ -115,6 +121,13 @@ module Byebug
115
121
  end
116
122
  end
117
123
 
124
+ def program
125
+ @program ||= begin
126
+ candidate = which($ARGV.shift)
127
+ candidate == which('ruby') ? which($ARGV.shift) : candidate
128
+ end
129
+ end
130
+
118
131
  #
119
132
  # An option that doesn't need a script specified was given
120
133
  #
@@ -143,25 +156,17 @@ module Byebug
143
156
  # Extracts debugged program from command line args.
144
157
  #
145
158
  def non_existing_script?
146
- Byebug.mode = :standalone
147
-
148
- program = which($ARGV.shift)
149
- program = which($ARGV.shift) if program == which('ruby')
159
+ return false if program
150
160
 
151
- if program
152
- $PROGRAM_NAME = program
153
- false
154
- else
155
- print_error("The script doesn't exist")
156
- true
157
- end
161
+ print_error("The script doesn't exist")
162
+ true
158
163
  end
159
164
 
160
165
  #
161
166
  # Checks the debugged script has correct syntax
162
167
  #
163
168
  def invalid_script?
164
- return false if syntax_valid?(File.read($PROGRAM_NAME))
169
+ return false if syntax_valid?(File.read(program))
165
170
 
166
171
  print_error('The script has incorrect syntax')
167
172
  true
@@ -171,28 +176,10 @@ module Byebug
171
176
  # Debugs a script only if syntax checks okay.
172
177
  #
173
178
  def debug_program
174
- error = Byebug.debug_load($PROGRAM_NAME, stop)
179
+ error = Byebug.debug_load(program, stop)
175
180
  puts "#{error}\n#{error.backtrace}" if error
176
181
  end
177
182
 
178
- #
179
- # Cross-platform way of finding an executable in the $PATH.
180
- # Borrowed from: http://stackoverflow.com/questions/2108727
181
- #
182
- def which(cmd)
183
- return File.expand_path(cmd) if File.exist?(cmd)
184
-
185
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
186
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
187
- exts.each do |ext|
188
- exe = File.join(path, "#{cmd}#{ext}")
189
- return exe if File.executable?(exe) && !File.directory?(exe)
190
- end
191
- end
192
-
193
- nil
194
- end
195
-
196
183
  #
197
184
  # Prints an error message and a help string
198
185
  #
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'byebug/setting'
3
4
 
4
5
  module Byebug
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Reopen main module to define the library version
4
5
  #
5
6
  module Byebug
6
- VERSION = '9.0.6'.freeze
7
+ VERSION = '9.1.0'.freeze
7
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: 9.0.6
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-09-30 00:00:00.000000000 Z
13
+ date: 2017-08-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -27,12 +27,11 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.7'
29
29
  description: |-
30
- Byebug is a Ruby 2 debugger. It's implemented using the
31
- Ruby 2 TracePoint C API for execution control and the Debug Inspector C API
32
- for call stack navigation. The core component provides support that
33
- front-ends can build on. It provides breakpoint handling and bindings for
34
- stack frames among other things and it comes with an easy to use command
35
- line interface.
30
+ Byebug is a Ruby debugger. It's implemented using the
31
+ TracePoint C API for execution control and the Debug Inspector C API for
32
+ call stack navigation. The core component provides support that front-ends
33
+ can build on. It provides breakpoint handling and bindings for stack frames
34
+ among other things and it comes with an easy to use command line interface.
36
35
  email: deivid.rodriguez@mail.com
37
36
  executables:
38
37
  - byebug
@@ -124,6 +123,7 @@ files:
124
123
  - lib/byebug/core.rb
125
124
  - lib/byebug/errors.rb
126
125
  - lib/byebug/frame.rb
126
+ - lib/byebug/helpers/bin.rb
127
127
  - lib/byebug/helpers/eval.rb
128
128
  - lib/byebug/helpers/file.rb
129
129
  - lib/byebug/helpers/frame.rb
@@ -181,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
181
  requirements:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
- version: 2.0.0
184
+ version: 2.2.0
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  requirements:
187
187
  - - ">="
@@ -189,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.6.7
192
+ rubygems_version: 2.6.12
193
193
  signing_key:
194
194
  specification_version: 4
195
- summary: Ruby 2.0 fast debugger - base + CLI
195
+ summary: Ruby fast debugger - base + CLI
196
196
  test_files: []