fast_gettext 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,4 +6,5 @@ group :development do
6
6
  gem 'sqlite3'
7
7
  gem 'rspec', '~>2'
8
8
  gem 'activerecord', ENV['AR']
9
+ gem 'i18n'
9
10
  end
data/Gemfile.lock CHANGED
@@ -1,29 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fast_gettext (0.6.7)
4
+ fast_gettext (0.6.8)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- activemodel (3.1.0)
10
- activesupport (= 3.1.0)
11
- bcrypt-ruby (~> 3.0.0)
9
+ activemodel (3.2.5)
10
+ activesupport (= 3.2.5)
12
11
  builder (~> 3.0.0)
13
- i18n (~> 0.6)
14
- activerecord (3.1.0)
15
- activemodel (= 3.1.0)
16
- activesupport (= 3.1.0)
17
- arel (~> 2.2.1)
12
+ activerecord (3.2.5)
13
+ activemodel (= 3.2.5)
14
+ activesupport (= 3.2.5)
15
+ arel (~> 3.0.2)
18
16
  tzinfo (~> 0.3.29)
19
- activesupport (3.1.0)
17
+ activesupport (3.2.5)
18
+ i18n (~> 0.6)
20
19
  multi_json (~> 1.0)
21
- arel (2.2.1)
22
- bcrypt-ruby (3.0.1)
20
+ arel (3.0.2)
23
21
  builder (3.0.0)
24
22
  diff-lcs (1.1.3)
25
23
  i18n (0.6.0)
26
- multi_json (1.0.3)
24
+ multi_json (1.3.6)
27
25
  rake (0.9.2)
28
26
  rspec (2.6.0)
29
27
  rspec-core (~> 2.6.0)
@@ -33,8 +31,8 @@ GEM
33
31
  rspec-expectations (2.6.0)
34
32
  diff-lcs (~> 1.1.2)
35
33
  rspec-mocks (2.6.0)
36
- sqlite3 (1.3.4)
37
- tzinfo (0.3.29)
34
+ sqlite3 (1.3.6)
35
+ tzinfo (0.3.33)
38
36
 
39
37
  PLATFORMS
40
38
  ruby
@@ -42,6 +40,7 @@ PLATFORMS
42
40
  DEPENDENCIES
43
41
  activerecord
44
42
  fast_gettext!
43
+ i18n
45
44
  rake
46
45
  rspec (~> 2)
47
46
  sqlite3
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
3
  task :default do
4
- sh "AR='~>2' && (bundle || bundle install) && bundle exec rspec spec" # ActiveRecord 2
5
- sh "AR='~>3' && (bundle || bundle install) && bundle exec rspec spec" # ActiveRecord 3
4
+ ['~>2', '~>3'].each do |version|
5
+ sh "export AR='#{version}' && (bundle check || bundle) && bundle exec rspec spec"
6
+ end
7
+ sh "git checkout Gemfile.lock"
6
8
  end
7
9
 
8
10
  task :benchmark do
@@ -6,8 +6,14 @@ module FastGettext
6
6
  class PoFile
7
7
  def self.to_mo_file(file, options={})
8
8
  require 'fast_gettext/vendor/poparser'
9
+ parser = FastGettext::GetText::PoParser.new
10
+
11
+ warn ":ignore_obsolete is no longer supported, use :report_warning" if options.key? :ignore_obsolete
12
+ parser.ignore_fuzzy = options[:ignore_fuzzy]
13
+ parser.report_warning = options.fetch(:report_warning, true)
14
+
9
15
  mo_file = FastGettext::GetText::MOFile.new
10
- FastGettext::GetText::PoParser.new.parse(File.read(file), mo_file, !options[:ignore_fuzzy], !options[:ignore_obsolete])
16
+ parser.parse(File.read(file), mo_file)
11
17
  MoFile.new(mo_file)
12
18
  end
13
19
  end
