review 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +90 -66
- data/.travis.yml +1 -1
- data/Gemfile +0 -1
- data/NEWS.ja.md +82 -0
- data/NEWS.md +83 -0
- data/README.md +5 -3
- data/Rakefile +8 -8
- data/bin/review +1 -5
- data/bin/review-catalog-converter +22 -27
- data/bin/review-check +36 -43
- data/bin/review-checkdep +10 -15
- data/bin/review-compile +37 -55
- data/bin/review-epubmaker +4 -5
- data/bin/review-index +21 -29
- data/bin/review-init +26 -37
- data/bin/review-pdfmaker +0 -2
- data/bin/review-preproc +25 -45
- data/bin/review-validate +19 -18
- data/bin/review-vol +15 -27
- data/doc/config.yml.sample +5 -2
- data/doc/format.ja.md +20 -1
- data/doc/format.md +21 -5
- data/doc/images/review-generate.png +0 -0
- data/lib/epubmaker.rb +1 -3
- data/lib/epubmaker/content.rb +24 -27
- data/lib/epubmaker/epubcommon.rb +135 -148
- data/lib/epubmaker/epubv2.rb +39 -46
- data/lib/epubmaker/epubv3.rb +93 -103
- data/lib/epubmaker/producer.rb +138 -151
- data/lib/epubmaker/zip_exporter.rb +21 -26
- data/lib/review/book.rb +3 -6
- data/lib/review/book/base.rb +78 -103
- data/lib/review/book/chapter.rb +36 -40
- data/lib/review/book/compilable.rb +28 -31
- data/lib/review/book/image_finder.rb +6 -13
- data/lib/review/book/index.rb +100 -121
- data/lib/review/book/page_metric.rb +2 -7
- data/lib/review/book/part.rb +18 -20
- data/lib/review/book/volume.rb +9 -13
- data/lib/review/builder.rb +81 -116
- data/lib/review/catalog.rb +15 -19
- data/lib/review/compiler.rb +64 -83
- data/lib/review/configure.rb +87 -97
- data/lib/review/converter.rb +2 -7
- data/lib/review/epubbuilder.rb +1 -3
- data/lib/review/epubmaker.rb +213 -205
- data/lib/review/exception.rb +2 -4
- data/lib/review/extentions.rb +0 -1
- data/lib/review/extentions/hash.rb +2 -2
- data/lib/review/extentions/string.rb +5 -30
- data/lib/review/htmlbuilder.rb +320 -375
- data/lib/review/htmltoc.rb +4 -7
- data/lib/review/htmlutils.rb +29 -32
- data/lib/review/i18n.rb +33 -44
- data/lib/review/i18n.yml +3 -3
- data/lib/review/idgxmlbuilder.rb +309 -345
- data/lib/review/latexbuilder.rb +175 -212
- data/lib/review/latexindex.rb +2 -8
- data/lib/review/latexutils.rb +33 -43
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +21 -0
- data/lib/review/makerhelper.rb +1 -4
- data/lib/review/markdownbuilder.rb +44 -53
- data/lib/review/md2inaobuilder.rb +6 -12
- data/lib/review/pdfmaker.rb +143 -173
- data/lib/review/preprocessor.rb +64 -101
- data/lib/review/rstbuilder.rb +126 -158
- data/lib/review/sec_counter.rb +18 -34
- data/lib/review/template.rb +4 -5
- data/lib/review/textbuilder.rb +2 -3
- data/lib/review/textutils.rb +7 -13
- data/lib/review/tocparser.rb +31 -56
- data/lib/review/tocprinter.rb +26 -52
- data/lib/review/topbuilder.rb +219 -247
- data/lib/review/unfold.rb +15 -24
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +75 -99
- data/lib/review/webtocprinter.rb +15 -20
- data/lib/review/yamlloader.rb +13 -15
- data/review.gemspec +20 -22
- data/templates/latex/layout.tex.erb +2 -2
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/black.eps +280 -0
- data/test/assets/fit.png +0 -0
- data/test/assets/large.gif +0 -0
- data/test/assets/large.jpg +0 -0
- data/test/assets/large.png +0 -0
- data/test/assets/large.svg +65 -0
- data/test/assets/test_template.tex +1 -1
- data/test/book_test_helper.rb +2 -2
- data/test/run_test.rb +4 -4
- data/test/sample-book/src/Rakefile +21 -22
- data/test/syntax-book/Gemfile +4 -0
- data/test/syntax-book/Rakefile +72 -0
- data/test/syntax-book/appA.re +22 -0
- data/test/syntax-book/bib.re +6 -0
- data/test/syntax-book/catalog.yml +15 -0
- data/test/syntax-book/ch01.re +136 -0
- data/test/syntax-book/ch02.re +351 -0
- data/test/syntax-book/ch03.re +82 -0
- data/test/syntax-book/config.yml +35 -0
- data/test/syntax-book/images/ball.png +0 -0
- data/test/syntax-book/images/cover.jpg +0 -0
- data/test/syntax-book/images/fractal.png +0 -0
- data/test/syntax-book/images/img3-1.png +0 -0
- data/test/syntax-book/images/inlineicon.jpg +0 -0
- data/test/syntax-book/images/logic.png +0 -0
- data/test/syntax-book/images/logic2.png +0 -0
- data/test/syntax-book/images/puzzle.jpg +0 -0
- data/test/syntax-book/images/table.jpg +0 -0
- data/test/syntax-book/part2.re +6 -0
- data/test/syntax-book/pre01.re +26 -0
- data/test/syntax-book/review-ext.rb +14 -0
- data/test/syntax-book/sty/jumoline.sty +310 -0
- data/test/syntax-book/sty/reviewmacro.sty +39 -0
- data/test/syntax-book/style.css +494 -0
- data/test/syntax-book/syntax.dic +2 -0
- data/test/test_book.rb +106 -111
- data/test/test_book_chapter.rb +21 -22
- data/test/test_book_part.rb +3 -5
- data/test/test_builder.rb +11 -22
- data/test/test_catalog.rb +17 -18
- data/test/test_catalog_converter_cmd.rb +5 -5
- data/test/test_compiler.rb +18 -16
- data/test/test_configure.rb +35 -38
- data/test/test_converter.rb +3 -4
- data/test/test_epub3maker.rb +136 -117
- data/test/test_epubmaker.rb +107 -114
- data/test/test_epubmaker_cmd.rb +2 -4
- data/test/test_extentions_hash.rb +32 -33
- data/test/test_helper.rb +9 -11
- data/test/test_htmlbuilder.rb +454 -420
- data/test/test_htmltoc.rb +8 -12
- data/test/test_htmlutils.rb +0 -2
- data/test/test_i18n.rb +159 -150
- data/test/test_idgxmlbuilder.rb +190 -197
- data/test/test_image_finder.rb +21 -22
- data/test/test_index.rb +24 -29
- data/test/test_latexbuilder.rb +274 -264
- data/test/test_lineinput.rb +7 -10
- data/test/test_location.rb +7 -7
- data/test/test_makerhelper.rb +13 -25
- data/test/test_markdownbuilder.rb +23 -26
- data/test/test_md2inaobuilder.rb +8 -11
- data/test/test_pdfmaker.rb +114 -123
- data/test/test_pdfmaker_cmd.rb +1 -3
- data/test/test_review_ext.rb +3 -5
- data/test/test_rstbuilder.rb +92 -97
- data/test/test_template.rb +3 -7
- data/test/test_textutils.rb +27 -27
- data/test/test_tocparser.rb +2 -2
- data/test/test_topbuilder.rb +98 -103
- data/test/test_webtocprinter.rb +5 -6
- data/test/test_yamlloader.rb +42 -42
- data/test/test_zip_exporter.rb +12 -18
- metadata +86 -9
- data/lib/review/ewbbuilder.rb +0 -382
data/test/test_htmltoc.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'test_helper'
|
4
2
|
require 'review/htmltoc'
|
5
3
|
|
@@ -13,21 +11,19 @@ class HTMLTocTest < Test::Unit::TestCase
|
|
13
11
|
end
|
14
12
|
|
15
13
|
def test_tocfilename
|
16
|
-
toc = HTMLToc.new(
|
17
|
-
assert_equal
|
14
|
+
toc = HTMLToc.new('/var/tmp')
|
15
|
+
assert_equal '/var/tmp/toc-html.txt', toc.tocfilename
|
18
16
|
end
|
19
17
|
|
20
18
|
def test_encode_args
|
21
|
-
toc = HTMLToc.new(
|
22
|
-
assert_equal
|
23
|
-
assert_equal
|
19
|
+
toc = HTMLToc.new('/var/tmp')
|
20
|
+
assert_equal 'chaptype=pre', toc.encode_args(chaptype: 'pre')
|
21
|
+
assert_equal 'force_include=true,chaptype=body,properties=foo', toc.encode_args({ force_include: true, chaptype: 'body', 'properties' => 'foo' })
|
24
22
|
end
|
25
23
|
|
26
24
|
def test_decode_args
|
27
|
-
toc = HTMLToc.new(
|
28
|
-
assert_equal({:
|
29
|
-
assert_equal({:
|
25
|
+
toc = HTMLToc.new('/var/tmp')
|
26
|
+
assert_equal({ chaptype: 'pre' }, toc.decode_args('chaptype=pre'))
|
27
|
+
assert_equal({ force_include: 'true', chaptype: 'body', properties: 'foo' }, toc.decode_args('force_include=true,chaptype=body,properties=foo'))
|
30
28
|
end
|
31
|
-
|
32
29
|
end
|
33
|
-
|
data/test/test_htmlutils.rb
CHANGED
data/test/test_i18n.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require 'test_helper'
|
3
2
|
require 'review'
|
4
3
|
require 'tmpdir'
|
@@ -9,10 +8,10 @@ class I18nTest < Test::Unit::TestCase
|
|
9
8
|
def test_load_locale_yml
|
10
9
|
Dir.mktmpdir do |dir|
|
11
10
|
Dir.chdir(dir) do
|
12
|
-
file = File.join(dir,
|
13
|
-
File.open(file,
|
11
|
+
file = File.join(dir, 'locale.yml')
|
12
|
+
File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
|
14
13
|
I18n.setup
|
15
|
-
assert_equal
|
14
|
+
assert_equal 'bar', I18n.t('foo')
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -20,8 +19,8 @@ class I18nTest < Test::Unit::TestCase
|
|
20
19
|
def test_load_locale_yaml
|
21
20
|
Dir.mktmpdir do |dir|
|
22
21
|
Dir.chdir(dir) do
|
23
|
-
file = File.join(dir,
|
24
|
-
File.open(file,
|
22
|
+
file = File.join(dir, 'locale.yaml')
|
23
|
+
File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
|
25
24
|
assert_raise ReVIEW::ConfigError do
|
26
25
|
I18n.setup
|
27
26
|
end
|
@@ -32,10 +31,10 @@ class I18nTest < Test::Unit::TestCase
|
|
32
31
|
def test_load_foo_yaml
|
33
32
|
Dir.mktmpdir do |dir|
|
34
33
|
Dir.chdir(dir) do
|
35
|
-
file = File.join(dir,
|
36
|
-
File.open(file,
|
37
|
-
I18n.setup(
|
38
|
-
assert_equal
|
34
|
+
file = File.join(dir, 'foo.yml')
|
35
|
+
File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
|
36
|
+
I18n.setup('ja', 'foo.yml')
|
37
|
+
assert_equal 'bar', I18n.t('foo')
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
@@ -43,11 +42,11 @@ class I18nTest < Test::Unit::TestCase
|
|
43
42
|
def test_update_foo_yaml
|
44
43
|
Dir.mktmpdir do |dir|
|
45
44
|
Dir.chdir(dir) do
|
46
|
-
file = File.join(dir,
|
47
|
-
File.open(file,
|
48
|
-
i18n = ReVIEW::I18n.new(
|
49
|
-
i18n.update_localefile(File.join(Dir.pwd,
|
50
|
-
assert_equal
|
45
|
+
file = File.join(dir, 'foo.yml')
|
46
|
+
File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
|
47
|
+
i18n = ReVIEW::I18n.new('ja')
|
48
|
+
i18n.update_localefile(File.join(Dir.pwd, 'foo.yml'))
|
49
|
+
assert_equal 'bar', i18n.t('foo')
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
@@ -55,10 +54,10 @@ class I18nTest < Test::Unit::TestCase
|
|
55
54
|
def test_update_foo_yaml_i18nclass
|
56
55
|
Dir.mktmpdir do |dir|
|
57
56
|
Dir.chdir(dir) do
|
58
|
-
file = File.join(dir,
|
59
|
-
File.open(file,
|
60
|
-
I18n.setup(
|
61
|
-
assert_equal
|
57
|
+
file = File.join(dir, 'foo.yml')
|
58
|
+
File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
|
59
|
+
I18n.setup('ja', 'foo.yml')
|
60
|
+
assert_equal 'bar', I18n.t('foo')
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|
@@ -66,14 +65,14 @@ class I18nTest < Test::Unit::TestCase
|
|
66
65
|
def test_load_locale_yml_i18n
|
67
66
|
Dir.mktmpdir do |dir|
|
68
67
|
Dir.chdir(dir) do
|
69
|
-
file = File.join(dir,
|
70
|
-
File.open(file,
|
68
|
+
file = File.join(dir, 'locale.yml')
|
69
|
+
File.open(file, 'w') { |f| f.write(%Q(ja:\n foo: "bar"\nen:\n foo: "buz"\n)) }
|
71
70
|
I18n.setup
|
72
|
-
assert_equal
|
73
|
-
assert_equal
|
74
|
-
I18n.setup(
|
75
|
-
assert_equal
|
76
|
-
assert_equal
|
71
|
+
assert_equal 'bar', I18n.t('foo')
|
72
|
+
assert_equal '図', I18n.t('image')
|
73
|
+
I18n.setup('en')
|
74
|
+
assert_equal 'buz', I18n.t('foo')
|
75
|
+
assert_equal 'Figure ', I18n.t('image')
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|
@@ -81,8 +80,8 @@ class I18nTest < Test::Unit::TestCase
|
|
81
80
|
def test_load_locale_invalid_yml
|
82
81
|
Dir.mktmpdir do |dir|
|
83
82
|
Dir.chdir(dir) do
|
84
|
-
file = File.join(dir,
|
85
|
-
File.open(file,
|
83
|
+
file = File.join(dir, 'locale.yml')
|
84
|
+
File.open(file, 'w') { |f| f.write(%Q(local: ja\nfoo: "bar"\n)) }
|
86
85
|
assert_raises(ReVIEW::KeyError) do
|
87
86
|
I18n.setup
|
88
87
|
end
|
@@ -93,62 +92,62 @@ class I18nTest < Test::Unit::TestCase
|
|
93
92
|
def test_custom_format
|
94
93
|
Dir.mktmpdir do |dir|
|
95
94
|
Dir.chdir(dir) do
|
96
|
-
file = File.join(dir,
|
97
|
-
File.open(file,
|
98
|
-
I18n.setup(
|
99
|
-
assert_equal
|
100
|
-
|
101
|
-
File.open(file,
|
102
|
-
I18n.setup(
|
103
|
-
assert_equal
|
104
|
-
|
105
|
-
File.open(file,
|
106
|
-
I18n.setup(
|
107
|
-
assert_equal
|
108
|
-
|
109
|
-
File.open(file,
|
110
|
-
I18n.setup(
|
111
|
-
assert_equal
|
112
|
-
|
113
|
-
File.open(file,
|
114
|
-
I18n.setup(
|
115
|
-
assert_equal
|
116
|
-
|
117
|
-
File.open(file,
|
118
|
-
I18n.setup(
|
119
|
-
assert_equal
|
120
|
-
|
121
|
-
File.open(file,
|
122
|
-
I18n.setup(
|
123
|
-
assert_equal
|
124
|
-
|
125
|
-
File.open(file,
|
126
|
-
I18n.setup(
|
127
|
-
assert_equal
|
128
|
-
|
129
|
-
File.open(file,
|
130
|
-
I18n.setup(
|
131
|
-
assert_equal
|
132
|
-
|
133
|
-
File.open(file,
|
134
|
-
I18n.setup(
|
135
|
-
assert_equal
|
136
|
-
|
137
|
-
File.open(file,
|
138
|
-
I18n.setup(
|
139
|
-
assert_equal
|
140
|
-
|
141
|
-
File.open(file,
|
142
|
-
I18n.setup(
|
143
|
-
assert_equal
|
144
|
-
|
145
|
-
File.open(file,
|
146
|
-
I18n.setup(
|
147
|
-
assert_equal
|
148
|
-
|
149
|
-
File.open(file,
|
150
|
-
I18n.setup(
|
151
|
-
assert_equal
|
95
|
+
file = File.join(dir, 'locale.yml')
|
96
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pa章") }
|
97
|
+
I18n.setup('ja')
|
98
|
+
assert_equal '第a章', I18n.t('chapter', 1)
|
99
|
+
|
100
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pA章") }
|
101
|
+
I18n.setup('ja')
|
102
|
+
assert_equal '第B章', I18n.t('chapter', 2)
|
103
|
+
|
104
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pAW章") }
|
105
|
+
I18n.setup('ja')
|
106
|
+
assert_equal '第B章', I18n.t('chapter', 2)
|
107
|
+
|
108
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%paW章") }
|
109
|
+
I18n.setup('ja')
|
110
|
+
assert_equal '第b章', I18n.t('chapter', 2)
|
111
|
+
|
112
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pR章") }
|
113
|
+
I18n.setup('ja')
|
114
|
+
assert_equal '第I章', I18n.t('chapter', 1)
|
115
|
+
|
116
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pr章") }
|
117
|
+
I18n.setup('ja')
|
118
|
+
assert_equal '第ii章', I18n.t('chapter', 2)
|
119
|
+
|
120
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pRW章") }
|
121
|
+
I18n.setup('ja')
|
122
|
+
assert_equal '第Ⅻ章', I18n.t('chapter', 12)
|
123
|
+
|
124
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pJ章") }
|
125
|
+
I18n.setup('ja')
|
126
|
+
assert_equal '第二十七章', I18n.t('chapter', 27)
|
127
|
+
|
128
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pdW章") }
|
129
|
+
I18n.setup('ja')
|
130
|
+
assert_equal '第1章', I18n.t('chapter', 1)
|
131
|
+
|
132
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pdW章") }
|
133
|
+
I18n.setup('ja')
|
134
|
+
assert_equal '第27章', I18n.t('chapter', 27)
|
135
|
+
|
136
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pDW章") }
|
137
|
+
I18n.setup('ja')
|
138
|
+
assert_equal '第1章', I18n.t('chapter', 1)
|
139
|
+
|
140
|
+
File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pDW章") }
|
141
|
+
I18n.setup('ja')
|
142
|
+
assert_equal '第27章', I18n.t('chapter', 27)
|
143
|
+
|
144
|
+
File.open(file, 'w') { |f| f.write("locale: ja\npart: Part %pRW") }
|
145
|
+
I18n.setup('ja')
|
146
|
+
assert_equal 'Part 0', I18n.t('part', 0)
|
147
|
+
|
148
|
+
File.open(file, 'w') { |f| f.write("locale: ja\npart: 第%pJ部") }
|
149
|
+
I18n.setup('ja')
|
150
|
+
assert_equal '第一部', I18n.t('part', 1)
|
152
151
|
end
|
153
152
|
end
|
154
153
|
end
|
@@ -156,27 +155,27 @@ class I18nTest < Test::Unit::TestCase
|
|
156
155
|
def test_custom_format_numbers
|
157
156
|
Dir.mktmpdir do |dir|
|
158
157
|
Dir.chdir(dir) do
|
159
|
-
file = File.join(dir,
|
158
|
+
file = File.join(dir, 'locale.yml')
|
160
159
|
|
161
|
-
File.open(file,
|
162
|
-
I18n.setup(
|
163
|
-
assert_equal
|
160
|
+
File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%s-%pA:") }
|
161
|
+
I18n.setup('ja')
|
162
|
+
assert_equal '1-B:', I18n.t('format_number_header', [1, 2])
|
164
163
|
|
165
|
-
File.open(file,
|
166
|
-
I18n.setup(
|
167
|
-
assert_equal
|
164
|
+
File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%s.%pa:") }
|
165
|
+
I18n.setup('ja')
|
166
|
+
assert_equal '2.c:', I18n.t('format_number_header', [2, 3])
|
168
167
|
|
169
|
-
File.open(file,
|
170
|
-
I18n.setup(
|
171
|
-
assert_equal
|
168
|
+
File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%pA,%pAW:") }
|
169
|
+
I18n.setup('ja')
|
170
|
+
assert_equal 'C,D:', I18n.t('format_number_header', [3, 4])
|
172
171
|
|
173
|
-
File.open(file,
|
174
|
-
I18n.setup(
|
175
|
-
assert_equal
|
172
|
+
File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%pJ・%pJ:") }
|
173
|
+
I18n.setup('ja')
|
174
|
+
assert_equal '十二・二十六:', I18n.t('format_number_header', [12, 26])
|
176
175
|
|
177
|
-
File.open(file,
|
178
|
-
I18n.setup(
|
179
|
-
assert_equal
|
176
|
+
File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%pdW―%pdW:") }
|
177
|
+
I18n.setup('ja')
|
178
|
+
assert_equal '3―12:', I18n.t('format_number_header', [3, 12])
|
180
179
|
end
|
181
180
|
end
|
182
181
|
end
|
@@ -184,67 +183,67 @@ class I18nTest < Test::Unit::TestCase
|
|
184
183
|
def test_format_with_mismatched_number_of_arguments
|
185
184
|
Dir.mktmpdir do |dir|
|
186
185
|
Dir.chdir(dir) do
|
187
|
-
file = File.join(dir,
|
186
|
+
file = File.join(dir, 'locale.yml')
|
188
187
|
|
189
|
-
File.open(file,
|
190
|
-
I18n.setup(
|
191
|
-
assert_equal
|
188
|
+
File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%2$d") }
|
189
|
+
I18n.setup('ja')
|
190
|
+
assert_equal '10', I18n.t('format_number_header', [1, 10])
|
192
191
|
|
193
|
-
File.open(file,
|
194
|
-
I18n.setup(
|
192
|
+
File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%2$d-%1$d") }
|
193
|
+
I18n.setup('ja')
|
195
194
|
# ERROR: returns raw format
|
196
|
-
assert_equal
|
195
|
+
assert_equal '%2$d-%1$d', I18n.t('format_number_header', [1])
|
197
196
|
end
|
198
197
|
end
|
199
198
|
end
|
200
199
|
|
201
200
|
def test_ja
|
202
|
-
I18n.setup(
|
203
|
-
assert_equal
|
204
|
-
assert_equal
|
205
|
-
assert_equal
|
206
|
-
assert_equal
|
201
|
+
I18n.setup('ja')
|
202
|
+
assert_equal '図', I18n.t('image')
|
203
|
+
assert_equal '表', I18n.t('table')
|
204
|
+
assert_equal '第1章', I18n.t('chapter', 1)
|
205
|
+
assert_equal 'etc', I18n.t('etc')
|
207
206
|
end
|
208
207
|
|
209
208
|
def test_ja_with_user_i18n
|
210
|
-
i18n = I18n.new(
|
211
|
-
i18n.update({
|
212
|
-
assert_equal
|
213
|
-
assert_equal
|
214
|
-
assert_equal
|
215
|
-
assert_equal
|
209
|
+
i18n = I18n.new('ja')
|
210
|
+
i18n.update({ 'image' => 'ず' }, 'ja')
|
211
|
+
assert_equal 'ず', i18n.t('image')
|
212
|
+
assert_equal '表', i18n.t('table')
|
213
|
+
assert_equal '第1章', i18n.t('chapter', 1)
|
214
|
+
assert_equal 'etc', i18n.t('etc')
|
216
215
|
end
|
217
216
|
|
218
217
|
def test_en
|
219
|
-
I18n.setup
|
220
|
-
assert_equal
|
221
|
-
assert_equal
|
222
|
-
assert_equal
|
223
|
-
assert_equal
|
218
|
+
I18n.setup 'en'
|
219
|
+
assert_equal 'Figure ', I18n.t('image')
|
220
|
+
assert_equal 'Table ', I18n.t('table')
|
221
|
+
assert_equal 'Chapter 1', I18n.t('chapter', 1)
|
222
|
+
assert_equal 'etc', I18n.t('etc')
|
224
223
|
end
|
225
224
|
|
226
225
|
def test_nil
|
227
|
-
I18n.setup
|
228
|
-
assert_equal
|
229
|
-
assert_equal
|
230
|
-
assert_equal
|
226
|
+
I18n.setup 'nil'
|
227
|
+
assert_equal 'image', I18n.t('image')
|
228
|
+
assert_equal 'table', I18n.t('table')
|
229
|
+
assert_equal 'etc', I18n.t('etc')
|
231
230
|
end
|
232
231
|
|
233
232
|
def test_htmlbuilder
|
234
233
|
_setup_htmlbuilder
|
235
234
|
actual = compile_block("={test} this is test.\n")
|
236
|
-
assert_equal %Q
|
235
|
+
assert_equal %Q(<h1 id="test"><a id="h1"></a><span class="secno">Chapter 1. </span>this is test.</h1>\n), actual
|
237
236
|
end
|
238
237
|
|
239
238
|
def _setup_htmlbuilder
|
240
|
-
I18n.setup
|
241
|
-
@builder = HTMLBuilder.new
|
239
|
+
I18n.setup 'en'
|
240
|
+
@builder = HTMLBuilder.new
|
242
241
|
@config = ReVIEW::Configure[
|
243
|
-
|
244
|
-
|
245
|
-
|
242
|
+
'secnolevel' => 2, # for IDGXMLBuilder, HTMLBuilder
|
243
|
+
'stylesheet' => nil, # for HTMLBuilder
|
244
|
+
'ext' => '.re'
|
246
245
|
]
|
247
|
-
@book = Book::Base.new(
|
246
|
+
@book = Book::Base.new('.')
|
248
247
|
@book.config = @config
|
249
248
|
@compiler = ReVIEW::Compiler.new(@builder)
|
250
249
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
@@ -253,39 +252,49 @@ class I18nTest < Test::Unit::TestCase
|
|
253
252
|
end
|
254
253
|
|
255
254
|
def test_update
|
256
|
-
i18n = ReVIEW::I18n.new(
|
257
|
-
hash = {
|
255
|
+
i18n = ReVIEW::I18n.new('ja')
|
256
|
+
hash = { 'foo' => 'bar' }
|
258
257
|
i18n.update(hash)
|
259
|
-
assert_equal
|
258
|
+
assert_equal 'bar', i18n.t('foo')
|
260
259
|
end
|
261
260
|
|
262
261
|
def test_update_newlocale
|
263
|
-
i18n = ReVIEW::I18n.new(
|
264
|
-
hash = {
|
265
|
-
i18n.update(hash,
|
266
|
-
i18n.locale =
|
267
|
-
assert_equal
|
262
|
+
i18n = ReVIEW::I18n.new('ja')
|
263
|
+
hash = { 'foo' => 'bar' }
|
264
|
+
i18n.update(hash, 'abc')
|
265
|
+
i18n.locale = 'abc'
|
266
|
+
assert_equal 'bar', i18n.t('foo')
|
268
267
|
end
|
269
268
|
|
270
269
|
def test_ja_appendix_alphabet
|
271
|
-
i18n = I18n.new(
|
272
|
-
i18n.update({
|
273
|
-
assert_equal
|
274
|
-
assert_equal
|
275
|
-
assert_equal
|
270
|
+
i18n = I18n.new('ja')
|
271
|
+
i18n.update({ 'appendix' => '付録%pA' }, 'ja')
|
272
|
+
assert_equal '付録A', i18n.t('appendix', 1)
|
273
|
+
assert_equal '付録B', i18n.t('appendix', 2)
|
274
|
+
assert_equal '付録C', i18n.t('appendix', 3)
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_ja_part
|
278
|
+
i18n = I18n.new('ja')
|
279
|
+
assert_equal '第III部', i18n.t('part', 3)
|
280
|
+
assert_equal 'III', i18n.t('part_short', 3)
|
281
|
+
i18n.update({ 'part' => '第%pRW部' }, 'ja')
|
282
|
+
i18n.update({ 'part_short' => '%pRW' }, 'ja')
|
283
|
+
assert_equal '第Ⅲ部', i18n.t('part', 3)
|
284
|
+
assert_equal 'Ⅲ', i18n.t('part_short', 3)
|
276
285
|
end
|
277
286
|
|
278
287
|
def test_i18n_error
|
279
288
|
I18n.setup
|
280
289
|
assert_raises NotImplementedError do
|
281
|
-
I18n.i18n(
|
290
|
+
I18n.i18n('ja')
|
282
291
|
end
|
283
292
|
assert_raises NotImplementedError do
|
284
|
-
I18n.i18n(
|
293
|
+
I18n.i18n('ja', {})
|
285
294
|
end
|
286
295
|
end
|
287
296
|
|
288
297
|
def teardown
|
289
|
-
I18n.setup
|
298
|
+
I18n.setup 'ja'
|
290
299
|
end
|
291
300
|
end
|