File: base.rb

package info (click to toggle)
ruby-pry-byebug 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 324 kB
  • sloc: ruby: 1,171; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 770 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require "pry-byebug/helpers/location"

#
# 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 = Helpers::Location.current_file(target)
    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