2012-03-14 46 views
2

我如何定製rake:stats,以便我可以檢查不同目錄中的代碼行數?自定義耙:統計

例如,我有一個應用程序/工作人員目錄,供我的工作人員進行配置。

我正在使用rspec。我想沿Rake stats and Cucumber行,但我沒有/lib/tasks/rspec.rake

+0

也許這可以幫助? http://stackoverflow.com/questions/1613655/rake-stats-and-cucumber – Spyros 2012-03-14 08:46:11

+0

我嘗試過,但我得到'耙中止! 未定義的方法'calculate_statistics'爲'CodeStatistics'類 任務:TOP => statsetup' – Cyrus 2012-03-15 00:52:42

回答

2

對不起,我不知道如何編輯耙統計。但你可以在終端試試這個腳本在Mac上,例如在views目錄計數LOC:

find app/views -name "*html.erb" -exec wc -l {} \; 

希望幫助

+0

不是我正在尋找的東西,而是訣竅。 – Cyrus 2012-05-14 23:23:25

3

This article展示瞭如何做到這一點:

task :stats => "omakase:stats" 

namespace :omakase do 
    task :stats do 
    require 'rails/code_statistics' 
    ::STATS_DIRECTORIES << ["Services", "app/services"] 
    ::STATS_DIRECTORIES << ["Services Tests", "test/services"] 
    CodeStatistics::TEST_TYPES << 'Services Tests' 
    end 
end