]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - Rakefile
rename plugin_files to source_files in rgettext_proc
[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   source_files, pot_file = t.prerequisites, t.name
43   puts "#{source_files.join(', ')} => #{pot_file}"
44   GetText.rgettext(source_files, pot_file)
45 end
46
47 # generate pot file for non-plugin files
48 file('po/rbot.pot' => NON_PLUGIN_FILES, &rgettext_proc)
49
50 # generate pot files for plugin files
51 rule(%r'^po/.+\.pot$' => proc {|fn|
52   PLUGIN_FILES.select {|f| f.pathmap('rbot-%n') == fn.pathmap('%n')}
53 }, &rgettext_proc)
54
55 # update po files
56 # ruby-gettext treats empty output from msgmerge as error, causing this task to
57 # fail. we provide a wrapper to work around it. see bin/msgmerge-wrapper.rb for
58 # details
59 ENV['REAL_MSGMERGE_PATH'] = ENV['MSGMERGE_PATH']
60 ENV['MSGMERGE_PATH'] = ENV['MSGMERGE_WRAPPER_PATH'] || 'ruby msgmerge-wrapper.rb'
61 rule(%r'^po/.+/.+\.po$' => proc {|fn| fn.pathmap '%{^po/.+/,po/}X.pot'}) do |t|
62   require 'gettext/utils'
63   po_file, pot_file = t.name, t.source
64   puts "#{pot_file} => #{po_file}"
65   GetText.msgmerge po_file, pot_file, 'rbot'
66 end
67
68 # generate mo files
69 rule(%r'^data/locale/.+/LC_MESSAGES/.+\.mo$' => proc {|fn|
70   [ fn.pathmap('%{^data/locale,po;LC_MESSAGES/,}X.po'), 
71     # the directory is created if not existing
72     fn.pathmap('%d') ]
73 }) do |t|
74   po_file, mo_file = t.source, t.name
75   puts "#{po_file} => #{mo_file}"
76   require 'gettext/utils'
77   GetText.rmsgfmt po_file, mo_file
78 end
79
80 PLUGIN_BASENAMES = PLUGIN_FILES.map {|f| f.pathmap('%n')}
81 LOCALES = FileList['po/*/'].map {|d| d.pathmap('%n')}
82
83 LOCALES.each do |l|
84   directory "data/locale/#{l}/LC_MESSAGES"
85 end
86
87 desc 'Update po files'
88 task :updatepo => LOCALES.map {|l|
89   ["po/#{l}/rbot.po"] +
90   PLUGIN_BASENAMES.map {|n| "po/#{l}/rbot-#{n}.po"}
91 }.flatten
92
93 desc 'Generate mo files'
94 task :makemo => LOCALES.map {|l|
95   ["data/locale/#{l}/LC_MESSAGES/rbot.mo"] +
96   PLUGIN_BASENAMES.map {|n| "data/locale/#{l}/LC_MESSAGES/rbot-#{n}.mo"}
97 }.flatten
98