forked from qrush/m
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
96 lines (81 loc) · 2.4 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
92
93
94
95
96
#!/usr/bin/env rake
require 'rubygems'
require 'bundler/setup'
require 'appraisal'
require 'coveralls'
require 'bundler/gem_tasks'
require 'rake/clean'
require 'rake/testtask'
task :default => [:test]
Rake::TestTask.new do |t|
t.libs << 'test'
t.libs << 'lib'
t.pattern = 'test/*_test.rb'
end
desc 'Run all tests and get merged test coverage'
task :tests do
system "rake test" or exit!(1)
system "appraisal minitest4 rake test" or exit!(1)
system "appraisal minitest5 rake test TEST=test/minitest_5_test.rb" or exit!(1)
system "appraisal test_unit_gem rake test TEST=test/test_unit_test.rb" or exit!(1)
Coveralls.push!
end
desc 'Run simple benchmarks'
task :bench do
current_commit = `git rev-parse HEAD`
file_name = "benchmarks/#{Time.now.strftime('%Y%m%d')}-benchmark.log"
exec "echo -e 'Data for commit: #{current_commit}' > #{file_name} && ruby test/bench.rb >> #{file_name}"
end
# ROCCO ===============================================================
begin
require 'rdiscount'
rescue LoadError => e
warn e.inspect
end
begin
require 'rocco/tasks'
Rocco::make 'docs/'
rescue LoadError => e
warn e.inspect
end
desc 'Build rocco docs'
task :docs => :rocco
directory 'docs/'
desc 'Build docs and open in browser for the reading'
task :read => :docs do
sh 'open docs/lib/m.html'
end
# Make index.html a copy of rocco.html
file 'docs/index.html' => 'docs/lib/m.html' do |f|
cp 'docs/lib/m.html', 'docs/index.html', :preserve => true
end
task :docs => 'docs/index.html'
CLEAN.include 'docs/index.html'
# Alias for docs task
task :doc => :docs
# GITHUB PAGES ===============================================================
desc "really kill docs folder"
task :clean_docs do
sh "rm -rf docs/"
end
desc 'Update gh-pages branch'
task :pages => [:clean_docs, 'docs/.git', :docs] do
rev = `git rev-parse --short HEAD`.strip
Dir.chdir 'docs' do
sh "mv lib/m m"
sh "mv lib/m.html m.html"
sh "git add -A"
sh "git commit -m 'rebuild pages from #{rev}'" do |ok,res|
if ok
verbose { puts "gh-pages updated" }
sh "git push -q o HEAD:gh-pages"
end
end
end
end
# Update the pages/ directory clone
file 'docs/.git' => ['docs/'] do |f|
sh "cd docs && git init -q && git remote add o ../.git" if !File.exist?(f.name)
sh "cd docs && git fetch -q o && git reset -q --hard o/gh-pages && git rm -r . && git commit -m 'blank out' && touch ."
end
CLOBBER.include 'docs/.git'