class RubyDep::Warning
Constants
- DISABLING_ENVIRONMENT_VAR
- NOTICE_BUGGY_ALTERNATIVE
- NOTICE_HOW_TO_DISABLE
- NOTICE_OPEN_ISSUE
- NOTICE_RECOMMENDATION
- PREFIX
- WARNING
Public Class Methods
Source
# File lib/ruby_dep/warning.rb, line 28 def initialize @version = RubyVersion.new(RUBY_VERSION, RUBY_ENGINE) end
Public Instance Methods
Source
# File lib/ruby_dep/warning.rb, line 32 def show_warnings return if silenced? return warn_ruby(WARNING[status]) if WARNING.key?(status) return if status == :unknown raise "Unknown problem type: #{problem.inspect}" end
Source
# File lib/ruby_dep/warning.rb, line 39 def silence! ENV[DISABLING_ENVIRONMENT_VAR] = '1' end
Private Instance Methods
Source
# File lib/ruby_dep/warning.rb, line 81 def buggy_alternatives @version.recommended(:buggy) end
Source
# File lib/ruby_dep/warning.rb, line 62 def recommendation return unrecognized_msg unless @version.recognized? return recommendation_msg unless status == :insecure [recommendation_msg, safer_alternatives_msg].join(' ') end
Source
# File lib/ruby_dep/warning.rb, line 85 def recommendation_msg format( NOTICE_RECOMMENDATION, @version.version, status, recommended_versions.join(' or ') ) end
Source
# File lib/ruby_dep/warning.rb, line 77 def recommended_versions @version.recommended(:unknown) end
Source
# File lib/ruby_dep/warning.rb, line 94 def safer_alternatives_msg format(NOTICE_BUGGY_ALTERNATIVE, buggy_alternatives.join(' or ')) end
Source
# File lib/ruby_dep/warning.rb, line 45 def silenced? value = ENV[DISABLING_ENVIRONMENT_VAR] (value || '0') !~ /^0|false|no|n$/ end
Source
# File lib/ruby_dep/warning.rb, line 68 def unrecognized_msg format( "Your Ruby is: %s '%s' (unrecognized). %s", @version.version, @version.engine, NOTICE_OPEN_ISSUE ) end
Source
# File lib/ruby_dep/warning.rb, line 54 def warn_ruby(msg) RubyDep.logger.tap do |logger| logger.warn(PREFIX + msg) logger.info(PREFIX + recommendation) logger.info(PREFIX + NOTICE_HOW_TO_DISABLE) end end