Module: RosettAi::Deprecation
- Defined in:
- lib/rosett_ai/deprecation.rb
Overview
Structured deprecation warning system.
Emits formatted warnings to stderr when deprecated features are used, including the version where deprecation started and the planned removal version. Warnings are deduplicated per session to avoid noise.
Class Method Summary collapse
-
.already_warned?(feature) ⇒ Boolean
Check whether a feature has already been warned in this session.
-
.reset!
Reset all warned state.
-
.warn_deprecated(feature:, replacement:, since:, removal:, stderr: $stderr)
Emit a deprecation warning for a feature.
Class Method Details
.already_warned?(feature) ⇒ Boolean
Check whether a feature has already been warned in this session.
47 48 49 |
# File 'lib/rosett_ai/deprecation.rb', line 47 def already_warned?(feature) @mutex.synchronize { @warned.key?(feature) } end |
.reset!
This method returns an undefined value.
Reset all warned state. Intended for test isolation.
54 55 56 |
# File 'lib/rosett_ai/deprecation.rb', line 54 def reset! @mutex.synchronize { @warned = {} } end |
.warn_deprecated(feature:, replacement:, since:, removal:, stderr: $stderr)
This method returns an undefined value.
Emit a deprecation warning for a feature.
Deduplicates by feature name — a second call for the same feature within the same process is silently ignored.
34 35 36 37 38 39 40 41 |
# File 'lib/rosett_ai/deprecation.rb', line 34 def warn_deprecated(feature:, replacement:, since:, removal:, stderr: $stderr) return if already_warned?(feature) mark_warned(feature) = (feature: feature, replacement: replacement, since: since, removal: removal) formatted = tty?(stderr) ? Rainbow().yellow : stderr.puts formatted end |