class LogAnalyzer::Utils
Constants
- DANGER_DEFAULT
- DEFAULT_PATH_WIDTH
- INFO_DEFAULT
- PARTIAL_LABEL
- VIEW_LABEL
- WARNING_DEFAULT
Public Class Methods
avg_label(avg)
click to toggle source
# File lib/log_analyzer/utils.rb, line 26 def Utils.avg_label(avg) str = avg.to_s if avg > DANGER_DEFAULT str.white.on_red elsif avg > WARNING_DEFAULT str.red elsif avg > INFO_DEFAULT str.yellow else str.green end end
find_type(view)
click to toggle source
# File lib/log_analyzer/utils.rb, line 10 def Utils.find_type(view) if view.split('/'.freeze).last[0] == '_'.freeze LogAnalyzer::Configuration::PARTIALS else LogAnalyzer::Configuration::VIEWS end end
path_to_display(path, short: false, length: DEFAULT_PATH_WIDTH)
click to toggle source
# File lib/log_analyzer/utils.rb, line 39 def Utils.path_to_display(path, short: false, length: DEFAULT_PATH_WIDTH) if short PathShortener.shrink(path, max: length.last) else path[length] end end
report_name(extension)
click to toggle source
# File lib/log_analyzer/utils.rb, line 47 def Utils.report_name(extension) "report-log-analyzer-#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.#{extension}" end
type_label(type)
click to toggle source
# File lib/log_analyzer/utils.rb, line 18 def Utils.type_label(type) if type == LogAnalyzer::Configuration::PARTIALS PARTIAL_LABEL else VIEW_LABEL end end