Sha256: bc8f8b7bfdf68fe58b757c47f3bebf202643ad37e2e1b774b3f26e0b8cf8d422

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

require 'byebug/printers/base'

module Byebug
  module Printers
    #
    # Plain text printer
    #
    class Plain < Base
      def print(path, args = {})
        message = translate(locate(path), args)
        tail = parts(path).include?('confirmations') ? ' (y/n) ' : "\n"
        message << tail
      end

      def print_collection(path, collection, &block)
        lines = array_of_args(collection, &block).map do |args|
          print(path, args)
        end

        lines.join
      end

      def print_variables(variables, *_)
        print_collection('variable.variable', variables) do |(key, value), _|
          value = value.nil? ? 'nil' : value.to_s
          if "#{key} = #{value}".size > Setting[:width]
            key_size = "#{key} = ".size
            value = value[0..Setting[:width] - key_size - 4] + '...'
          end

          { key: key, value: value }
        end
      end

      private

      def contents_files
        [File.join(__dir__, 'texts', 'plain.yml')] + super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0/lib/byebug/printers/plain.rb
tdiary-5.0.6 vendor/bundle/gems/byebug-9.1.0/lib/byebug/printers/plain.rb
byebug-9.1.0 lib/byebug/printers/plain.rb