rabbit 1.0.9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/GPL +19 -20
  2. data/Rakefile +25 -10
  3. data/bin/rabbit +20 -844
  4. data/bin/rabbit-command +25 -36
  5. data/bin/rabbit-slide +22 -0
  6. data/bin/rabbit-theme +22 -0
  7. data/bin/rabbit-theme-manager +30 -30
  8. data/data/account.kou.gpg +0 -0
  9. data/data/locale/en/LC_MESSAGES/rabbit.mo +0 -0
  10. data/data/locale/fr/LC_MESSAGES/rabbit.mo +0 -0
  11. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  12. data/doc/_config.yml +8 -0
  13. data/doc/_includes/en.menu.html +8 -0
  14. data/doc/_includes/ja.menu.html +8 -0
  15. data/doc/_layouts/en.html +19 -16
  16. data/doc/_layouts/ja.html +19 -16
  17. data/doc/_plugins/converters/rd.rb +1 -1
  18. data/doc/_plugins/support_symlink.rb +11 -0
  19. data/doc/en/development.rd +2 -2
  20. data/doc/en/how-to-make/index.rd +5 -5
  21. data/doc/en/how-to-make/rd.rd +1 -1
  22. data/doc/en/index.rd +6 -12
  23. data/doc/en/sample/index.rd +3 -3
  24. data/doc/en/slides.rd +2 -0
  25. data/doc/en/usage.rd +14 -356
  26. data/doc/en/usage/rabbit.rd +360 -0
  27. data/doc/en/users.rd +3 -1
  28. data/doc/images/screenshots/en/blue-circle-raw.png +0 -0
  29. data/doc/images/screenshots/en/blue-circle.png +0 -0
  30. data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
  31. data/doc/images/screenshots/en/clear-blue.png +0 -0
  32. data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
  33. data/doc/images/screenshots/en/cozmixng.png +0 -0
  34. data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
  35. data/doc/images/screenshots/en/dark-gradation.png +0 -0
  36. data/doc/images/screenshots/en/day-white.png +0 -0
  37. data/doc/images/screenshots/en/debian-raw.png +0 -0
  38. data/doc/images/screenshots/en/debian.png +0 -0
  39. data/doc/images/screenshots/en/green-circle-raw.png +0 -0
  40. data/doc/images/screenshots/en/green-circle.png +0 -0
  41. data/doc/images/screenshots/en/night-black.png +0 -0
  42. data/doc/images/screenshots/en/rabbit-raw.png +0 -0
  43. data/doc/images/screenshots/en/rabbit.png +0 -0
  44. data/doc/images/screenshots/en/ranguba-raw.png +0 -0
  45. data/doc/images/screenshots/en/ranguba.png +0 -0
  46. data/doc/images/screenshots/en/red-frame-raw.png +0 -0
  47. data/doc/images/screenshots/en/red-frame.png +0 -0
  48. data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
  49. data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
  50. data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
  51. data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
  52. data/doc/images/screenshots/ja/blue-circle-raw.png +0 -0
  53. data/doc/images/screenshots/ja/blue-circle.png +0 -0
  54. data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
  55. data/doc/images/screenshots/ja/clear-blue.png +0 -0
  56. data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
  57. data/doc/images/screenshots/ja/cozmixng.png +0 -0
  58. data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
  59. data/doc/images/screenshots/ja/dark-gradation.png +0 -0
  60. data/doc/images/screenshots/ja/day-white.png +0 -0
  61. data/doc/images/screenshots/ja/debian-raw.png +0 -0
  62. data/doc/images/screenshots/ja/debian.png +0 -0
  63. data/doc/images/screenshots/ja/green-circle-raw.png +0 -0
  64. data/doc/images/screenshots/ja/green-circle.png +0 -0
  65. data/doc/images/screenshots/ja/night-black.png +0 -0
  66. data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
  67. data/doc/images/screenshots/ja/rabbit.png +0 -0
  68. data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
  69. data/doc/images/screenshots/ja/ranguba.png +0 -0
  70. data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
  71. data/doc/images/screenshots/ja/red-frame.png +0 -0
  72. data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
  73. data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
  74. data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
  75. data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
  76. data/doc/index.html.en +1 -1
  77. data/doc/index.html.ja +1 -1
  78. data/doc/ja/about.rd +3 -3
  79. data/doc/ja/development.rd +2 -2
  80. data/doc/ja/how-to-make/index.rd +5 -5
  81. data/doc/ja/index.rd +10 -16
  82. data/doc/ja/install/macports.rd +1 -1
  83. data/doc/ja/news.rd +4 -4
  84. data/doc/ja/sample/index.rd +3 -3
  85. data/doc/ja/usage.rd +13 -358
  86. data/doc/ja/usage/rabbit.rd +362 -0
  87. data/doc/ja/users.rd +1 -1
  88. data/lib/rabbit/action.rb +2 -2
  89. data/lib/rabbit/author-configuration.rb +73 -0
  90. data/lib/rabbit/canvas.rb +0 -14
  91. data/lib/rabbit/command/rabbit-slide.rb +571 -0
  92. data/lib/rabbit/command/rabbit-theme.rb +381 -0
  93. data/lib/rabbit/command/rabbit.rb +898 -0
  94. data/lib/rabbit/config.rb +40 -0
  95. data/lib/rabbit/console.rb +124 -55
  96. data/lib/rabbit/gem-finder.rb +61 -0
  97. data/lib/rabbit/gettext.rb +6 -79
  98. data/lib/rabbit/html/generator.rb +1 -0
  99. data/lib/rabbit/image.rb +1 -1
  100. data/lib/rabbit/logger.rb +12 -2
  101. data/lib/rabbit/logger/base.rb +33 -32
  102. data/lib/rabbit/logger/stderr.rb +1 -1
  103. data/lib/rabbit/menu.rb +1 -1
  104. data/lib/rabbit/parser.rb +2 -0
  105. data/lib/rabbit/parser/ext/image.rb +14 -20
  106. data/lib/rabbit/path-manipulatable.rb +40 -0
  107. data/lib/rabbit/rabbit.rb +18 -8
  108. data/lib/rabbit/renderer/base.rb +3 -4
  109. data/lib/rabbit/renderer/color.rb +0 -1
  110. data/lib/rabbit/slideshare.rb +116 -0
  111. data/lib/rabbit/source/base.rb +1 -1
  112. data/lib/rabbit/stock.rb +1 -1
  113. data/lib/rabbit/task.rb +18 -0
  114. data/lib/rabbit/task/slide.rb +162 -0
  115. data/lib/rabbit/task/theme.rb +122 -0
  116. data/lib/rabbit/theme-browser/tree.rb +1 -1
  117. data/lib/rabbit/theme/applier.rb +9 -0
  118. data/lib/rabbit/theme/background-image-toolkit/background-image-toolkit.rb +1 -2
  119. data/lib/rabbit/theme/blue-bar/blue-bar.rb +0 -11
  120. data/lib/rabbit/theme/clear-blue/clear-blue.rb +0 -11
  121. data/lib/rabbit/theme/cozmixng/cozmixng.rb +0 -11
  122. data/lib/rabbit/theme/day-white/day-white.rb +0 -6
  123. data/lib/rabbit/theme/default/default.rb +7 -1
  124. data/lib/rabbit/theme/enishi-green/property.rb +2 -2
  125. data/lib/rabbit/theme/entry.rb +85 -27
  126. data/lib/rabbit/theme/image-slide-number/image-slide-number.rb +4 -1
  127. data/lib/rabbit/theme/lightning-monochrome/lightning-monochrome.rb +0 -1
  128. data/lib/rabbit/theme/lightning-simple/lightning-simple.rb +0 -1
  129. data/lib/rabbit/theme/nari/nari.rb +6 -16
  130. data/lib/rabbit/theme/nari/property.rb +3 -0
  131. data/lib/rabbit/theme/night-black/night-black.rb +0 -6
  132. data/lib/rabbit/theme/pdf/pdf.rb +0 -4
  133. data/lib/rabbit/theme/rabbit/rabbit.rb +0 -6
  134. data/lib/rabbit/theme/ranguba/ranguba.rb +0 -12
  135. data/lib/rabbit/theme/ruby-gnome2/ruby-gnome2.rb +7 -4
  136. data/lib/rabbit/theme/rubykaigi2011/rubykaigi2011.rb +2 -9
  137. data/lib/rabbit/theme/searcher.rb +38 -16
  138. data/lib/rabbit/theme/syntax-highlighting/property.rb +2 -2
  139. data/lib/rabbit/version.rb +19 -0
  140. data/po/en/rabbit.po +1605 -1425
  141. data/po/fr/rabbit.po +1756 -1684
  142. data/po/ja/rabbit.po +2198 -2097
  143. data/po/rabbit.pot +1556 -1419
  144. metadata +34 -100
  145. data/bin/rabbirack +0 -99
  146. data/bin/rabbiter +0 -108
  147. data/bin/rabrick +0 -95
  148. data/bin/rabwii +0 -77
  149. data/lib/rabbit/default-config.rb +0 -24
  150. data/lib/rabbit/div/comment-i.erb +0 -7
  151. data/lib/rabbit/div/comment.erb +0 -45
  152. data/lib/rabbit/div/css.erb +0 -1
  153. data/lib/rabbit/div/js.erb +0 -1
  154. data/lib/rabbit/div/log.erb +0 -5
  155. data/lib/rabbit/div/main-i.erb +0 -24
  156. data/lib/rabbit/div/main.css +0 -40
  157. data/lib/rabbit/div/main.erb +0 -33
  158. data/lib/rabbit/div/navi-i.erb +0 -6
  159. data/lib/rabbit/div/navi.erb +0 -6
  160. data/lib/rabbit/div/prototype.js +0 -4320
  161. data/lib/rabbit/div/slide-i.erb +0 -2
  162. data/lib/rabbit/div/slide.erb +0 -5
  163. data/lib/rabbit/div/tofu.rb +0 -309
  164. data/lib/rabbit/middleware/config.ru +0 -42
  165. data/lib/rabbit/middleware/controller.rb +0 -63
  166. data/lib/rabbit/middleware/public/stylesheets/rabbirack.css +0 -12
  167. data/lib/rabbit/middleware/views/index.haml +0 -13
  168. data/lib/rabbit/middleware/views/layout.haml +0 -8
  169. data/lib/rabbit/post-setup.rb +0 -8
  170. data/lib/rabbit/pre-clean.rb +0 -2
  171. data/lib/rabbit/pre-distclean.rb +0 -2
  172. data/lib/rabbit/theme/twitter-comment/property.rb +0 -4
  173. data/lib/rabbit/theme/twitter-comment/twitter-comment.rb +0 -15
  174. data/lib/rabbit/twitter.rb +0 -239
  175. data/sample/theme-bench-en.hiki +0 -100
  176. data/sample/theme-bench-en.rab +0 -127
  177. data/sample/theme-bench.hiki +0 -101
  178. data/sample/theme-bench.rab +0 -128
  179. data/setup.rb +0 -1585
  180. data/update-mo.rb +0 -20
  181. 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
