-
Notifications
You must be signed in to change notification settings - Fork 36
/
Rakefile
76 lines (64 loc) · 2.14 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
require 'rubygems'
require 'rspec'
require 'rspec/core/rake_task'
require 'bundler/gem_tasks'
require 'yard'
namespace :gem do
desc "Build the spira-#{File.read('VERSION').chomp}.gem file"
task :build do
sh "gem build spira.gemspec && mv spira-#{File.read('VERSION').chomp}.gem pkg/"
end
desc "Release the spira-#{File.read('VERSION').chomp}.gem file"
task :release do
sh "gem push pkg/spira-#{File.read('VERSION').chomp}.gem"
end
end
YARD::Rake::YardocTask.new
desc 'Run specs'
task 'spec' do
RSpec::Core::RakeTask.new("spec") do |t|
t.pattern = 'spec/**/*.{spec,rb}'
t.rspec_opts = ["-c --order rand"]
end
end
desc 'Run specs with backtrace'
task 'tracespec' do
RSpec::Core::RakeTask.new("tracespec") do |t|
t.pattern = 'spec/**/*.{spec,rb}'
t.rspec_opts = ["-bcf documentation"]
end
end
desc 'Run coverage'
task 'coverage' do
RSpec::Core::RakeTask.new("coverage") do |t|
t.pattern = 'spec/**/*.{spec,rb}'
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 "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