Class: Rbcli::DeprecationWarning
- Inherits:
-
Object
- Object
- Rbcli::DeprecationWarning
- Defined in:
- lib/rbcli/util/deprecation_warning.rb
Constant Summary collapse
- @@warnings =
[]
- @@errors_exist =
false
Class Method Summary collapse
Instance Method Summary collapse
- #display ⇒ Object
-
#initialize(original_feature_name, message_text, change_by_version, caller) ⇒ DeprecationWarning
constructor
A new instance of DeprecationWarning.
Constructor Details
#initialize(original_feature_name, message_text, change_by_version, caller) ⇒ DeprecationWarning
Returns a new instance of DeprecationWarning.
27 28 29 30 31 32 33 34 |
# File 'lib/rbcli/util/deprecation_warning.rb', line 27 def initialize original_feature_name, , change_by_version, caller #@caller = caller_locations(2,1)[0].label @original_feature_name = original_feature_name = @change_by_version = change_by_version @caller = caller @@warnings.append self end |
Class Method Details
.display_warnings ⇒ Object
56 57 58 59 |
# File 'lib/rbcli/util/deprecation_warning.rb', line 56 def self.display_warnings @@warnings.each { |w| w.display } exit(1) if @@errors_exist end |
Instance Method Details
#display ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rbcli/util/deprecation_warning.rb', line 36 def display deprecated_version_parts = @change_by_version.split('.').map { |i| i.to_i } current_version_parts = Rbcli::VERSION.split('.').map { |i| i.to_i } if deprecated_version_parts[0] > current_version_parts[0] or deprecated_version_parts[1] > current_version_parts[1] or deprecated_version_parts[2] >= current_version_parts[2] = "DEPRECATION ERROR: The feature `#{@original_feature_name}` has been deprecated as of Rbcli version #{@change_by_version}. #{@message_text} Please update the relevant code to continue using Rbcli." Rbcli::log.error { } puts .red @@errors_exist = true else = "DEPRECATION WARNING: The feature `#{@original_feature_name}` has been deprecated. #{@message_text} This feature will be removed in version #{@change_by_version}." Rbcli::log.warn { } puts .yellow end puts @caller[0], "" end |