Module: Xmi::Performance::Term
Overview
Terminal formatting for benchmark output. Colors live on the parent Xmi::Performance module; box-drawing characters here.
Constant Summary collapse
- HL =
"─"- VL =
"│"- TL =
"┌"- TR =
"┐"- BL =
"└"- BR =
"┘"
Instance Method Summary collapse
- #category(title, icon:, description:, failure_means:, compare_against: nil) ⇒ Object
- #env_info(ruby_version, platform) ⇒ Object
- #header(title, color: CYAN) ⇒ Object
- #sep(char: HL, width: 78) ⇒ Object
Instance Method Details
#category(title, icon:, description:, failure_means:, compare_against: nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/xmi/performance/term.rb', line 38 def category(title, icon:, description:, failure_means:, compare_against: nil) puts puts "#{CYAN}#{VL}#{CLEAR} #{BOLD}#{MAGENTA}#{icon} #{title}#{CLEAR}" puts puts " #{DIM}#{description}#{CLEAR}" puts if compare_against puts " #{CYAN}Comparing against:#{CLEAR} #{compare_against}" puts end puts " #{YELLOW}⚠️ Failure means:#{CLEAR} #{failure_means}" puts sep(width: 76) puts end |
#env_info(ruby_version, platform) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/xmi/performance/term.rb', line 30 def env_info(ruby_version, platform) puts puts " #{DIM}Environment:#{CLEAR}" puts " #{VL} Ruby #{ruby_version} on #{platform}#{' ' * (60 - ruby_version.length - platform.length)}#{VL}" puts " #{DIM}#{BL}#{HL * 76}#{BR}#{CLEAR}" puts end |
#header(title, color: CYAN) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/xmi/performance/term.rb', line 17 def header(title, color: CYAN) width = 78 line = HL * width puts puts "#{color}#{TL}#{line}#{TR}#{CLEAR}" puts "#{color}#{VL}#{CLEAR} #{BOLD}#{color}#{title}#{CLEAR}#{' ' * (width - title.length - 4)}#{color}#{VL}#{CLEAR}" puts "#{color}#{BL}#{line}#{BR}#{CLEAR}" end |