Sha256: dec486c63ef3329d2992bd5165907e12fb552dab5b6adba04d3403d312635481

Contents?: true

Size: 938 Bytes

Versions: 8

Compression:

Stored size: 938 Bytes

Contents

require 'byebug/command'

module Byebug
  #
  # Execute a file containing byebug commands.
  #
  # It can be used to restore a previously saved debugging session.
  #
  class SourceCommand < Command
    self.allow_in_control = true

    def regexp
      /^\s* so(?:urce)? (?:\s+(\S+))? \s*$/x
    end

    def execute
      return puts(self.class.help) if self.class.names.include?(@match[0])

      unless @state && @state.interface
        return errmsg(pr('source.errors.not_available'))
      end

      file = File.expand_path(@match[1]).strip
      unless File.exist?(file)
        return errmsg(pr('source.errors.not_found', file: file))
      end

      @state.interface.read_file(file)
    end

    class << self
      def names
        %w(source)
      end

      def description
        prettify <<-EOD
          source <file>

          Executes file <file> containing byebug commands.
        EOD
      end
    end
  end
end

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/byebug-4.0.5/lib/byebug/commands/source.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/byebug-4.0.5/lib/byebug/commands/source.rb
byebug-4.0.5 lib/byebug/commands/source.rb
byebug-4.0.4 lib/byebug/commands/source.rb
byebug-4.0.3 lib/byebug/commands/source.rb
byebug-4.0.2 lib/byebug/commands/source.rb
byebug-4.0.1 lib/byebug/commands/source.rb
byebug-4.0.0 lib/byebug/commands/source.rb