module Autoloaded::Deprecation
Prints deprecation messages to stderr.
@since 1.3
@api private
Attributes
io[W]
Sets the deprecation stream.
@param [IO] value a new value for io
Public Class Methods
deprecate(keywords)
click to toggle source
Prints a deprecation message to #io regarding the specified deprecated_usage.
@param [Hash] keywords the parameters of the deprecation message @option keywords [String] :deprecated_usage API usage that is soon to be
discontinued
@option keywords [String] :sanctioned_usage API usage that will succeed
_:deprecated_usage_
@option keywords [String] :source_filename the file path of the source
invoking the deprecated API
@return [Module] Deprecation
@raise [ArgumentError] one or more keywords are missing
# File lib/autoloaded/deprecation.rb, line 36 def deprecate(keywords) deprecated_usage = fetch(keywords, :deprecated_usage) sanctioned_usage = fetch(keywords, :sanctioned_usage) source_filename = fetch(keywords, :source_filename) deprecation = "\e[33m*** \e[7m DEPRECATED \e[0m " + "\e[4m#{deprecated_usage}\e[0m -- use " + "\e[4m#{sanctioned_usage}\e[0m instead in #{source_filename}" io.puts deprecation self end
io()
click to toggle source
The deprecation stream. Defaults to +$stderr+.
@return [IO] the deprecation stream
# File lib/autoloaded/deprecation.rb, line 18 def io @io || $stderr end
Private Class Methods
fetch(keywords, keyword)
click to toggle source
# File lib/autoloaded/deprecation.rb, line 51 def fetch(keywords, keyword) keywords.fetch keyword do raise ::ArgumentError, "missing keyword: #{keyword}" end end