gettext 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_po.rb CHANGED
@@ -504,4 +504,19 @@ msgstr ""
504
504
  end
505
505
  end
506
506
  end
507
+
508
+ class TestEmpty < self
509
+ def setup
510
+ @po = GetText::PO.new
511
+ end
512
+
513
+ def test_true
514
+ assert_true(@po.empty?)
515
+ end
516
+
517
+ def test_false
518
+ @po["Hello"] = "Bonjour"
519
+ assert_false(@po.empty?)
520
+ end
521
+ end
507
522
  end
@@ -378,6 +378,23 @@ msgstr ""
378
378
  PO
379
379
  end
380
380
  end
381
+
382
+ class TestEncoding < self
383
+ def setup
384
+ @entry = GetText::POEntry.new(:normal)
385
+ @entry.msgid = "hello"
386
+ @entry.msgstr = "こんにちは"
387
+ end
388
+
389
+ def test_default
390
+ assert_equal(Encoding::UTF_8, @entry.to_s.encoding)
391
+ end
392
+
393
+ def test_valid
394
+ assert_equal(Encoding::EUC_JP,
395
+ @entry.to_s(:encoding => "EUC-JP").encoding)
396
+ end
397
+ end
381
398
  end
382
399
  end
383
400
 
@@ -313,8 +313,7 @@ msgstr ""
313
313
  pot_content = generate(":hello", "--package-name", package_name)
314
314
 
315
315
  options = {:package_name => package_name}
316
- expected_header = "#{header(options)}\n"
317
- assert_equal(expected_header, pot_content)
316
+ assert_equal(header(options), pot_content)
318
317
  end
319
318
 
320
319
  def test_package_version
@@ -322,8 +321,7 @@ msgstr ""
322
321
  pot_content = generate(":hello", "--package-version", package_version)
323
322
 
324
323
  options = {:package_version => package_version}
325
- expected_header = "#{header(options)}\n"
326
- assert_equal(expected_header, pot_content)
324
+ assert_equal(header(options), pot_content)
327
325
  end
328
326
 
329
327
  def test_report_msgid_bugs_to
@@ -332,8 +330,7 @@ msgstr ""
332
330
  "--msgid-bugs-address", msgid_bugs_address)
333
331
 
334
332
  options = {:msgid_bugs_address => msgid_bugs_address}
335
- expected_header = "#{header(options)}\n"
336
- assert_equal(expected_header, pot_content)
333
+ assert_equal(header(options), pot_content)
337
334
  end
338
335
 
339
336
  def test_copyright_holder
@@ -341,8 +338,7 @@ msgstr ""
341
338
  pot_content = generate(":hello", "--copyright-holder", copyright_holder)
342
339
 
343
340
  options = {:copyright_holder => copyright_holder}
344
- expected_header = "#{header(options)}\n"
345
- assert_equal(expected_header, pot_content)
341
+ assert_equal(header(options), pot_content)
346
342
  end
347
343
 
348
344
  def test_to_code
@@ -365,6 +361,189 @@ EOP
365
361
 
366
362
  assert_equal(expected_pot, pot_content)
367
363
  end
