Sha256: 0cb6c164fa357835067a7cf7bda513e2dfaed76e31916bbfff93d0f139e22857

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

module Webgen

  class Node

    def flagged(key)
      warn("Deprecation warning: this method will be removed in one of the next releases - use Node#flagged? instead!")
      flagged?(key)
    end

  end

  def self.const_missing(const)
    if const.to_s == 'Block'
      warn("Deprecation warning: Webgen::Block name will be removed in one of the next releases - use Webgen::Page::Block instead!")
      Webgen::Page::Block
    elsif const.to_s == "WebgenPageFormatError"
      warn("Deprecation warning: Webgen::WebgenPageFormatError name will be removed in one of the next releases - use Webgen::Page::FormatError instead!")
      Webgen::Page::FormatError
    else
      super
    end
  end

  module ContentProcessor

    def self.const_missing(const)
      if const.to_s == 'Context'
        warn("Deprecation warning: Webgen::ContentProcessor::Context is now named Webgen::Context! This alias will be removed in one of the next releases.")
        Webgen::Context
      else
        super
      end
    end

    module Deprecated

      def deprecate(old, new, obj)
        klass = Class.new
        klass.instance_methods.select {|m| m.to_s !~ /^(__|instance_eval|object_id)/}.each {|m| klass.__send__(:undef_method, m)}
        result = klass.new
        result.instance_eval { @old, @new, @obj = old, new, obj }
        def result.method_missing(sym, *args, &block)
          Kernel::warn("Deprecation warning (~ #{caller.first}): The alias '#{@old}' will be removed in one of the next releases - use '#{@new}' instead!")
          @obj.send(sym, *args, &block)
        end
        result
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.8.20090507 lib/webgen/deprecated.rb
webgen-0.5.8 lib/webgen/deprecated.rb