|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -## |
4 | | -# Provides 3 methods for declaring when something is going away. |
5 | | -# |
6 | | -# +deprecate(name, repl, year, month)+: |
7 | | -# Indicate something may be removed on/after a certain date. |
8 | | -# |
9 | | -# +rubygems_deprecate(name, replacement=:none)+: |
10 | | -# Indicate something will be removed in the next major RubyGems version, |
11 | | -# and (optionally) a replacement for it. |
12 | | -# |
13 | | -# +rubygems_deprecate_command+: |
14 | | -# Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be |
15 | | -# removed in the next RubyGems version. |
16 | | -# |
17 | | -# Also provides +skip_during+ for temporarily turning off deprecation warnings. |
18 | | -# This is intended to be used in the test suite, so deprecation warnings |
19 | | -# don't cause test failures if you need to make sure stderr is otherwise empty. |
20 | | -# |
21 | | -# |
22 | | -# Example usage of +deprecate+ and +rubygems_deprecate+: |
23 | | -# |
24 | | -# class Legacy |
25 | | -# def self.some_class_method |
26 | | -# # ... |
27 | | -# end |
28 | | -# |
29 | | -# def some_instance_method |
30 | | -# # ... |
31 | | -# end |
32 | | -# |
33 | | -# def some_old_method |
34 | | -# # ... |
35 | | -# end |
36 | | -# |
37 | | -# extend Gem::Deprecate |
38 | | -# deprecate :some_instance_method, "X.z", 2011, 4 |
39 | | -# rubygems_deprecate :some_old_method, "Modern#some_new_method" |
40 | | -# |
41 | | -# class << self |
42 | | -# extend Gem::Deprecate |
43 | | -# deprecate :some_class_method, :none, 2011, 4 |
44 | | -# end |
45 | | -# end |
46 | | -# |
47 | | -# |
48 | | -# Example usage of +rubygems_deprecate_command+: |
49 | | -# |
50 | | -# class Gem::Commands::QueryCommand < Gem::Command |
51 | | -# extend Gem::Deprecate |
52 | | -# rubygems_deprecate_command |
53 | | -# |
54 | | -# # ... |
55 | | -# end |
56 | | -# |
57 | | -# |
58 | | -# Example usage of +skip_during+: |
59 | | -# |
60 | | -# class TestSomething < Gem::Testcase |
61 | | -# def test_some_thing_with_deprecations |
62 | | -# Gem::Deprecate.skip_during do |
63 | | -# actual_stdout, actual_stderr = capture_output do |
64 | | -# Gem.something_deprecated |
65 | | -# end |
66 | | -# assert_empty actual_stdout |
67 | | -# assert_equal(expected, actual_stderr) |
68 | | -# end |
69 | | -# end |
70 | | -# end |
71 | | - |
72 | 3 | module Gem |
| 4 | + ## |
| 5 | + # Provides 3 methods for declaring when something is going away. |
| 6 | + # |
| 7 | + # +deprecate(name, repl, year, month)+: |
| 8 | + # Indicate something may be removed on/after a certain date. |
| 9 | + # |
| 10 | + # +rubygems_deprecate(name, replacement=:none)+: |
| 11 | + # Indicate something will be removed in the next major RubyGems version, |
| 12 | + # and (optionally) a replacement for it. |
| 13 | + # |
| 14 | + # +rubygems_deprecate_command+: |
| 15 | + # Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be |
| 16 | + # removed in the next RubyGems version. |
| 17 | + # |
| 18 | + # Also provides +skip_during+ for temporarily turning off deprecation warnings. |
| 19 | + # This is intended to be used in the test suite, so deprecation warnings |
| 20 | + # don't cause test failures if you need to make sure stderr is otherwise empty. |
| 21 | + # |
| 22 | + # |
| 23 | + # Example usage of +deprecate+ and +rubygems_deprecate+: |
| 24 | + # |
| 25 | + # class Legacy |
| 26 | + # def self.some_class_method |
| 27 | + # # ... |
| 28 | + # end |
| 29 | + # |
| 30 | + # def some_instance_method |
| 31 | + # # ... |
| 32 | + # end |
| 33 | + # |
| 34 | + # def some_old_method |
| 35 | + # # ... |
| 36 | + # end |
| 37 | + # |
| 38 | + # extend Gem::Deprecate |
| 39 | + # deprecate :some_instance_method, "X.z", 2011, 4 |
| 40 | + # rubygems_deprecate :some_old_method, "Modern#some_new_method" |
| 41 | + # |
| 42 | + # class << self |
| 43 | + # extend Gem::Deprecate |
| 44 | + # deprecate :some_class_method, :none, 2011, 4 |
| 45 | + # end |
| 46 | + # end |
| 47 | + # |
| 48 | + # |
| 49 | + # Example usage of +rubygems_deprecate_command+: |
| 50 | + # |
| 51 | + # class Gem::Commands::QueryCommand < Gem::Command |
| 52 | + # extend Gem::Deprecate |
| 53 | + # rubygems_deprecate_command |
| 54 | + # |
| 55 | + # # ... |
| 56 | + # end |
| 57 | + # |
| 58 | + # |
| 59 | + # Example usage of +skip_during+: |
| 60 | + # |
| 61 | + # class TestSomething < Gem::Testcase |
| 62 | + # def test_some_thing_with_deprecations |
| 63 | + # Gem::Deprecate.skip_during do |
| 64 | + # actual_stdout, actual_stderr = capture_output do |
| 65 | + # Gem.something_deprecated |
| 66 | + # end |
| 67 | + # assert_empty actual_stdout |
| 68 | + # assert_equal(expected, actual_stderr) |
| 69 | + # end |
| 70 | + # end |
| 71 | + # end |
| 72 | + |
73 | 73 | module Deprecate |
74 | 74 | def self.skip # :nodoc: |
75 | 75 | @skip ||= false |
|
0 commit comments