Class: CommandLineMetricOutput
- Inherits:
-
Object
- Object
- CommandLineMetricOutput
- Defined in:
- lib/command_line_metric_output.rb
Instance Method Summary collapse
-
#initialize ⇒ CommandLineMetricOutput
constructor
A new instance of CommandLineMetricOutput.
- #print_header ⇒ Object
- #print_section(section) ⇒ Object
- #print_splitter ⇒ Object
- #print_stats(stats) ⇒ Object
- #print_totals(metrics) ⇒ Object
Constructor Details
#initialize ⇒ CommandLineMetricOutput
Returns a new instance of CommandLineMetricOutput.
4 5 6 7 8 9 10 |
# File 'lib/command_line_metric_output.rb', line 4 def initialize metrics = RailsAppSourceMetrics.new() print_header metrics.code_sections.each { |section| print_section(section) } print_splitter print_totals(metrics) end |
Instance Method Details
#print_header ⇒ Object
17 18 19 20 21 |
# File 'lib/command_line_metric_output.rb', line 17 def print_header print_splitter puts "| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |" print_splitter end |
#print_section(section) ⇒ Object
23 24 25 |
# File 'lib/command_line_metric_output.rb', line 23 def print_section(section) puts "| #{section[:name].ljust(20)} "+ print_stats(section[:stats]) end |
#print_splitter ⇒ Object
13 14 15 |
# File 'lib/command_line_metric_output.rb', line 13 def print_splitter puts "+----------------------+-------+-------+---------+---------+-----+-------+" end |
#print_stats(stats) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/command_line_metric_output.rb', line 34 def print_stats(stats) "| #{stats[:lines].to_s.rjust(5)} " + "| #{stats[:lines_of_code].to_s.rjust(5)} " + "| #{stats[:classes].to_s.rjust(7)} " + "| #{stats[:methods].to_s.rjust(7)} " + "| #{stats[:methods_per_class].to_s.rjust(3)} " + "| #{stats[:lines_of_code_per_method].to_s.rjust(5)} |" end |
#print_totals(metrics) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/command_line_metric_output.rb', line 27 def print_totals(metrics) puts "| #{'Totals'.ljust(20)} "+ print_stats(metrics.totals) print_splitter puts " Code LOC: #{metrics.lines_of_code} Test LOC: #{metrics.lines_of_test_code} Code to Test Ratio: 1:#{sprintf("%.1f", metrics.code_to_test_ratio)}" puts "" end |