deprecate_soft 1.0.0 β 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +22 -7
- data/CHANGELOG.md +34 -3
- data/README.md +109 -62
- data/lib/deprecate_soft/global_monkey_patch.rb +7 -11
- data/lib/deprecate_soft/method_wrapper.rb +39 -9
- data/lib/deprecate_soft/version.rb +1 -1
- data/lib/deprecate_soft.rb +46 -18
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71f04af257e3e75e4c00ab45333c7e800a440f29f7677361bb6057d300eb6553
|
4
|
+
data.tar.gz: 62e5028bb462ac1cfec9d91a462baaaca81ba0f9211392c387cbff926aaf5a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a50dfb57c19b479a103192f8e86f2bd3abed9bf1400db03e6ad4d1f3aba1eddd67eff0226a101b8c3d3813d69839e7ac505a8feb38252a521d1c9038b9a3aa
|
7
|
+
data.tar.gz: 7ffb74d9dfdf8d2051d20a7fa1c8efca196248bd2c8358e8077534f7900bea851ef30868c6a5cb3ed267b3b49ed2ebecb9fea166394b0280c5ebe284036b00de
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.5 # purposely an old Ruby version
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
Layout/LineLength:
|
5
|
+
Max: 180
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
Lint/ConstantDefinitionInBlock:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Lint/UnusedBlockArgument:
|
11
|
+
Enabled: false
|
9
12
|
|
10
13
|
Metrics/AbcSize:
|
11
14
|
Enabled: false
|
@@ -22,9 +25,6 @@ Metrics/CyclomaticComplexity:
|
|
22
25
|
Metrics/MethodLength:
|
23
26
|
Enabled: false
|
24
27
|
|
25
|
-
Lint/UnusedBlockArgument:
|
26
|
-
Enabled: false
|
27
|
-
|
28
28
|
Naming/MethodParameterName:
|
29
29
|
Enabled: false
|
30
30
|
|
@@ -34,5 +34,20 @@ Style/SafeNavigation:
|
|
34
34
|
Style/Documentation:
|
35
35
|
Enabled: false
|
36
36
|
|
37
|
+
Style/IfUnlessModifier:
|
38
|
+
Enabled: false
|
39
|
+
|
37
40
|
Style/RedundantSelf:
|
38
41
|
Enabled: false
|
42
|
+
|
43
|
+
Style/SingleLineMethods:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Style/StringLiterals:
|
47
|
+
EnforcedStyle: single_quotes
|
48
|
+
|
49
|
+
Style/StringLiteralsInInterpolation:
|
50
|
+
EnforcedStyle: single_quotes
|
51
|
+
|
52
|
+
Style/TrivialAccessors:
|
53
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,38 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
## π DepracateSoft Change Log
|
3
|
+
|
4
|
+
## [1.2.0] - 2025-04-05
|
5
|
+
### β¨ Added Support
|
6
|
+
- improving handling of class methods
|
7
|
+
- added deprecate_class_soft for class methods. Fixed [Issue #1](https://github.com/tilo/deprecate_soft/issues/1)
|
8
|
+
- support to define the method after the declaration
|
9
|
+
### π οΈ Internals
|
10
|
+
- stream-lined include DeprecateSoft
|
11
|
+
### π Deliberate Limitations
|
12
|
+
- Class methods need to be defined via `def self.method`, not in `class << self` blocks.
|
13
|
+
Simply move the to-be-deprecated method out of the `self << class` and declare it via `self.method_name`.
|
14
|
+
This also makes the to be deleted method stand out more.
|
15
|
+
|
16
|
+
## [1.1.0] - 2025-03-29
|
17
|
+
### β¨ Added Support
|
18
|
+
- Errors in `before_hook` / `after_hook` do not prevent method execution.
|
19
|
+
- `Kernel.warn` is used to log hook exceptions instead of raising.
|
20
|
+
- No impact if `deprecate_soft` is called twice for the same method
|
21
|
+
### π§ͺ Test Coverage
|
22
|
+
- deprecate_soft called before method definition
|
23
|
+
- deprecate_soft called twice
|
24
|
+
- deprecate_soft for private instance and class methods
|
25
|
+
- errors in `before_hook` or `after_hook`
|
26
|
+
### π οΈ Internals
|
27
|
+
- simplified initialization
|
2
28
|
|
3
29
|
## [1.0.0] - 2025-03-24
|
4
|
-
|
30
|
+
- Initial release of `deprecate_soft`.
|
31
|
+
- Support for soft-deprecating instance and class methods, as well as private methods.
|
32
|
+
- Added `before_hook` and `after_hook` for custom instrumentation or logging.
|
33
|
+
- Safe wrapping of methods with optional message.
|
34
|
+
- Skips wrapping if method is not yet defined.
|
35
|
+
- Supports defining deprecations inline with method definitions.
|
36
|
+
|
5
37
|
## [0.0.1] - 2025-03-22
|
6
38
|
- pre-release
|
7
|
-
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
|
2
2
|
# DeprecateSoft
|
3
3
|
|
4
|
-
|
4
|
+
[](https://badge.fury.io/rb/deprecate_soft)
|
5
|
+
[](https://github.com/tilo/deprecate_soft/actions/workflows/main.yml)
|
6
|
+
[](https://codecov.io/gh/tilo/deprecate_soft)
|
7
|
+
|
8
|
+
DeprecateSoft is a lightweight and flexible Ruby gem designed to help you gracefully and safely delete methods.
|
5
9
|
|
6
10
|
It was inspired by the need to track deprecated method usage in large codebases before safely removing old code β with zero disruption and flexible metrics support.
|
7
11
|
|
@@ -11,6 +15,8 @@ Itβs ideal for monitoring deprecated method usage across your application usin
|
|
11
15
|
|
12
16
|
Once tracking confirms that a deprecated method is no longer in use, you can confidently delete it from your codebase.
|
13
17
|
|
18
|
+
This mechanism has been **proven in large-scale production systems** to safely clean up legacy code β this gem reimagines that functionality to help you clean up your code with confidence.
|
19
|
+
|
14
20
|
---
|
15
21
|
|
16
22
|
## β¨ Features
|
@@ -19,10 +25,14 @@ Once tracking confirms that a deprecated method is no longer in use, you can con
|
|
19
25
|
- Works with instance methods in any class or module
|
20
26
|
- Works with class or module methods in any class or module
|
21
27
|
- System-wide hook configuration (before and after)
|
22
|
-
- No monkey-patching or global pollution
|
28
|
+
- No monkey-patching or global pollution β unless you explicitly opt in via `GlobalMonkeyPatch`
|
23
29
|
- Fully compatible with Rails or plain Ruby apps
|
24
30
|
|
25
31
|
---
|
32
|
+
## π Blog Posts
|
33
|
+
- [Safely Delete Old Ruby Code with deprecate_soft](https://medium.com/@tilo-sloboda/safely-delete-old-code-with-deprecate-soft-89e819b41d52)
|
34
|
+
---
|
35
|
+
## π [Change Log](https://github.com/tilo/deprecate_soft/blob/main/CHANGELOG.md)
|
26
36
|
|
27
37
|
## π Installation
|
28
38
|
|
@@ -38,6 +48,66 @@ Then run:
|
|
38
48
|
bundle install
|
39
49
|
```
|
40
50
|
|
51
|
+
And add your initializer file.
|
52
|
+
|
53
|
+
---
|
54
|
+
|
55
|
+
## 𧩠Usage
|
56
|
+
|
57
|
+
Declare `deprecate_soft` **after** the method definition.
|
58
|
+
|
59
|
+
### For Instance Methods:
|
60
|
+
|
61
|
+
use `deprecate_soft`
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
class MyService
|
65
|
+
include DeprecateSoft
|
66
|
+
|
67
|
+
def deprecated_method(a, b)
|
68
|
+
puts "doing something with #{a} and #{b}"
|
69
|
+
end
|
70
|
+
|
71
|
+
deprecate_soft :deprecated_method, "Use #new_method instead"
|
72
|
+
end
|
73
|
+
|
74
|
+
MyService.new.deprecated_method(1, 2) # will exercise the tracking hooks
|
75
|
+
```
|
76
|
+
|
77
|
+
### For Class Methods:
|
78
|
+
|
79
|
+
use `deprecate_class_soft`
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
class MyService
|
83
|
+
include DeprecateSoft
|
84
|
+
|
85
|
+
def self.deprecated_method(a, b)
|
86
|
+
puts "doing something with #{a} and #{b}"
|
87
|
+
end
|
88
|
+
|
89
|
+
deprecate_class_soft :deprecated_method, "will be removed" # β οΈ
|
90
|
+
end
|
91
|
+
|
92
|
+
MyService.deprecated_method(1, 2) # will exercise the tracking hooks
|
93
|
+
|
94
|
+
```
|
95
|
+
|
96
|
+
---
|
97
|
+
|
98
|
+
## π What It Does Under the Hood
|
99
|
+
|
100
|
+
When you call `deprecate_soft :method_name, "reason"`:
|
101
|
+
|
102
|
+
1. It renames the original method to `__method_name_deprecated`.
|
103
|
+
2. It defines a new method with the original name that:
|
104
|
+
- Calls the configured `before_hook` (if set)
|
105
|
+
- Delegates to the original method
|
106
|
+
- Calls the configured `after_hook` (if set)
|
107
|
+
3. The optional `message` with the reason can help identifying alternatives.
|
108
|
+
|
109
|
+
This ensures consistent tracking, clean method resolution, and avoids accidental bypassing.
|
110
|
+
|
41
111
|
---
|
42
112
|
|
43
113
|
## βοΈ Configuration
|
@@ -96,7 +166,7 @@ end
|
|
96
166
|
|
97
167
|
This setup ensures you can plug in **any tracking backend** you like β without polluting the global namespace.
|
98
168
|
|
99
|
-
### π§ Customizing Method Name Wrapping
|
169
|
+
### π§ Optional: Customizing Method Name Wrapping
|
100
170
|
|
101
171
|
When `deprecate_soft` wraps a method, it renames the original method internally to preserve its behavior. You can customize how that internal method is named by configuring a `prefix` and `suffix`.
|
102
172
|
|
@@ -137,61 +207,6 @@ This gives you full control over how deprecated methods are renamed internally.
|
|
137
207
|
|
138
208
|
These names are never called directly β they're used internally to wrap and preserve the original method logic.
|
139
209
|
|
140
|
-
|
141
|
-
---
|
142
|
-
|
143
|
-
## 𧩠Usage
|
144
|
-
|
145
|
-
π¨ Always declare `deprecate_soft` **after** the method definition!
|
146
|
-
|
147
|
-
### For Instance Methods:
|
148
|
-
|
149
|
-
```ruby
|
150
|
-
class MyService
|
151
|
-
include DeprecateSoft
|
152
|
-
|
153
|
-
def deprecated_method(a, b)
|
154
|
-
puts "doing something with #{a} and #{b}"
|
155
|
-
end
|
156
|
-
|
157
|
-
deprecate_soft :deprecated_method, "Use #new_method instead"
|
158
|
-
end
|
159
|
-
|
160
|
-
MyService.new.deprecated_method(1, 2) # will exercise the tracking hooks
|
161
|
-
```
|
162
|
-
|
163
|
-
### For Class Methods:
|
164
|
-
|
165
|
-
```ruby
|
166
|
-
class MyService
|
167
|
-
extend DeprecateSoft
|
168
|
-
|
169
|
-
def self.deprecated_method(a, b)
|
170
|
-
puts "doing something with #{a} and #{b}"
|
171
|
-
end
|
172
|
-
|
173
|
-
deprecate_soft :deprecated_method, "will be removed"
|
174
|
-
end
|
175
|
-
|
176
|
-
MyService.deprecated_method(1, 2) # will exercise the tracking hooks
|
177
|
-
|
178
|
-
```
|
179
|
-
|
180
|
-
---
|
181
|
-
|
182
|
-
## π What It Does Under the Hood
|
183
|
-
|
184
|
-
When you call `deprecate_soft :method_name, "reason"`:
|
185
|
-
|
186
|
-
1. It renames the original method to `__method_name_deprecated`.
|
187
|
-
2. It defines a new method with the original name that:
|
188
|
-
- Calls the configured `before_hook` (if set)
|
189
|
-
- Delegates to the original method
|
190
|
-
- Calls the configured `after_hook` (if set)
|
191
|
-
3. The optional `message` with the reason can help identifying alternatives.
|
192
|
-
|
193
|
-
This ensures consistent tracking, clean method resolution, and avoids accidental bypassing.
|
194
|
-
|
195
210
|
---
|
196
211
|
|
197
212
|
## π§ͺ Example Hook Logic
|
@@ -273,6 +288,36 @@ Klass#legacy_method:caller:app/jobs/cleanup_job.rb:88 β 4
|
|
273
288
|
|
274
289
|
π‘ Now you not only know that the method is still used -- you know where from, and how often -- so you can fix your code.
|
275
290
|
|
291
|
+
---
|
292
|
+
|
293
|
+
## πͺ Optional: Global Monkey Patching
|
294
|
+
|
295
|
+
For large projects, it can be beneficial to enable deprecate_soft across the entire codebase without having to explicitly `include DeprecateSoft` or e`xtend DeprecateSoft` in each class or module.
|
296
|
+
|
297
|
+
To do this, you can globally monkey-patch `Module` by including `DeprecateSoft::GlobalMonkeyPatch`. This is **entirely optional and not enabled by default**.
|
298
|
+
|
299
|
+
Add the following to your `config/initializers/deprecate_soft.rb` initializer:
|
300
|
+
|
301
|
+
```ruby
|
302
|
+
# config/initializers/deprecate_soft.rb
|
303
|
+
|
304
|
+
require "deprecate_soft"
|
305
|
+
require "deprecate_soft/global_monkey_patch"
|
306
|
+
|
307
|
+
# ...
|
308
|
+
|
309
|
+
class Module
|
310
|
+
include DeprecateSoft::GlobalMonkeyPatch
|
311
|
+
end
|
312
|
+
|
313
|
+
DeprecateSoft.configure do |config|
|
314
|
+
#
|
315
|
+
# ...
|
316
|
+
#
|
317
|
+
end
|
318
|
+
|
319
|
+
```
|
320
|
+
|
276
321
|
---
|
277
322
|
|
278
323
|
## π‘ Best Practices
|
@@ -280,7 +325,7 @@ Klass#legacy_method:caller:app/jobs/cleanup_job.rb:88 β 4
|
|
280
325
|
- Use `deprecate_soft` for methods you plan to remove but want to confirm they are no longer used.
|
281
326
|
- Integrate with your observability platform for tracking.
|
282
327
|
- Review usage stats before deleting deprecated methods from your code.
|
283
|
-
-
|
328
|
+
- Always declare `deprecate_soft` **after** the method definition.
|
284
329
|
|
285
330
|
---
|
286
331
|
|
@@ -289,7 +334,9 @@ Klass#legacy_method:caller:app/jobs/cleanup_job.rb:88 β 4
|
|
289
334
|
- Make sure hooks do not raise or interfere with production behavior.
|
290
335
|
- Only use non-blocking, low-latency methods for tracking!
|
291
336
|
- Currently assumes Ruby 2.5+ (for `&.` and keyword args support).
|
292
|
-
-
|
337
|
+
- Class methods need to be defined via `def self.method`, not in `class << self` blocks.
|
338
|
+
Simply move the to-be-deprecated method out of the `self << class` and declare it via `self.method_name`.
|
339
|
+
This also makes the to be deleted method stand out more.
|
293
340
|
|
294
341
|
---
|
295
342
|
|
@@ -297,9 +344,9 @@ Klass#legacy_method:caller:app/jobs/cleanup_job.rb:88 β 4
|
|
297
344
|
|
298
345
|
Feel free to open issues or pull requests if you'd like to:
|
299
346
|
|
300
|
-
-
|
347
|
+
- Request new features
|
301
348
|
- Add Railtie for automatic setup
|
302
|
-
- Add
|
349
|
+
- Add support for other backends
|
303
350
|
|
304
351
|
---
|
305
352
|
|
@@ -3,17 +3,13 @@
|
|
3
3
|
module DeprecateSoft
|
4
4
|
module GlobalMonkeyPatch
|
5
5
|
def deprecate_soft(method_name, message)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# protect against declaring deprecate_soft before method is defined
|
14
|
-
#
|
15
|
-
# Do nothing β fail-safe in production
|
16
|
-
end
|
6
|
+
extend DeprecateSoft::ClassMethods unless is_a?(DeprecateSoft::ClassMethods)
|
7
|
+
deprecate_soft(method_name, message)
|
8
|
+
end
|
9
|
+
|
10
|
+
def deprecate_class_soft(method_name, message = nil)
|
11
|
+
extend DeprecateSoft::ClassMethods unless is_a?(DeprecateSoft::ClassMethods)
|
12
|
+
deprecate_class_soft(method_name, message)
|
17
13
|
end
|
18
14
|
end
|
19
15
|
end
|
@@ -6,27 +6,57 @@ module DeprecateSoft
|
|
6
6
|
hidden_method_name = "#{DeprecateSoft.prefix}#{method_name}_#{DeprecateSoft.suffix}"
|
7
7
|
|
8
8
|
if is_class_method
|
9
|
+
target = context.singleton_class
|
10
|
+
|
11
|
+
return if target.method_defined?(hidden_method_name) || target.private_method_defined?(hidden_method_name)
|
12
|
+
|
9
13
|
original_method = context.method(method_name)
|
14
|
+
target.define_method(hidden_method_name, original_method)
|
15
|
+
|
16
|
+
target.define_method(method_name) do |*args, &block|
|
17
|
+
klass_name = self.class.name || self.class.to_s
|
18
|
+
full_name = "#{klass_name}.#{method_name}"
|
10
19
|
|
11
|
-
|
20
|
+
begin
|
21
|
+
DeprecateSoft.before_hook&.call(full_name, message, args: args)
|
22
|
+
rescue StandardError => e
|
23
|
+
warn "DeprecateSoft.before_hook error: #{e.class} - #{e.message}"
|
24
|
+
end
|
12
25
|
|
13
|
-
context.singleton_class.define_method(method_name) do |*args, &block|
|
14
|
-
full_name = "#{self.name}.#{method_name}"
|
15
|
-
DeprecateSoft.before_hook&.call(full_name, message, args: args) if defined?(DeprecateSoft.before_hook)
|
16
26
|
result = send(hidden_method_name, *args, &block)
|
17
|
-
|
27
|
+
|
28
|
+
begin
|
29
|
+
DeprecateSoft.after_hook&.call(full_name, message, result: result)
|
30
|
+
rescue StandardError => e
|
31
|
+
warn "DeprecateSoft.after_hook error: #{e.class} - #{e.message}"
|
32
|
+
end
|
33
|
+
|
18
34
|
result
|
19
35
|
end
|
20
36
|
else
|
21
|
-
|
37
|
+
return if context.method_defined?(hidden_method_name) || context.private_method_defined?(hidden_method_name)
|
22
38
|
|
39
|
+
original_method = context.instance_method(method_name)
|
23
40
|
context.define_method(hidden_method_name, original_method)
|
24
41
|
|
25
42
|
context.define_method(method_name) do |*args, &block|
|
26
|
-
|
27
|
-
|
43
|
+
klass_name = self.class.name || self.to_s
|
44
|
+
full_name = "#{klass_name}.#{method_name}"
|
45
|
+
|
46
|
+
begin
|
47
|
+
DeprecateSoft.before_hook&.call(full_name, message, args: args)
|
48
|
+
rescue StandardError => e
|
49
|
+
warn "DeprecateSoft.before_hook error: #{e.class} - #{e.message}"
|
50
|
+
end
|
51
|
+
|
28
52
|
result = send(hidden_method_name, *args, &block)
|
29
|
-
|
53
|
+
|
54
|
+
begin
|
55
|
+
DeprecateSoft.after_hook&.call(full_name, message, result: result)
|
56
|
+
rescue StandardError => e
|
57
|
+
warn "DeprecateSoft.after_hook error: #{e.class} - #{e.message}"
|
58
|
+
end
|
59
|
+
|
30
60
|
result
|
31
61
|
end
|
32
62
|
end
|
data/lib/deprecate_soft.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
# require all files under lib/deprecate_soft
|
4
|
+
Dir[File.join(__dir__, 'deprecate_soft', '*.rb')].sort.each do |file|
|
5
|
+
require file
|
6
|
+
end
|
6
7
|
|
7
8
|
module DeprecateSoft
|
8
9
|
class << self
|
@@ -21,30 +22,57 @@ module DeprecateSoft
|
|
21
22
|
yield self
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
-
|
25
|
+
def prefixed_name(method_name)
|
26
|
+
"#{prefix}#{method_name}_#{suffix}".to_sym
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
-
base.extend
|
30
|
-
end
|
31
|
-
end
|
29
|
+
def included(base)
|
30
|
+
base.extend(ClassMethods)
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
base.define_singleton_method(:method_added) do |method_name|
|
33
|
+
pending = base.instance_variable_get(:@__pending_soft_wraps)
|
34
|
+
if pending&.key?(method_name)
|
35
|
+
DeprecateSoft::MethodWrapper.wrap_method(base, method_name, pending.delete(method_name), is_class_method: false)
|
36
|
+
end
|
37
|
+
super(method_name) if defined?(super)
|
38
|
+
end
|
37
39
|
|
38
|
-
|
40
|
+
base.singleton_class.define_method(:singleton_method_added) do |method_name|
|
41
|
+
pending = instance_variable_get(:@_pending_soft_wraps)
|
42
|
+
if pending&.key?(method_name)
|
43
|
+
DeprecateSoft::MethodWrapper.wrap_method(base, method_name, pending.delete(method_name), is_class_method: true)
|
44
|
+
end
|
45
|
+
super(method_name) if defined?(super)
|
46
|
+
end
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
42
50
|
module ClassMethods
|
43
|
-
def deprecate_soft(method_name, message)
|
44
|
-
|
45
|
-
|
51
|
+
def deprecate_soft(method_name, message = nil)
|
52
|
+
hidden = DeprecateSoft.prefixed_name(method_name)
|
53
|
+
|
54
|
+
if method_defined?(method_name) || private_method_defined?(method_name)
|
55
|
+
return if method_defined?(hidden) || private_method_defined?(hidden)
|
56
|
+
|
57
|
+
DeprecateSoft::MethodWrapper.wrap_method(self, method_name, message, is_class_method: false)
|
58
|
+
else
|
59
|
+
@__pending_soft_wraps ||= {}
|
60
|
+
@__pending_soft_wraps[method_name] = message
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def deprecate_class_soft(method_name, message = nil)
|
65
|
+
hidden = DeprecateSoft.prefixed_name(method_name)
|
66
|
+
target = singleton_class
|
67
|
+
|
68
|
+
if target.method_defined?(method_name) || target.private_method_defined?(method_name)
|
69
|
+
return if target.method_defined?(hidden) || target.private_method_defined?(hidden)
|
46
70
|
|
47
|
-
|
71
|
+
DeprecateSoft::MethodWrapper.wrap_method(self, method_name, message, is_class_method: true)
|
72
|
+
else
|
73
|
+
@_pending_soft_wraps ||= {}
|
74
|
+
@_pending_soft_wraps[method_name] = message
|
75
|
+
end
|
48
76
|
end
|
49
77
|
end
|
50
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deprecate_soft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilo Sloboda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dogstatsd-ruby
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,20 @@ dependencies:
|
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '1.21'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description: |
|
84
112
|
DeprecateSoft is a lightweight Ruby gem that lets you gracefully deprecate methods
|
85
113
|
in your codebase without breaking functionality. It wraps existing instance or
|