kostasnw

Rakefile

Jun 10th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.18 KB | None | 0 0
  1. #added this so that code specs work (and also become more accurate)
  2. namespace :spec do
  3.   desc "Add files that DHH doesn't consider to be 'code' to stats"
  4.   task :statsetup do
  5.     require 'rails/code_statistics'
  6.  
  7.     class CodeStatistics
  8.       alias calculate_statistics_orig calculate_statistics
  9.       def calculate_statistics
  10.         @pairs.inject({}) do |stats, pair|
  11.           if 3 == pair.size
  12.             stats[pair.first] = calculate_directory_statistics(pair[1], pair[2]); stats
  13.           else
  14.             stats[pair.first] = calculate_directory_statistics(pair.last); stats
  15.           end
  16.         end
  17.       end
  18.     end
  19.     ::STATS_DIRECTORIES << ['Views',  'app/views', /\.(rhtml|erb|rb)$/]
  20.     # note, I renamed all my rails-generated email fixtures to add .txt
  21.     ::STATS_DIRECTORIES << ['Static HTML', 'public', /\.html$/]
  22.     ::STATS_DIRECTORIES << ['Static CSS',  'public', /\.css$/]
  23.     # ::STATS_DIRECTORIES << ['Static JS',  'public', /\.js$/]
  24.     # prototype is ~5384 LOC all by itself - very hard to filter out
  25.  
  26.     ::CodeStatistics::TEST_TYPES << "Test Fixtures"
  27.     ::CodeStatistics::TEST_TYPES << "Email Fixtures"
  28.   end
  29. end
  30. task :stats => "spec:statsetup"
Advertisement
Add Comment
Please, Sign In to add comment