Class: CodeStatistics

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/code_statistics.rb

Overview

:nodoc:

Constant Summary collapse

TEST_TYPES =
["Controller tests",
"Helper tests",
"Model tests",
"Mailer tests",
"Mailbox tests",
"Channel tests",
"Job tests",
"Integration tests",
"System tests"]
HEADERS =
{ lines: " Lines", code_lines: "   LOC", classes: "Classes", methods: "Methods" }

Instance Method Summary collapse

Constructor Details

#initialize(*pairs) ⇒ CodeStatistics

Returns a new instance of CodeStatistics.



19
20
21
22
23
# File 'lib/rails/code_statistics.rb', line 19

def initialize(*pairs)
  @pairs      = pairs
  @statistics = calculate_statistics
  @total      = calculate_total if pairs.length > 1
end

Instance Method Details

#to_sObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rails/code_statistics.rb', line 25

def to_s
  print_header
  @pairs.each { |pair| print_line(pair.first, @statistics[pair.first]) }
  print_splitter

  if @total
    print_line("Total", @total)
    print_splitter
  end

  print_code_test_stats
end