You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

grade.rb 728B

1234567891011121314151617181920212223242526272829303132
  1. module CryptCheck
  2. module Tls
  3. module Grade
  4. def grade
  5. @grade ||= calculate_grade
  6. end
  7. private
  8. def calculate_grade
  9. return :V unless self.valid?
  10. return :T unless self.trusted?
  11. states = self.states
  12. { critical: :G, error: :F, warning: :E }.each do |type, grade|
  13. return grade if states[type].any? { |s| s == true }
  14. end
  15. {good: %i(D C), great: %i(C B), best: %i(B A)}.each do |type, scores|
  16. state = states[type]
  17. return scores.first if state.all? { |s| s != false }
  18. if state.any? { |s| s == false }
  19. Logger.info { "Missing #{type} : #{states[type].select { |s| s == false }.collect &:key}" }
  20. return scores.last
  21. end
  22. end
  23. :'A+'
  24. end
  25. end
  26. end
  27. end