@@ -1,27 +1,43 @@
1
- =begin
2
- poparser.rb - Generate a .mo
3
-
4
- Copyright (C) 2003-2009 Masao Mutoh <mutoh at highway.ne.jp>
5
-
6
- You may redistribute it and/or modify it under the same
7
- license terms as Ruby.
8
- =end
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # poparser.rb - Generate a .mo
4
+ #
5
+ # Copyright (C) 2003-2009 Masao Mutoh <mutomasa at gmail.com>
6
+ # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
7
+ #
8
+ # You may redistribute it and/or modify it under the same
9
+ # license terms as Ruby or LGPL.
9
10
 
10
11
  #MODIFIED
11
- # removed include GetText etc
12
- # added stub translation method _(x)
13
- require 'racc/parser'
12
+ # removed include GetText
13
+ # added stub translation method _(message_id)
14
14
 
15
+ require 'racc/parser.rb'
15
16
  module FastGettext
16
17
  module GetText
17
-
18
18
  class PoParser < Racc::Parser
19
19
 
20
- def _(x)
21
- x
22
- end
20
+ module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry', 118)
21
+
22
+ def _(message_id)
23
+ message_id
24
+ end
25
+ private :_
26
+
27
+ attr_writer :ignore_fuzzy, :report_warning
28
+ def initialize
29
+ @ignore_fuzzy = true
30
+ @report_warning = true
31
+ end
32
+
33
+ def ignore_fuzzy?
34
+ @ignore_fuzzy
35
+ end
36
+
37
+ def report_warning?
38
+ @report_warning
39
+ end
23
40
 
24
- module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry', 108
25
41
  def unescape(orig)
26
42
  ret = orig.gsub(/\\n/, "\n")
27
43
  ret.gsub!(/\\t/, "\t")
@@ -29,13 +45,18 @@ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry',
29
45
  ret.gsub!(/\\"/, "\"")
30
46
  ret
31
47
  end
32
-
33
- def parse(str, data, ignore_fuzzy = true, show_obsolete = true)
48
+ private :unescape
49
+
50
+ def unescape_string(string)
51
+ string.gsub(/\\\\/, "\\")
52
+ end
53
+ private :unescape_string
54
+
55
+ def parse(str, data)
34
56
  @comments = []
35
57
  @data = data
36
58
  @fuzzy = false
37
59
  @msgctxt = ""
38
- $ignore_fuzzy = ignore_fuzzy
39
60
 
40
61
  str.strip!
41
62
  @q = []
@@ -59,24 +80,24 @@ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry',
59
80
  @q.push [:PLURAL_NUM, $1]
60
81
  str = $'
61
82
  when /\A\#~(.*)/
62
- if show_obsolete
63
- $stderr.print _("Warning: obsolete msgid exists.\n")
64
- $stderr.print " #{$&}\n"
65
- end
83
+ if report_warning?
84
+ $stderr.print _("Warning: obsolete msgid exists.\n")
85
+ $stderr.print " #{$&}\n"
86
+ end
66
87
  @q.push [:COMMENT, $&]
67
88
  str = $'
68
89
  when /\A\#(.*)/
69
90
  @q.push [:COMMENT, $&]
70
- str = $'
71
- when /\A\"(.*)\"/
72
91
  str = $'
92
+ when /\A\"(.*)\"/
73
93
  @q.push [:STRING, unescape_string($1)]
94
+ str = $'
74
95
  else
75
96
  #c = str[0,1]
76
97
  #@q.push [:STRING, c]
77
98
  str = str[1..-1]
78
99
  end
79
- end
100
+ end
80
101
  @q.push [false, '$end']
81
102
  if $DEBUG
82
103
  @q.each do |a,b|
@@ -91,7 +112,7 @@ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry',
91
112
  end
92
113
  @data
93
114
  end
94
-
115
+
95
116
  def next_token
96
117
  @q.shift
97
118
  end
@@ -104,175 +125,199 @@ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry',
104
125
  @comments.clear
