Module: PacketGen::Deprecation Private
- Defined in:
- lib/packetgen/deprecation.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Deprecation module
Constant Summary collapse
- REMOVE_VERSION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default remove version for deprecated classes/methods
'4.0.0'
Class Method Summary collapse
-
.deprecated(klass, deprecated_method, new_method = nil, klass_method: false, remove_version: REMOVE_VERSION) ⇒ Object
private
Warn when using a deprecated method.
-
.deprecated_class(klass, new_klass = nil, remove_version: REMOVE_VERSION) ⇒ Object
private
Warn when using a deprecated method.
-
.deprecated_option(klass, method, option, klass_method: false, remove_version: REMOVE_VERSION) ⇒ Object
private
Warn when using a deprecated method’s option.
- .removed(remove_version) ⇒ String private
Class Method Details
.deprecated(klass, deprecated_method, new_method = nil, klass_method: false, remove_version: REMOVE_VERSION) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Warn when using a deprecated method
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/packetgen/deprecation.rb', line 29 def self.deprecated(klass, deprecated_method, new_method=nil, klass_method: false, remove_version: REMOVE_VERSION) base_name = "#{klass}#{klass_method ? '.' : '#'}" complete_deprecated_method_name = "#{base_name}#{deprecated_method}" complete_new_method_name = "#{base_name}#{new_method}" unless new_method.nil? file, line = caller(2..2).first.split(':')[0, 2] = +"#{file}:#{line}: #{complete_deprecated_method_name} is deprecated" << " in favor of #{complete_new_method_name}" unless new_method.nil? << '. ' << self.removed(remove_version) warn end |
.deprecated_class(klass, new_klass = nil, remove_version: REMOVE_VERSION) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Warn when using a deprecated method
47 48 49 50 51 52 53 |
# File 'lib/packetgen/deprecation.rb', line 47 def self.deprecated_class(klass, new_klass=nil, remove_version: REMOVE_VERSION) file, line = caller(2..2).first.split(':')[0, 2] = +"#{file}:#{line}: #{klass} is deprecated" << " in favor of #{new_klass}" unless new_klass.nil? << '. ' << self.removed(remove_version) warn end |
.deprecated_option(klass, method, option, klass_method: false, remove_version: REMOVE_VERSION) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Warn when using a deprecated method’s option
64 65 66 67 68 69 70 |
# File 'lib/packetgen/deprecation.rb', line 64 def self.deprecated_option(klass, method, option, klass_method: false, remove_version: REMOVE_VERSION) base_name = "#{klass}#{klass_method ? '.' : '#'}" method_name = "#{base_name}#{method}" = +"option #{option} is deprecated for method #{method_name}. " << self.removed(remove_version) warn end |
.removed(remove_version) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/packetgen/deprecation.rb', line 17 def self.removed(remove_version) "It will be removed in PacketGen #{remove_version}" end |