Module: Term
- Defined in:
- lib/tasks/benchmark_runner.rb
Overview
Pretty terminal formatting for benchmark output
Constant Summary collapse
- CLEAR =
"\e[0m"- BOLD =
"\e[1m"- DIM =
"\e[2m"- RED =
"\e[31m"- GREEN =
"\e[32m"- YELLOW =
"\e[33m"- CYAN =
"\e[36m"- MAGENTA =
"\e[35m"- HL =
"─"- VL =
"│"- TL =
"┌"- TR =
"┐"- BL =
"└"- BR =
"┘"
Class 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
Class Method Details
.category(title, icon:, description:, failure_means:, compare_against: nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tasks/benchmark_runner.rb', line 50 def self.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
42 43 44 45 46 47 48 |
# File 'lib/tasks/benchmark_runner.rb', line 42 def self.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
29 30 31 32 33 34 35 36 |
# File 'lib/tasks/benchmark_runner.rb', line 29 def self.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 |