105
126
  @msgctxt = ""
106
127
  end
107
-
128
+
108
129
  def on_comment(comment)
109
130
  @fuzzy = true if (/fuzzy/ =~ comment)
110
131
  @comments << comment
111
- end
132
+ end
112
133
 
113
- def unescape_string(string)
114
- string.gsub(/\\\\/, "\\")
134
+ def parse_file(po_file, data)
135
+ args = [ po_file ]
136
+ # In Ruby 1.9, we must detect proper encoding of a PO file.
137
+ if String.instance_methods.include?(:encode)
138
+ encoding = detect_file_encoding(po_file)
139
+ args << "r:#{encoding}"
140
+ end
141
+ @po_file = po_file
142
+ parse(File.open(*args) {|io| io.read }, data)
115
143
  end
116
144
 
117
- ..end src/poparser.ry modeval..id7a99570e05
118
-
119
- ##### racc 1.4.5 generates ###
120
-
121
- racc_reduce_table = [
122
- 0, 0, :racc_error,
123
- 0, 10, :_reduce_none,
124
- 2, 10, :_reduce_none,
125
- 2, 10, :_reduce_none,
126
- 2, 10, :_reduce_none,
127
- 2, 12, :_reduce_5,
128
- 1, 13, :_reduce_none,
129
- 1, 13, :_reduce_none,
130
- 4, 15, :_reduce_8,
131
- 5, 16, :_reduce_9,
132
- 2, 17, :_reduce_10,
133
- 1, 17, :_reduce_none,
134
- 3, 18, :_reduce_12,
135
- 1, 11, :_reduce_13,
136
- 2, 14, :_reduce_14,
137
- 1, 14, :_reduce_15 ]
138
-
139
- racc_reduce_n = 16
140
-
141
- racc_shift_n = 26
142
-
143
- racc_action_table = [
144
- 3, 13, 5, 7, 9, 15, 16, 17, 20, 17,
145
- 13, 17, 13, 13, 11, 17, 23, 20, 13, 17 ]
146
-
147
- racc_action_check = [
148
- 1, 16, 1, 1, 1, 12, 12, 12, 18, 18,
149
- 7, 14, 15, 9, 3, 19, 20, 21, 23, 25 ]
150
-
151
- racc_action_pointer = [
152
- nil, 0, nil, 14, nil, nil, nil, 3, nil, 6,
153
- nil, nil, 0, nil, 4, 5, -6, nil, 2, 8,
154
- 8, 11, nil, 11, nil, 12 ]
155
-
156
- racc_action_default = [
157
- -1, -16, -2, -16, -3, -13, -4, -16, -6, -16,
158
- -7, 26, -16, -15, -5, -16, -16, -14, -16, -8,
159
- -16, -9, -11, -16, -10, -12 ]
160
-
161
- racc_goto_table = [
162
- 12, 22, 14, 4, 24, 6, 2, 8, 18, 19,
163
- 10, 21, 1, nil, nil, nil, 25 ]
164
-
165
- racc_goto_check = [
166
- 5, 9, 5, 3, 9, 4, 2, 6, 5, 5,
167
- 7, 8, 1, nil, nil, nil, 5 ]
168
-
169
- racc_goto_pointer = [
170
- nil, 12, 5, 2, 4, -7, 6, 9, -7, -17 ]
171
-
172
- racc_goto_default = [
173
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ]
174
-
175
- racc_token_table = {
176
- false => 0,
177
- Object.new => 1,
178
- :COMMENT => 2,
179
- :MSGID => 3,
180
- :MSGCTXT => 4,
181
- :MSGID_PLURAL => 5,
182
- :MSGSTR => 6,
183
- :STRING => 7,
184
- :PLURAL_NUM => 8 }
185
-
186
- racc_use_result_var = true
187
-
188
- racc_nt_base = 9
189
-
190
- Racc_arg = [
191
- racc_action_table,
192
- racc_action_check,
193
- racc_action_default,
194
- racc_action_pointer,
195
- racc_goto_table,
196
- racc_goto_check,
197
- racc_goto_default,
198
- racc_goto_pointer,
199
- racc_nt_base,
200
- racc_reduce_table,
201
- racc_token_table,
202
- racc_shift_n,
203
- racc_reduce_n,
204
- racc_use_result_var ]
205
-
206
- Racc_token_to_s_table = [
207
- '$end',
208
- 'error',
209
- 'COMMENT',
210
- 'MSGID',
211
- 'MSGCTXT',
212
- 'MSGID_PLURAL',
213
- 'MSGSTR',
214
- 'STRING',
215
- 'PLURAL_NUM',
216
- '$start',
217
- 'msgfmt',
218
- 'comment',
219
- 'msgctxt',
220
- 'message',
221
- 'string_list',
222
- 'single_message',
223
- 'plural_message',
224
- 'msgstr_plural',
225
- 'msgstr_plural_line']
226
-
227
- Racc_debug_parser = true
228
-
229
- ##### racc system variables end #####
230
-
231
- # reduce 0 omitted
232
-
233
- # reduce 1 omitted
234
-
235
- # reduce 2 omitted
236
-
237
- # reduce 3 omitted
238
-
239
- # reduce 4 omitted
240
-
241
- module_eval <<'.,.,', 'src/poparser.ry', 25
242
- def _reduce_5( val, _values, result )
243
- @msgctxt = unescape(val[1]) + "\004"
244
- result
145
+ def detect_file_encoding(po_file)
146
+ open(po_file, :encoding => 'ASCII-8BIT') do |input|
147
+ input.lines.each do |line|
148
+ return Encoding.find($1) if %r["Content-Type:.*\scharset=(.*)\\n"] =~ line
149
+ end
150
+ end
151
+ Encoding.default_external
152
+ end
153
+ private :detect_file_encoding
154
+ ...end poparser.ry/module_eval...
155
+ ##### State transition tables begin ###
156
+
157
+ racc_action_table = [
158
+ 2, 13, 10, 9, 6, 17, 16, 15, 22, 15,
159
+ 15, 13, 13, 13, 15, 11, 22, 24, 13, 15 ]
160
+
161
+ racc_action_check = [
162
+ 1, 17, 1, 1, 1, 14, 14, 14, 19, 19,
163
+ 12, 6, 16, 9, 18, 2, 20, 22, 24, 25 ]
164
+
165
+ racc_action_pointer = [
166
+ nil, 0, 15, nil, nil, nil, 4, nil, nil, 6,
167
+ nil, nil, 3, nil, 0, nil, 5, -6, 7, 2,
168
+ 10, nil, 9, nil, 11, 12 ]
169
+
170
+ racc_action_default = [
171
+ -1, -16, -16, -2, -3, -4, -16, -6, -7, -16,
172
+ -13, 26, -5, -15, -16, -14, -16, -16, -8, -16,
173
+ -9, -11, -16, -10, -16, -12 ]
174
+
175
+ racc_goto_table = [
176
+ 12, 21, 23, 14, 4, 5, 3, 7, 8, 20,
177
+ 18, 19, 1, nil, nil, nil, nil, nil, 25 ]
178
+
179
+ racc_goto_check = [
180
+ 5, 9, 9, 5, 3, 4, 2, 6, 7, 8,
181
+ 5, 5, 1, nil, nil, nil, nil, nil, 5 ]
182
+
183
+ racc_goto_pointer = [
184
+ nil, 12, 5, 3, 4, -6, 6, 7, -10, -18 ]
185
+
186
+ racc_goto_default = [
187
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ]
188
+
189
+ racc_reduce_table = [
190
+ 0, 0, :racc_error,
191
+ 0, 10, :_reduce_none,
192
+ 2, 10, :_reduce_none,
193
+ 2, 10, :_reduce_none,
194
+ 2, 10, :_reduce_none,
195
+ 2, 12, :_reduce_5,
196
+ 1, 13, :_reduce_none,
197
+ 1, 13, :_reduce_none,
198
+ 4, 15, :_reduce_8,
199
+ 5, 16, :_reduce_9,
200
+ 2, 17, :_reduce_10,
201
+ 1, 17, :_reduce_none,
202
+ 3, 18, :_reduce_12,
203
+ 1, 11, :_reduce_13,
204
+ 2, 14, :_reduce_14,
205
+ 1, 14, :_reduce_15 ]
206
+
207
+ racc_reduce_n = 16
208
+
209
+ racc_shift_n = 26
210
+
211
+ racc_token_table = {
212
+ false => 0,
213
+ :error => 1,
214
+ :COMMENT => 2,
215
+ :MSGID => 3,
216
+ :MSGCTXT => 4,
217
+ :MSGID_PLURAL => 5,
218
+ :MSGSTR => 6,
219
+ :STRING => 7,
220
+ :PLURAL_NUM => 8 }
221
+
222
+ racc_nt_base = 9
223
+
224
+ racc_use_result_var = true
225
+
226
+ Racc_arg = [
227
+ racc_action_table,
228
+ racc_action_check,
229
+ racc_action_default,
230
+ racc_action_pointer,
231
+ racc_goto_table,
232
+ racc_goto_check,
233
+ racc_goto_default,
234
+ racc_goto_pointer,
235
+ racc_nt_base,
236
+ racc_reduce_table,
237
+ racc_token_table,
238
+ racc_shift_n,
239
+ racc_reduce_n,
240
+ racc_use_result_var ]
241
+
242
+ Racc_token_to_s_table = [
243
+ "$end",
244
+ "error",
245
+ "COMMENT",
246
+ "MSGID",
247
+ "MSGCTXT",
248
+ "MSGID_PLURAL",
249
+ "MSGSTR",
250
+ "STRING",
251
+ "PLURAL_NUM",
252
+ "$start",
253
+ "msgfmt",
254
+ "comment",
255
+ "msgctxt",
256
+ "message",
257
+ "string_list",
258
+ "single_message",
259
+ "plural_message",
260
+ "msgstr_plural",
261
+ "msgstr_plural_line" ]
262
+
263
+ Racc_debug_parser = true
264
+
265
+ ##### State transition tables end #####
266
+
267
+ # reduce 0 omitted
268
+
269
+ # reduce 1 omitted
270
+
271
+ # reduce 2 omitted
272
+
273
+ # reduce 3 omitted
274
+
275
+ # reduce 4 omitted
276
+
277
+ module_eval(<<'.,.,', 'poparser.ry', 25)
278
+ def _reduce_5(val, _values, result)
279
+ @msgctxt = unescape(val[1]) + "\004"
280
+
281
+ result
245
282
  end