364
+
365
+ class TestLocation < self
366
+ def test_default
367
+ assert_equal(<<-POT, generate("_('hello')"))
368
+ #{header}
369
+ #: ../lib/xgettext.rb:1
370
+ msgid "hello"
371
+ msgstr ""
372
+ POT
373
+ end
374
+
375
+ def test_location
376
+ assert_equal(<<-POT, generate("_('hello')", "--location"))
377
+ #{header}
378
+ #: ../lib/xgettext.rb:1
379
+ msgid "hello"
380
+ msgstr ""
381
+ POT
382
+ end
383
+
384
+ def test_no_location
385
+ assert_equal(<<-POT, generate("_('hello')", "--no-location"))
386
+ #{header}
387
+ msgid "hello"
388
+ msgstr ""
389
+ POT
390
+ end
391
+ end
392
+
393
+ class TestSort < self
394
+ def setup
395
+ super
396
+ @code = <<-RUBY
397
+ RUBY
398
+ end
399
+
400
+ def test_default
401
+ assert_equal(<<-POT, generate)
402
+ #{header}
403
+ #: ../lib/xgettext.rb:1
404
+ msgid "World"
405
+ msgstr ""
406
+
407
+ #: ../lib/xgettext.rb:2
408
+ msgid "Hello"
409
+ msgstr ""
410
+
411
+ #: ../templates/xgettext.rhtml:1
412
+ msgid "ABC"
413
+ msgstr ""
414
+
415
+ #: ../templates/xgettext.rhtml:2
416
+ msgid "123"
417
+ msgstr ""
418
+ POT
419
+ end
420
+
421
+ def test_no_sort_output
422
+ assert_equal(<<-POT, generate("--no-sort-output"))
423
+ #{header}
424
+ #: ../templates/xgettext.rhtml:1
425
+ msgid "ABC"
426
+ msgstr ""
427
+
428
+ #: ../templates/xgettext.rhtml:2
429
+ msgid "123"
430
+ msgstr ""
431
+
432
+ #: ../lib/xgettext.rb:1
433
+ msgid "World"
434
+ msgstr ""
435
+
436
+ #: ../lib/xgettext.rb:2
437
+ msgid "Hello"
438
+ msgstr ""
439
+ POT
440
+ end
441
+
442
+ def test_sort_by_file
443
+ assert_equal(<<-POT, generate("--sort-by-file"))
444
+ #{header}
445
+ #: ../lib/xgettext.rb:1
446
+ msgid "World"
447
+ msgstr ""
448
+
449
+ #: ../lib/xgettext.rb:2
450
+ msgid "Hello"
451
+ msgstr ""
452
+
453
+ #: ../templates/xgettext.rhtml:1
454
+ msgid "ABC"
455
+ msgstr ""
456
+
457
+ #: ../templates/xgettext.rhtml:2
458
+ msgid "123"
459
+ msgstr ""
460
+ POT
461
+ end
462
+
463
+ def test_sort_by_msgid
464
+ assert_equal(<<-POT, generate("--sort-by-msgid"))
465
+ #{header}
466
+ #: ../templates/xgettext.rhtml:2
467
+ msgid "123"
468
+ msgstr ""
469
+
470
+ #: ../templates/xgettext.rhtml:1
471
+ msgid "ABC"
472
+ msgstr ""
473
+
474
+ #: ../lib/xgettext.rb:2
475
+ msgid "Hello"
476
+ msgstr ""
477
+
478
+ #: ../lib/xgettext.rb:1
479
+ msgid "World"
480
+ msgstr ""
481
+ POT
482
+ end
483
+
484
+ private
485
+ def generate(*command_line_options)
486
+ File.open(@rhtml_file_path, "w") do |rhtml_file|
487
+ rhtml_file.puts(<<-RHTML)
488
+ <%= _("ABC") %>
489
+ <%= _("123") %>
490
+ RHTML
491
+ end
492
+
493
+ File.open(@rb_file_path, "w") do |rb_file|
494
+ rb_file.puts(<<-RUBY)
495
+ _('World')
496
+ _('Hello')
497
+ RUBY
498
+ end
499
+
500
+ command_line = ["--output", @pot_file_path]
501
+ command_line += command_line_options
502
+ command_line += [@rhtml_file_path, @rb_file_path]
503
+ @xgettext.run(*command_line)
504
+
505
+ File.read(@pot_file_path)
506
+ end
507
+ end
508
+
509
+ class TestWidth < self
510
+ def msgid
511
+ <<-MSGID.chomp
512
+ Hello very long line! This line is very long. Yes! This line is very long! Very very long line!
513
+ MSGID
514
+ end
515
+
516
+ def test_default
517
+ assert_equal(<<-POT, generate("_('#{msgid}')"))
518
+ #{header}
519
+ #: ../lib/xgettext.rb:1
520
+ msgid ""
521
+ "Hello very long line! This line is very long. Yes! This line is very long! Ver"
522
+ "y very long line!"
523
+ msgstr ""
524
+ POT
525
+ end
526
+
527
+ def test_width
528
+ assert_equal(<<-POT, generate("_('#{msgid}')", "--width", "70"))
529
+ #{header}
530
+ #: ../lib/xgettext.rb:1
531
+ msgid ""
532
+ "Hello very long line! This line is very long. Yes! This line is very l"
533
+ "ong! Very very long line!"
534
+ msgstr ""
535
+ POT
536
+ end
537
+
538
+ def test_no_wrap
539
+ assert_equal(<<-POT, generate("_('#{msgid}')", "--no-wrap"))
540
+ #{header}
541
+ #: ../lib/xgettext.rb:1
542
+ msgid "Hello very long line! This line is very long. Yes! This line is very long! Very very long line!"
543
+ msgstr ""
544
+ POT
545
+ end
546
+ end
368
547
  end
369
548
 
370
549
  class TestAddParser < self
@@ -399,7 +578,7 @@ EOP
399
578
  po_entry = GetText::POEntry.new(:normal)
400
579
  po_entry.msgid = "Message"
401
580
  assert_equal([po_entry],
402
- xgettext.parse(["index.html"]))
581
+ xgettext.parse(["index.html"]).to_a)
403
582
  end
404
583
 
405
584
  def test_instance_method
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-20 00:00:00.000000000 Z
13
+ date: 2013-09-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: locale