Sha256: 9f9a2f59e3c679d882f480be338e79a331e37cf2f7e7d53adccb03d0a02b85d9

Contents?: true

Size: 1.9 KB

Versions: 6484

Compression:

Stored size: 1.9 KB

Contents

# 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

      #
      # Prints a message with bold font.
      #
      def bold_puts(msg)
        output.puts(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
                      "#{bold('Condition:')} #{breakpoint.expr}\n"
                    else
                      ""
                    end

        output.puts <<-BREAKPOINT.gsub(/ {8}/, "")

          #{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}/, "")

          #{bold(header)}
          #{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

Version data entries

6,484 entries across 6,481 versions & 27 rubygems

Version Path
affixapi-1.1.102 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/pry-byebug-3.9.0/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb
cybrid_api_organization_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/pry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb