-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
77 lines (65 loc) · 2.1 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- ruby -*-
require 'rubygems'
require 'hoe'
# Hoe::plugin :gemcutter
hoe = Hoe.spec 'AvantiConveniences' do
developer('Jamie Flournoy', '[email protected]')
extra_deps << ['activesupport', '>= 1.2.6']
extra_deps << ['text-hyphen', '>= 1.0.0']
extra_dev_deps << ['thoughtbot-shoulda', '>= 2.10.1']
end
task :gemspec do
File.open("#{hoe.name}.gemspec", "w") {|f| f << hoe.spec.to_ruby }
end
task :package => :gemspec
# The rcov task in this file worked until Hoe was updated; this code keeps the old behavior
# and disables Hoe's rcov task.
Rake::TaskManager.class_eval do
def remove_task(task_name)
@tasks.delete(task_name.to_s)
end
end
def remove_task(task_name)
Rake.application.remove_task(task_name)
end
remove_task 'rcov'
task :rcov do
sh 'rcov test/test_*.rb'
end
task :clean_rcov do
sh 'rm -rf ./coverage/*'
end
task :clean => [:clean_rcov]
# vim: syntax=Ruby
# stats
begin
gem 'rails'
require 'code_statistics'
namespace :spec do
desc "Use Rails's rake:stats task for a gem"
task :statsetup do
class CodeStatistics
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 = [['Libraries', 'lib', /\.(sql|rhtml|erb|rb|yml)$/],
['Tests', 'test', /\.(sql|rhtml|erb|rb|yml)$/]]
::CodeStatistics::TEST_TYPES << "Tests"
end
end
desc "Report code statistics (KLOCs, etc) from the application"
task :stats => "spec:statsetup" do
CodeStatistics.new(*STATS_DIRECTORIES).to_s
end
rescue Gem::LoadError => le
task :stats do
raise RuntimeError, "'rails' gem not found - you must install it in order to use this task.\n"
end
end