Sha256: 89ac638c440bad0c5eeeb44001120f43fa0ae037d0ad35bed2579bca0f459131
Contents?: true
Size: 1.55 KB
Versions: 47
Compression:
Stored size: 1.55 KB
Contents
module Vagrant module Util # Automatically add deprecation notices to commands module CommandDeprecation # @return [String] generated name of command def deprecation_command_name name_parts = self.class.name.split("::") [ name_parts[1].sub('Command', ''), name_parts[3] ].compact.map(&:downcase).join(" ") end def self.included(klass) klass.class_eval do class << self if method_defined?(:synopsis) alias_method :non_deprecated_synopsis, :synopsis def synopsis if !non_deprecated_synopsis.to_s.empty? "#{non_deprecated_synopsis} [DEPRECATED]" else non_deprecated_synopsis end end end end alias_method :non_deprecated_execute, :execute def execute(*args, &block) @env[:ui].warn(I18n.t("vagrant.commands.deprecated", name: deprecation_command_name ) + "\n") non_deprecated_execute(*args, &block) end end end # Mark command deprecation complete and fully disable # the command's functionality module Complete def self.included(klass) klass.include(CommandDeprecation) klass.class_eval do def execute(*_) raise Vagrant::Errors::CommandDeprecated, name: deprecation_command_name end end end end end end end
Version data entries
47 entries across 43 versions & 5 rubygems