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
|
require 'rubygems'
require 'rake'
require 'rake/gempackagetask'
task :default => [:repackage]
spec = Gem::Specification.new do |s|
s.name = 'rbot'
s.version = '0.9.11'
s.summary = <<-EOF
A modular ruby IRC bot.
EOF
s.description = <<-EOF
A modular ruby IRC bot specifically designed for ease of extension via plugins.
EOF
s.requirements << 'Ruby, version 1.8.0 (or newer)'
# s.files = Dir.glob("**/*").delete_if { |item| item.include?(".svn") }
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"}
s.executables << 'rbot'
# s.autorequire = 'rbot/ircbot'
s.has_rdoc = true
s.rdoc_options = ['--exclude', 'post-install.rb',
'--title', 'rbot API Documentation', '--main', 'README', 'README']
s.author = 'Tom Gilbert'
s.email = 'tom@linuxbrit.co.uk'
s.homepage = 'http://ruby-rbot.org'
s.rubyforge_project = 'rbot'
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
PLUGIN_FILES = FileList['data/rbot/plugins/**/*.rb']
NON_PLUGIN_FILES = FileList["{lib,bin,data}/**/*.{rb,rhtml}"] - PLUGIN_FILES
rgettext_proc = proc do |t|
require 'gettext/utils'
plugin_files, pot_file = t.prerequisites, t.name
puts "#{plugin_files.join(', ')} => #{pot_file}"
GetText.rgettext(plugin_files, pot_file)
end
# generate pot file for non-plugin files
file('po/rbot.pot' => NON_PLUGIN_FILES, &rgettext_proc)
# generate pot files for plugin files
rule(%r'^po/.+\.pot$' => proc {|fn|
PLUGIN_FILES.select {|f| f.pathmap('rbot-%n') == fn.pathmap('%n')}
}, &rgettext_proc)
# update po files
# ruby-gettext treats empty output from msgmerge as error, causing this task to
# fail. we provide a wrapper to work around it. see bin/msgmerge-wrapper.rb for
# details
ENV['REAL_MSGMERGE_PATH'] = ENV['MSGMERGE_PATH']
ENV['MSGMERGE_PATH'] = ENV['MSGMERGE_WRAPPER_PATH'] || 'ruby msgmerge-wrapper.rb'
rule(%r'^po/.+/.+\.po$' => proc {|fn| fn.pathmap '%{^po/.+/,po/}X.pot'}) do |t|
require 'gettext/utils'
po_file, pot_file = t.name, t.source
puts "#{pot_file} => #{po_file}"
GetText.msgmerge po_file, pot_file, 'rbot'
end
# generate mo files
rule(%r'^data/locale/.+/LC_MESSAGES/.+\.mo$' => proc {|fn|
[ fn.pathmap('%{^data/locale,po;LC_MESSAGES/,}X.po'),
# the directory is created if not existing
fn.pathmap('%d') ]
}) do |t|
po_file, mo_file = t.source, t.name
puts "#{po_file} => #{mo_file}"
require 'gettext/utils'
GetText.rmsgfmt po_file, mo_file
end
PLUGIN_BASENAMES = PLUGIN_FILES.map {|f| f.pathmap('%n')}
LOCALES = FileList['po/*/'].map {|d| d.pathmap('%n')}
LOCALES.each do |l|
directory "data/locale/#{l}/LC_MESSAGES"
end
desc 'Update po files'
task :updatepo => LOCALES.map {|l|
["po/#{l}/rbot.po"] +
PLUGIN_BASENAMES.map {|n| "po/#{l}/rbot-#{n}.po"}
}.flatten
desc 'Generate mo files'
task :makemo => LOCALES.map {|l|
["data/locale/#{l}/LC_MESSAGES/rbot.mo"] +
PLUGIN_BASENAMES.map {|n| "data/locale/#{l}/LC_MESSAGES/rbot-#{n}.mo"}
}.flatten
|