246
283
  .,.,
247
284
 
248
- # reduce 6 omitted
249
-
250
- # reduce 7 omitted
251
-
252
- module_eval <<'.,.,', 'src/poparser.ry', 48
253
- def _reduce_8( val, _values, result )
254
- if @fuzzy and $ignore_fuzzy
255
- if val[1] != ""
256
- $stderr.print _("Warning: fuzzy message was ignored.\n")
257
- $stderr.print " msgid '#{val[1]}'\n"
258
- else
259
- on_message('', unescape(val[3]))
285
+ # reduce 6 omitted
286
+
287
+ # reduce 7 omitted
288
+
289
+ module_eval(<<'.,.,', 'poparser.ry', 37)
290
+ def _reduce_8(val, _values, result)
291
+ msgid_raw = val[1]
292
+ msgid = unescape(msgid_raw)
293
+ msgstr = unescape(val[3])
294
+ use_message_p = true
295
+ if @fuzzy and not msgid.empty?
296
+ use_message_p = (not ignore_fuzzy?)
297
+ if report_warning?
298
+ if ignore_fuzzy?
299
+ $stderr.print _("Warning: fuzzy message was ignored.\n")
300
+ else
301
+ $stderr.print _("Warning: fuzzy message was used.\n")
302
+ end
303
+ $stderr.print " #{@po_file}: msgid '#{msgid_raw}'\n"
260
304
  end
