forked from tribalvibes/ohm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Thorfile
58 lines (47 loc) · 1.49 KB
/
Thorfile
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
# encoding: UTF-8
class OhmTasks < Thor
namespace :ohm
desc "doc", "Generate documentation"
method_options :open => false
def doc
invoke :yard
invoke :rocco
system "open doc/index.html" if options[:open]
end
desc "yard", "Generate YARD documentation"
def yard
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 "rocco", "Generate ROCCO documentation"
def rocco
`mkdir doc/examples` unless Dir.exists?("doc/examples")
`rocco examples/*.*`
`mv examples/*.html doc/examples`
end
desc "deploy", "Deploy documentation"
def deploy
system "rsync --del -avz doc/* ohm.keyvalue.org:deploys/ohm.keyvalue.org/"
end
end