Sha256: 0c179b463e89bf5613717a8d89441f4dacefd119cee8b823fee021fda37ba04e

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

require_relative "warner/version"

class Warner

  def self.colored_warning(message, callstack = nil)
    if Object.const_defined?('ActiveSupport')
      ActiveSupport::Deprecation.warn message, callstack
    else
      warn "\e[41;37;1m[DEPRECATION WARNING]: #{message}\e[0m"
    end
  end

  def self.rails_version_warning(version, message)
    if Object.const_defined?('Rails')
      if Gem::Version.new(Rails.version) > Gem::Version.new(version)
        colored_warning "[RAILS] %s > %s : %s" % [Rails.version, version, message], caller
      end
    else
      raise "Rails not loaded"
    end
  end

  def self.gem_version_warning(gem_name, version, message)
    if Gem.loaded_specs[gem_name].version > Gem::Version.new(version)
      colored_warning "[gem:%s] %s > %s : %s" % [gem_name, Gem.loaded_specs[gem_name].version, version, message], caller
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
warner-1.0.2 lib/warner.rb