Module: Gravedigger::OutputPrinter
- Defined in:
- lib/gravedigger/output_printer.rb
Constant Summary collapse
- NEW_LINE =
"\n"
Class Method Summary collapse
- .print_output(unused_methods, unused_variables, error_messages = []) ⇒ Object
- .print_scan_results(unused_methods_length, unused_variables_length, error_messages_length) ⇒ Object
- .print_with_green_color(string) ⇒ Object
- .print_with_red_color(string) ⇒ Object
Class Method Details
.print_output(unused_methods, unused_variables, error_messages = []) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gravedigger/output_printer.rb', line 6 def self.print_output(unused_methods, unused_variables, = []) print_scan_results(unused_methods.length, unused_variables.length, .length) if unused_methods.any? puts NEW_LINE puts "Unused methods in your project:" puts NEW_LINE unused_methods.each do |method_name, location| puts "#{method_name}: #{location}" end end if unused_variables.any? puts NEW_LINE puts "Unused variables in your project:" puts NEW_LINE unused_variables.each do |variable_name, location| puts "#{variable_name}: #{location}" end end if .any? puts NEW_LINE puts "Errors encountered while processing:" puts NEW_LINE .each do || puts end end end |
.print_scan_results(unused_methods_length, unused_variables_length, error_messages_length) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/gravedigger/output_printer.rb', line 37 def self.print_scan_results(unused_methods_length, unused_variables_length, ) puts "="*80 + NEW_LINE puts "Scanning completed." puts print_with_green_color(unused_methods_length) + " unused method definitions found." puts print_with_green_color(unused_variables_length) + " unused variable definitions found." puts print_with_red_color() + " errors encountered." puts "="*80 +NEW_LINE end |
.print_with_green_color(string) ⇒ Object
46 47 48 |
# File 'lib/gravedigger/output_printer.rb', line 46 def self.print_with_green_color(string) "\e[32m#{string}\e[0m" end |
.print_with_red_color(string) ⇒ Object
50 51 52 |
# File 'lib/gravedigger/output_printer.rb', line 50 def self.print_with_red_color(string) "\e[31m#{string}\e[0m" end |