Skip to content

Instantly share code, notes, and snippets.

@joshuaclayton
Created July 23, 2009 13:49
Show Gist options
  • Save joshuaclayton/152937 to your computer and use it in GitHub Desktop.
Save joshuaclayton/152937 to your computer and use it in GitHub Desktop.
# Rakefile
task :stats => "stats:stats_fix"
namespace :stats do
# Fix statistics calculation to allow file type regex be included
task :stats_fix do
require "code_statistics"
class CodeStatistics
private
def calculate_statistics
@pairs.inject({}) do |stats, pair|
stats[pair[0]] = calculate_directory_statistics(pair[1], pair[2])
stats
end
end
def calculate_directory_statistics_with_override(directory, pattern = nil)
calculate_directory_statistics_without_override(directory, pattern || /.*\.rb$/)
end
alias_method_chain :calculate_directory_statistics, :override
end
end
end
task :stats => "stats:include_views"
namespace :stats do
task :include_views do
require "code_statistics"
location_to_insert = 0
::STATS_DIRECTORIES.each_with_index do |dir, idx|
location_to_insert = (idx + 1) if dir.first == "Models"
end
::STATS_DIRECTORIES.insert location_to_insert, ["Views", "app/views", /.*\.erb$/]
end
end
# lib/tasks/cucumber.rake
task :stats => "stats:include_cucumber"
namespace :stats do
# Setup specs for stats
task :include_cucumber do
require 'code_statistics'
if File.exist?("features")
::STATS_DIRECTORIES << ["Cucumber coverage", "features", /.+\.feature$/]
::CodeStatistics::TEST_TYPES << "Cucumber coverage"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment