class RubyDep::Warning
Constants
- DISABLING_ENVIRONMENT_VAR
- NOTICE_BUGGY_ALTERNATIVE
- NOTICE_HOW_TO_DISABLE
- NOTICE_OPEN_ISSUE
- NOTICE_RECOMMENDATION
- PREFIX
- WARNING
Public Class Methods
new()
click to toggle source
# File lib/ruby_dep/warning.rb, line 28 def initialize @version = RubyVersion.new(RUBY_VERSION, RUBY_ENGINE) end
Public Instance Methods
show_warnings()
click to toggle 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
silence!()
click to toggle source
# File lib/ruby_dep/warning.rb, line 39 def silence! ENV[DISABLING_ENVIRONMENT_VAR] = '1' end
Private Instance Methods
buggy_alternatives()
click to toggle source
# File lib/ruby_dep/warning.rb, line 81 def buggy_alternatives @version.recommended(:buggy) end
recommendation()
click to toggle 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
recommendation_msg()
click to toggle source
# File lib/ruby_dep/warning.rb, line 85 def recommendation_msg format( NOTICE_RECOMMENDATION, @version.version, status, recommended_versions.join(' or ') ) end
recommended_versions()
click to toggle source
# File lib/ruby_dep/warning.rb, line 77 def recommended_versions @version.recommended(:unknown) end
safer_alternatives_msg()
click to toggle source
# File lib/ruby_dep/warning.rb, line 94 def safer_alternatives_msg format(NOTICE_BUGGY_ALTERNATIVE, buggy_alternatives.join(' or ')) end
silenced?()
click to toggle source
# File lib/ruby_dep/warning.rb, line 45 def silenced? value = ENV[DISABLING_ENVIRONMENT_VAR] (value || '0') !~ /^0|false|no|n$/ end
status()
click to toggle source
# File lib/ruby_dep/warning.rb, line 50 def status @version.status end
unrecognized_msg()
click to toggle 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
warn_ruby(msg)
click to toggle 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