@@ -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
- module Console
33
+ class Console
34
+ include GetText
35
+
17
36
  @@locale_dir_option_name = "--locale-dir"
18
37
 
19
- module_function
20
- def parse!(args, logger=nil)
21
- bindtextdomain
22
- logger ||= guess_default_logger
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
- opts = OptionParser.new(banner) do |opts|
30
- yield(opts, options)
31
- setup_common_options(opts, 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
- opts.parse!(args)
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(opts, options)
58
- opts.separator ""
59
- opts.separator _("Common options")
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
- setup_locale_options(opts, options)
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(opts, options)
67
- opts.on("--locale-dir=DIR",
68
- _("Specify locale dir as [DIR]."),
69
- _("(auto)")) do |d|
70
- bindtextdomain(d)
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
- opts.separator ""
150
+ parser.separator ""
74
151
  end
75
152
 
76
- def setup_logger_options(opts, 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
- opts.on("--logger-type=TYPE",
82
- logger_type_names,
83
- _("Specify logger type as [TYPE]."),
84
- _("Select from [%s].") % logger_type_names.join(', '),
85
- "(#{get_last_name(options.logger.class)})") do |logger_type|
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
- opts.on("--log-level=LEVEL",
99
- level_names,
100
- _("Specify log level as [LEVEL]."),
101
- _("Select from [%s].") % level_names.join(', '),
102
- "(#{Logger::Severity.name(options.logger.level)})") do |name|
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
- opts.separator ""
183
+ parser.separator ""
107
184
  end
108
185
 
109
- def setup_common_options_on_tail(opts, options)
110
- opts.on_tail("--help", _("Show this message.")) do
111
- output_info_and_exit(options, opts.to_s)
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
- opts.on_tail("--version", _("Show version.")) do
115
- output_info_and_exit(options, "#{VERSION}\n")
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
- klass.name.split("::").last
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
@@ -1,87 +1,14 @@
1
- begin
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
- def N_(msgid)
73
- msgid
74
- end
75
-
76
- def locale=(locale)
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
@@ -14,6 +14,7 @@ require 'rabbit/keys'
14
14
  module Rabbit
15
15
  module HTML
16
16
  class Generator
17
+ include GetText
17
18
  include ERB::Util
18
19
  public :h
19
20