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) @logger = Logger.new(STDERR, PREFIX) end
Public Instance Methods
show_warnings()
click to toggle source
# File lib/ruby_dep/warning.rb, line 33 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 40 def silence! ENV[DISABLING_ENVIRONMENT_VAR] = '1' end
Private Instance Methods
buggy_alternatives()
click to toggle source
# File lib/ruby_dep/warning.rb, line 80 def buggy_alternatives @version.recommended(:buggy) end
recommendation()
click to toggle source
# File lib/ruby_dep/warning.rb, line 61 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 84 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 76 def recommended_versions @version.recommended(:unknown) end
safer_alternatives_msg()
click to toggle source
# File lib/ruby_dep/warning.rb, line 93 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 46 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 51 def status @version.status end
unrecognized_msg()
click to toggle source
# File lib/ruby_dep/warning.rb, line 67 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 55 def warn_ruby(msg) @logger.warning(msg) @logger.notice(recommendation) @logger.notice(NOTICE_HOW_TO_DISABLE) end