Sha256: 3433d2d417e11c47d7dc8b07cc19f3f5de8a77f5a86cd1bd082d050962223618

Contents?: true

Size: 1.42 KB

Versions: 43

Compression:

Stored size: 1.42 KB

Contents

# -*- ruby encoding: utf-8 -*-

require 'mime/types/logger'

# The namespace for MIME applications, tools, and libraries.
module MIME
  class Types
    # Used to mark a method as deprecated in the mime-types interface.
    def self.deprecated(klass, sym, message = nil, &block) # :nodoc:
      level = case klass
              when Class, Module
                '.'
              else
                klass = klass.class
                '#'
              end
      message = case message
                when :private, :protected
                  "and will be #{message}"
                when nil
                  'and will be removed'
                else
                  message
                end
      MIME::Types.logger.warn <<-warning.chomp
#{caller[1]}: #{klass}#{level}#{sym} is deprecated #{message}.
      warning
      block.call if block
    end
  end

  class << self
    # MIME::InvalidContentType was moved to MIME::Type::InvalidContentType.
    # Provide a single warning about this fact in the interim.
    def const_missing(name) # :nodoc:
      case name.to_s
      when 'InvalidContentType'
        warn_about_moved_constants(name)
        MIME::Type.const_get(name.to_sym)
      else
        super
      end
    end

    private

    def warn_about_moved_constants(name)
      MIME::Types.logger.warn <<-warning.chomp
#{caller[1]}: MIME::#{name} is deprecated. Use MIME::Type::#{name} instead.
      warning
    end
  end
end

Version data entries

43 entries across 41 versions & 11 rubygems

Version Path
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/mime-types-2.99.3/lib/mime/types/deprecations.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/mime-types-2.99.3/lib/mime/types/deprecations.rb
tdiary-5.0.7 vendor/bundle/gems/mime-types-2.99.3/lib/mime/types/deprecations.rb
tdiary-5.0.6 vendor/bundle/gems/mime-types-2.99.3/lib/mime/types/deprecations.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mime-types-2.99.3/lib/mime/types/deprecations.rb
tdiary-5.0.5 vendor/bundle/gems/mime-types-2.99.3/lib/mime/types/deprecations.rb
tdiary-5.0.4 vendor/bundle/gems/mime-types-2.99.3/lib/mime/types/deprecations.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/mime-types-2.99.3/lib/mime/types/deprecations.rb
tdiary-5.0.2 vendor/bundle/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
mime-types-2.99.3 lib/mime/types/deprecations.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
tdiary-5.0.1 vendor/bundle/gems/mime-types-2.99.2/lib/mime/types/deprecations.rb
mime-types-2.99.2 lib/mime/types/deprecations.rb