-
Notifications
You must be signed in to change notification settings - Fork 39
/
Rakefile
172 lines (137 loc) · 2.95 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
require 'rake/clean'
require 'rake/testtask'
#
# Helpers
#
def command?(command)
!`type #{command} 2> /dev/null`.empty?
end
#
# Tests
#
task :default => :test
if command? :turn
desc "Run tests"
task :test do
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
sh "turn -Ilib:test test/*.rb #{suffix}"
end
else
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
end
if command? :kicker
desc "Launch Kicker (like autotest)"
task :kicker do
puts "Kicking... (ctrl+c to cancel)"
exec "kicker -e rake test lib"
end
end
desc "Run a git-daemon for the tests."
task "daemon:git" do
cmd = "git daemon --export-all --base-path=test/fixtures"
puts "Running #{cmd}"
sh cmd
end
desc "Run a gem server for the tests."
task "daemon:gem" do
cmd = "gem server --dir test/fixtures/gems --no-daemon"
puts "Running #{cmd}"
sh cmd
end
desc "Run gem and git daemons for the tests."
multitask :daemons => %w( daemon:git daemon:gem )
#
# Ron
#
if command? :ronn
CLOBBER.include('man/*.{1,5}')
CLOBBER.include('man/*.{1,5}.html')
desc "Show the manual"
task :man => "man:build" do
exec "man man/rip.1"
end
desc "Build the manual"
task "man:build" do
sh "ronn -br5 --organization=DEFUNKT --manual='rip manual' man/*.ronn"
end
end
#
# Site
#
desc "Build the site. Requires ronn."
task :site do
require 'lib/rip/version'
manuals = []
mkdir_p mandir = "docs/manual/#{Rip::Version}"
Dir["man/*.ronn"].each do |file|
out = `ronn -5 -b #{file} 2>&1`.chomp
if out =~ /(?:.+?): (.+)/
file = File.basename($1)
manuals << file
mv $1, "#{mandir}/#{file}"
end
end
index = '<div style="clear:both;"></div>'
index << '<ol>'
manuals.sort.each do |manual|
name, section, ext = manual.split('.')
index << "<li><a href='#{manual}'>#{name}(#{section})</a></li>"
end
index << '</ol>'
require 'ronn'
require 'ronn/document'
require 'ronn/template'
klass = Class.new(Ronn::Template) do
def initialize(manuals, html)
@manuals = manuals
@html = html
end
def html
@html
end
def section_heads
false
end
def any_section_heads
!!section_heads
end
def page_name
""
end
def manual
"rip manual"
end
alias_method :title, :manual
def organization
"rip"
end
def date
Time.now.strftime('%B %Y')
end
end
view = klass.new(manuals, index)
File.open("#{mandir}/index.html", 'w+') do |f|
f.puts view.render
end
end
#
# Installation
#
desc "Installs Rip"
task :install do
prefix = ENV['PREFIX'] || ENV['prefix'] || '/usr/local'
bindir = ENV['BINDIR'] || ENV['bindir'] || "#{prefix}/bin"
libdir = ENV['LIBDIR'] || ENV['libdir'] || "#{prefix}/lib/rip"
mkdir_p bindir
Dir["bin/*"].each do |f|
cp f, bindir, :preserve => true, :verbose => true
end
mkdir_p libdir
Dir["lib/*"].each do |f|
cp_r f, libdir
end
end