Sha256: 60bf4ff997a2dd131ad439ddc7a947579a23bd46c63f0782baa123a074721868

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

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, *_unused)
        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

12 entries across 12 versions & 7 rubygems

Version Path
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/byebug-10.0.2/lib/byebug/printers/plain.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/printers/plain.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/printers/plain.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/byebug-11.0.1/lib/byebug/printers/plain.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/byebug-11.0.1/lib/byebug/printers/plain.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/byebug-11.0.1/lib/byebug/printers/plain.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/byebug-11.0.1/lib/byebug/printers/plain.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/byebug-10.0.2/lib/byebug/printers/plain.rb
byebug-11.0.1 lib/byebug/printers/plain.rb
byebug-11.0.0 lib/byebug/printers/plain.rb
byebug-10.0.2 lib/byebug/printers/plain.rb
byebug-10.0.1 lib/byebug/printers/plain.rb