Skip to content

Instantly share code, notes, and snippets.

@kmarsh
Created January 26, 2009 17:57
Show Gist options
  • Select an option

  • Save kmarsh/52889 to your computer and use it in GitHub Desktop.

Select an option

Save kmarsh/52889 to your computer and use it in GitHub Desktop.

Revisions

  1. kmarsh revised this gist Jan 26, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    namespace :spec do
    # http://www.pervasivecode.com/blog/2007/06/28/hacking-rakestats-to-get-gross-loc/
    # largely lifted from http://www.pervasivecode.com/blog/2007/06/28/hacking-rakestats-to-get-gross-loc/
    task :stats_setup do
    require 'code_statistics'

  2. kmarsh created this gist Jan 26, 2009.
    27 changes: 27 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    namespace :spec do
    # http://www.pervasivecode.com/blog/2007/06/28/hacking-rakestats-to-get-gross-loc/
    task :stats_setup do
    require 'code_statistics'

    class CodeStatistics
    alias calculate_statistics_orig calculate_statistics
    def calculate_statistics
    @pairs.inject({}) do |stats, pair|
    if 3 == pair.size
    stats[pair.first] = calculate_directory_statistics(pair[1], pair[2]); stats
    else
    stats[pair.first] = calculate_directory_statistics(pair.last); stats
    end
    end
    end
    end
    ::STATS_DIRECTORIES = []
    ::STATS_DIRECTORIES << ['Views', 'app/views', /\.(rhtml|erb|rb)$/]
    ::STATS_DIRECTORIES << ['CSS', 'public', /\.css$/]
    end
    end

    namespace :stats do
    desc "Report code statistics (KLOCs, etc) for non-code like HTML and CSS from the application"
    task :static => ["spec:stats_setup", "stats"]
    end