rabbit 1.0.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/GPL +19 -20
- data/Rakefile +25 -10
- data/bin/rabbit +20 -844
- data/bin/rabbit-command +25 -36
- data/bin/rabbit-slide +22 -0
- data/bin/rabbit-theme +22 -0
- data/bin/rabbit-theme-manager +30 -30
- data/data/account.kou.gpg +0 -0
- data/data/locale/en/LC_MESSAGES/rabbit.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rabbit.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
- data/doc/_config.yml +8 -0
- data/doc/_includes/en.menu.html +8 -0
- data/doc/_includes/ja.menu.html +8 -0
- data/doc/_layouts/en.html +19 -16
- data/doc/_layouts/ja.html +19 -16
- data/doc/_plugins/converters/rd.rb +1 -1
- data/doc/_plugins/support_symlink.rb +11 -0
- data/doc/en/development.rd +2 -2
- data/doc/en/how-to-make/index.rd +5 -5
- data/doc/en/how-to-make/rd.rd +1 -1
- data/doc/en/index.rd +6 -12
- data/doc/en/sample/index.rd +3 -3
- data/doc/en/slides.rd +2 -0
- data/doc/en/usage.rd +14 -356
- data/doc/en/usage/rabbit.rd +360 -0
- data/doc/en/users.rd +3 -1
- data/doc/images/screenshots/en/blue-circle-raw.png +0 -0
- data/doc/images/screenshots/en/blue-circle.png +0 -0
- data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
- data/doc/images/screenshots/en/clear-blue.png +0 -0
- data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
- data/doc/images/screenshots/en/cozmixng.png +0 -0
- data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
- data/doc/images/screenshots/en/dark-gradation.png +0 -0
- data/doc/images/screenshots/en/day-white.png +0 -0
- data/doc/images/screenshots/en/debian-raw.png +0 -0
- data/doc/images/screenshots/en/debian.png +0 -0
- data/doc/images/screenshots/en/green-circle-raw.png +0 -0
- data/doc/images/screenshots/en/green-circle.png +0 -0
- data/doc/images/screenshots/en/night-black.png +0 -0
- data/doc/images/screenshots/en/rabbit-raw.png +0 -0
- data/doc/images/screenshots/en/rabbit.png +0 -0
- data/doc/images/screenshots/en/ranguba-raw.png +0 -0
- data/doc/images/screenshots/en/ranguba.png +0 -0
- data/doc/images/screenshots/en/red-frame-raw.png +0 -0
- data/doc/images/screenshots/en/red-frame.png +0 -0
- data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
- data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
- data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
- data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
- data/doc/images/screenshots/ja/blue-circle-raw.png +0 -0
- data/doc/images/screenshots/ja/blue-circle.png +0 -0
- data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
- data/doc/images/screenshots/ja/clear-blue.png +0 -0
- data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
- data/doc/images/screenshots/ja/cozmixng.png +0 -0
- data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
- data/doc/images/screenshots/ja/dark-gradation.png +0 -0
- data/doc/images/screenshots/ja/day-white.png +0 -0
- data/doc/images/screenshots/ja/debian-raw.png +0 -0
- data/doc/images/screenshots/ja/debian.png +0 -0
- data/doc/images/screenshots/ja/green-circle-raw.png +0 -0
- data/doc/images/screenshots/ja/green-circle.png +0 -0
- data/doc/images/screenshots/ja/night-black.png +0 -0
- data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
- data/doc/images/screenshots/ja/rabbit.png +0 -0
- data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
- data/doc/images/screenshots/ja/ranguba.png +0 -0
- data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
- data/doc/images/screenshots/ja/red-frame.png +0 -0
- data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
- data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
- data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
- data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
- data/doc/index.html.en +1 -1
- data/doc/index.html.ja +1 -1
- data/doc/ja/about.rd +3 -3
- data/doc/ja/development.rd +2 -2
- data/doc/ja/how-to-make/index.rd +5 -5
- data/doc/ja/index.rd +10 -16
- data/doc/ja/install/macports.rd +1 -1
- data/doc/ja/news.rd +4 -4
- data/doc/ja/sample/index.rd +3 -3
- data/doc/ja/usage.rd +13 -358
- data/doc/ja/usage/rabbit.rd +362 -0
- data/doc/ja/users.rd +1 -1
- data/lib/rabbit/action.rb +2 -2
- data/lib/rabbit/author-configuration.rb +73 -0
- data/lib/rabbit/canvas.rb +0 -14
- data/lib/rabbit/command/rabbit-slide.rb +571 -0
- data/lib/rabbit/command/rabbit-theme.rb +381 -0
- data/lib/rabbit/command/rabbit.rb +898 -0
- data/lib/rabbit/config.rb +40 -0
- data/lib/rabbit/console.rb +124 -55
- data/lib/rabbit/gem-finder.rb +61 -0
- data/lib/rabbit/gettext.rb +6 -79
- data/lib/rabbit/html/generator.rb +1 -0
- data/lib/rabbit/image.rb +1 -1
- data/lib/rabbit/logger.rb +12 -2
- data/lib/rabbit/logger/base.rb +33 -32
- data/lib/rabbit/logger/stderr.rb +1 -1
- data/lib/rabbit/menu.rb +1 -1
- data/lib/rabbit/parser.rb +2 -0
- data/lib/rabbit/parser/ext/image.rb +14 -20
- data/lib/rabbit/path-manipulatable.rb +40 -0
- data/lib/rabbit/rabbit.rb +18 -8
- data/lib/rabbit/renderer/base.rb +3 -4
- data/lib/rabbit/renderer/color.rb +0 -1
- data/lib/rabbit/slideshare.rb +116 -0
- data/lib/rabbit/source/base.rb +1 -1
- data/lib/rabbit/stock.rb +1 -1
- data/lib/rabbit/task.rb +18 -0
- data/lib/rabbit/task/slide.rb +162 -0
- data/lib/rabbit/task/theme.rb +122 -0
- data/lib/rabbit/theme-browser/tree.rb +1 -1
- data/lib/rabbit/theme/applier.rb +9 -0
- data/lib/rabbit/theme/background-image-toolkit/background-image-toolkit.rb +1 -2
- data/lib/rabbit/theme/blue-bar/blue-bar.rb +0 -11
- data/lib/rabbit/theme/clear-blue/clear-blue.rb +0 -11
- data/lib/rabbit/theme/cozmixng/cozmixng.rb +0 -11
- data/lib/rabbit/theme/day-white/day-white.rb +0 -6
- data/lib/rabbit/theme/default/default.rb +7 -1
- data/lib/rabbit/theme/enishi-green/property.rb +2 -2
- data/lib/rabbit/theme/entry.rb +85 -27
- data/lib/rabbit/theme/image-slide-number/image-slide-number.rb +4 -1
- data/lib/rabbit/theme/lightning-monochrome/lightning-monochrome.rb +0 -1
- data/lib/rabbit/theme/lightning-simple/lightning-simple.rb +0 -1
- data/lib/rabbit/theme/nari/nari.rb +6 -16
- data/lib/rabbit/theme/nari/property.rb +3 -0
- data/lib/rabbit/theme/night-black/night-black.rb +0 -6
- data/lib/rabbit/theme/pdf/pdf.rb +0 -4
- data/lib/rabbit/theme/rabbit/rabbit.rb +0 -6
- data/lib/rabbit/theme/ranguba/ranguba.rb +0 -12
- data/lib/rabbit/theme/ruby-gnome2/ruby-gnome2.rb +7 -4
- data/lib/rabbit/theme/rubykaigi2011/rubykaigi2011.rb +2 -9
- data/lib/rabbit/theme/searcher.rb +38 -16
- data/lib/rabbit/theme/syntax-highlighting/property.rb +2 -2
- data/lib/rabbit/version.rb +19 -0
- data/po/en/rabbit.po +1605 -1425
- data/po/fr/rabbit.po +1756 -1684
- data/po/ja/rabbit.po +2198 -2097
- data/po/rabbit.pot +1556 -1419
- metadata +34 -100
- data/bin/rabbirack +0 -99
- data/bin/rabbiter +0 -108
- data/bin/rabrick +0 -95
- data/bin/rabwii +0 -77
- data/lib/rabbit/default-config.rb +0 -24
- data/lib/rabbit/div/comment-i.erb +0 -7
- data/lib/rabbit/div/comment.erb +0 -45
- data/lib/rabbit/div/css.erb +0 -1
- data/lib/rabbit/div/js.erb +0 -1
- data/lib/rabbit/div/log.erb +0 -5
- data/lib/rabbit/div/main-i.erb +0 -24
- data/lib/rabbit/div/main.css +0 -40
- data/lib/rabbit/div/main.erb +0 -33
- data/lib/rabbit/div/navi-i.erb +0 -6
- data/lib/rabbit/div/navi.erb +0 -6
- data/lib/rabbit/div/prototype.js +0 -4320
- data/lib/rabbit/div/slide-i.erb +0 -2
- data/lib/rabbit/div/slide.erb +0 -5
- data/lib/rabbit/div/tofu.rb +0 -309
- data/lib/rabbit/middleware/config.ru +0 -42
- data/lib/rabbit/middleware/controller.rb +0 -63
- data/lib/rabbit/middleware/public/stylesheets/rabbirack.css +0 -12
- data/lib/rabbit/middleware/views/index.haml +0 -13
- data/lib/rabbit/middleware/views/layout.haml +0 -8
- data/lib/rabbit/post-setup.rb +0 -8
- data/lib/rabbit/pre-clean.rb +0 -2
- data/lib/rabbit/pre-distclean.rb +0 -2
- data/lib/rabbit/theme/twitter-comment/property.rb +0 -4
- data/lib/rabbit/theme/twitter-comment/twitter-comment.rb +0 -15
- data/lib/rabbit/twitter.rb +0 -239
- data/sample/theme-bench-en.hiki +0 -100
- data/sample/theme-bench-en.rab +0 -127
- data/sample/theme-bench.hiki +0 -101
- data/sample/theme-bench.rab +0 -128
- data/setup.rb +0 -1585
- data/update-mo.rb +0 -20
- data/update-po.rb +0 -57
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Copyright (C) 2005-2012 Kouhei Sutou <kou@cozmixng.org>
|
|
2
|
+
#
|
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
16
|
+
|
|
17
|
+
require 'rbconfig'
|
|
18
|
+
|
|
19
|
+
module Rabbit
|
|
20
|
+
module Config
|
|
21
|
+
IMAGE_PATH = [
|
|
22
|
+
File.join(File.dirname(__FILE__), "..", "..", "data"),
|
|
23
|
+
RbConfig::CONFIG["datadir"],
|
|
24
|
+
]
|
|
25
|
+
append_path_from_gem = lambda do
|
|
26
|
+
return unless Object.const_defined?(:Gem)
|
|
27
|
+
rabbit_gem_spec = Gem.loaded_specs["rabbit"]
|
|
28
|
+
return if rabbit_gem_spec.nil?
|
|
29
|
+
unless rabbit_gem_spec.respond_to?(:activated?)
|
|
30
|
+
def rabbit_gem_spec.activated?
|
|
31
|
+
loaded?
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
if rabbit_gem_spec.activated?
|
|
35
|
+
IMAGE_PATH.unshift(File.join(rabbit_gem_spec.full_gem_path, "data"))
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
append_path_from_gem.call
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/rabbit/console.rb
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
# Copyright (C) 2005-2012 Kouhei Sutou <kou@cozmixng.org>
|
|
2
|
+
#
|
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
16
|
+
|
|
1
17
|
require 'English'
|
|
2
18
|
|
|
19
|
+
require "shellwords"
|
|
3
20
|
require "optparse"
|
|
4
21
|
require "ostruct"
|
|
22
|
+
require "uri"
|
|
23
|
+
require "pathname"
|
|
5
24
|
|
|
6
25
|
require "rabbit/rabbit"
|
|
7
26
|
require "rabbit/logger"
|
|
@@ -10,36 +29,83 @@ require "rabbit/console/roff"
|
|
|
10
29
|
|
|
11
30
|
Thread.abort_on_exception = true
|
|
12
31
|
|
|
13
|
-
include Rabbit::GetText
|
|
14
|
-
|
|
15
32
|
module Rabbit
|
|
16
|
-
|
|
33
|
+
class Console
|
|
34
|
+
include GetText
|
|
35
|
+
|
|
17
36
|
@@locale_dir_option_name = "--locale-dir"
|
|
18
37
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
38
|
+
class << self
|
|
39
|
+
def parse!(args, logger=nil, &block)
|
|
40
|
+
new(logger).parse!(args, &block)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def get_last_name(klass)
|
|
44
|
+
klass.name.split("::").last
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def initialize(logger=nil)
|
|
49
|
+
@logger = logger || Logger.default
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def parse!(args)
|
|
23
53
|
options = OpenStruct.new
|
|
24
|
-
options.logger = logger
|
|
25
|
-
options.default_logger = logger
|
|
54
|
+
options.logger = @logger
|
|
55
|
+
options.default_logger = @logger
|
|
56
|
+
options.druby_uri = "druby://127.0.0.1:10101"
|
|
57
|
+
options.version = VERSION
|
|
58
|
+
options.options_file = nil
|
|
59
|
+
options.rest = []
|
|
60
|
+
options.after_hooks = []
|
|
26
61
|
|
|
27
62
|
process_locale_options(args)
|
|
28
63
|
|
|
29
|
-
|
|
30
|
-
yield(
|
|
31
|
-
setup_common_options(
|
|
64
|
+
parser = OptionParser.new(banner) do |_parser|
|
|
65
|
+
yield(_parser, options)
|
|
66
|
+
setup_common_options(_parser, options)
|
|
32
67
|
end
|
|
33
68
|
|
|
34
69
|
begin
|
|
35
|
-
|
|
70
|
+
options_file = options.options_file
|
|
71
|
+
if options_file and File.exist?(options_file)
|
|
72
|
+
read_options_file(parser, options, options_file)
|
|
73
|
+
end
|
|
74
|
+
options.rest.concat(parser.parse!(args))
|
|
75
|
+
options.after_hooks.each do |hook|
|
|
76
|
+
hook.call(self, parser, options)
|
|
77
|
+
end
|
|
36
78
|
rescue
|
|
37
|
-
logger.fatal($!.message)
|
|
79
|
+
@logger.fatal($!.message)
|
|
38
80
|
end
|
|
39
81
|
|
|
40
82
|
[options, options.logger]
|
|
41
83
|
end
|
|
42
84
|
|
|
85
|
+
def read_options_file(parser, options, options_file)
|
|
86
|
+
options_in_file = []
|
|
87
|
+
File.open(options_file) do |file|
|
|
88
|
+
file.each_line do |line|
|
|
89
|
+
options_in_file.concat(Shellwords.split(line))
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
source_info = parser.parse(options_in_file)
|
|
93
|
+
|
|
94
|
+
source_info = source_info.collect do |path|
|
|
95
|
+
if URI(path).scheme
|
|
96
|
+
path
|
|
97
|
+
else
|
|
98
|
+
if Pathname(path).absolute?
|
|
99
|
+
path
|
|
100
|
+
else
|
|
101
|
+
File.join(File.dirname(options_file), path)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
options.rest.concat(source_info)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
43
109
|
def banner
|
|
44
110
|
_("Usage: %s [options]") % File.basename($0, '.*')
|
|
45
111
|
end
|
|
@@ -47,42 +113,53 @@ module Rabbit
|
|
|
47
113
|
def process_locale_options(args)
|
|
48
114
|
args.each_with_index do |arg, i|
|
|
49
115
|
if arg == @@locale_dir_option_name
|
|
50
|
-
bindtextdomain(args[i + 1])
|
|
116
|
+
self.class.bindtextdomain(GetText::DOMAIN, :path => args[i + 1])
|
|
51
117
|
elsif /#{@@locale_dir_option_name}=/ =~ arg
|
|
52
|
-
bindtextdomain($POSTMATCH)
|
|
118
|
+
self.class.bindtextdomain(GetText::DOMAIN, :path => $POSTMATCH)
|
|
53
119
|
end
|
|
54
120
|
end
|
|
55
121
|
end
|
|
56
122
|
|
|
57
|
-
def setup_common_options(
|
|
58
|
-
|
|
59
|
-
|
|
123
|
+
def setup_common_options(parser, options)
|
|
124
|
+
parser.separator ""
|
|
125
|
+
parser.separator _("Common options")
|
|
126
|
+
|
|
127
|
+
setup_options_options(parser, options)
|
|
128
|
+
setup_locale_options(parser, options)
|
|
129
|
+
setup_logger_options(parser, options)
|
|
130
|
+
setup_common_options_on_tail(parser, options)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def setup_options_options(parser, options)
|
|
134
|
+
parser.on("--options-file=FILE",
|
|
135
|
+
_("Load options from FILE."),
|
|
136
|
+
_("(none)")) do |file|
|
|
137
|
+
read_options_file(parser, options, file)
|
|
138
|
+
end
|
|
60
139
|
|
|
61
|
-
|
|
62
|
-
setup_logger_options(opts, options)
|
|
63
|
-
setup_common_options_on_tail(opts, options)
|
|
140
|
+
parser.separator ""
|
|
64
141
|
end
|
|
65
|
-
|
|
66
|
-
def setup_locale_options(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
bindtextdomain(
|
|
142
|
+
|
|
143
|
+
def setup_locale_options(parser, options)
|
|
144
|
+
parser.on("--locale-dir=DIR",
|
|
145
|
+
_("Specify locale dir as [DIR]."),
|
|
146
|
+
_("(auto)")) do |directory|
|
|
147
|
+
self.class.bindtextdomain(GetText::DOMAIN, :path => directory)
|
|
71
148
|
end
|
|
72
149
|
|
|
73
|
-
|
|
150
|
+
parser.separator ""
|
|
74
151
|
end
|
|
75
152
|
|
|
76
|
-
def setup_logger_options(
|
|
153
|
+
def setup_logger_options(parser, options)
|
|
77
154
|
logger_type_names = Rabbit::Logger.types.collect do |x|
|
|
78
155
|
get_last_name(x).downcase
|
|
79
156
|
end
|
|
80
157
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
158
|
+
parser.on("--logger-type=TYPE",
|
|
159
|
+
logger_type_names,
|
|
160
|
+
_("Specify logger type as [TYPE]."),
|
|
161
|
+
_("Select from [%s].") % logger_type_names.join(', '),
|
|
162
|
+
"(#{get_last_name(options.logger.class)})") do |logger_type|
|
|
86
163
|
logger_class = Rabbit::Logger.types.find do |t|
|
|
87
164
|
get_last_name(t).downcase == logger_type.downcase
|
|
88
165
|
end
|
|
@@ -95,24 +172,24 @@ module Rabbit
|
|
|
95
172
|
end
|
|
96
173
|
|
|
97
174
|
level_names = Logger::Severity.names
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
175
|
+
parser.on("--log-level=LEVEL",
|
|
176
|
+
level_names,
|
|
177
|
+
_("Specify log level as [LEVEL]."),
|
|
178
|
+
_("Select from [%s].") % level_names.join(', '),
|
|
179
|
+
"(#{Logger::Severity.name(options.logger.level)})") do |name|
|
|
103
180
|
options.logger.level = Logger::Severity.level(name)
|
|
104
181
|
end
|
|
105
182
|
|
|
106
|
-
|
|
183
|
+
parser.separator ""
|
|
107
184
|
end
|
|
108
185
|
|
|
109
|
-
def setup_common_options_on_tail(
|
|
110
|
-
|
|
111
|
-
output_info_and_exit(options,
|
|
186
|
+
def setup_common_options_on_tail(parser, options)
|
|
187
|
+
parser.on_tail("--help", _("Show this message.")) do
|
|
188
|
+
output_info_and_exit(options, parser.to_s)
|
|
112
189
|
end
|
|
113
190
|
|
|
114
|
-
|
|
115
|
-
output_info_and_exit(options, "#{
|
|
191
|
+
parser.on_tail("--version", _("Show version.")) do
|
|
192
|
+
output_info_and_exit(options, "#{options.version}\n")
|
|
116
193
|
end
|
|
117
194
|
end
|
|
118
195
|
|
|
@@ -127,15 +204,7 @@ module Rabbit
|
|
|
127
204
|
end
|
|
128
205
|
|
|
129
206
|
def get_last_name(klass)
|
|
130
|
-
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def guess_default_logger
|
|
134
|
-
if Utils.support_console_output? or !Logger.const_defined?(:GUI)
|
|
135
|
-
Logger::STDERR.new
|
|
136
|
-
else
|
|
137
|
-
Logger::GUI.new
|
|
138
|
-
end
|
|
207
|
+
self.class.get_last_name(klass)
|
|
139
208
|
end
|
|
140
209
|
end
|
|
141
210
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
|
2
|
+
#
|
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
16
|
+
|
|
17
|
+
require "rabbit/gettext"
|
|
18
|
+
|
|
19
|
+
module Rabbit
|
|
20
|
+
class GemFinder
|
|
21
|
+
include GetText
|
|
22
|
+
|
|
23
|
+
def initialize(logger=nil)
|
|
24
|
+
@logger = logger || Logger.default
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def find(name, prefix)
|
|
28
|
+
normalized_name = name.downcase
|
|
29
|
+
unless normalized_name.start_with?(prefix)
|
|
30
|
+
normalized_name = "#{prefix}#{normalized_name}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
retried = false
|
|
34
|
+
spec = nil
|
|
35
|
+
begin
|
|
36
|
+
spec = Gem::Specification.find_by_name(name)
|
|
37
|
+
rescue Gem::LoadError
|
|
38
|
+
begin
|
|
39
|
+
spec = Gem::Specification.find_by_name(normalized_name)
|
|
40
|
+
rescue Gem::LoadError
|
|
41
|
+
unless retried
|
|
42
|
+
retried = true
|
|
43
|
+
require "rubygems/dependency_installer"
|
|
44
|
+
options = {}
|
|
45
|
+
if File.writable?(Gem.dir)
|
|
46
|
+
@logger.info(_("Installing gem: %s") % normalized_name)
|
|
47
|
+
else
|
|
48
|
+
options[:user_install] = true
|
|
49
|
+
format = _("Installing gem in user install mode: %s")
|
|
50
|
+
@logger.info(format % normalized_name)
|
|
51
|
+
end
|
|
52
|
+
installer = Gem::DependencyInstaller.new(options)
|
|
53
|
+
installer.install(normalized_name, Gem::Requirement.default)
|
|
54
|
+
retry
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
spec
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
data/lib/rabbit/gettext.rb
CHANGED
|
@@ -1,87 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
require "rubygems"
|
|
3
|
-
raise LoadError if Gem.respond_to?(:_deprecated_all_load_paths)
|
|
4
|
-
require "gettext"
|
|
5
|
-
module GetText
|
|
6
|
-
if ::GetText::TextDomainManager.respond_to?(:textdomain)
|
|
7
|
-
alias _gettext gettext
|
|
8
|
-
module_function :_gettext
|
|
9
|
-
def gettext(msgid)
|
|
10
|
-
return msgid
|
|
11
|
-
if @@__textdomain[callersrc]
|
|
12
|
-
_gettext(msgid)
|
|
13
|
-
else
|
|
14
|
-
msgid
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
rescue LoadError
|
|
20
|
-
module GetText
|
|
21
|
-
|
|
22
|
-
module_function
|
|
23
|
-
def bindtextdomain(*args)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def gettext(msgid)
|
|
27
|
-
msgid
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
module Locale
|
|
32
|
-
module_function
|
|
33
|
-
def get
|
|
34
|
-
["LC_ALL", "LC_MESSAGES", "LANG"].each do |env|
|
|
35
|
-
ret = ENV[env]
|
|
36
|
-
break if ret
|
|
37
|
-
end
|
|
38
|
-
ret = "C" unless ret
|
|
39
|
-
ret
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
1
|
+
require "gettext"
|
|
43
2
|
|
|
44
3
|
module Rabbit
|
|
45
4
|
module GetText
|
|
46
|
-
|
|
47
5
|
DOMAIN = "rabbit"
|
|
48
|
-
module_function
|
|
49
|
-
def bindtextdomain(path=nil, locale=nil, charset=nil)
|
|
50
|
-
if Rabbit::Config.const_defined?(:GETTEXT_PATH)
|
|
51
|
-
path ||= Rabbit::Config::GETTEXT_PATH
|
|
52
|
-
end
|
|
53
|
-
charset ||= "UTF-8"
|
|
54
|
-
::GetText.bindtextdomain(DOMAIN, path, locale, charset)
|
|
55
|
-
if defined?(::GetText::TextDomainManager) and path
|
|
56
|
-
if ::GetText::TextDomainManager.respond_to?(:textdomain)
|
|
57
|
-
# workaround for Ruby-GetText 1.6.0 < 2.0.0
|
|
58
|
-
textdomain = ::GetText::TextDomainManager.textdomain(DOMAIN)
|
|
59
|
-
locale_paths = ["#{path}/%{locale}/LC_MESSAGES/%{name}.mo",
|
|
60
|
-
"#{path}/%{locale}/%{name}.mo"]
|
|
61
|
-
textdomain.locale_paths.concat(locale_paths)
|
|
62
|
-
locale ||= textdomain.current_locale || Locale.get
|
|
63
|
-
textdomain.set_locale(locale, true)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def _(msgid)
|
|
69
|
-
::GetText.gettext(msgid)
|
|
70
|
-
end
|
|
71
6
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
::GetText.locale = locale
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
module Locale
|
|
82
|
-
module_function
|
|
83
|
-
def get
|
|
84
|
-
::Locale.get
|
|
7
|
+
class << self
|
|
8
|
+
def included(mod)
|
|
9
|
+
mod.send(:include, ::GetText)
|
|
10
|
+
mod.bindtextdomain(DOMAIN)
|
|
11
|
+
end
|
|
85
12
|
end
|
|
86
13
|
end
|
|
87
14
|
end
|