0.04
No commit activity in last 3 years
No release in over 3 years
rake stats is great for looking at statistics on your code, displaying things like KLOCs (thousands of lines of code) and your code to test ratio.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

< 5.0, > 3.0
 Project Readme

CodeMetrics Inline docs

Independent library extracted from Rails code statistics.

Getting Started

  1. Install at the command prompt if you haven't yet:

    gem install code_metrics

Usage

  • Lines of code statistics for a folder

    • Command-line

      code_metrics
    • As rake task

      require 'code_metrics/statistics'
      rake code_metrics:stats
      # or in Rails (check `rake -W stats` to see what tasks are loading)
      rake stats
    • As a library

      require 'code_metrics/code_statistics'
      dirs = CodeMetrics::StatsDirectories.new
      dirs.add_test_directories('spec/**/*_spec.rb', 'spec') # where the 2nd argument is a required string in the filename
      dirs.add_directories('engines/**/*.rb') # no restrictions on the file name, 2nd argument omitted
      dirs.add_test_directory('Acceptance specs', 'spec/acceptance')
      dirs.directories # outputs an array of [description, folder_path] to run statistics against
      CodeMetrics::Statistics.new(*dirs).to_s
      
      # in Rails
      
      require 'rails/code_statistics'
      {
        'Acceptance' => 'spec/acceptance',
      }.each do |type, dir|
        ::STATS_DIRECTORIES << ["#{name} specs", dir]
        ::CodeStatistics::TEST_TYPES << "#{name} specs"
      end
      CodeStatistics.new(*STATS_DIRECTORIES).to_s
  • Lines of code statistics for a list of files

    • As rake task

      require 'code_metrics/line_statistics'
      rake code_metrics:line_statistics[file_pattern] # e.g. ['lib/**/*.rb']
    • As a library

      require 'code_metrics/line_statistics'
      files = FileList["lib/active_record/**/*.rb"]
      CodeMetrics::LineStatistics.new(files).print_loc
  • Profiling memory usage of requires. POSIX-only. Requires ps

    • Command-line

      code_metrics-profile <path/to/rubyfile.rb> [optional: ruby-prof mode]

Contributing

Code Status

  • Build Status
  • Dependencies

License

Released under the MIT License.

Bitdeli Badge