forked from ruby-rdf/spira
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
75 lines (62 loc) · 2 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
require 'rubygems'
require 'rspec'
require 'rspec/core/rake_task'
desc 'Run specs'
task 'spec' do
RSpec::Core::RakeTask.new("spec") do |t|
t.pattern = 'spec/**/*.{spec,rb}'
t.rcov = false
t.rspec_opts = ["-c"]
end
end
desc 'Run specs with backtrace'
task 'tracespec' do
RSpec::Core::RakeTask.new("tracespec") do |t|
t.pattern = 'spec/**/*.{spec,rb}'
t.rcov = false
t.rspec_opts = ["-bcfn"]
end
end
desc 'Run coverage'
task 'coverage' do
RSpec::Core::RakeTask.new("coverage") do |t|
t.pattern = 'spec/**/*.{spec,rb}'
t.rcov = true
t.rspec_opts = ["-c"]
end
end
desc "Open an irb session with everything loaded, including test fixtures"
task :console do
sh "irb -rubygems -I lib -r spira -I spec/fixtures -r person -r event -r cds -r cars -r posts -I spec -r spec_helper -r loading"
end
task :default => [:spec]
desc "Create yardocs according to .yardopts file"
task :yardoc do
`yardoc`
end
desc "Add analytics tracking information to yardocs"
task :addanalytics do
tracking_code = <<EOC
<script type="text\/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3784741-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text\/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https:\/\/ssl' : 'http:\/\/www') + '.google-analytics.com\/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
EOC
files = Dir.glob('./doc/yard/**/*.html').reject { |file| %w{class_list file_list frames.html _index.html method_list}.any? { |skipfile| file.include?(skipfile) }}
files.each do |file|
contents = File.read(file)
writer = File.open(file, 'w')
writer.write(contents.gsub(/\<\/body\>/, tracking_code + "</body>"))
writer.flush
end
end
desc "Upload docs to rubyforge"
task :uploadyardocs => [:yardoc, :addanalytics] do
`rsync -av doc/yard/* [email protected]:/var/www/gforge-projects/spira`
end