Hello community, here is the log from the commit of package rubygem-byebug for openSUSE:Factory checked in at 2017-09-07 22:10:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-byebug (Old) and /work/SRC/openSUSE:Factory/.rubygem-byebug.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-byebug" Thu Sep 7 22:10:16 2017 rev:15 rq:520445 version:9.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-byebug/rubygem-byebug.changes 2016-10-13 11:24:30.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-byebug.new/rubygem-byebug.changes 2017-09-07 22:10:18.139599066 +0200 @@ -1,0 +2,23 @@ +Sun Sep 3 08:57:33 UTC 2017 - co...@suse.com + +- updated to version 9.1.0 + see installed CHANGELOG.md + + ## 9.1.0 - 2016-08-22 + + ### Added + + * Better UI messages for breakpoint management. + + ### Fixed + + * `where` command failing on instance_exec block stack frames. + * `restart` command crashing in certain cases because of a missing `require 'English'` (#321, @akaneko3). + * `restart` command crashing when debugged script is not executable or has no shebang (#321, @akaneko3). + + ### Removed + + * Ruby 2.0 and Ruby 2.1 official & unofficial support. Byebug no longer installs + on these platforms. + +------------------------------------------------------------------- Old: ---- byebug-9.0.6.gem New: ---- byebug-9.1.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-byebug.spec ++++++ --- /var/tmp/diff_new_pack.fiKiWA/_old 2017-09-07 22:10:19.499407405 +0200 +++ /var/tmp/diff_new_pack.fiKiWA/_new 2017-09-07 22:10:19.503406842 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-byebug # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-byebug -Version: 9.0.6 +Version: 9.1.0 Release: 0 %define mod_name byebug %define mod_full_name %{mod_name}-%{version} @@ -34,7 +34,7 @@ %endif # /MANUAL BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{rubydevel >= 2.0.0} +BuildRequires: %{rubydevel >= 2.2.0} BuildRequires: %{rubygem gem2rpm} BuildRequires: ruby-macros >= 5 BuildRequires: update-alternatives @@ -42,18 +42,17 @@ Source: http://rubygems.org/gems/%{mod_full_name}.gem Source1: rubygem-byebug-rpmlintrc Source2: gem2rpm.yml -Summary: Ruby 2.0 fast debugger - base + CLI +Summary: Ruby fast debugger - base + CLI License: BSD-2-Clause Group: Development/Languages/Ruby PreReq: update-alternatives %description -Byebug is a Ruby 2 debugger. It's implemented using the -Ruby 2 TracePoint C API for execution control and the Debug Inspector C API -for call stack navigation. The core component provides support that -front-ends can build on. It provides breakpoint handling and bindings for -stack frames among other things and it comes with an easy to use command -line interface. +Byebug is a Ruby debugger. It's implemented using the +TracePoint C API for execution control and the Debug Inspector C API for +call stack navigation. The core component provides support that front-ends +can build on. It provides breakpoint handling and bindings for stack frames +among other things and it comes with an easy to use command line interface. %prep ++++++ byebug-9.0.6.gem -> byebug-9.1.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2016-09-30 02:09:25.000000000 +0200 +++ new/CHANGELOG.md 2017-08-22 11:50:13.000000000 +0200 @@ -2,6 +2,23 @@ ## Master (Unreleased) +## 9.1.0 - 2016-08-22 + +### Added + +* Better UI messages for breakpoint management. + +### Fixed + +* `where` command failing on instance_exec block stack frames. +* `restart` command crashing in certain cases because of a missing `require 'English'` (#321, @akaneko3). +* `restart` command crashing when debugged script is not executable or has no shebang (#321, @akaneko3). + +### Removed + +* Ruby 2.0 and Ruby 2.1 official & unofficial support. Byebug no longer installs + on these platforms. + ## 9.0.6 - 2016-09-29 ### Fixed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/GUIDE.md new/GUIDE.md --- old/GUIDE.md 2016-09-30 02:09:25.000000000 +0200 +++ new/GUIDE.md 2017-08-22 11:50:13.000000000 +0200 @@ -186,7 +186,21 @@ n_args = $ARGV.length -fail('*** Need number of disks or no parameter') if n_args > 1 +raise('*** Need number of disks or no parameter') if n_args > 1 + +n = 3 + +if n_args > 0 + begin + n = $ARGV[0].to_i + rescue ValueError + raise("*** Expecting an integer, got: #{$ARGV[0]}") + end +end + +raise('*** Number of disks should be between 1 and 100') if n < 1 || n > 100 + +hanoi(n, :a, :b, :c) ``` Recall in the first section it was stated that before the `def` is run, the @@ -316,7 +330,7 @@ 11: => 12: n_args = $ARGV.length 13: - 14: fail('*** Need number of disks or no parameter') if n_args > 1 + 14: raise('*** Need number of disks or no parameter') if n_args > 1 (byebug) private_methods.member?(:hanoi) true (byebug) @@ -442,15 +456,15 @@ 19: begin 20: n = $ARGV[0].to_i 21: rescue ValueError - 22: raise("** Expecting an integer, got: #{$ARGV[0]}") + 22: raise("*** Expecting an integer, got: #{$ARGV[0]}") 23: end 24: end 25: - 26: fail('*** Number of disks should be between 1 and 100') if n < 1 || n > 100 + 26: raise('*** Number of disks should be between 1 and 100') if n < 1 || n > 100 27: => 28: hanoi(n, :a, :b, :c) (byebug) n_args -0 +1 (byebug) eval n 3 (byebug) down 2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-09-30 02:09:25.000000000 +0200 +++ new/README.md 2017-08-22 11:50:13.000000000 +0200 @@ -18,10 +18,10 @@ [tip_url]: https://gratipay.com/byebug [irc_url]: https://gitter.im/deivid-rodriguez/byebug -Byebug is a simple to use, feature rich debugger for Ruby 2. It uses the new -TracePoint API for execution control and the new Debug Inspector API for call -stack navigation, so it doesn't depend on internal core sources. It's developed -as a C extension, so it's fast. And it has a full test suite so it's reliable. +Byebug is a simple to use, feature rich debugger for Ruby. It uses the +TracePoint API for execution control and the Debug Inspector API for call stack +navigation, so it doesn't depend on internal core sources. It's developed as a C +extension, so it's fast. And it has a full test suite so it's reliable. It allows you to see what is going on _inside_ a Ruby program while it executes and offers many of the traditional debugging features such as: @@ -48,12 +48,10 @@ ## Requirements -* Required: MRI 2.0.0 or higher. For debugging ruby 1.9.3 or older, use - [debugger]. * Recommended: - * MRI 2.1.8 or higher. * MRI 2.2.4 or higher. * MRI 2.3.0 or higher. + * MRI 2.4.0 or higher. ## Install @@ -63,6 +61,8 @@ ## Usage +### From within the Ruby code + Simply drop byebug @@ -74,6 +74,7 @@ def index byebug @articles = Article.find_recent +end ``` And then start a Rails server. @@ -84,6 +85,14 @@ Once the execution gets to your `byebug` command you will get a debugging prompt. +### From the command line + +If you want to debug a Ruby script without editing it, you can invoke byebug from the command line. + +```shell +byebug myscript.rb +``` + ## Byebug's commands Command | Aliases | Subcommands @@ -145,6 +154,7 @@ connected. * [minitest-byebug] starts a byebug session on minitest failures. * [sublime_debugger] provides a plugin for ruby debugging on Sublime Text. +* [atom-byebug] provides integration with the Atom editor [EXPERIMENTAL]. ## Contribute @@ -168,3 +178,4 @@ [ruby-debug-passenger]: https://github.com/davejamesmiller/ruby-debug-passenger [minitest-byebug]: https://github.com/kaspth/minitest-byebug [sublime_debugger]: https://github.com/shuky19/sublime_debugger +[atom-byebug]: https://github.com/izaera/atom-byebug diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bin/byebug new/bin/byebug --- old/bin/byebug 2016-09-30 02:09:25.000000000 +0200 +++ new/bin/byebug 2017-08-22 11:50:13.000000000 +0200 @@ -1,6 +1,8 @@ #!/usr/bin/env ruby -$LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib') +bin_dir = File.dirname(File.realpath(__FILE__)) + +$LOAD_PATH.unshift(File.expand_path(File.join('..', 'lib'), bin_dir)) require 'byebug/runner' Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/breakpoint.rb new/lib/byebug/breakpoint.rb --- old/lib/byebug/breakpoint.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/breakpoint.rb 2017-08-22 11:50:13.000000000 +0200 @@ -81,7 +81,7 @@ # Prints all information associated to the breakpoint # def inspect - meths = %w(id pos source expr hit_condition hit_count hit_value enabled?) + meths = %w[id pos source expr hit_condition hit_count hit_value enabled?] values = meths.map { |field| "#{field}: #{send(field)}" }.join(', ') "#<Byebug::Breakpoint #{values}>" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/commands/catch.rb new/lib/byebug/commands/catch.rb --- old/lib/byebug/commands/catch.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/commands/catch.rb 2017-08-22 11:50:13.000000000 +0200 @@ -36,7 +36,7 @@ def execute return info unless @match[1] - return 'off' == @match[1] ? clear : add(@match[1]) unless @match[2] + return @match[1] == 'off' ? clear : add(@match[1]) unless @match[2] return errmsg pr('catch.errors.off', off: cmd) unless @match[2] == 'off' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/commands/delete.rb new/lib/byebug/commands/delete.rb --- old/lib/byebug/commands/delete.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/commands/delete.rb 2017-08-22 11:50:13.000000000 +0200 @@ -44,8 +44,10 @@ return errmsg(err) unless pos - unless Breakpoint.remove(pos) - return errmsg(pr('break.errors.no_breakpoint_delete', pos: pos)) + if Breakpoint.remove(pos) + puts(pr('break.messages.breakpoint_deleted', pos: pos)) + else + errmsg(pr('break.errors.no_breakpoint_delete', pos: pos)) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/commands/enable/breakpoints.rb new/lib/byebug/commands/enable/breakpoints.rb --- old/lib/byebug/commands/enable/breakpoints.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/commands/enable/breakpoints.rb 2017-08-22 11:50:13.000000000 +0200 @@ -29,7 +29,7 @@ end def self.short_description - 'Disable all or specific breakpoints' + 'Enable all or specific breakpoints' end def execute diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/commands/info/file.rb new/lib/byebug/commands/info/file.rb --- old/lib/byebug/commands/info/file.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/commands/info/file.rb 2017-08-22 11:50:13.000000000 +0200 @@ -10,6 +10,7 @@ # class FileCommand < Command include Helpers::FileHelper + include Helpers::StringHelper self.allow_in_post_mortem = true @@ -38,8 +39,7 @@ return errmsg(pr('info.errors.undefined_file', file: file)) end - puts <<-EOC.gsub(/^ {6}/, '') - + puts prettify <<-EOC File #{info_file_basic(file)} Breakpoint line numbers: #{info_file_breakpoints(file)} @@ -47,7 +47,6 @@ Modification time: #{info_file_mtime(file)} Sha1 Signature: #{info_file_sha1(file)} - EOC end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/commands/irb.rb new/lib/byebug/commands/irb.rb --- old/lib/byebug/commands/irb.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/commands/irb.rb 2017-08-22 11:50:13.000000000 +0200 @@ -1,5 +1,6 @@ require 'byebug/command' require 'irb' +require 'English' module Byebug # @@ -29,7 +30,7 @@ return errmsg(pr('base.errors.only_local')) end - # @todo IRB tries to parse ARGV so we must clear it (see #197). Add a + # @todo IRB tries to parse $ARGV so we must clear it (see #197). Add a # test case for it so we can remove this comment. with_clean_argv { IRB.start } end @@ -37,12 +38,12 @@ private def with_clean_argv - saved_argv = ARGV.dup - ARGV.clear + saved_argv = $ARGV.dup + $ARGV.clear begin yield ensure - ARGV.concat(saved_argv) + $ARGV.concat(saved_argv) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/commands/kill.rb new/lib/byebug/commands/kill.rb --- old/lib/byebug/commands/kill.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/commands/kill.rb 2017-08-22 11:50:13.000000000 +0200 @@ -38,7 +38,7 @@ signame = 'KILL' end - processor.interface.close if 'KILL' == signame + processor.interface.close if signame == 'KILL' Process.kill(signame, Process.pid) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/commands/restart.rb new/lib/byebug/commands/restart.rb --- old/lib/byebug/commands/restart.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/commands/restart.rb 2017-08-22 11:50:13.000000000 +0200 @@ -1,12 +1,16 @@ require 'byebug/command' +require 'byebug/helpers/bin' require 'byebug/helpers/path' require 'shellwords' +require 'English' +require 'rbconfig' module Byebug # # Restart debugged program from within byebug. # class RestartCommand < Command + include Helpers::BinHelper include Helpers::PathHelper self.allow_in_control = true @@ -32,14 +36,27 @@ end def execute - argv = [$PROGRAM_NAME] + cmd = [$PROGRAM_NAME] - argv.unshift(bin_file) if Byebug.mode == :standalone + cmd = prepend_byebug_bin(cmd) + cmd = prepend_ruby_bin(cmd) - argv += (@match[:args] ? @match[:args].shellsplit : $ARGV.compact) + cmd += (@match[:args] ? @match[:args].shellsplit : $ARGV) - puts pr('restart.success', cmd: argv.shelljoin) - Kernel.exec(*argv) + puts pr('restart.success', cmd: cmd.shelljoin) + Kernel.exec(*cmd) + end + + private + + def prepend_byebug_bin(cmd) + cmd.unshift(bin_file) if Byebug.mode == :standalone + cmd + end + + def prepend_ruby_bin(cmd) + cmd.unshift(RbConfig.ruby) if which('ruby') != which(cmd.first) + cmd end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/commands/save.rb new/lib/byebug/commands/save.rb --- old/lib/byebug/commands/save.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/commands/save.rb 2017-08-22 11:50:13.000000000 +0200 @@ -62,7 +62,7 @@ end def save_settings(file) - %w(autoirb autolist basename).each do |setting| + %w[autoirb autolist basename].each do |setting| file.puts "set #{setting} #{Setting[setting.to_sym]}" end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/core.rb new/lib/byebug/core.rb --- old/lib/byebug/core.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/core.rb 2017-08-22 11:50:13.000000000 +0200 @@ -51,7 +51,7 @@ end def self.load_settings - Dir.glob(File.expand_path('../settings/*.rb', __FILE__)).each do |file| + Dir.glob(File.join(__dir__, 'settings', '*.rb')).each do |file| require file end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/frame.rb new/lib/byebug/frame.rb --- old/lib/byebug/frame.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/frame.rb 2017-08-22 11:50:13.000000000 +0200 @@ -47,13 +47,10 @@ # # Gets local variables for the frame. # - # @todo Use `Binding#local_variables` directly once we drop 2.1 support - # since it's a public method since ruby 2.2 - # def locals return [] unless _binding - _binding.eval('local_variables').each_with_object({}) do |e, a| + _binding.local_variables.each_with_object({}) do |e, a| a[e] = _binding.local_variable_get(e) a end @@ -161,14 +158,14 @@ def c_args return [] unless _self.to_s != 'main' - _self.method(_method).parameters + _class.instance_method(_method).parameters end def ruby_args meth_name = _binding.eval('__method__') return [] unless meth_name - meth_obj = _self.method(meth_name) + meth_obj = _class.instance_method(meth_name) return [] unless meth_obj meth_obj.parameters diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/helpers/bin.rb new/lib/byebug/helpers/bin.rb --- old/lib/byebug/helpers/bin.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/byebug/helpers/bin.rb 2017-08-22 11:50:13.000000000 +0200 @@ -0,0 +1,26 @@ +module Byebug + module Helpers + # + # Utilities for interaction with executables + # + module BinHelper + # + # Cross-platform way of finding an executable in the $PATH. + # Borrowed from: http://stackoverflow.com/questions/2108727 + # + def which(cmd) + return File.expand_path(cmd) if File.exist?(cmd) + + exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] + ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| + exts.each do |ext| + exe = File.join(path, "#{cmd}#{ext}") + return exe if File.executable?(exe) && !File.directory?(exe) + end + end + + nil + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/helpers/file.rb new/lib/byebug/helpers/file.rb --- old/lib/byebug/helpers/file.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/helpers/file.rb 2017-08-22 11:50:13.000000000 +0200 @@ -8,7 +8,7 @@ # Reads lines of source file +filename+ into an array # def get_lines(filename) - File.foreach(filename).reduce([]) { |a, e| a << e.chomp } + File.foreach(filename).reduce([]) { |acc, elem| acc << elem.chomp } end # @@ -26,7 +26,7 @@ # one-line-at-a-time way. # def n_lines(filename) - File.foreach(filename).reduce(0) { |a, _e| a + 1 } + File.foreach(filename).reduce(0) { |acc, _elem| acc + 1 } end # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/helpers/path.rb new/lib/byebug/helpers/path.rb --- old/lib/byebug/helpers/path.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/helpers/path.rb 2017-08-22 11:50:13.000000000 +0200 @@ -5,27 +5,23 @@ # module PathHelper def bin_file - @bin_file ||= Gem.bin_path('byebug', 'byebug') + @bin_file ||= File.join(root_path, 'bin', 'byebug') end def root_path - @root_path ||= File.expand_path('../..', bin_file) + @root_path ||= File.expand_path(File.join('..', '..', '..'), __dir__) end def lib_files - @lib_files ||= expand_from_root('lib/**/*.{rb,yml}') - end - - def ext_files - @ext_files ||= expand_from_root('ext/**/*.{c,h,rb}') + @lib_files ||= glob_for('lib') end def test_files - @test_files ||= expand_from_root('test/**/*.rb') + @test_files ||= glob_for('test') end def gem_files - @gem_files ||= [bin_file] + lib_files + ext_files + @gem_files ||= [bin_file] + lib_files end def all_files @@ -34,8 +30,8 @@ private - def expand_from_root(glob) - Dir.glob(File.expand_path(glob, root_path)) + def glob_for(dir) + Dir.glob(File.join(root_path, dir, '**', '*.rb')) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/helpers/string.rb new/lib/byebug/helpers/string.rb --- old/lib/byebug/helpers/string.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/helpers/string.rb 2017-08-22 11:50:13.000000000 +0200 @@ -17,7 +17,17 @@ # command prompt. # def prettify(str) - "\n" + str.gsub(/^ {6}/, '') + "\n" + "\n" + deindent(str) + "\n" + end + + # + # Removes a number of leading whitespace for each input line. + # + # @note Might be unnecessary when Ruby 2.2 support is dropped and we can + # use squiggly heredoc's. + # + def deindent(str, leading_spaces: 6) + str.gsub(/^ {#{leading_spaces}}/, '') end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/helpers/toggle.rb new/lib/byebug/helpers/toggle.rb --- old/lib/byebug/helpers/toggle.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/helpers/toggle.rb 2017-08-22 11:50:13.000000000 +0200 @@ -9,50 +9,51 @@ include ParseHelper def enable_disable_breakpoints(is_enable, args) - return errmsg(pr('toggle.errors.no_breakpoints')) if Breakpoint.none? + raise pr('toggle.errors.no_breakpoints') if Breakpoint.none? - all_breakpoints = Byebug.breakpoints.sort_by(&:id) - if args.nil? - selected_breakpoints = all_breakpoints - else - selected_ids = [] - args.split(/ +/).each do |pos| - last_id = all_breakpoints.last.id - pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id) - return errmsg(err) unless pos - - selected_ids << pos - end - selected_breakpoints = all_breakpoints.select do |b| - selected_ids.include?(b.id) - end - end - - selected_breakpoints.each do |b| - enabled = ('enable' == is_enable) + select_breakpoints(is_enable, args).each do |b| + enabled = (is_enable == 'enable') if enabled && !syntax_valid?(b.expr) - return errmsg(pr('toggle.errors.expression', expr: b.expr)) + raise pr('toggle.errors.expression', expr: b.expr) end + puts pr('toggle.messages.toggled', bpnum: b.id, + endis: enabled ? 'en' : 'dis') b.enabled = enabled end end def enable_disable_display(is_enable, args) - return errmsg(pr('toggle.errors.no_display')) if n_displays.zero? + raise pr('toggle.errors.no_display') if n_displays.zero? selected_displays = args ? args.split(/ +/) : [1..n_displays + 1] selected_displays.each do |pos| pos, err = get_int(pos, "#{is_enable} display", 1, n_displays) - return errmsg(err) unless err.nil? + raise err unless err.nil? - Byebug.displays[pos - 1][0] = ('enable' == is_enable) + Byebug.displays[pos - 1][0] = (is_enable == 'enable') end end private + def select_breakpoints(is_enable, args) + all_breakpoints = Byebug.breakpoints.sort_by(&:id) + return all_breakpoints if args.nil? + + selected_ids = [] + args.split(/ +/).each do |pos| + last_id = all_breakpoints.last.id + pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id) + raise(ArgumentError, err) unless pos + + selected_ids << pos + end + + all_breakpoints.select { |b| selected_ids.include?(b.id) } + end + def n_displays Byebug.displays.size end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/helpers/var.rb new/lib/byebug/helpers/var.rb --- old/lib/byebug/helpers/var.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/helpers/var.rb 2017-08-22 11:50:13.000000000 +0200 @@ -18,7 +18,7 @@ def var_global globals = global_variables.reject do |v| - [:$IGNORECASE, :$=, :$KCODE, :$-K, :$binding].include?(v) + %i[$IGNORECASE $= $KCODE $-K $binding].include?(v) end var_list(globals) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/interfaces/local_interface.rb new/lib/byebug/interfaces/local_interface.rb --- old/lib/byebug/interfaces/local_interface.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/interfaces/local_interface.rb 2017-08-22 11:50:13.000000000 +0200 @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Byebug # # Interface class for standard byebug use. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/printers/base.rb new/lib/byebug/printers/base.rb --- old/lib/byebug/printers/base.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/printers/base.rb 2017-08-22 11:50:13.000000000 +0200 @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'yaml' module Byebug @@ -61,7 +62,7 @@ end def contents_files - [File.expand_path(File.join('..', 'texts', 'base.yml'), __FILE__)] + [File.join(__dir__, 'texts', 'base.yml')] end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/printers/plain.rb new/lib/byebug/printers/plain.rb --- old/lib/byebug/printers/plain.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/printers/plain.rb 2017-08-22 11:50:13.000000000 +0200 @@ -35,8 +35,7 @@ private def contents_files - [File.expand_path(File.join('..', 'texts', 'plain.yml'), __FILE__)] + - super + [File.join(__dir__, 'texts', 'plain.yml')] + super end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/printers/texts/base.yml new/lib/byebug/printers/texts/base.yml --- old/lib/byebug/printers/texts/base.yml 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/printers/texts/base.yml 2017-08-22 11:50:13.000000000 +0200 @@ -16,6 +16,8 @@ not_changed: "Incorrect expression \"{expr}\", breakpoint not changed" confirmations: delete_all: "Delete all breakpoints?" + messages: + breakpoint_deleted: "Deleted breakpoint {pos}" catch: added: "Catching exception {exception}." @@ -97,6 +99,8 @@ no_display: "No display expressions have been set" syntax: "\"{toggle}\" must be followed by \"display\", \"breakpoints\" or breakpoint ids" expression: "Expression \"{expr}\" syntactically incorrect; breakpoint remains disabled." + messages: + toggled: "Breakpoint {bpnum} {endis}abled" parse: errors: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/printers/texts/plain.yml new/lib/byebug/printers/texts/plain.yml --- old/lib/byebug/printers/texts/plain.yml 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/printers/texts/plain.yml 2017-08-22 11:50:13.000000000 +0200 @@ -1,5 +1,5 @@ break: - created: "Successfully created breakpoint with id {id}" + created: "Created breakpoint {id} at {file}:{line}" display: result: "{n}: {exp} = {result}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/runner.rb new/lib/byebug/runner.rb --- old/lib/byebug/runner.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/runner.rb 2017-08-22 11:50:13.000000000 +0200 @@ -2,7 +2,9 @@ require 'English' require 'byebug/core' require 'byebug/version' +require 'byebug/helpers/bin' require 'byebug/helpers/parse' +require 'byebug/helpers/string' require 'byebug/option_setter' require 'byebug/processors/control_processor' @@ -11,7 +13,9 @@ # Responsible for starting the debugger when started from the command line. # class Runner + include Helpers::BinHelper include Helpers::ParseHelper + include Helpers::StringHelper # # Special working modes that don't actually start the debugger. @@ -71,12 +75,10 @@ # Usage banner. # def banner - <<-EOB.gsub(/^ {6}/, '') - + prettify <<-EOB byebug #{Byebug::VERSION} Usage: byebug [options] <script.rb> -- <script.rb parameters> - EOB end @@ -84,9 +86,13 @@ # Starts byebug to debug a program. # def run + Byebug.mode = :standalone + option_parser.order!($ARGV) return if non_script_option? || error_in_script? + $PROGRAM_NAME = program + Byebug.run_init_script if init_script loop do @@ -115,6 +121,13 @@ end end + def program + @program ||= begin + candidate = which($ARGV.shift) + candidate == which('ruby') ? which($ARGV.shift) : candidate + end + end + # # An option that doesn't need a script specified was given # @@ -143,25 +156,17 @@ # Extracts debugged program from command line args. # def non_existing_script? - Byebug.mode = :standalone - - program = which($ARGV.shift) - program = which($ARGV.shift) if program == which('ruby') + return false if program - if program - $PROGRAM_NAME = program - false - else - print_error("The script doesn't exist") - true - end + print_error("The script doesn't exist") + true end # # Checks the debugged script has correct syntax # def invalid_script? - return false if syntax_valid?(File.read($PROGRAM_NAME)) + return false if syntax_valid?(File.read(program)) print_error('The script has incorrect syntax') true @@ -171,29 +176,11 @@ # Debugs a script only if syntax checks okay. # def debug_program - error = Byebug.debug_load($PROGRAM_NAME, stop) + error = Byebug.debug_load(program, stop) puts "#{error}\n#{error.backtrace}" if error end # - # Cross-platform way of finding an executable in the $PATH. - # Borrowed from: http://stackoverflow.com/questions/2108727 - # - def which(cmd) - return File.expand_path(cmd) if File.exist?(cmd) - - exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] - ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| - exts.each do |ext| - exe = File.join(path, "#{cmd}#{ext}") - return exe if File.executable?(exe) && !File.directory?(exe) - end - end - - nil - end - - # # Prints an error message and a help string # def print_error(msg) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/settings/callstyle.rb new/lib/byebug/settings/callstyle.rb --- old/lib/byebug/settings/callstyle.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/settings/callstyle.rb 2017-08-22 11:50:13.000000000 +0200 @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'byebug/setting' module Byebug diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/byebug/version.rb new/lib/byebug/version.rb --- old/lib/byebug/version.rb 2016-09-30 02:09:25.000000000 +0200 +++ new/lib/byebug/version.rb 2017-08-22 11:50:13.000000000 +0200 @@ -1,7 +1,8 @@ # frozen_string_literal: true + # # Reopen main module to define the library version # module Byebug - VERSION = '9.0.6'.freeze + VERSION = '9.1.0'.freeze end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-09-30 02:09:25.000000000 +0200 +++ new/metadata 2017-08-22 11:50:13.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: byebug version: !ruby/object:Gem::Version - version: 9.0.6 + version: 9.1.0 platform: ruby authors: - David Rodriguez @@ -10,7 +10,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2016-09-30 00:00:00.000000000 Z +date: 2017-08-22 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler @@ -27,12 +27,11 @@ - !ruby/object:Gem::Version version: '1.7' description: |- - Byebug is a Ruby 2 debugger. It's implemented using the - Ruby 2 TracePoint C API for execution control and the Debug Inspector C API - for call stack navigation. The core component provides support that - front-ends can build on. It provides breakpoint handling and bindings for - stack frames among other things and it comes with an easy to use command - line interface. + Byebug is a Ruby debugger. It's implemented using the + TracePoint C API for execution control and the Debug Inspector C API for + call stack navigation. The core component provides support that front-ends + can build on. It provides breakpoint handling and bindings for stack frames + among other things and it comes with an easy to use command line interface. email: deivid.rodrig...@mail.com executables: - byebug @@ -124,6 +123,7 @@ - lib/byebug/core.rb - lib/byebug/errors.rb - lib/byebug/frame.rb +- lib/byebug/helpers/bin.rb - lib/byebug/helpers/eval.rb - lib/byebug/helpers/file.rb - lib/byebug/helpers/frame.rb @@ -181,7 +181,7 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: 2.0.0 + version: 2.2.0 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -189,8 +189,8 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.6.7 +rubygems_version: 2.6.12 signing_key: specification_version: 4 -summary: Ruby 2.0 fast debugger - base + CLI +summary: Ruby fast debugger - base + CLI test_files: []