-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rakefile
45 lines (37 loc) · 1.4 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
require 'rspec/core/rake_task'
desc 'Run specs'
RSpec::Core::RakeTask.new(:spec) do |t|
# Force load the test_helper to ensure SimpleCov is loaded before the test files
t.ruby_opts = ['-r "./spec/spec_helper"']
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-4']);
_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/promise`
end