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
|
require "rake/packagetask"
begin
require "rubygems"
require "rake/gempackagetask"
$have_rubygems = true
rescue
$have_rubygems = false
end
PKG_VERSION = File.open("VERSION").read.chomp
PKG_FILES = FileList[*%w{[A-Z]* README setup.rb lib/**/*.rb}]
MAINTAINER_MAILNAME = "wigwam.brockman.se"
SCP_TARGET = "teepee:/var/www/www.brockman.se/software/ruby-event-loop/"
task :default => ["README", :check]
file "README" => ["README.utf-8", "Rakefile"] do |t|
# I'm paranoid and I don't trust Ruby with Unicode.
if "a—b".gsub(/—/, "---") != "a---b"
warn "Can't build `README': broken Unicode support."
else
File.open("README", "w") do |out|
out << "\
------------------------------------------------------------
This file was automatically generated from `README.utf-8'.
------------------------------------------------------------\n\n"
IO.foreach("README.utf-8") do |line|
out << line.
gsub(/©/, "(C)").
gsub(/—/, "---").
gsub(/‘/, "`").
gsub(/’/, "'").
gsub(/“/, "\"").
gsub(/”/, "\"")
end
end
end
end
task :check do
Dir.foreach("lib/event-loop/") do |basename|
next if basename[0] == ?.
system %{ruby -w -Ilib "lib/event-loop/#{basename}"}
end
end
if $have_rubygems
GEMSPEC = Gem::Specification.new do |gem|
gem.name = "event-loop"
gem.version = PKG_VERSION
gem.summary = "Simple and usable event loop and signal system"
gem.description =
"This package contains a simple select-based event loop " +
"featuring IO (file descriptor) and timer event sources. " +
"It comes with a signal system inspired by that of GLib."
gem.files = PKG_FILES.to_a
gem.require_path = "lib"
gem.author = "Daniel Brockman"
gem.email = "daniel@brockman.se"
gem.homepage = "http://www.brockman.se/software/ruby-event-loop/"
end
Rake::GemPackageTask.new(GEMSPEC) do |task|
task.need_tar_gz = true
end
else
Rake::PackageTask.new("event-loop", PKG_VERSION) do |task|
task.need_tar_gz = true
task.package_files = PKG_FILES
end
end
task :upload => :package do
mailname = File.read("/etc/mailname").chomp rescue "(none)"
if mailname == MAINTAINER_MAILNAME
sh %{scp -r pkg/*#{PKG_VERSION}* #{SCP_TARGET}}
else
warn "The `upload' target is only meant for the maintainer."
end
end
|