pax_global_header00006660000000000000000000000064134334555600014522gustar00rootroot0000000000000052 comment=283357cb5837022096373851950a69b37f0a4f8a pry-byebug-3.7.0/000077500000000000000000000000001343345556000136165ustar00rootroot00000000000000pry-byebug-3.7.0/.circleci/000077500000000000000000000000001343345556000154515ustar00rootroot00000000000000pry-byebug-3.7.0/.circleci/config.yml000066400000000000000000000060551343345556000174470ustar00rootroot00000000000000--- version: 2.1 executors: test: parameters: version: type: string docker: - image: ruby:<< parameters.version >> jobs: spec: parameters: executor: type: executor executor: << parameters.executor >> steps: - checkout - restore_cache: keys: - dependencies-{{ checksum "Gemfile.lock" }} - run: name: Install dependencies command: | gem install bundler -v 2.0.1 bundle install --jobs 3 --retry 3 --path .bundle - run: name: Run tests command: | RUBYOPT="-E UTF-8" bundle exec rake - attach_workspace: at: coverage - attach_workspace: at: /usr/local/bin - run: name: Save coverage command: | cc-test-reporter format-coverage --output coverage/codeclimate.$CIRCLE_JOB.json - persist_to_workspace: root: coverage paths: - codeclimate.*.json - save_cache: key: dependencies-{{ checksum "Gemfile.lock" }} paths: - .bundle setup_coverage: docker: - image: ruby:2.6.0 working_directory: /usr/local/bin steps: - run: name: Download test coverage reporter command: | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > cc-test-reporter - run: name: Give test coverage reporter executable permissions command: | chmod +x cc-test-reporter - persist_to_workspace: root: /usr/local/bin paths: - cc-test-reporter upload_coverage: docker: - image: ruby:2.6.0 environment: - CC_TEST_REPORTER_ID: f06a22b27a507a3054eb69873c9e3bbc9ef97476d6ef22eec8cd24686494cb2b steps: - attach_workspace: at: coverage - attach_workspace: at: /usr/local/bin - run: name: Aggregate coverage results command: | cc-test-reporter sum-coverage coverage/codeclimate.*.json - run: name: Upload coverage results to codeclimate command: | cc-test-reporter upload-coverage workflows: version: 2 test: jobs: - setup_coverage - spec: name: "2.3" executor: name: test version: 2.3.8 requires: - setup_coverage - spec: name: "2.4" executor: name: test version: 2.4.5 requires: - setup_coverage - spec: name: "2.5" executor: name: test version: 2.5.3 requires: - setup_coverage - spec: name: "2.6" executor: name: test version: 2.6.0 requires: - setup_coverage - upload_coverage: requires: - "2.3" - "2.4" - "2.5" - "2.6" pry-byebug-3.7.0/.codeclimate.yml000066400000000000000000000012571343345556000166750ustar00rootroot00000000000000--- version: "2" checks: method-complexity: config: threshold: 6 similar-code: enabled: false plugins: grep: enabled: true config: patterns: no-trailing-whitespace: pattern: \s*$ annotation: "Don't leave trailing whitespace" severity: minor categories: Style path_patterns: - .rubocop.yml - .travis.yml no-tabs: pattern: " " annotation: "Don't use hard tabs" severity: minor categories: Style path_patterns: - .rubocop.yml - .travis.yml exclude_patterns: - coverage/ - .bundle/ pry-byebug-3.7.0/.gitignore000066400000000000000000000001721343345556000156060ustar00rootroot00000000000000# # Only generated pry-byebug specific files to be kept here. # tmp pkg doc coverage .bundle .ruby-gemset .ruby-version pry-byebug-3.7.0/.mdlrc000066400000000000000000000000261343345556000147160ustar00rootroot00000000000000rules '~MD013,~MD024' pry-byebug-3.7.0/.rubocop.yml000066400000000000000000000006011343345556000160650ustar00rootroot00000000000000AllCops: DisplayCopNames: true DisplayStyleGuide: true TargetRubyVersion: 2.3 Lint/Debugger: Exclude: - test/examples/*.rb Metrics: Enabled: false Naming/FileName: Exclude: - lib/pry-byebug.rb - pry-byebug.gemspec Style/ModuleFunction: Enabled: false Style/StringLiterals: EnforcedStyle: double_quotes Layout/ExtraSpacing: AllowForAlignment: false pry-byebug-3.7.0/CHANGELOG.md000066400000000000000000000061001343345556000154240ustar00rootroot00000000000000# CHANGELOG ## Master (Unreleased) ## 3.7.0 (2019-02-21) * Byebug 11 compatibility, with ruby 2.6 support. ## 3.6.0 (2018-02-07) ### Added * Byebug 10 compatibility, with ruby 2.5 support. ## 3.5.1 (2017-11-27) ### Fixed * Allow other threads like Pry. (#142) ## 3.5.0 (2017-08-23) ### Added * Byebug 9.1 support. As a result, Ruby 2.0 & Ruby 2.1 support has been dropped. Pry-byebug no longer installs on these platforms. ## 3.4.3 (2017-08-22) ### Fixed * Installation on old rubies after byebug dropping support for them. ## 3.4.2 (2016-12-06) ### Fixed * Byebug doesn't start after `disable-pry` command. ## 3.4.1 (2016-11-22) ### Fixed * control_d handler not being required properly when `pry-byebug` loaded as a `pry` plugin and not through explicit require. ## 3.4.0 (2016-05-15) ### Fixed * Byebug 9 compatibility. ### Added * A new `backtrace` command. ## 3.3.0 (2015-11-05) ### Fixed * Byebug 8 compatibility. * Fix encoding error in gemspec file (#70). * Debugger being too slow (#80, thanks @k0kubun). ## 3.2.0 (2015-07-18) ### Added * `continue` can now receive a line number argument (#56). ### Fixed * Conflicts with `break` and `next` Ruby keywords inside multiline statements (#44). ### Removed * `breaks` command. It was broken anyways (#47). ## 3.1.0 (2015-04-14) ### Added * Frame navigation commands `up`, `down` and `frame`. ## 3.0.1 (2015-04-02) ### Fixed * Several formatting and alignment issues. ## 3.0.0 (2015-02-02) ### Fixed * `binding.pry` would not stop at the correct place when called at the last line of a method/block. ### Removed * Stepping aliases for `next` (`n`), `step` (`s`), `finish` (`f`) and `continue` (`c`). See #34. ## 2.0.0 (2014-01-09) ### Fixed * Byebug 3 compatibility. * Pry not starting at the first line after `binding.pry` but at `binding.pry`. * `continue` not finishing pry instance (#13). ## 1.3.3 (2014-25-06) ### Fixed * Pry 0.10 series and further minor version level releases compatibility. ## 1.3.2 (2014-24-02) ### Fixed * Bug inherited from `byebug`. ## 1.3.1 (2014-08-02) ### Fixed * Bug #22 (thanks @andreychernih). ## 1.3.0 (2014-05-02) ### Added * Breakpoints on method names (thanks @andreychernih & @palkan). ### Fixed * "Undefined method `interface`" error (huge thanks to @andreychernih). ## 1.2.1 (2013-30-12) ### Fixed * "Uncaught throw :breakout_nav" error (thanks @lukebergen). ## 1.2.0 (2013-24-09) ### Fixed * Compatibility with byebug's 2.x series ## 1.1.2 (2013-11-07) ### Fixed * Compatibility with backwards compatible byebug versions. ## 1.1.1 (2013-02-07) ### Fixed * Bug when doing `step n` or `next n` where n > 1 right after `binding.pry`. ## 1.1.0 (2013-06-06) ### Added * `s`, `n`, `f` and `c` aliases (thanks @jgakos!). ## 1.0.1 (2013-05-07) ### Fixed * Unwanted debugging printf. ## 1.0.0 (2013-05-07) ### Added * Initial release forked from [pry-debugger](https://github.com/nixme/pry-debugger) to support byebug. ### Removed * pry-remote support. ## Older releases * Check [pry-debugger](https://github.com/nixme/pry-debugger)'s CHANGELOG. pry-byebug-3.7.0/CONTRIBUTING.md000066400000000000000000000011021343345556000160410ustar00rootroot00000000000000# CONTRIBUTING Please note that this project is released with a [Contributor Code of Conduct](code_of_conduct.md). By participating in this project you agree to abide by its terms. ## Bug Reports * Try to reproduce the issue against the latest revision. There might be unrealeased work that fixes your problem! * Ensure that your issue has not already been reported. * Include the steps you carried out to produce the problem. If we can't reproduce it, we can't fix it. * Include the behavior you observed along with the behavior you expected, and why you expected it. pry-byebug-3.7.0/Gemfile000066400000000000000000000003251343345556000151110ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec gem "rake", "~> 12.3" gem "chandler", "0.9.0" gem "mdl", "0.5.0" gem "minitest", "~> 5.11" gem "rubocop", "0.65.0" gem "simplecov", "0.16.1" pry-byebug-3.7.0/Gemfile.lock000066400000000000000000000033641343345556000160460ustar00rootroot00000000000000PATH remote: . specs: pry-byebug (3.7.0) byebug (~> 11.0) pry (~> 0.10) GEM remote: https://rubygems.org/ specs: addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) ast (2.4.0) byebug (11.0.0) chandler (0.9.0) netrc octokit (>= 2.2.0) coderay (1.1.2) docile (1.3.0) faraday (0.15.4) multipart-post (>= 1.2, < 3) jaro_winkler (1.5.2) json (2.1.0) kramdown (1.17.0) mdl (0.5.0) kramdown (~> 1.12, >= 1.12.0) mixlib-cli (~> 1.7, >= 1.7.0) mixlib-config (~> 2.2, >= 2.2.1) method_source (0.9.2) minitest (5.11.3) mixlib-cli (1.7.0) mixlib-config (2.2.8) tomlrb multipart-post (2.0.0) netrc (0.11.0) octokit (4.13.0) sawyer (~> 0.8.0, >= 0.5.3) parallel (1.13.0) parser (2.6.0.0) ast (~> 2.4.0) powerpack (0.1.2) pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) psych (3.1.0) public_suffix (3.0.3) rainbow (3.0.0) rake (12.3.2) rubocop (0.65.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) powerpack (~> 0.1) psych (>= 3.1.0) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.4.0) ruby-progressbar (1.10.0) sawyer (0.8.1) addressable (>= 2.3.5, < 2.6) faraday (~> 0.8, < 1.0) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) tomlrb (1.2.7) unicode-display_width (1.4.1) PLATFORMS ruby DEPENDENCIES chandler (= 0.9.0) mdl (= 0.5.0) minitest (~> 5.11) pry-byebug! rake (~> 12.3) rubocop (= 0.65.0) simplecov (= 0.16.1) BUNDLED WITH 2.0.1 pry-byebug-3.7.0/LICENSE000066400000000000000000000021171343345556000146240ustar00rootroot00000000000000MIT License Copyright (c) 2018 David Rodríguez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pry-byebug-3.7.0/README.md000066400000000000000000000136121343345556000151000ustar00rootroot00000000000000# pry-byebug [![Version][VersionBadge]][VersionURL] [![Build][CircleCIBadge]][CircleCIURL] [![Inline docs][InchCIBadge]][InchCIURL] [![Coverage][CoverageBadge]][CoverageURL] Adds step-by-step debugging and stack navigation capabilities to [pry] using [byebug]. To use, invoke pry normally. No need to start your script or app differently. Execution will stop in the first statement after your `binding.pry`. ```ruby def some_method puts 'Hello World' # Run 'step' in the console to move here end binding.pry some_method # Execution will stop here. puts 'Goodbye World' # Run 'next' in the console to move here. ``` ## Requirements MRI 2.3.0 or higher. ## Installation Add ```ruby gem 'pry-byebug' ``` to your Gemfile and run ```console bundle install ``` Make sure you include the gem globally or inside the `:test` group if you plan to use it to debug your tests! ## Commands ### Step-by-step debugging **break:** Manage breakpoints. **step:** Step execution into the next line or method. Takes an optional numeric argument to step multiple times. **next:** Step over to the next line within the same frame. Also takes an optional numeric argument to step multiple lines. **finish:** Execute until current stack frame returns. **continue:** Continue program execution and end the Pry session. ### Callstack navigation **backtrace:** Shows the current stack. You can use the numbers on the left side with the `frame` command to navigate the stack. **up:** Moves the stack frame up. Takes an optional numeric argument to move multiple frames. **down:** Moves the stack frame down. Takes an optional numeric argument to move multiple frames. **frame:** Moves to a specific frame. Called without arguments will show the current frame. ## Matching Byebug Behaviour If you're coming from Byebug or from Pry-Byebug versions previous to 3.0, you may be lacking the 'n', 's', 'c' and 'f' aliases for the stepping commands. These aliases were removed by default because they usually conflict with scratch variable names. But it's very easy to reenable them if you still want them, just add the following shortcuts to your `~/.pryrc` file: ```ruby if defined?(PryByebug) Pry.commands.alias_command 'c', 'continue' Pry.commands.alias_command 's', 'step' Pry.commands.alias_command 'n', 'next' Pry.commands.alias_command 'f', 'finish' end ``` Also, you might find useful as well the repeat the last command by just hitting the `Enter` key (e.g., with `step` or `next`). To achieve that, add this to your `~/.pryrc` file: ```ruby # Hit Enter to repeat last command Pry::Commands.command /^$/, "repeat last command" do _pry_.run_command Pry.history.to_a.last end ``` ## Breakpoints You can set and adjust breakpoints directly from a Pry session using the `break` command: **break:** Set a new breakpoint from a line number in the current file, a file and line number, or a method. Pass an optional expression to create a conditional breakpoint. Edit existing breakpoints via various flags. Examples: ```ruby break SomeClass#run # Break at the start of `SomeClass#run`. break Foo#bar if baz? # Break at `Foo#bar` only if `baz?`. break app/models/user.rb:15 # Break at line 15 in user.rb. break 14 # Break at line 14 in the current file. break --condition 4 x > 2 # Change condition on breakpoint #4 to 'x > 2'. break --condition 3 # Remove the condition on breakpoint #3. break --delete 5 # Delete breakpoint #5. break --disable-all # Disable all breakpoints. break # List all breakpoints. break --show 2 # Show details about breakpoint #2. ``` Type `break --help` from a Pry session to see all available options. ## Alternatives Note that all of the alternatives here are incompatible with pry-byebug. If your platform is supported by pry-byebug, you should remove any of the gems mentioned here if they are present in your Gemfile. * [pry-debugger]: Provides step-by-step debugging for MRI 1.9.3 or older rubies. If you're still using those and need a step-by-step debugger to help with the upgrade, pry-debugger can be handy. * [pry-stack_explorer]: Provides stack navigation capabilities for MRI 1.9.3 or older rubies. If you're still using those and need to navigate your stack to help with the upgrade, pry-stack_explorer can be handy. * [pry-nav]: Provides step-by-step debugging for JRuby. ## Contribute See [Getting Started with Development](CONTRIBUTING.md). You can also help `pry-byebug` by leaving a small (or big) tip through [Liberapay][liberapay.com]. [![Support via Liberapay][liberapay-button]][liberapay-donate] [liberapay.com]: https://liberapay.com [liberapay-button]: https://liberapay.com/assets/widgets/donate.svg [liberapay-donate]: https://liberapay.com/pry-byebug/donate ## Credits * Gopal Patel (@nixme), creator of [pry-debugger], and everybody who contributed to it. pry-byebug is a fork of pry-debugger so it wouldn't exist as it is without those contributions. * John Mair (@banister), creator of [pry]. Patches and bug reports are welcome. [pry]: http://pry.github.com [byebug]: https://github.com/deivid-rodriguez/byebug [pry-debugger]: https://github.com/nixme/pry-debugger [pry-nav]: https://github.com/nixme/pry-nav [pry-stack_explorer]: https://github.com/pry/pry-stack_explorer [VersionBadge]: https://badge.fury.io/rb/pry-byebug.svg [VersionURL]: http://badge.fury.io/rb/pry-byebug [CircleCIBadge]: https://circleci.com/gh/deivid-rodriguez/pry-byebug/tree/master.svg?style=shield [CircleCIURL]: https://circleci.com/gh/deivid-rodriguez/pry-byebug/tree/master [InchCIBadge]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug.svg?branch=master [InchCIURL]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug [CoverageBadge]: https://img.shields.io/codeclimate/coverage/github/deivid-rodriguez/pry-byebug.svg [CoverageURL]: https://codeclimate.com/github/deivid-rodriguez/pry-byebug pry-byebug-3.7.0/Rakefile000066400000000000000000000011151343345556000152610ustar00rootroot00000000000000# frozen_string_literal: true require "bundler/gem_tasks" require "chandler/tasks" require "rake/testtask" require "rubocop/rake_task" # # Add chandler as a prerequisite for `rake release` # task "release:rubygem_push" => "chandler:push" desc "Run tests" Rake::TestTask.new(:test) do |t| t.libs << "test" t.warning = false t.verbose = true t.pattern = "test/**/*_test.rb" end RuboCop::RakeTask.new desc "Checks markdown code style with Markdownlint" task :mdl do puts "Running mdl..." abort unless system("mdl", *Dir.glob("*.md")) end task default: %i[test rubocop mdl] pry-byebug-3.7.0/bin/000077500000000000000000000000001343345556000143665ustar00rootroot00000000000000pry-byebug-3.7.0/bin/bundle000077500000000000000000000026511343345556000155710ustar00rootroot00000000000000#!/usr/bin/env ruby # frozen_string_literal: true require "rubygems" m = Module.new do extend self def invoked_as_script? File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) end def cli_arg_version return unless invoked_as_script? # don't want to hijack other binstubs return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` bundler_version = nil update_index = nil ARGV.each_with_index do |a, i| bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ bundler_version = Regexp.last_match(1) || ">= 0.a" update_index = i end bundler_version end def gemfile File.expand_path("../Gemfile", __dir__) end def lockfile "#{gemfile}.lock" end def lockfile_version lockfile_contents = File.read(lockfile) regexp = /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ regexp.match(lockfile_contents)[1] end def bundler_version @bundler_version ||= cli_arg_version || lockfile_version end def load_bundler! ENV["BUNDLE_GEMFILE"] ||= gemfile activate_bundler(bundler_version) end def activate_bundler(bundler_version) gem "bundler", bundler_version end end m.load_bundler! load Gem.bin_path("bundler", "bundle") if m.invoked_as_script? pry-byebug-3.7.0/bin/rubocop000077500000000000000000000003411343345556000157630ustar00rootroot00000000000000#!/usr/bin/env ruby # frozen_string_literal: true ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) load File.expand_path("bundle", __dir__) require "bundler/setup" load Gem.bin_path("rubocop", "rubocop") pry-byebug-3.7.0/code_of_conduct.md000066400000000000000000000062441343345556000172630ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at deivid.rodriguez@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ pry-byebug-3.7.0/lib/000077500000000000000000000000001343345556000143645ustar00rootroot00000000000000pry-byebug-3.7.0/lib/byebug/000077500000000000000000000000001343345556000156415ustar00rootroot00000000000000pry-byebug-3.7.0/lib/byebug/processors/000077500000000000000000000000001343345556000200435ustar00rootroot00000000000000pry-byebug-3.7.0/lib/byebug/processors/pry_processor.rb000066400000000000000000000067121343345556000233070ustar00rootroot00000000000000# frozen_string_literal: true require "byebug/core" module Byebug # # Extends raw byebug's processor. # class PryProcessor < CommandProcessor attr_accessor :pry extend Forwardable def_delegators :@pry, :output def_delegators Pry::Helpers::Text, :bold def self.start Byebug.start Setting[:autolist] = false Context.processor = self Byebug.current_context.step_out(4, true) end # # Wrap a Pry REPL to catch navigational commands and act on them. # def run(&_block) return_value = nil command = catch(:breakout_nav) do # Throws from PryByebug::Commands return_value = allowing_other_threads { yield } {} # Nothing thrown == no navigational command end # Pry instance to resume after stepping @pry = command[:pry] perform(command[:action], command[:options]) return_value end # # Set up a number of navigational commands to be performed by Byebug. # def perform(action, options = {}) return unless %i[ backtrace down finish frame next step up ].include?(action) send("perform_#{action}", options) end # --- Callbacks from byebug C extension --- # # Called when the debugger wants to stop at a regular line # def at_line resume_pry end # # Called when the debugger wants to stop right before a method return # def at_return(_return_value) resume_pry end # # Called when the debugger wants to stop right before the end of a class # definition # def at_end resume_pry end # # Called when a breakpoint is hit. Note that `at_line`` is called # inmediately after with the context's `stop_reason == :breakpoint`, so we # must not resume the pry instance here # def at_breakpoint(breakpoint) @pry ||= Pry.new output.puts bold("\n Breakpoint #{breakpoint.id}. ") + n_hits(breakpoint) expr = breakpoint.expr return unless expr output.puts bold("Condition: ") + expr end private def n_hits(breakpoint) n_hits = breakpoint.hit_count n_hits == 1 ? "First hit" : "Hit #{n_hits} times." end # # Resume an existing Pry REPL at the paused point. # def resume_pry new_binding = frame._binding run do if defined?(@pry) && @pry @pry.repl(new_binding) else @pry = Pry.start_without_pry_byebug(new_binding) end end end def perform_backtrace(_options) Byebug::WhereCommand.new(self, "backtrace").execute resume_pry end def perform_next(options) lines = (options[:lines] || 1).to_i context.step_over(lines, frame.pos) end def perform_step(options) times = (options[:times] || 1).to_i context.step_into(times, frame.pos) end def perform_finish(*) context.step_out(1) end def perform_up(options) times = (options[:times] || 1).to_i Byebug::UpCommand.new(self, "up #{times}").execute resume_pry end def perform_down(options) times = (options[:times] || 1).to_i Byebug::DownCommand.new(self, "down #{times}").execute resume_pry end def perform_frame(options) index = options[:index] ? options[:index].to_i : "" Byebug::FrameCommand.new(self, "frame #{index}").execute resume_pry end end end pry-byebug-3.7.0/lib/pry-byebug.rb000066400000000000000000000001061343345556000167730ustar00rootroot00000000000000# frozen_string_literal: true require "pry" require "pry-byebug/cli" pry-byebug-3.7.0/lib/pry-byebug/000077500000000000000000000000001343345556000164515ustar00rootroot00000000000000pry-byebug-3.7.0/lib/pry-byebug/base.rb000066400000000000000000000013141343345556000177070ustar00rootroot00000000000000# frozen_string_literal: true # # Main container module for Pry-Byebug functionality # module PryByebug # Reference to currently running pry-remote server. Used by the processor. attr_accessor :current_remote_server module_function # # Checks that a target binding is in a local file context. # def file_context?(target) file = target.eval("__FILE__") file == Pry.eval_path || !Pry::Helpers::BaseHelpers.not_a_real_file?(file) end # # Ensures that a command is executed in a local file context. # def check_file_context(target, msg = nil) msg ||= "Cannot find local context. Did you use `binding.pry`?" raise(Pry::CommandError, msg) unless file_context?(target) end end pry-byebug-3.7.0/lib/pry-byebug/cli.rb000066400000000000000000000002331343345556000175430ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/base" require "pry-byebug/pry_ext" require "pry-byebug/commands" require "pry-byebug/control_d_handler" pry-byebug-3.7.0/lib/pry-byebug/commands.rb000066400000000000000000000006211343345556000205760ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/commands/backtrace" require "pry-byebug/commands/next" require "pry-byebug/commands/step" require "pry-byebug/commands/continue" require "pry-byebug/commands/finish" require "pry-byebug/commands/up" require "pry-byebug/commands/down" require "pry-byebug/commands/frame" require "pry-byebug/commands/breakpoint" require "pry-byebug/commands/exit_all" pry-byebug-3.7.0/lib/pry-byebug/commands/000077500000000000000000000000001343345556000202525ustar00rootroot00000000000000pry-byebug-3.7.0/lib/pry-byebug/commands/backtrace.rb000066400000000000000000000010521343345556000225140ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Display the current stack # class BacktraceCommand < Pry::ClassCommand include Helpers::Navigation match "backtrace" group "Byebug" description "Display the current stack." banner <<-BANNER Usage: backtrace Display the current stack. BANNER def process PryByebug.check_file_context(target) breakout_navigation :backtrace end end end Pry::Commands.add_command(PryByebug::BacktraceCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/breakpoint.rb000066400000000000000000000102061343345556000227340ustar00rootroot00000000000000# frozen_string_literal: true require "pry/byebug/breakpoints" require "pry-byebug/helpers/breakpoints" require "pry-byebug/helpers/multiline" module PryByebug # # Add, show and remove breakpoints # class BreakCommand < Pry::ClassCommand include Helpers::Breakpoints include Helpers::Multiline match "break" group "Byebug" description "Set or edit a breakpoint." banner <<-BANNER Usage: break [if CONDITION] break --condition N [CONDITION] break [--show | --delete | --enable | --disable] N break [--delete-all | --disable-all] break Set a breakpoint. Accepts a line number in the current file, a file and line number, or a method, and an optional condition. Pass appropriate flags to manipulate existing breakpoints. Examples: break SomeClass#run Break at the start of `SomeClass#run`. break Foo#bar if baz? Break at `Foo#bar` only if `baz?`. break app/models/user.rb:15 Break at line 15 in user.rb. break 14 Break at line 14 in the current file. break --condition 4 x > 2 Add/change condition on breakpoint #4. break --condition 3 Remove the condition on breakpoint #3. break --delete 5 Delete breakpoint #5. break --disable-all Disable all breakpoints. break --show 2 Show details about breakpoint #2. break List all breakpoints. BANNER def options(opt) defaults = { argument: true, as: Integer } opt.on :c, :condition, "Change condition of a breakpoint.", defaults opt.on :s, :show, "Show breakpoint details and source.", defaults opt.on :D, :delete, "Delete a breakpoint.", defaults opt.on :d, :disable, "Disable a breakpoint.", defaults opt.on :e, :enable, "Enable a disabled breakpoint.", defaults opt.on :'disable-all', "Disable all breakpoints." opt.on :'delete-all', "Delete all breakpoints." end def process return if check_multiline_context PryByebug.check_file_context(target) option, = opts.to_hash.find { |key, _value| opts.present?(key) } return send(option_to_method(option)) if option return new_breakpoint unless args.empty? print_all end private %w[delete disable enable disable_all delete_all].each do |command| define_method(:"process_#{command}") do breakpoints.send(*[command, opts[command]].compact) print_all end end def process_show print_full_breakpoint(breakpoints.find_by_id(opts[:show])) end def process_condition expr = args.empty? ? nil : args.join(" ") breakpoints.change(opts[:condition], expr) end def new_breakpoint place = args.shift condition = args.join(" ") if args.shift == "if" bp = add_breakpoint(place, condition) print_full_breakpoint(bp) end def option_to_method(option) "process_#{option.to_s.tr('-', '_')}" end def print_all print_breakpoints_header breakpoints.each { |b| print_short_breakpoint(b) } end def add_breakpoint(place, condition) case place when /^(\d+)$/ errmsg = "Line number declaration valid only in a file context." PryByebug.check_file_context(target, errmsg) lineno = Regexp.last_match[1].to_i breakpoints.add_file(current_file, lineno, condition) when /^(.+):(\d+)$/ file = Regexp.last_match[1] lineno = Regexp.last_match[2].to_i breakpoints.add_file(file, lineno, condition) when /^(.*)[.#].+$/ # Method or class name if Regexp.last_match[1].strip.empty? errmsg = "Method name declaration valid only in a file context." PryByebug.check_file_context(target, errmsg) place = target.eval("self.class.to_s") + place end breakpoints.add_method(place, condition) else raise(ArgumentError, "Cannot identify arguments as breakpoint") end end end end Pry::Commands.add_command(PryByebug::BreakCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/continue.rb000066400000000000000000000020121343345556000224160ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/helpers/navigation" require "pry-byebug/helpers/breakpoints" module PryByebug # # Continue program execution until the next breakpoint # class ContinueCommand < Pry::ClassCommand include Helpers::Navigation include Helpers::Breakpoints match "continue" group "Byebug" description "Continue program execution and end the Pry session." banner <<-BANNER Usage: continue [LINE] Continue program execution until the next breakpoint, or the program ends. Optionally continue to the specified line number. Examples: continue #=> Continue until the next breakpoint. continue 4 #=> Continue to line number 4. BANNER def process PryByebug.check_file_context(target) breakpoints.add_file(current_file, args.first.to_i) if args.first breakout_navigation :continue ensure Byebug.stop if Byebug.stoppable? end end end Pry::Commands.add_command(PryByebug::ContinueCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/down.rb000066400000000000000000000012461343345556000215510ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Travel down the frame stack # class DownCommand < Pry::ClassCommand include Helpers::Navigation match "down" group "Byebug" description "Move current frame down." banner <<-BANNER Usage: down [TIMES] Move current frame down. By default, moves by 1 frame. Examples: down #=> Move down 1 frame. down 5 #=> Move down 5 frames. BANNER def process PryByebug.check_file_context(target) breakout_navigation :down, times: args.first end end end Pry::Commands.add_command(PryByebug::DownCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/exit_all.rb000066400000000000000000000004401343345556000223760ustar00rootroot00000000000000# frozen_string_literal: true module PryByebug # # Exit pry REPL with Byebug.stop # class ExitAllCommand < Pry::Command::ExitAll def process super ensure Byebug.stop if Byebug.stoppable? end end end Pry::Commands.add_command(PryByebug::ExitAllCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/finish.rb000066400000000000000000000010341343345556000220550ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Run until the end of current frame # class FinishCommand < Pry::ClassCommand include PryByebug::Helpers::Navigation match "finish" group "Byebug" description "Execute until current stack frame returns." banner <<-BANNER Usage: finish BANNER def process PryByebug.check_file_context(target) breakout_navigation :finish end end end Pry::Commands.add_command(PryByebug::FinishCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/frame.rb000066400000000000000000000012531343345556000216720ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Move to a specific frame in the callstack # class FrameCommand < Pry::ClassCommand include Helpers::Navigation match "frame" group "Byebug" description "Move to specified frame #." banner <<-BANNER Usage: frame [TIMES] Move to specified frame #. Examples: frame #=> Show current frame #. frame 5 #=> Move to frame 5. BANNER def process PryByebug.check_file_context(target) breakout_navigation :frame, index: args.first end end end Pry::Commands.add_command(PryByebug::FrameCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/next.rb000066400000000000000000000015471343345556000215640ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/helpers/navigation" require "pry-byebug/helpers/multiline" module PryByebug # # Run a number of lines and then stop again # class NextCommand < Pry::ClassCommand include Helpers::Navigation include Helpers::Multiline match "next" group "Byebug" description "Execute the next line within the current stack frame." banner <<-BANNER Usage: next [LINES] Step over within the same frame. By default, moves forward a single line. Examples: next #=> Move a single line forward. next 4 #=> Execute the next 4 lines. BANNER def process return if check_multiline_context PryByebug.check_file_context(target) breakout_navigation :next, lines: args.first end end end Pry::Commands.add_command(PryByebug::NextCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/step.rb000066400000000000000000000013541343345556000215550ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Run a number of Ruby statements and then stop again # class StepCommand < Pry::ClassCommand include Helpers::Navigation match "step" group "Byebug" description "Step execution into the next line or method." banner <<-BANNER Usage: step [TIMES] Step execution forward. By default, moves a single step. Examples: step #=> Move a single step forward. step 5 #=> Execute the next 5 steps. BANNER def process PryByebug.check_file_context(target) breakout_navigation :step, times: args.first end end end Pry::Commands.add_command(PryByebug::StepCommand) pry-byebug-3.7.0/lib/pry-byebug/commands/up.rb000066400000000000000000000012161343345556000212230ustar00rootroot00000000000000# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Travel up the frame stack # class UpCommand < Pry::ClassCommand include Helpers::Navigation match "up" group "Byebug" description "Move current frame up." banner <<-BANNER Usage: up [TIMES] Move current frame up. By default, moves by 1 frame. Examples: up #=> Move up 1 frame. up 5 #=> Move up 5 frames. BANNER def process PryByebug.check_file_context(target) breakout_navigation :up, times: args.first end end end Pry::Commands.add_command(PryByebug::UpCommand) pry-byebug-3.7.0/lib/pry-byebug/control_d_handler.rb000066400000000000000000000003561343345556000224620ustar00rootroot00000000000000# frozen_string_literal: true original_handler = Pry.config.control_d_handler Pry.config.control_d_handler = proc do |eval_string, pry_instance| Byebug.stop if Byebug.stoppable? original_handler.call(eval_string, pry_instance) end pry-byebug-3.7.0/lib/pry-byebug/helpers/000077500000000000000000000000001343345556000201135ustar00rootroot00000000000000pry-byebug-3.7.0/lib/pry-byebug/helpers/breakpoints.rb000066400000000000000000000041431343345556000227630ustar00rootroot00000000000000# frozen_string_literal: true require "byebug" module PryByebug module Helpers # # Common helpers for breakpoint related commands # module Breakpoints # # Byebug's array of breakpoints. # def breakpoints Pry::Byebug::Breakpoints end # # Current file in the target binding. Used as the default breakpoint # location. # def current_file target.eval("__FILE__") end # # Prints a message with bold font. # def bold_puts(msg) output.puts(text.bold(msg)) end # # Print out full information about a breakpoint. # # Includes surrounding code at that point. # def print_full_breakpoint(breakpoint) header = "Breakpoint #{breakpoint.id}:" status = breakpoint.enabled? ? "Enabled" : "Disabled" code = breakpoint.source_code.with_line_numbers.to_s condition = if breakpoint.expr "#{text.bold('Condition:')} #{breakpoint.expr}\n" else "" end output.puts <<-BREAKPOINT.gsub(/ {8}/, "") #{text.bold(header)} #{breakpoint} (#{status}) #{condition} #{code} BREAKPOINT end # # Print out concise information about a breakpoint. # def print_short_breakpoint(breakpoint) id = format("%*d", max_width, breakpoint.id) status = breakpoint.enabled? ? "Yes" : "No " expr = breakpoint.expr ? " #{breakpoint.expr} " : "" output.puts(" #{id} #{status} #{breakpoint}#{expr}") end # # Prints a header for the breakpoint list. # def print_breakpoints_header header = "#{' ' * (max_width - 1)}# Enabled At " output.puts <<-BREAKPOINTS.gsub(/ {8}/, "") #{text.bold(header)} #{text.bold('-' * header.size)} BREAKPOINTS end # # Max width of breakpoints id column # def max_width breakpoints.last ? breakpoints.last.id.to_s.length : 1 end end end end pry-byebug-3.7.0/lib/pry-byebug/helpers/multiline.rb000066400000000000000000000010321343345556000224360ustar00rootroot00000000000000# frozen_string_literal: true module PryByebug module Helpers # # Helpers to help handling multiline inputs # module Multiline # # Returns true if we are in a multiline context and, as a side effect, # updates the partial evaluation string with the current input. # # Returns false otherwise # def check_multiline_context return false if eval_string.empty? eval_string.replace("#{eval_string}#{match} #{arg_string}\n") true end end end end pry-byebug-3.7.0/lib/pry-byebug/helpers/navigation.rb000066400000000000000000000006321343345556000226000ustar00rootroot00000000000000# frozen_string_literal: true module PryByebug module Helpers # # Helpers to aid breaking out of the REPL loop # module Navigation # # Breaks out of the REPL loop and signals tracer # def breakout_navigation(action, options = {}) _pry_.binding_stack.clear throw :breakout_nav, action: action, options: options, pry: _pry_ end end end end pry-byebug-3.7.0/lib/pry-byebug/pry_ext.rb000066400000000000000000000007741343345556000205000ustar00rootroot00000000000000# frozen_string_literal: true require "byebug/processors/pry_processor" class << Pry alias start_without_pry_byebug start def start_with_pry_byebug(target = TOPLEVEL_BINDING, options = {}) if target.is_a?(Binding) && PryByebug.file_context?(target) Byebug::PryProcessor.start unless ENV["DISABLE_PRY"] else # No need for the tracer unless we have a file context to step through start_without_pry_byebug(target, options) end end alias start start_with_pry_byebug end pry-byebug-3.7.0/lib/pry-byebug/pry_remote_ext.rb000066400000000000000000000021171343345556000220440ustar00rootroot00000000000000# frozen_string_literal: true require "pry-remote" module PryRemote # # Overrides PryRemote::Server # class Server # # Override the call to Pry.start to save off current Server, and not # teardown the server right after Pry.start finishes. # def run raise("Already running a pry-remote session!") if PryByebug.current_remote_server PryByebug.current_remote_server = self setup Pry.start @object, input: client.input_proxy, output: client.output end # # Override to reset our saved global current server session. # alias teardown_without_pry_byebug teardown def teardown_with_pry_byebug return if @torn teardown_without_pry_byebug PryByebug.current_remote_server = nil @torn = true end alias teardown teardown_with_pry_byebug end end # Ensure cleanup when a program finishes without another break. For example, # 'next' on the last line of a program won't hit Byebug::PryProcessor#run, # which normally handles cleanup. at_exit do PryByebug.current_remote_server&.teardown end pry-byebug-3.7.0/lib/pry-byebug/version.rb000066400000000000000000000002011343345556000204540ustar00rootroot00000000000000# frozen_string_literal: true # # Main container module for Pry-Byebug functionality # module PryByebug VERSION = "3.7.0" end pry-byebug-3.7.0/lib/pry/000077500000000000000000000000001343345556000151765ustar00rootroot00000000000000pry-byebug-3.7.0/lib/pry/byebug/000077500000000000000000000000001343345556000164535ustar00rootroot00000000000000pry-byebug-3.7.0/lib/pry/byebug/breakpoints.rb000066400000000000000000000072041343345556000213240ustar00rootroot00000000000000# frozen_string_literal: true class Pry module Byebug # # Wrapper for Byebug.breakpoints that respects our Processor and has better # failure behavior. Acts as an Enumerable. # module Breakpoints extend Enumerable extend self # # Breakpoint in a file:line location # class FileBreakpoint < SimpleDelegator def source_code Pry::Code.from_file(source).around(pos, 3).with_marker(pos) end def to_s "#{source} @ #{pos}" end end # # Breakpoint in a Class#method location # class MethodBreakpoint < SimpleDelegator def initialize(byebug_bp, method) __setobj__ byebug_bp @method = method end def source_code Pry::Code.from_method(Pry::Method.from_str(@method)) end def to_s @method end end def breakpoints @breakpoints ||= [] end # # Adds a method breakpoint. # def add_method(method, expression = nil) validate_expression expression owner, name = method.split(/[\.#]/) byebug_bp = ::Byebug::Breakpoint.add(owner, name.to_sym, expression) bp = MethodBreakpoint.new byebug_bp, method breakpoints << bp bp end # # Adds a file breakpoint. # def add_file(file, line, expression = nil) real_file = (file != Pry.eval_path) raise(ArgumentError, "Invalid file!") if real_file && !File.exist?(file) validate_expression expression path = (real_file ? File.expand_path(file) : file) bp = FileBreakpoint.new ::Byebug::Breakpoint.add(path, line, expression) breakpoints << bp bp end # # Changes the conditional expression for a breakpoint. # def change(id, expression = nil) validate_expression expression breakpoint = find_by_id(id) breakpoint.expr = expression breakpoint end # # Deletes an existing breakpoint with the given ID. # def delete(id) deleted = ::Byebug.started? && ::Byebug::Breakpoint.remove(id) && breakpoints.delete(find_by_id(id)) raise(ArgumentError, "No breakpoint ##{id}") unless deleted end # # Deletes all breakpoints. # def delete_all @breakpoints = [] ::Byebug.breakpoints.clear if ::Byebug.started? end # # Enables a disabled breakpoint with the given ID. # def enable(id) change_status id, true end # # Disables a breakpoint with the given ID. # def disable(id) change_status id, false end # # Disables all breakpoints. # def disable_all each do |breakpoint| breakpoint.enabled = false end end def to_a breakpoints end def size to_a.size end def each(&block) to_a.each(&block) end def last to_a.last end def find_by_id(id) breakpoint = find { |b| b.id == id } raise(ArgumentError, "No breakpoint ##{id}!") unless breakpoint breakpoint end private def change_status(id, enabled = true) breakpoint = find_by_id(id) breakpoint.enabled = enabled breakpoint end def validate_expression(exp) valid = exp && (exp.empty? || !Pry::Code.complete_expression?(exp)) return unless valid raise("Invalid breakpoint conditional: #{expression}") end end end end pry-byebug-3.7.0/pry-byebug.gemspec000066400000000000000000000015301343345556000172470ustar00rootroot00000000000000# frozen_string_literal: true require File.dirname(__FILE__) + "/lib/pry-byebug/version" Gem::Specification.new do |gem| gem.name = "pry-byebug" gem.version = PryByebug::VERSION gem.authors = ["David Rodríguez", "Gopal Patel"] gem.email = "deivid.rodriguez@gmail.com" gem.license = "MIT" gem.homepage = "https://github.com/deivid-rodriguez/pry-byebug" gem.summary = "Fast debugging with Pry." gem.description = "Combine 'pry' with 'byebug'. Adds 'step', 'next', 'finish', 'continue' and 'break' commands to control execution." gem.files = Dir["lib/**/*.rb", "LICENSE"] gem.extra_rdoc_files = %w[CHANGELOG.md README.md] gem.require_path = "lib" gem.executables = [] # Dependencies gem.required_ruby_version = ">= 2.3.0" gem.add_runtime_dependency "byebug", "~> 11.0" gem.add_runtime_dependency "pry", "~> 0.10" end pry-byebug-3.7.0/test/000077500000000000000000000000001343345556000145755ustar00rootroot00000000000000pry-byebug-3.7.0/test/base_test.rb000066400000000000000000000006301343345556000170720ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" # # Checks current pry-byebug's context. # class BaseTest < MiniTest::Spec def test_main_file_context Pry.stub :eval_path, "
" do assert PryByebug.file_context?(TOPLEVEL_BINDING) end end def test_other_file_context Pry.stub :eval_path, "something" do refute PryByebug.file_context?(TOPLEVEL_BINDING) end end end pry-byebug-3.7.0/test/breakpoints_test.rb000066400000000000000000000020021343345556000204740ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" # # Tests for pry-byebug breakpoints. # class BreakpointsTestGeneral < MiniTest::Spec # # Minimal dummy example class. # class Tester def self.class_method; end def instance_method; end end def breakpoints_class Pry::Byebug::Breakpoints end def test_add_file_raises_argument_error Pry.stub :eval_path, "something" do assert_raises(ArgumentError) { breakpoints_class.add_file("file", 1) } end end def test_add_method_adds_instance_method_breakpoint breakpoints_class.add_method "BreakpointsTest::Tester#instance_method" bp = Byebug.breakpoints.last assert_equal "BreakpointsTest::Tester", bp.source assert_equal "instance_method", bp.pos end def test_add_method_adds_class_method_breakpoint breakpoints_class.add_method "BreakpointsTest::Tester.class_method" bp = Byebug.breakpoints.last assert_equal "BreakpointsTest::Tester", bp.source assert_equal "class_method", bp.pos end end pry-byebug-3.7.0/test/commands/000077500000000000000000000000001343345556000163765ustar00rootroot00000000000000pry-byebug-3.7.0/test/commands/breakpoints_test.rb000066400000000000000000000072571343345556000223160ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" # # Some common specs for breakpoints # module BreakpointSpecs def test_shows_breakpoint_enabled assert_match @regexp, @output.string end def test_shows_breakpoint_hit assert_match @regexp, @output.string match = @output.string.match(@regexp) assert_match(/^ Breakpoint #{match[:id]}\. First hit/, @output.string) end def test_shows_breakpoint_line assert_match(/\=> \s*#{@line}:/, @output.string) end end # # Tests for breakpoint commands # class BreakpointsTest < Minitest::Test def setup super @input = InputTester.new "break --delete-all" @output = StringIO.new end def teardown super clean_remove_const(:Break1Example) clean_remove_const(:Break2Example) end def width Byebug.breakpoints.last.id.to_s.length end end # # Tests setting a breakpoint by line number # class SettingBreakpointsTestByLineNumber < BreakpointsTest def setup super @input.add("break 8") redirect_pry_io(@input, @output) { load test_file("break1") } @line = 8 @regexp = / Breakpoint (?\d+): #{test_file('break1')} @ 8 \(Enabled\)/ end include BreakpointSpecs end # # Tests setting a breakpoint in a method # class SettingBreakpointsTestByMethodId < BreakpointsTest def setup super @input.add("break Break1Example#a") redirect_pry_io(@input, @output) { load test_file("break1") } @line = RUBY_VERSION >= "2.5.0" ? 8 : 7 @regexp = / Breakpoint (?\d+): Break1Example#a \(Enabled\)/ end include BreakpointSpecs end # # Tests setting a breakpoint in a bang method # class SettingBreakpointsTestByMethodIdForBangMethods < BreakpointsTest def setup super @input.add("break Break1Example#c!") redirect_pry_io(@input, @output) { load test_file("break1") } @line = RUBY_VERSION >= "2.5.0" ? 18 : 17 @regexp = / Breakpoint (?\d+): Break1Example#c! \(Enabled\)/ end include BreakpointSpecs end # # Tests setting a breakpoint in a (non fully qualified) method # class SettingBreakpointsTestByMethodIdWithinContext < BreakpointsTest def setup super @input.add("break #b") redirect_pry_io(@input, @output) { load test_file("break2") } @line = 9 @regexp = / Breakpoint (?\d+): Break2Example#b \(Enabled\)/ end include BreakpointSpecs end # # Tests listing breakpoints # class ListingBreakpoints < BreakpointsTest def setup super @input.add("break #b", "break") redirect_pry_io(@input, @output) { load test_file("break2") } end def test_shows_all_breakpoints assert_match(/Yes \s*Break2Example#b/, @output.string) end def test_properly_displays_breakpoint_list assert_match(/ {#{width - 1}}# Enabled At/, @output.string) assert_match(/ \d{#{width}} Yes Break2Example#b/, @output.string) end end # # Tests disabling breakpoints # class DisablingBreakpoints < BreakpointsTest def setup super @input.add("break #b", "break --disable-all") redirect_pry_io(@input, @output) { load test_file("break2") } end def test_shows_breakpoints_as_disabled assert_match(/ {#{width - 1}}# Enabled At/, @output.string) assert_match(/ \d{#{width}} No Break2Example#b/, @output.string) end end # # Tests that the break Ruby keyword does not conflict with the break command # class BreakInsideMultilineInput < BreakpointsTest def setup super @input.add("2.times do |i|", "break 18 if i > 0", "end") redirect_pry_io(@input, @output) { load test_file("break1") } end def test_it_is_ignored assert_equal 0, Pry::Byebug::Breakpoints.size end def test_lets_input_be_properly_evaluated assert_match(/=> 18/, @output.string) end end pry-byebug-3.7.0/test/commands/frames_test.rb000066400000000000000000000034151343345556000212420ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" require "stringio" # # Tests for pry-byebug frame commands. # class FramesTest < MiniTest::Spec let(:output) { StringIO.new } after { clean_remove_const(:FramesExample) } describe "Up command" do let(:input) { InputTester.new("up", "down") } before do redirect_pry_io(input, output) { load test_file("frames") } end it "shows current line" do output.string.must_match(/=> \s*8: \s*method_b/) end end describe "Down command" do let(:input) { InputTester.new("up", "down") } before do redirect_pry_io(input, output) { load test_file("frames") } end it "shows current line" do output.string.must_match(/=> \s*13: \s*end/) end end describe "Frame command" do before do redirect_pry_io(input, output) { load test_file("frames") } end describe "jump to frame 1" do let(:input) { InputTester.new("frame 1", "frame 0") } it "shows current line" do output.string.must_match(/=> \s*8: \s*method_b/) end end describe "jump to current frame" do let(:input) { InputTester.new("frame 0") } it "shows current line" do output.string.must_match(/=> \s*13: \s*end/) end end end describe "Backtrace command" do let(:input) { InputTester.new("backtrace") } before do @stdout, @stderr = capture_subprocess_io do redirect_pry_io(input) { load test_file("frames") } end end it "shows a backtrace" do frames = @stdout.split("\n") assert_match(/\A--> #0 FramesExample\.method_b at/, frames[0]) assert_match(/\A #1 FramesExample\.method_a at/, frames[1]) assert_match(/\A #2 at/, frames[2]) end end end pry-byebug-3.7.0/test/commands/stepping_test.rb000066400000000000000000000061761343345556000216250ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" # # Tests for pry-byebug stepping commands # class SteppingTest < MiniTest::Test def setup super @output = StringIO.new @input = InputTester.new("break --delete-all") end def teardown clean_remove_const(:SteppingExample) super end end # # Tests the step command without arguments # class StepCommandSingleStepTest < SteppingTest def setup super @input.add("step") redirect_pry_io(@input, @output) { load test_file("stepping") } end def test_stops_at_the_next_statement assert_match(/\=> \s*9:/, @output.string) end end # # Tests the step command with a step argument # class StepCommandMultipleStepTest < SteppingTest def setup super @input.add("step 2") redirect_pry_io(@input, @output) { load test_file("stepping") } end def test_stops_a_correct_number_of_steps_after assert_match(/\=> \s*14:/, @output.string) end end # # Tests the next command without arguments # class NextCommandSingleStepTest < SteppingTest def setup super @input.add("next") redirect_pry_io(@input, @output) { load test_file("stepping") } end def test_stops_at_the_next_line_in_the_current_frame assert_match(/\=> \s*26:/, @output.string) end end # # Tests the next command with an argument # class NextCommandMultipleStepTest < SteppingTest def setup super @input.add("next 2") redirect_pry_io(@input, @output) { load test_file("stepping") } end def test_advances_the_correct_number_of_lines assert_match(/\=> \s*27:/, @output.string) end end # # Tests that the next Ruby keyword does not conflict with the next command # class NextInsideMultilineInput < SteppingTest def setup super @input.add( "2.times do |i|", "if i == 0", "next", "end", "break 1001 + i", "end" ) redirect_pry_io(@input, @output) { load test_file("stepping") } end def test_it_is_ignored assert_match(/\=> \s*8:/, @output.string) refute_match(/\=> \s*26:/, @output.string) end def test_lets_input_be_properly_evaluated assert_match(/=> 1002/, @output.string) end end # # Tests the finish command # class FinishCommand < SteppingTest def setup super @input.add("break 21", "continue", "finish") redirect_pry_io(@input, @output) { load test_file("stepping") } end def test_advances_until_the_end_of_the_current_frame assert_match(/\=> \s*17:/, @output.string) end end # # Tests the continue command without arguments # class ContinueCommandWithoutArguments < SteppingTest def setup super @input.add("break 16", "continue") redirect_pry_io(@input, @output) { load test_file("stepping") } end def test_advances_until_the_next_breakpoint assert_match(/\=> \s*16:/, @output.string) end end # # Tests the continue command with a line argument # class ContinueCommandWithALineArgument < SteppingTest def setup super @input.add("continue 16") redirect_pry_io(@input, @output) { load test_file("stepping") } end def test_advances_until_the_specified_line assert_match(/\=> \s*16:/, @output.string) end end pry-byebug-3.7.0/test/examples/000077500000000000000000000000001343345556000164135ustar00rootroot00000000000000pry-byebug-3.7.0/test/examples/break1.rb000066400000000000000000000003571343345556000201120ustar00rootroot00000000000000# frozen_string_literal: true # # A toy example for testing break commands. # class Break1Example def a z = 2 z + b end def b z = 5 z + c! end def c! z = 4 z end end binding.pry Break1Example.new.a pry-byebug-3.7.0/test/examples/break2.rb000066400000000000000000000003541343345556000201100ustar00rootroot00000000000000# frozen_string_literal: true # # Another toy example for testing break commands. # class Break2Example def a binding.pry z = 2 z + b end def b c end def c z = 4 z + 5 end end Break2Example.new.a pry-byebug-3.7.0/test/examples/deep_stepping.rb000066400000000000000000000002411343345556000215630ustar00rootroot00000000000000# frozen_string_literal: true # # Toy program for testing binding.pry initialization # new_str = "string".gsub(/str/) do |_| binding.pry end _foo = new_str pry-byebug-3.7.0/test/examples/echo_thread.rb000066400000000000000000000003311343345556000212020ustar00rootroot00000000000000# frozen_string_literal: true require "socket" client, server = Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) Thread.new do while (line = server.readline) server.write(line) end end binding.pry client pry-byebug-3.7.0/test/examples/frames.rb000066400000000000000000000003061343345556000202140ustar00rootroot00000000000000# frozen_string_literal: true # # Toy class for testing frame commands # class FramesExample def method_a method_b end def method_b binding.pry end end FramesExample.new.method_a pry-byebug-3.7.0/test/examples/multiple.rb000066400000000000000000000000741343345556000205740ustar00rootroot00000000000000# frozen_string_literal: true 5.times do binding.pry end pry-byebug-3.7.0/test/examples/stepping.rb000066400000000000000000000005141343345556000205710ustar00rootroot00000000000000# frozen_string_literal: true binding.pry # # Toy class for testing steps # class SteppingExample def method_a z = 2 z + method_b end def method_b c = Math::PI / 2 c += method_c c + 1 end def method_c z = 4 z end end ex = SteppingExample.new.method_a 2.times do ex += 1 end _foo = ex pry-byebug-3.7.0/test/processor_test.rb000066400000000000000000000016171343345556000202050ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" # # Tests for pry-byebug's processor. # class ProcessorTest < Minitest::Spec let(:output) { StringIO.new } describe "Initialization" do let(:input) { InputTester.new } describe "normally" do let(:source_file) { test_file("stepping") } before do redirect_pry_io(input, output) { load source_file } end after { clean_remove_const(:SteppingExample) } it "stops execution at the first line after binding.pry" do output.string.must_match(/\=> 8:/) end end describe "at the end of block/method call" do let(:source_file) { test_file("deep_stepping") } before do redirect_pry_io(input, output) { load source_file } end it "stops execution at the first line after binding.pry" do output.string.must_match(/\=> 9:/) end end end end pry-byebug-3.7.0/test/pry_ext_test.rb000066400000000000000000000011221343345556000176470ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" class PryExtTest < MiniTest::Spec let(:output) { StringIO.new } let(:input) { InputTester.new } describe "when disable-pry called" do subject { redirect_pry_io(input, output) { load test_file("multiple") } } before { input.add "disable-pry" } after { ENV.delete("DISABLE_PRY") } it "keeps pry's default behaviour" do subject assert_equal 1, output.string.scan(/binding\.pry/).size end it "does not start byebug" do Byebug.stop subject assert !Byebug.started? end end end pry-byebug-3.7.0/test/pry_remote_ext_test.rb000066400000000000000000000001421343345556000212230ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" class PryRemoteExtTest < MiniTest::Spec end pry-byebug-3.7.0/test/support/000077500000000000000000000000001343345556000163115ustar00rootroot00000000000000pry-byebug-3.7.0/test/support/coverage.rb000066400000000000000000000003031343345556000204250ustar00rootroot00000000000000# frozen_string_literal: true # # Starts code coverage tracking. # def start_coverage_tracking require "simplecov" SimpleCov.add_filter "test" SimpleCov.start end start_coverage_tracking pry-byebug-3.7.0/test/test_helper.rb000066400000000000000000000016151343345556000174430ustar00rootroot00000000000000# frozen_string_literal: true require "support/coverage" require "minitest/autorun" require "pry-byebug" Pry.config.color = false Pry.config.pager = false Pry.config.correct_indent = false # # Set I/O streams. Out defaults to an anonymous StringIO. # def redirect_pry_io(new_in, new_out = StringIO.new) old_in = Pry.input old_out = Pry.output Pry.input = new_in Pry.output = new_out begin yield ensure Pry.input = old_in Pry.output = old_out end end def test_file(name) (Pathname.new(__FILE__) + "../examples/#{name}.rb").cleanpath.to_s end def clean_remove_const(const) Object.send(:remove_const, const.to_s) if Object.send(:const_defined?, const) end # # Simulate pry-byebug's input for testing # class InputTester def initialize(*actions) @actions = actions end def add(*actions) @actions += actions end def readline(*) @actions.shift end end pry-byebug-3.7.0/test/thread_lock_test.rb000066400000000000000000000010421343345556000204350ustar00rootroot00000000000000# frozen_string_literal: true require "test_helper" require "timeout" class ThreadLockTest < MiniTest::Spec let(:output) { StringIO.new } let(:input) { InputTester.new } describe "when there's another thread" do before do input.add 'client.puts("Hello")' input.add "IO.select([client], [], [], 1) && client.readline" redirect_pry_io(input, output) { load test_file("echo_thread") } end it "another thread isn't locked" do assert_equal "=> \"Hello\\n\"\n", output.string.lines.last end end end