class Rails::CodeStatistics

Parent:
Object

Constants

DIRECTORIES
HEADERS
TEST_TYPES

Public Class Methods

new(*pairs) Show source
# File railties/lib/rails/code_statistics.rb, line 60
def initialize(*pairs)
  @pairs      = pairs
  @statistics = calculate_statistics
  @total      = calculate_total if pairs.length > 1
end
register_directory(label, path, test_directory: false) Show source
# File railties/lib/rails/code_statistics.rb, line 55
def self.register_directory(label, path, test_directory: false)
  self.directories << [label, path]
  self.test_types << label if test_directory
end

Add directories to the output of the ‘bin/rails stats` command.

Rails::CodeStatistics.register_directory("My Directory", "path/to/dir")

For directories that contain test code, set the ‘test_directory` argument to true.

Rails::CodeStatistics.register_directory("Model specs", "spec/models", test_directory: true)

Public Instance Methods

to_s() Show source
# File railties/lib/rails/code_statistics.rb, line 66
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

© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.