261
- @fuzzy = false
262
- else
263
- on_message(@msgctxt + unescape(val[1]), unescape(val[3]))
264
305
  end
306
+ @fuzzy = false
307
+ on_message(@msgctxt + msgid, msgstr) if use_message_p
265
308
  result = ""
266
- result
309
+ result
267
310
  end
268
311
  .,.,
269
312
 
270
- module_eval <<'.,.,', 'src/poparser.ry', 65
271
- def _reduce_9( val, _values, result )
272
- if @fuzzy and $ignore_fuzzy
313
+ module_eval(<<'.,.,', 'poparser.ry', 60)
314
+ def _reduce_9(val, _values, result)
315
+ if @fuzzy and ignore_fuzzy?
273
316
  if val[1] != ""
274
- $stderr.print _("Warning: fuzzy message was ignored.\n")
275
- $stderr.print "msgid = '#{val[1]}\n"
317
+ if report_warning?
318
+ $stderr.print _("Warning: fuzzy message was ignored.\n")
319
+ $stderr.print "msgid = '#{val[1]}\n"
320
+ end
276
321
  else
277
322
  on_message('', unescape(val[3]))
278
323
  end
@@ -281,56 +326,61 @@ module_eval <<'.,.,', 'src/poparser.ry', 65
281
326
  on_message(@msgctxt + unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4]))
