How do you add a folder to rake stats?

I've added some folders (lib, spec, cells, etc.) to my Rails app and would like to add them to the rake stats list. Is it possible to add new folders?

Here is an excellent answer to find where a specific rake task is defined.

With that tip, found that the rake stats task is defined in gems/railties-3.2.11/lib/rails/tasks/statistics.rake file; so it is in the railties gem which is part of the rails repository.

At the very top of the file, the directories to be considered are included in the STATS_DIRECTORIES variable.

Probably best to implement a custom rake task - named my_stats for example - with the same code, and add the new folders that you want to include.

ruby on rails - How do you add a folder to rake stats?, Here is an excellent answer to find where a specific rake task is defined. With that tip, found that the rake stats task is defined in  Select the SPSSINC_RAKE.spe file from the C:\Program Files\IBM\SPSS\Statistics\19\extensions folder and then click Open. If successfully installed, you will receive a message stating the dialog will appear next time you start SPSS. Close Statistics and restart. The RAKE Weights option will appear on the Data menu. Executing "SPSSINC RAKE /HELP."

I know I'm late to the party, but as I did not find more information, I'm adding my answer into the mix.

I've added a rake-task to my project with content similar to the following:

task :stats => "todolist:statsetup"

namespace :todolist do
  task :statsetup do
    require 'rails/code_statistics'
    ::STATS_DIRECTORIES << ["Policies", "app/policies"]
    ::STATS_DIRECTORIES << ["Services", "app/services"]

    # For test folders not defined in CodeStatistics::TEST_TYPES (ie: spec/)
    ::STATS_DIRECTORIES << ["Services specs", "specs/services"]
    CodeStatistics::TEST_TYPES << "Services specs"

This added both folders to my rake stats

Add more folders to rake stats · GitHub, Add more folders to rake stats. register_statistics.rake. task :register_statistics do. require 'rails/code_statistics'. STATS_DIRECTORIES << ['Services'  sh (run system commands) safe_ln (create a symbolic link in your file system) Rake includes the FileUtils module. That means you can copy files with cp, create directories with mkdir_p, and even change file permissions with chown.

I found it useful to insert new stats at a sensible position in the list.

Here's what I'm using (with rails 5.1):

# lib/stats.rake

require "rails/code_statistics"

task stats: :more_stats

task :more_stats do
  %w[Forms Policies Presenters Serializers Services].each_with_index do |type, i|
    STATS_DIRECTORIES.insert i + 5, [type, "app/#{type.downcase}"]
    STATS_DIRECTORIES.insert i * 2 + 13, ["#{type} tests", "test/#{type.downcase}"]
    CodeStatistics::TEST_TYPES << "#{type} tests"

Riding the Clutch, How to add directories to `rake stats` You probably know about rake stats: that neat task that breaks down your app by class type and tells you  We spend countless hours researching various file formats and software that can open, convert, create or otherwise work with those files. If you have additional information about the RAKE file format or software that uses files with the RAKE suffix, please do get in touch - we would love hearing from you.

Code metrics extension for Rails statistics • Michaël Rigart, Extend the stats task. Luckily, it is not that hard to add your non-Rails directories to the statistics. All you need to do is create a rake task  If no new folders appeared after clicking "Auto Detect", manually add the Hand History Folder we located from Step 1. Figure 5 - Click here to open the selected Auto Import Folder from figure 3. If you just played a couple hands, this folder should have Hand History text files in the folder.

Hacking rake:stats to get gross LOC – Pervasive Code, desc "Add files that DHH doesn't consider to be 'code' to stats" maybe in a quick 'svn export' temporary directory, and run rake:stats in there  On my computer, only a few folders (and their subfolders) are indexed. To add a folder to the index, click on the Modify button then select the folder you'd like to be indexed. In my example below

Simple Test Metrics in Your Rails App, and What They Mean, If you haven't used it before, rake stats , when run, outputs a quick So, I put this aside as a possible cause, but now that I've started to review  3. From the schedule page, find the game you want to import the stats for. You will select the Green Plus Sign under the Add/Edit column. 4. Enter the box scores or final score and select, Save & Import Stats. 5. Choose File the file you saved to your computer and select, Import. 6. On the stats page, you will be able to see your athlete's stats.

  • You're correct, lib is being included (not sure why I included it). I do still have some other folders I'd like to include. Factories for example, cells (, and a few others. Is it possible to specify the folders you want tracked?
  • Thanks. That works. Unfortunately you can't specify customer file types to track. The Rails master added support for .js and .coffee but theres no way to track anything else. That hasn't made it into the 3.2 branch yet (…).
  • Worked perfectly for me (tested in Rails 4). Thanks!