Sha256: 3adabb75bc55eeb818f1fe3b05a3349f4fcd135ca905e2c42f65f483c8f6f8ee
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
require 'cape/xterm' module Cape module Deprecation # Prints to a stream a message related to deprecated API usage. # # @abstract class Base # Sets the value of {#stream}. # # @param [IO] value a new value for {#stream} # # @return [IO] _value_ attr_writer :stream # Formats {#message_content} for display. # # @return [String] the full message def formatted_message [].tap do |fragments| fragments << XTerm.bold_and_foreground_red('*** DEPRECATED:') fragments << ' ' fragments << XTerm.bold(message_content) end.join end # Prepares a message based on deprecated API usage. # # @raise [NotImplementedError] # # @abstract def message_content raise ::NotImplementedError end # The stream to which deprecation messages are printed. Defaults to # $stderr. # # @return [IO] def stream @stream ||= $stderr end # Writes {#formatted_message} to {#stream}. # # @return [Base] the object def write_formatted_message_to_stream stream.puts formatted_message self end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cape-1.8.0 | lib/cape/deprecation/base.rb |
cape-1.7.0 | lib/cape/deprecation/base.rb |