282
327
  end
283
328
  result = ""
284
- result
329
+
330
+ result
285
331
  end
286
332
  .,.,
287
333
 
288
- module_eval <<'.,.,', 'src/poparser.ry', 76
289
- def _reduce_10( val, _values, result )
290
- if val[0].size > 0
334
+ module_eval(<<'.,.,', 'poparser.ry', 80)
335
+ def _reduce_10(val, _values, result)
336
+ if val[0].size > 0
291
337
  result = val[0] + "\000" + val[1]
292
338
  else
293
339
  result = ""
294
340
  end
295
- result
341
+
342
+ result
296
343
  end
297
344
  .,.,
298
345
 
299
- # reduce 11 omitted
346
+ # reduce 11 omitted
347
+
348
+ module_eval(<<'.,.,', 'poparser.ry', 92)
349
+ def _reduce_12(val, _values, result)
350
+ result = val[2]
300
351
 
301
- module_eval <<'.,.,', 'src/poparser.ry', 84
302
- def _reduce_12( val, _values, result )
303
- result = val[2]
304
- result
352
+ result
305
353
  end
306
354
  .,.,
307
355
 
308
- module_eval <<'.,.,', 'src/poparser.ry', 91
309
- def _reduce_13( val, _values, result )
310
- on_comment(val[0])
311
- result
356
+ module_eval(<<'.,.,', 'poparser.ry', 99)
357
+ def _reduce_13(val, _values, result)
358
+ on_comment(val[0])
359
+
360
+ result
312
361
  end
313
362
  .,.,
314
363
 
315
- module_eval <<'.,.,', 'src/poparser.ry', 99
316
- def _reduce_14( val, _values, result )
317
- result = val.delete_if{|item| item == ""}.join
318
- result
364
+ module_eval(<<'.,.,', 'poparser.ry', 107)
365
+ def _reduce_14(val, _values, result)
366
+ result = val.delete_if{|item| item == ""}.join
367
+
368
+ result
319
369
  end
320
370
  .,.,
321
371
 
322
- module_eval <<'.,.,', 'src/poparser.ry', 103
323
- def _reduce_15( val, _values, result )
324
- result = val[0]
325
- result
372
+ module_eval(<<'.,.,', 'poparser.ry', 111)
373
+ def _reduce_15(val, _values, result)
374
+ result = val[0]
375
+
376
+ result
326
377
  end
