Explicitly list all the files we want to distribute.
[redact.git] / Rakefile
1 require "rake/clean"
2 require "rake/testtask"
3 require "rake/rdoctask"
4 require "rake/packagetask"
5 require "rake/contrib/compositepublisher.rb"
6 require "rake/contrib/sshpublisher"
7
8 # make sure we run at least Rake 0.5.0
9 if (RAKEVERSION.split(".").map { |p| p.to_i } <=> [0, 5, 0]) < 0
10         raise("Rake 0.5.0 or greater required")
11 end
12
13 PKG_NAME = "redact"
14 PKG_VERSION = File.read("lib/redact/redact.rb").
15               match(/^\s*VERSION = \"(.*)\"\s*$/).captures.first
16 PKG_FILES = FileList[
17         "AUTHORS", "COPYING", "ChangeLog", "NEWS", "README", "Rakefile",
18         "TODO",
19         "bin/redact", "lib/redact/app.rb", "lib/redact/part.rb",
20         "lib/redact/program.rb", "lib/redact/redact.rb",
21         "lib/redact/source.rb",
22         "test/crossfade.rb", "test/red_rect.rb", "test/test_basic.rb"
23 ]
24
25 CLOBBER.include("test/*.edj")
26
27 task :install do |t|
28         sitelibdir = Config::CONFIG["sitelibdir"]
29         destdir = "#{ENV["DESTDIR"]}"
30         prefix = ENV["PREFIX"] || "/usr/local"
31
32         ddir = destdir + prefix + "/bin"
33         FileUtils::Verbose.install("bin/redact", ddir, :mode => 0755)
34
35         ddir = destdir + sitelibdir + "/redact"
36
37         FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir)
38         FileUtils::Verbose.install(Dir["lib/redact/*.rb"], ddir,
39                                    :mode => 0644)
40 end
41
42 task :test
43
44 Rake::TestTask.new do |t|
45         t.libs << "lib"
46         t.test_files = FileList["test/test*.rb"]
47         t.verbose = true
48 end
49
50 Rake::RDocTask.new do |t|
51         t.rdoc_dir = "doc"
52         t.title = "Redact - An Edje Compiler written in Ruby"
53         t.options = ["--line-numbers", "--inline-source", "--main", "README"]
54         t.rdoc_files.include("README", "COPYING", "AUTHORS",
55                              "TODO", "NEWS", "lib/redact/redact.rb",
56                              "lib/redact/part.rb", "lib/redact/program.rb")
57 end
58
59 CLOBBER.include("ChangeLog")
60
61 file "ChangeLog" do
62         `git log > ChangeLog`
63 end
64
65 Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |t|
66         t.need_tar_gz = true
67         t.package_files = PKG_FILES
68 end
69
70 task :publish => [:rdoc, :package] do
71         p = Rake::CompositePublisher.new
72         p.add(Rake::SshFreshDirPublisher.new("code-monkey.de",
73                                              "public_docs/" +
74                                              PKG_NAME, "doc"))
75         p.add(Rake::SshFilePublisher.new("code-monkey.de",
76                                          ".", "pkg",
77                                          "#{PKG_NAME}-#{PKG_VERSION}.tar.gz"))
78         p.upload
79 end