forked from matta/rubymail
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
184 lines (156 loc) · 4.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
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
# -*- ruby -*-
#
# This is a Ruby file, used by the "rake" make-like program.
#
begin
# First, we use a few ruby things...
require 'rubygems'
require 'rubygems/package_task'
end
require 'rdoc/task'
require 'rake/testtask'
require 'shellwords'
#
# The default task is run if rake is given no explicit arguments.
#
desc "Default Task"
task :default => :test
#
# Test tasks
#
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/test*.rb'
t.verbose = true
end
def unreleasable_reason
can_release_package
unreleasable_reason
end
def can_release_package
reasons = []
unless news_is_current
reasons << 'the NEWS file is not current'
end
unless defined?(Gem)
reasons << 'RubyGems is not installed'
end
reason = if reasons.empty?
""
else
last = reasons.pop
("Can not release package because " +
(reasons.empty? ? "#{last}." :
(reasons.join(", ") + " and #{last}.")))
end
can_release = reason.length == 0
self.class.module_eval <<-END_OF_CODE
def unreleasable_reason
\"#{reason}\"
end
def can_release_package
#{can_release.inspect}
end
END_OF_CODE
can_release_package
end
# Is the NEWS file current?
def news_is_current
today = Time.now.strftime('%Y-%m-%d')
version = Regexp.new(Regexp.quote(PKG_VERSION))
if IO.readlines('NEWS').first =~
/= Changes in RubyMail #{PKG_VERSION} \(released #{today}\)$/
true
else
false
end
end
#
# These PKG_ variables are used by Rake's package rule.
#
PKG_VERSION = begin
version= IO.readlines('version').first.chomp
if version =~ /^\d+\.\d+\.\d+$/
version.untaint
else
fail "package version is bogus"
end
version
end
PKG_FILES = FileList.new('test/**/*',
'guide/**/*',
'lib/**/*',
'install.rb',
'NEWS',
'NOTES',
'README',
'THANKS',
'TODO',
'Rakefile',
'version')
#
# Teach Rake how to build the RDoc documentation for this package.
#
rdoc = Rake::RDocTask.new do |rdoc|
rdoc.main = 'README'
rdoc.rdoc_files.include("README", "NEWS", "THANKS",
"TODO", "guide/*.txt", "lib/**/*.rb")
rdoc.rdoc_files.exclude(/\bSCCS\b/,
"lib/rubymail/parser/*")
unreleased = if can_release_package
""
else
" (UNRELEASED!)"
end
rdoc.title = "RubyMail Documentation (version #{PKG_VERSION})"
rdoc.options << '--exclude' << 'SCCS'
end
# Make sure that we don't package anything that hasn't been tagged.
task :package => [ :can_release ]
desc "Check if the package is in a releasable state."
task :can_release do
unless can_release_package
puts unreleasable_reason
end
end
#
# Create a Gem::Specification right in the Rakefile, using some of the
# variables we have set up above.
#
if defined?(Gem)
spec = Gem::Specification.new do |s|
s.name = 'rmail-sup'
s.version = PKG_VERSION + if can_release_package
''
else
'.666'
end
s.summary = 'A MIME mail parsing and generation library.'
s.description = <<-EOF
RMail is a lightweight mail library containing various utility classes and
modules that allow ruby scripts to parse, modify, and generate MIME mail
messages.
EOF
s.files = PKG_FILES.to_a
s.required_ruby_version = Gem::Version::Requirement.new(">= 1.8.1")
s.has_rdoc = true
s.extra_rdoc_files = rdoc.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
s.rdoc_options.concat([ '--title', rdoc.title, '--main', rdoc.main,
rdoc.options ].flatten)
s.test_files = FileList['test/tc_*.rb'].to_a
s.author = "Sup maintainers"
s.email = "[email protected]"
s.homepage = "http://supmua.org"
end
#
# Use our Gem::Specification to make some package tasks.
#
Gem::PackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
end
desc "Install RubyMail using the standard install.rb script"
task :install do
ruby "install.rb"
end