Releases: tilo/deprecate_soft
1.2.0
✨ Release Notes: v1.2.0
What's new in deprecate_soft v1.2.0
📝 DepracateSoft Change Log
[1.2.0] - 2025-04-05
✨ Added Support
- improving handling of class methods
- added deprecate_class_soft for class methods. Fixed Issue #1
- support to define the method after the declaration
🛠️ Internals
- stream-lined include DeprecateSoft
📐 Deliberate Limitations
- Class methods need to be defined via
def self.method, not inclass << selfblocks.
Simply move the to-be-deprecated method out of theself << classand declare it viaself.method_name.
This also makes the
v1.1.0
✨ Release Notes: v1.1.0
What's new in deprecate_soft v1.1.0
✅ Features & Improvements
-
Double-wrap protection: Calling deprecate_soft multiple times on the same method no longer re-wraps it.
-
Hook failure isolation: If
before_hookorafter_hookraises, the original method still runs. Errors are logged to$stderrviaKernel.warn.
🧪 Test Suite Enhancements
-
Added coverage for corner cases:
-
Private methods (both instance and class-level).
-
before_hookandafter_hookraising exceptions. -
when
deprecate_softis called (incorrectly) before method is defined -
when
deprecate_softis called multiple times on the same method
-
-
Improved test robustness by capturing $stderr instead of mocking Kernel.warn.
🛠 Internal Cleanup
- Simplified Initialization.
- Used
Kernel.warndirectly to ensure compatibility with RSpec spies and Ruby internals.
v1.0.0
🎉 Initial Release: v1.0.0
Welcome to the first official release of deprecate_soft
A simple and non-intrusive way to ensure that methods you ear-marked for deletion are no longer used in production -- without impacting method execution.
This gem provides a lightweight mechanism to flag deprecated methods while continuing to execute them, enabling you to:
-
Notify developers or emit observability events when deprecated methods are called.
-
Configure custom hooks to log, alert, or track usage (e.g., in StatsD or DataDog).
-
Avoid breaking changes while gradually phasing out legacy code paths.
✨ Features
-
deprecate_soft method for both:
-
✅ Instance methods (via include DeprecateSoft)
-
✅ Class methods (via extend DeprecateSoft)
-
-
Customizable hooks:
Safely wrap methods with an optional message.-
DeprecateSoft.before_hook -
DeprecateSoft.after_hook
-
-
Hook parameters:
-
method (fully qualified name)
-
message (deprecation reason)
-
args / result
-
-
Non-invasive: No exceptions raised, no dependencies added.
-
Naming isolation: Internally renames original methods to avoid collisions.
-
Support for soft-deprecating instance and class methods, as well as private methods.
-
Safe defaults: Skips wrapping if method isn’t yet defined.