]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - Rakefile
makemo task autocreates data/locale/*/LC_MESSAGES directories
[user/henk/code/ruby/rbot.git] / Rakefile
1 require 'rubygems'
2 require 'rake'
3 require 'rake/gempackagetask'
4
5 task :default => [:repackage]
6
7 spec = Gem::Specification.new do |s|
8   s.name = 'rbot'
9   s.version = '0.9.11'
10   s.summary = <<-EOF
11     A modular ruby IRC bot.
12   EOF
13   s.description = <<-EOF
14     A modular ruby IRC bot specifically designed for ease of extension via plugins.
15   EOF
16   s.requirements << 'Ruby, version 1.8.0 (or newer)'
17
18   #  s.files = Dir.glob("**/*").delete_if { |item| item.include?(".svn") }
19   s.files = FileList['lib/**/*.rb', 'bin/*', 'data/**/*', 'AUTHORS', 'COPYING', 'README', 'REQUIREMENTS', 'TODO', 'ChangeLog', 'INSTALL',  'Usage_en.txt', 'setup.rb'].to_a.delete_if {|item| item == ".svn"}
20   s.executables << 'rbot'
21
22 #  s.autorequire = 'rbot/ircbot'
23   s.has_rdoc = true
24   s.rdoc_options = ['--exclude', 'post-install.rb',
25   '--title', 'rbot API Documentation', '--main', 'README', 'README']
26
27   s.author = 'Tom Gilbert'
28   s.email = 'tom@linuxbrit.co.uk'
29   s.homepage = 'http://ruby-rbot.org'
30   s.rubyforge_project = 'rbot'
31 end
32
33 Rake::GemPackageTask.new(spec) do |pkg|
34   pkg.need_zip = true
35   pkg.need_tar = true
36 end
37
38 PLUGIN_FILES = FileList['data/rbot/plugins/**/*.rb']
39 NON_PLUGIN_FILES = FileList["{lib,bin,data}/**/*.{rb,rhtml}"] - PLUGIN_FILES
40 rgettext_proc = proc do |t|
41   require 'gettext/utils'
42   plugin_files, pot_file = t.prerequisites, t.name
43   GetText.rgettext(plugin_files, pot_file)
44 end
45
46 # generate pot file for non-plugin files
47 file('po/rbot.pot' => NON_PLUGIN_FILES, &rgettext_proc)
48
49 # generate pot files for plugin files
50 rule(%r'^po/.+\.pot$' => proc {|fn|
51   PLUGIN_FILES.select {|f| f.pathmap('rbot-%n') == fn.pathmap('%n')}
52 }, &rgettext_proc)
53
54 # update po files
55 # ruby-gettext treats empty output from msgmerge as error, causing this task to
56 # fail. we provide a wrapper to work around it. see bin/msgmerge-wrapper.rb for
57 # details
58 ENV['REAL_MSGMERGE_PATH'] = ENV['MSGMERGE_PATH']
59 ENV['MSGMERGE_PATH'] = ENV['MSGMERGE_WRAPPER_PATH'] || 'ruby msgmerge-wrapper.rb'
60 rule(%r'^po/.+/.+\.po$' => proc {|fn| fn.pathmap '%{^po/.+/,po/}X.pot'}) do |t|
61   require 'gettext/utils'
62   po_file, pot_file = t.name, t.source
63   GetText.msgmerge po_file, pot_file, 'rbot'
64 end
65
66 # generate mo files
67 rule(%r'^data/locale/.+/LC_MESSAGES/.+\.mo$' => proc {|fn|
68   [ fn.pathmap('%{^data/locale,po;LC_MESSAGES/,}X.po'), 
69     # the directory is created if not existing
70     fn.pathmap('%d') ]
71 }) do |t|
72   po_file, mo_file = t.source, t.name
73   require 'gettext/utils'
74   GetText.rmsgfmt po_file, mo_file
75 end
76
77 PLUGIN_BASENAMES = PLUGIN_FILES.map {|f| f.pathmap('%n')}
78 LOCALES = FileList['po/*/'].map {|d| d.pathmap('%n')}
79
80 LOCALES.each do |l|
81   directory "data/locale/#{l}/LC_MESSAGES"
82 end
83
84 desc 'Update po files'
85 task :updatepo => LOCALES.map {|l|
86   ["po/#{l}/rbot.po"] +
87   PLUGIN_BASENAMES.map {|n| "po/#{l}/rbot-#{n}.po"}
88 }.flatten
89
90 desc 'Generate mo files'
91 task :makemo => LOCALES.map {|l|
92   ["data/locale/#{l}/LC_MESSAGES/rbot.mo"] +
93   PLUGIN_BASENAMES.map {|n| "data/locale/#{l}/LC_MESSAGES/rbot-#{n}.mo"}
94 }.flatten
95