Sha256: c0d99821a209102230078e8f3dc279d9ca91b4977bede6be340b1f2dae2dc2e1

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module RescuesResultUnhandledExceptions
        module Commands
          class FormatMessage < Support::Command
            ##
            # @!attribute [r] message
            #   @return [String, nil]
            #
            attr_reader :message

            ##
            # @param message [String, nil]
            # @return [void]
            #
            def initialize(message:)
              @message = message
            end

            ##
            # @return [String]
            #
            # @note Message formatting is inspired by RSpec. It has almost the same output (at least for RSpec 3).
            #
            # @note Underscores are used to highlight spaces in docs, they are NOT included in the resulting message, check `FormatException` for a full example.
            #
            # @example Message.
            #   __exception message
            #
            # @example Multiline message.
            #   __exception message first line
            #   __exception message second line
            #   __exception message third line
            #
            # @see ConvenientService::Service::Plugins::RescuesResultUnhandledExceptions::Commands::FormatException
            #
            def call
              message.to_s.chomp.split("\n").map { |line| line.prepend(Constants::MESSAGE_LINE_PREFIX) }.join("\n")
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.17.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.16.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.15.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.14.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.13.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.12.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.11.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.10.1 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
convenient_service-0.10.0 lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb