-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
190 lines (156 loc) · 5.37 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#========================================================================
# Rakefile for gurgitate-mail
#
# You should probably not be trying to use this if you're not me. :-) If
# you're looking at this file, that probably means you grabbed my code
# straight from CVS. In that case, if you're feeling adventurous you
# can try "rake install". No guarantees! But you're really better off
# either saying "rake tarball" and using the tarball generated to
# install, or simply pulling down the latest release tarball from:
#
# http://www.rubyforge.org/projects/gurgitate-mail/
#
# This file is read by "rake". Don't try to run it by itself! It'll
# just complain that it's never heard of RakeTools and then not compile.
# If you don't have rake installed then grab a copy of it at:
#
# http://jimweirich.umlcoop.net/packages/rake/
#========================================================================
require 'fileutils'
require 'rubygems'
BuildDir = "BUILD"
Package = "gurgitate-mail"
Modules = %w{gurgitate/deliver.rb
gurgitate/headers.rb
gurgitate/mail_headers.rb
gurgitate/message.rb
gurgitate/header.rb
gurgitate/mailmessage.rb
gurgitate/deliver/maildir.rb
gurgitate/deliver/mbox.rb
gurgitate/deliver/mh.rb}
Targets = %w{gurgitate-mail.rb
gurgitate-mail
gurgitate-mail.html
gurgitate-mail.man
README} + Modules
Tests = Dir["test/test_*.rb"]
Gemspec = "#{Package}.gemspec"
Releasefiles = %w{CHANGELOG INSTALL install.rb} + Targets + Tests
Webpage=ENV["HOME"]+"/public_html/software/gurgitate-mail"
Version=File.open("VERSION").read.chomp
Tarball="gurgitate-mail-"+Version+".tar.gz"
Gemfile="gurgitate-mail-"+Version+".gem"
task :default => Targets
task :dist => [ :tarball, :gem ]
task :tarball => Tarball
task :release => [:tag, :dist, :webpage]
task :rerelease => [:untag, :tag, :tarball, :webpage]
task :gem => Gemfile
task :clean => :gem_cleanup do
delete_all(*Targets+["pod2htm*~~","*.tmp",
"gurgitate-mail.text","doc","*~"])
end
task :gem_cleanup do
delete_all BuildDir
delete_all "*.gem"
end
file Gemfile => [ Gemspec, :gem_install ] do
gemspec = eval File.read(Gemspec)
FileUtils.touch File.join(BuildDir, ".gemtest")
olddir = Dir.pwd
chdir BuildDir
system("gem","build",File.join("..",Gemspec))
FileUtils.mv Gemfile,olddir
chdir olddir
end
task :gem_install => Targets do
load "install.rb"
Gurgitate::Install.install BuildDir
end
task :install => Targets do
load "install.rb"
Gurgitate::Install.install
end
file Tarball => Releasefiles do |t|
Dir.chdir("..") do
puts "Creating #{Dir.pwd}/#{Tarball}..."
files=t.prerequisites.map { |f| f.gsub(/^/,"gurgitate-mail/") }
File.chmod(0644, *files)
system("tar","zcvf",Tarball,*files)
end
end
task :tag => "VERSION" do
run("git checkout -f VERSION")
tag="RELEASE_"+File.open("VERSION").read.chomp.gsub(/\./,"_")
run("git tag #{tag}")
end
task :untag => "VERSION" do
run("git checkout -f VERSION")
tag="RELEASE_"+File.open("VERSION").read.chomp.gsub(/\./,"_")
run("git tag -d #{tag}")
end
task :doc => "gurgitate-mail.rb" do |task|
begin
require 'rdoc/rdoc'
RDoc::RDoc.new().document(task.prerequisites)
end
end
task :test => :default do
$:.unshift File.dirname(__FILE__)
require './test/runtests'
testcases = Tests.map do |file|
load file
eval("TC_" + File.basename(file,".rb").sub(/^test_/,'').capitalize)
end
runtests testcases
end
task :cover => :default do
system("rcov #{BuildDir}/test/runtests.rb")
end
task :webpage => [Tarball,"CHANGELOG","gurgitate-mail.html"] do
FileUtils.install(File.join("..",Tarball),Webpage,:mode => 0644)
FileUtils.install(Gemfile, Webpage, :mode => 0644)
FileUtils.install("CHANGELOG",Webpage+"/CHANGELOG.txt", :mode => 0644)
FileUtils.install("gurgitate-mail.html",Webpage, :mode => 0644)
end
# Should be ruby_"compile" but I can't put quote marks in method names :-)
def ruby_compile(task)
task.prerequisites.each do |p|
run("ruby -w -c #{p}")
end
FileUtils.cp(task.prerequisites[0], task.name)
end
file("gurgitate-mail.rb" => ["gurgitate-mail.RB"]) { |t| ruby_compile(t) }
file("gurgitate-mail" => ["gurgitate.rb"]) { |t| ruby_compile(t) }
Modules.map do |modname|
file(modname => [modname.sub(/.rb$/,".RB")]) do |t| ruby_compile(t) end
end
file "README" => "gurgitate-mail.text" do |t|
t.sources=[t.prerequisites[0]]
FileUtils.cp(t.source, t.name)
end
%w{html text}.each do |s|
rule('.'+s => '.pod') do |t|
run "pod2#{s} #{t.source} > #{t.name}"
end
end
['man'].each do |s|
rule('.'+s => '.pod') do |t|
run "pod2#{s} --center=\"Gurgitate-Mail\" #{t.source} > #{t.name}"
end
end
#------------------------------------------------------------------------
# Apparently rake/contrib/sys.rb is deprecated in favor of ftools, but
# ftools doesn't have these two really handy methods, so I'm stealing 'em.
#------------------------------------------------------------------------
def run(cmd)
puts cmd
system(cmd) or fail "Command Failed: [#{cmd}]"
end
def delete_all(*wildcards)
wildcards.each do |wildcard|
FileUtils.rm_rf wildcard
end
end
# Psst, Emacs, this file is actually -*- ruby -*-