forked from sinatra/sinatra.github.com
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
71 lines (60 loc) · 2.07 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
require 'rake/clean'
require 'rdoc/markup/to_html'
task :default => ['_sinatra', :build]
desc "Build outdated static files and API docs"
task :build => ['build:static']
desc "Build outdated static files"
task 'build:static' => [
'_includes/README.html',
'_includes/README.jp.html'
]
desc "Build anything that's outdated and stage changes for next commit"
task :regen => [:build] do
sh 'git add api _includes'
puts "\nPrebuilt files regenerated and staged in your index. Commit with:"
puts " git commit -m 'Regen prebuilt files'"
end
desc 'Pull in the latest from the sinatra and sinatra-book repos'
task :pull => ['pull:sinatra']
desc 'Pull in the latest from the sinatra repo'
task 'pull:sinatra' do
if File.directory?("_sinatra")
puts 'Pulling sinatra.git'
sh "cd _sinatra && git pull &>/dev/null"
touch '_sinatra', :verbose => false
else
puts 'Cloning sinatra repo'
sh "git clone git://github.com/sinatra/sinatra.git _sinatra"
end
end
file('_sinatra') { Rake::Task['pull:sinatra'].invoke }
CLOBBER.include '_sinatra'
%w[README.rdoc README.jp.rdoc AUTHORS].each do |fn|
file "_sinatra/#{fn}" => ['_sinatra']
end
# Build _includes/README.html from RDoc
file '_includes/README.html' => ['_sinatra/README.rdoc', 'Rakefile'] do |f|
html = RDoc::Markup::ToHtml.new.convert(File.read("_sinatra/README.rdoc")).
sub("<h1>Sinatra</h1>", "")
File.open(f.name, 'wb') { |io| io.write(html) }
end
CLEAN.include '_includes/README.html'
# Build _includes/README.jp.html from RDoc
file '_includes/README.jp.html' => ['_sinatra/README.jp.rdoc', 'Rakefile'] do |f|
html = RDoc::Markup::ToHtml.new.convert(File.read("_sinatra/README.jp.rdoc")).
sub("<h1>Sinatra</h1>", "")
File.open(f.name, 'wb') { |io| io.write(html) }
end
CLEAN.include '_includes/README.jp.html'
desc 'Rebuild site under _site with Jekyll'
task :jekyll do
rm_rf '_site'
sh 'jekyll --pygments'
end
desc 'Start the Jekyll server on http://localhost:4000/'
task :server do
rm_rf '_site'
puts 'jekyll --pygments --auto --server'
exec 'jekyll --pygments --auto --server'
end
CLEAN.include '_site'