Sha256: dd5ed55f5149a138554a3619177aa3b86b1abc2f6b3a0bd92e6ab839d5d49c6d

Contents?: true

Size: 774 Bytes

Versions: 73

Compression:

Stored size: 774 Bytes

Contents

# encoding: utf-8

module Github

  DEPRECATION_PREFIX = "[GithubAPI] Deprecation warning:"

  class << self

    attr_writer :deprecation_tracker

    def deprecation_tracker
      @deprecation_tracker ||= []
    end

    # Displays deprecation message to the user.
    # Each message is printed once.
    def deprecate(method, alternate_method=nil)
      return if deprecation_tracker.include? method
      deprecation_tracker << method

      message = <<-NOTICE
#{DEPRECATION_PREFIX}

* #{method} is deprecated.
NOTICE
      if alternate_method
        message << <<-ADDITIONAL
* please use #{alternate_method} instead.
ADDITIONAL
      end
      warn_deprecation(message)
    end

    def warn_deprecation(message)
      send :warn, message
    end
  end

end # Github

Version data entries

73 entries across 73 versions & 3 rubygems

Version Path
github_api-0.5.2 lib/github_api/deprecation.rb
github_api-0.5.1 lib/github_api/deprecation.rb
github_api-0.5.0 lib/github_api/deprecation.rb
github_api-0.5.0.rc1 lib/github_api/deprecation.rb
github_api-0.4.11 lib/github_api/deprecation.rb
github_api-0.4.10 lib/github_api/deprecation.rb
github_api-0.4.9 lib/github_api/deprecation.rb
github_api-0.4.8 lib/github_api/deprecation.rb
github_api-0.4.7 lib/github_api/deprecation.rb
github_api-0.4.6 lib/github_api/deprecation.rb
github_api-0.4.5 lib/github_api/deprecation.rb
github_api-0.4.4 lib/github_api/deprecation.rb
github_api-0.4.3 lib/github_api/deprecation.rb