327
378
  .,.,
328
379
 
329
- def _reduce_none( val, _values, result )
330
- result
331
- end
380
+ def _reduce_none(val, _values, result)
381
+ val[0]
382
+ end
332
383
 
333
384
  end # class PoParser
334
-
335
385
  end # module GetText
336
386
  end
@@ -1,3 +1,3 @@
1
1
  module FastGettext
2
- VERSION = Version = '0.6.7'
2
+ VERSION = Version = '0.6.8'
3
3
  end
@@ -28,14 +28,26 @@ describe 'FastGettext::TranslationRepository::Po' do
28
28
  end
29
29
 
30
30
  describe 'fuzzy' do
31
- it "should warn on fuzzy by default" do
31
+ before do
32
+ @fuzzy = File.join('spec','fuzzy_locale')
33
+ end
34
+
35
+ it "should use fuzzy by default" do
36
+ $stderr.should_receive(:print).at_least(:once)
37
+ repo = FastGettext::TranslationRepository.build('test',:path=>@fuzzy,:type=>:po)
38
+ repo["%{relative_time} ago"].should == "vor %{relative_time}"
39
+ end
40
+
41
+ it "should warn on fuzzy when ignoring" do
32
42
  $stderr.should_receive(:print).at_least(:once)
33
- FastGettext::TranslationRepository.build('test',:path=>File.join('spec','fuzzy_locale'),:type=>:po)
43
+ repo = FastGettext::TranslationRepository.build('test',:path=>@fuzzy,:type=>:po, :ignore_fuzzy => true)
44
+ repo["%{relative_time} ago"].should == nil
34
45
  end
35
46
 
36
- it "should ignore fuzzy when told to do so" do
47
+ it "should ignore fuzzy and not report when told to do so" do
37
48
  $stderr.should_not_receive(:print)
38
- FastGettext::TranslationRepository.build('test',:path=>File.join('spec','fuzzy_locale'),:type=>:po, :ignore_fuzzy => true)
49
+ repo = FastGettext::TranslationRepository.build('test',:path=>@fuzzy,:type=>:po, :ignore_fuzzy => true, :report_warning => false)
50
+ repo["%{relative_time} ago"].should == nil
39
51
  end
40
52
  end
41
53
 
@@ -47,7 +59,7 @@ describe 'FastGettext::TranslationRepository::Po' do
47
59
 
48
60
  it "should ignore obsolete when told to do so" do
49
61
  $stderr.should_not_receive(:print)
50
- FastGettext::TranslationRepository.build('test',:path=>File.join('spec','obsolete_locale'),:type=>:po, :ignore_obsolete => true)
62
+ FastGettext::TranslationRepository.build('test',:path=>File.join('spec','obsolete_locale'),:type=>:po, :report_warning => false)
51
63
  end
52
64
  end
53
65
  end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,12 @@
1
1
  # $VERBOSE = true # ignore complaints in spec files
2
2
 
3
3
  # ---- requirements
4
- require 'rubygems'
5
4
  $LOAD_PATH.unshift File.expand_path("../lib", File.dirname(__FILE__))
6
5
  require 'fast_gettext'
7
6
 
8
7
  # ---- revert to defaults
9
8
  RSpec.configure do |config|
10
- config.before :all do
9
+ config.before do
11
10
  FastGettext.locale = 'de'
12
11
  FastGettext.available_locales = nil
13
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-09 00:00:00.000000000 Z
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: michael@grosser.it
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: 2481622648606723903
113
+ hash: -3956951288386353458
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements:
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  segments:
121
121
  - 0
122
- hash: 2481622648606723903
122
+ hash: -3956951288386353458
123
123
  requirements: []
124
124
  rubyforge_project:
125
125
  rubygems_version: 1.8.24