| 1 |
require 'rake/testtask' |
| 2 |
require 'rdoc/task' |
| 3 |
|
| 4 |
# |
| 5 |
# Helpers |
| 6 |
# |
| 7 |
|
| 8 |
def command?(command) |
| 9 |
system("type #{command} &> /dev/null") |
| 10 |
end |
| 11 |
|
| 12 |
|
| 13 |
# |
| 14 |
# Tests |
| 15 |
# |
| 16 |
|
| 17 |
task :default => :test |
| 18 |
|
| 19 |
Rake::TestTask.new do |t| |
| 20 |
t.libs << 'lib' |
| 21 |
t.pattern = 'test/**/*_test.rb' |
| 22 |
t.verbose = false |
| 23 |
end |
| 24 |
|
| 25 |
|
| 26 |
# |
| 27 |
# Ron |
| 28 |
# |
| 29 |
|
| 30 |
if command? :ronn |
| 31 |
desc "Show the manual" |
| 32 |
task :man => "man:build" do |
| 33 |
exec "man man/mustache.1" |
| 34 |
end |
| 35 |
|
| 36 |
desc "Build the manual" |
| 37 |
task "man:build" do |
| 38 |
sh "ronn -br5 --organization=DEFUNKT --manual='Mustache Manual' man/*.ron" |
| 39 |
end |
| 40 |
end |
| 41 |
|
| 42 |
|
| 43 |
# |
| 44 |
# Gems |
| 45 |
# |
| 46 |
|
| 47 |
desc "Push a new version to Gemcutter and publish docs." |
| 48 |
task :publish do |
| 49 |
require File.dirname(__FILE__) + '/lib/mustache/version' |
| 50 |
|
| 51 |
system "git tag v#{Mustache::Version}" |
| 52 |
sh "gem build mustache.gemspec" |
| 53 |
sh "gem push mustache-#{Mustache::Version}.gem" |
| 54 |
sh "git push origin master --tags" |
| 55 |
sh "git clean -fd" |
| 56 |
exec "rake pages" |
| 57 |
end |
| 58 |
|
| 59 |
# |
| 60 |
# Documentation |
| 61 |
# |
| 62 |
|
| 63 |
desc "Publish to GitHub Pages" |
| 64 |
task :pages => [ "man:build" ] do |
| 65 |
Dir['man/*.html'].each do |f| |
| 66 |
cp f, File.basename(f).sub('.html', '.newhtml') |
| 67 |
end |
| 68 |
|
| 69 |
`git commit -am 'generated manual'` |
| 70 |
`git checkout site` |
| 71 |
|
| 72 |
Dir['*.newhtml'].each do |f| |
| 73 |
mv f, f.sub('.newhtml', '.html') |
| 74 |
end |
| 75 |
|
| 76 |
`git add .` |
| 77 |
`git commit -m updated` |
| 78 |
`git push site site:master` |
| 79 |
`git checkout master` |
| 80 |
puts :done |
| 81 |
end |