forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeprecation.rb
More file actions
39 lines (29 loc) · 774 Bytes
/
deprecation.rb
File metadata and controls
39 lines (29 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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