forked from soveran/ohm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
92 lines (73 loc) · 2.17 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require "rake/testtask"
REDIS_DIR = File.expand_path(File.join("..", "test"), __FILE__)
REDIS_CNF = File.join(REDIS_DIR, "test.conf")
REDIS_PID = File.join(REDIS_DIR, "db", "redis.pid")
task :default => :run
desc "Run tests and manage server start/stop"
task :run => [:start, :test, :stop]
desc "Start the Redis server"
task :start do
unless File.exists?(REDIS_PID)
system "redis-server #{REDIS_CNF}"
end
end
desc "Stop the Redis server"
task :stop do
if File.exists?(REDIS_PID)
system "kill #{File.read(REDIS_PID)}"
File.delete(REDIS_PID)
end
end
task :test do
require File.expand_path("./test/helper", File.dirname(__FILE__))
Cutest.run(Dir["test/*_test.rb"])
end
desc "Generate documentation"
task :doc => [:yard, :rocco]
desc "Generated YARD documentation"
task :yard do
require "yard"
opts = []
opts.push("--protected")
opts.push("--no-private")
opts.push("--private")
opts.push("--title", "Ohm — Object-hash mapping library for Redis")
YARD::CLI::Yardoc.run(*opts)
Dir["doc/**/*.html"].each do |file|
contents = File.read(file)
contents.sub! %r{</body>}, <<-EOS
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-11356145-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
EOS
File.open(file, "w") { |f| f.write(contents) }
end
end
desc "Generate ROCCO documentation"
task :rocco do
`mkdir doc/examples` unless Dir.exists?("doc/examples")
`rocco examples/*.*`
`mv examples/*.html doc/examples`
end
desc "Deploy documentation"
task :deploy do
system "rsync --del -avz doc/* ohm.keyvalue.org:deploys/ohm.keyvalue.org/"
end
namespace :examples do
desc "Run all the examples"
task :run do
begin
require "cutest"
rescue LoadError
raise "!! Missing gem `cutest`. Try `gem install cutest`."
end
Cutest.run(Dir["examples/*.rb"])
end
end