review 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +43 -1
  3. data/.rubocop_todo.yml +605 -0
  4. data/.travis.yml +9 -0
  5. data/ChangeLog +4 -0
  6. data/Dockerfile +22 -0
  7. data/README.rdoc +1 -1
  8. data/Rakefile +1 -1
  9. data/bin/review-check +8 -21
  10. data/bin/review-compile +9 -15
  11. data/bin/review-epubmaker-legacy +6 -6
  12. data/bin/review-index +2 -13
  13. data/bin/review-preproc +1 -14
  14. data/bin/review-validate +1 -1
  15. data/bin/review-vol +1 -13
  16. data/doc/NEWS.ja.md +22 -0
  17. data/doc/NEWS.md +22 -0
  18. data/doc/quickstart.ja.md +1 -1
  19. data/doc/quickstart.md +1 -1
  20. data/lib/epubmaker/content.rb +3 -3
  21. data/lib/epubmaker/epubcommon.rb +91 -108
  22. data/lib/epubmaker/epubv2.rb +14 -67
  23. data/lib/epubmaker/epubv3.rb +25 -59
  24. data/lib/epubmaker/producer.rb +12 -0
  25. data/lib/review/book/base.rb +12 -4
  26. data/lib/review/book/compilable.rb +1 -3
  27. data/lib/review/book/index.rb +4 -4
  28. data/lib/review/builder.rb +6 -11
  29. data/lib/review/compiler.rb +7 -7
  30. data/lib/review/configure.rb +20 -8
  31. data/lib/review/epubbuilder.rb +1 -1
  32. data/lib/review/epubmaker.rb +52 -122
  33. data/lib/review/ewbbuilder.rb +4 -4
  34. data/lib/review/exception.rb +1 -1
  35. data/lib/review/htmlbuilder.rb +49 -54
  36. data/lib/review/htmltoc.rb +45 -0
  37. data/lib/review/htmlutils.rb +3 -3
  38. data/lib/review/i18n.rb +6 -2
  39. data/lib/review/i18n.yml +1 -1
  40. data/lib/review/idgxmlbuilder.rb +4 -5
  41. data/lib/review/inaobuilder.rb +1 -1
  42. data/lib/review/latexbuilder.rb +2 -2
  43. data/lib/review/latexutils.rb +6 -6
  44. data/lib/review/markdownbuilder.rb +4 -3
  45. data/lib/review/pdfmaker.rb +92 -92
  46. data/lib/review/preprocessor.rb +14 -51
  47. data/lib/review/template.rb +21 -0
  48. data/lib/review/textbuilder.rb +1 -1
  49. data/lib/review/textutils.rb +0 -28
  50. data/lib/review/tocparser.rb +3 -3
  51. data/lib/review/tocprinter.rb +8 -31
  52. data/lib/review/topbuilder.rb +2 -3
  53. data/lib/review/unfold.rb +2 -2
  54. data/lib/review/version.rb +1 -1
  55. data/review.gemspec +2 -1
  56. data/templates/html/layout-html5.html.erb +17 -0
  57. data/templates/html/layout-xhtml1.html.erb +20 -0
  58. data/templates/ncx/epubv2.ncx.erb +11 -0
  59. data/templates/opf/epubv2.opf.erb +21 -0
  60. data/templates/opf/epubv3.opf.erb +18 -0
  61. data/templates/xml/container.xml.erb +6 -0
  62. data/test/assets/test.xml.erb +3 -0
  63. data/test/test.re +1 -1
  64. data/test/test_book.rb +4 -4
  65. data/test/test_book_chapter.rb +0 -76
  66. data/test/test_book_part.rb +1 -1
  67. data/test/test_builder.rb +0 -49
  68. data/test/test_configure.rb +50 -0
  69. data/test/test_htmlbuilder.rb +54 -4
  70. data/test/test_htmltoc.rb +32 -0
  71. data/test/test_i18n.rb +3 -5
  72. data/test/test_idgxmlbuilder.rb +0 -2
  73. data/test/test_inaobuilder.rb +2 -4
  74. data/test/test_latexbuilder.rb +2 -4
  75. data/test/test_lineinput.rb +0 -18
  76. data/test/test_markdownbuilder.rb +5 -4
  77. data/test/test_pdfmaker.rb +11 -10
  78. data/test/test_template.rb +26 -0
  79. data/test/test_topbuilder.rb +0 -2
  80. metadata +35 -4
  81. data/rubocop-todo.yml +0 -456
@@ -22,6 +22,8 @@ module ReVIEW
22
22
  include FileUtils
23
23
  include ReVIEW::LaTeXUtils
24
24
 
25
+ attr_accessor :config, :basedir
26
+
25
27
  def initialize
26
28
  @basedir = Dir.pwd
27
29
  end
@@ -39,13 +41,16 @@ module ReVIEW
39
41
  $stderr.puts "#{File.basename($0, '.*')}: warning: #{msg}"
40
42
  end
41
43
 
42
- def check_book(config)
43
- pdf_file = config["bookname"]+".pdf"
44
- File.unlink(pdf_file) if File.exist?(pdf_file)
44
+ def pdf_filepath
45
+ File.join(@basedir, @config["bookname"]+".pdf")
46
+ end
47
+
48
+ def remove_old_file
49
+ FileUtils.rm_f(pdf_filepath)
45
50
  end
46
51
 
47
- def build_path(config)
48
- "./#{config["bookname"]}-pdf"
52
+ def build_path
53
+ "./#{@config["bookname"]}-pdf"
49
54
  end
50
55
 
51
56
  def check_compile_status(ignore_errors)
@@ -89,31 +94,30 @@ module ReVIEW
89
94
  end
90
95
 
91
96
  def execute(*args)
92
- config = ReVIEW::Configure.values
97
+ @config = ReVIEW::Configure.values
93
98
  cmd_config, yamlfile = parse_opts(args)
94
99
 
95
- config.merge!(YAML.load_file(yamlfile))
100
+ @config.merge!(YAML.load_file(yamlfile))
96
101
  # YAML configs will be overridden by command line options.
97
- config.merge!(cmd_config)
98
- I18n.setup(config["language"])
99
- generate_pdf(config, yamlfile)
102
+ @config.merge!(cmd_config)
103
+ I18n.setup(@config["language"])
104
+ generate_pdf(yamlfile)
100
105
  end
101
106
 
102
- def generate_pdf(config, yamlfile)
103
- check_book(config)
104
- @path = build_path(config)
105
- bookname = config["bookname"]
107
+ def generate_pdf(yamlfile)
108
+ remove_old_file
109
+ @path = build_path()
106
110
  Dir.mkdir(@path)
107
111
 
108
112
  @chaps_fnames = Hash.new{|h, key| h[key] = ""}
109
113
  @compile_errors = nil
110
114
 
111
115
  book = ReVIEW::Book.load(@basedir)
112
- book.config = config
116
+ book.config = @config
113
117
  book.parts.each do |part|
114
118
  if part.name.present?
115
119
  if part.file?
116
- output_chaps(part.name, config, yamlfile)
120
+ output_chaps(part.name, yamlfile)
117
121
  @chaps_fnames["CHAPS"] << %Q|\\input{#{part.name}.tex}\n|
118
122
  else
119
123
  @chaps_fnames["CHAPS"] << %Q|\\part{#{part.name}}\n|
@@ -122,40 +126,39 @@ module ReVIEW
122
126
 
123
127
  part.chapters.each do |chap|
124
128
  filename = File.basename(chap.path, ".*")
125
- output_chaps(filename, config, yamlfile)
126
- @chaps_fnames["PREDEF"] << "\\input{#{filename}.tex}\n" if chap.on_PREDEF?
127
- @chaps_fnames["CHAPS"] << "\\input{#{filename}.tex}\n" if chap.on_CHAPS?
129
+ output_chaps(filename, yamlfile)
130
+ @chaps_fnames["PREDEF"] << "\\input{#{filename}.tex}\n" if chap.on_PREDEF?
131
+ @chaps_fnames["CHAPS"] << "\\input{#{filename}.tex}\n" if chap.on_CHAPS?
128
132
  @chaps_fnames["APPENDIX"] << "\\input{#{filename}.tex}\n" if chap.on_APPENDIX?
129
133
  @chaps_fnames["POSTDEF"] << "\\input{#{filename}.tex}\n" if chap.on_POSTDEF?
130
134
  end
131
135
  end
132
136
 
133
- check_compile_status(config["ignore-errors"])
137
+ check_compile_status(@config["ignore-errors"])
134
138
 
135
- config["pre_str"] = @chaps_fnames["PREDEF"]
136
- config["chap_str"] = @chaps_fnames["CHAPS"]
137
- config["appendix_str"] = @chaps_fnames["APPENDIX"]
138
- config["post_str"] = @chaps_fnames["POSTDEF"]
139
+ @config["pre_str"] = @chaps_fnames["PREDEF"]
140
+ @config["chap_str"] = @chaps_fnames["CHAPS"]
141
+ @config["appendix_str"] = @chaps_fnames["APPENDIX"]
142
+ @config["post_str"] = @chaps_fnames["POSTDEF"]
139
143
 
140
- config["usepackage"] = ""
141
- if config["texstyle"]
142
- config["usepackage"] = "\\usepackage{#{config['texstyle']}}"
144
+ @config["usepackage"] = ""
145
+ if @config["texstyle"]
146
+ @config["usepackage"] = "\\usepackage{#{@config['texstyle']}}"
143
147
  end
144
148
 
145
- copy_images("./images", "#{@path}/images")
146
- copyStyToDir(Dir.pwd + "/sty", @path)
147
- copyStyToDir(Dir.pwd + "/sty", @path, "fd")
148
- copyStyToDir(Dir.pwd + "/sty", @path, "cls")
149
+ copy_images("./images", File.join(@path, "images"))
150
+ copyStyToDir(File.join(Dir.pwd, "sty"), @path)
151
+ copyStyToDir(File.join(Dir.pwd, "sty"), @path, "fd")
152
+ copyStyToDir(File.join(Dir.pwd, "sty"), @path, "cls")
149
153
  copyStyToDir(Dir.pwd, @path, "tex")
150
154
 
151
- Dir.chdir(@path) {
152
- template = get_template(config)
155
+ Dir.chdir(@path) do
156
+ template = get_template
153
157
  File.open("./book.tex", "wb"){|f| f.write(template)}
154
158
 
155
- call_hook("hook_beforetexcompile", config)
159
+ call_hook("hook_beforetexcompile")
156
160
 
157
161
  ## do compile
158
- enc = config["params"].to_s.split(/\s+/).find{|i| i =~ /\A--outencoding=/ }
159
162
  kanji = 'utf8'
160
163
  texcommand = "platex"
161
164
  texoptions = "-kanji=#{kanji}"
@@ -165,36 +168,32 @@ module ReVIEW
165
168
  if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0
166
169
  warn "command configuration is prohibited in safe mode. ignored."
167
170
  else
168
- texcommand = config["texcommand"] if config["texcommand"]
169
- dvicommand = config["dvicommand"] if config["dvicommand"]
170
- dvioptions = config["dvioptions"] if config["dvioptions"]
171
- if enc
172
- kanji = enc.split(/\=/).last.gsub(/-/, '').downcase
173
- texoptions = "-kanji=#{kanji}"
174
- end
175
- texoptions = config["texoptions"] if config["texoptions"]
171
+ texcommand = @config["texcommand"] if @config["texcommand"]
172
+ dvicommand = @config["dvicommand"] if @config["dvicommand"]
173
+ dvioptions = @config["dvioptions"] if @config["dvioptions"]
174
+ texoptions = @config["texoptions"] if @config["texoptions"]
176
175
  end
177
176
  3.times do
178
177
  system_or_raise("#{texcommand} #{texoptions} book.tex")
179
178
  end
180
- call_hook("hook_aftertexcompile", config)
179
+ call_hook("hook_aftertexcompile")
181
180
 
182
- if File.exist?("book.dvi")
181
+ if File.exist?("book.dvi")
183
182
  system_or_raise("#{dvicommand} #{dvioptions} book.dvi")
184
183
  end
185
- }
186
- call_hook("hook_afterdvipdf", config)
187
-
188
- FileUtils.cp("#{@path}/book.pdf", "#{@basedir}/#{bookname}.pdf")
184
+ end
185
+ call_hook("hook_afterdvipdf")
186
+
187
+ FileUtils.cp(File.join(@path, "book.pdf"), pdf_filepath)
189
188
 
190
- unless config["debug"]
189
+ unless @config["debug"]
191
190
  remove_entry_secure @path
192
191
  end
193
192
  end
194
193
 
195
- def output_chaps(filename, config, yamlfile)
194
+ def output_chaps(filename, yamlfile)
196
195
  $stderr.puts "compiling #{filename}.tex"
197
- cmd = "#{ReVIEW::MakerHelper.bindir}/review-compile --yaml=#{yamlfile} --target=latex --level=#{config["secnolevel"]} --toclevel=#{config["toclevel"]} #{config["params"]} #{filename}.re > #{@path}/#{filename}.tex"
196
+ cmd = "#{ReVIEW::MakerHelper.bindir}/review-compile --yaml=#{yamlfile} --target=latex --level=#{@config["secnolevel"]} --toclevel=#{@config["toclevel"]} #{@config["params"]} #{filename}.re > #{@path}/#{filename}.tex"
198
197
  if system cmd
199
198
  # OK
200
199
  else
@@ -203,6 +202,8 @@ module ReVIEW
203
202
  end
204
203
  end
205
204
 
205
+ # PDFMaker#copy_images should copy image files _AND_ execute extractbb (or ebb).
206
+ #
206
207
  def copy_images(from, to)
207
208
  if File.exist?(from)
208
209
  Dir.mkdir(to)
@@ -237,57 +238,57 @@ module ReVIEW
237
238
  end
238
239
  end
239
240
 
240
- def make_colophon_role(role, config)
241
- if config[role].present?
242
- return "#{ReVIEW::I18n.t(role)} & #{escape_latex(join_with_separator(config[role], ReVIEW::I18n.t("names_splitter")))} \\\\\n"
241
+ def make_colophon_role(role)
242
+ if @config[role].present?
243
+ return "#{ReVIEW::I18n.t(role)} & #{escape_latex(join_with_separator(@config[role], ReVIEW::I18n.t("names_splitter")))} \\\\\n"
243
244
  else
244
245
  ""
245
246
  end
246
247
  end
247
248
 
248
- def make_colophon(config)
249
+ def make_colophon
249
250
  colophon = ""
250
- config["colophon_order"].each do |role|
251
- colophon += make_colophon_role(role, config)
251
+ @config["colophon_order"].each do |role|
252
+ colophon += make_colophon_role(role)
252
253
  end
253
254
  colophon
254
255
  end
255
256
 
256
- def make_authors(config)
257
+ def make_authors
257
258
  authors = ""
258
- if config["aut"].present?
259
- author_names = join_with_separator(config["aut"], ReVIEW::I18n.t("names_splitter"))
259
+ if @config["aut"].present?
260
+ author_names = join_with_separator(@config["aut"], ReVIEW::I18n.t("names_splitter"))
260
261
  authors = ReVIEW::I18n.t("author_with_label", author_names)
261
262
  end
262
- if config["csl"].present?
263
- csl_names = join_with_separator(config["csl"], ReVIEW::I18n.t("names_splitter"))
263
+ if @config["csl"].present?
264
+ csl_names = join_with_separator(@config["csl"], ReVIEW::I18n.t("names_splitter"))
264
265
  authors += " \\\\\n"+ ReVIEW::I18n.t("supervisor_with_label", csl_names)
265
266
  end
266
- if config["trl"].present?
267
- trl_names = join_with_separator(config["trl"], ReVIEW::I18n.t("names_splitter"))
267
+ if @config["trl"].present?
268
+ trl_names = join_with_separator(@config["trl"], ReVIEW::I18n.t("names_splitter"))
268
269
  authors += " \\\\\n"+ ReVIEW::I18n.t("translator_with_label", trl_names)
269
270
  end
270
271
  authors
271
272
  end
272
273
 
273
- def get_template(config)
274
- dclass = config["texdocumentclass"] || []
275
- documentclass = dclass[0] || "jsbook"
276
- documentclassoption = dclass[1] || "oneside"
274
+ def get_template
275
+ dclass = @config["texdocumentclass"] || []
276
+ documentclass = dclass[0] || "jsbook"
277
+ documentclassoption = dclass[1] || "oneside"
277
278
 
278
- okuduke = make_colophon(config)
279
- authors = make_authors(config)
279
+ okuduke = make_colophon
280
+ authors = make_authors
280
281
 
281
- custom_titlepage = make_custom_page(config["cover"]) || make_custom_page(config["coverfile"])
282
- custom_originaltitlepage = make_custom_page(config["originaltitlefile"])
283
- custom_creditpage = make_custom_page(config["creditfile"])
282
+ custom_titlepage = make_custom_page(@config["cover"]) || make_custom_page(@config["coverfile"])
283
+ custom_originaltitlepage = make_custom_page(@config["originaltitlefile"])
284
+ custom_creditpage = make_custom_page(@config["creditfile"])
284
285
 
285
- custom_profilepage = make_custom_page(config["profile"])
286
- custom_advfilepage = make_custom_page(config["advfile"])
287
- if config["colophon"] && config["colophon"].kind_of?(String)
288
- custom_colophonpage = make_custom_page(config["colophon"])
286
+ custom_profilepage = make_custom_page(@config["profile"])
287
+ custom_advfilepage = make_custom_page(@config["advfile"])
288
+ if @config["colophon"] && @config["colophon"].kind_of?(String)
289
+ custom_colophonpage = make_custom_page(@config["colophon"])
289
290
  end
290
- custom_backcoverpage = make_custom_page(config["backcover"])
291
+ custom_backcoverpage = make_custom_page(@config["backcover"])
291
292
 
292
293
  template = File.expand_path('layout.tex.erb', File.dirname(__FILE__))
293
294
  layout_file = File.join(@basedir, "layouts", "layout.tex.erb")
@@ -296,30 +297,29 @@ module ReVIEW
296
297
  end
297
298
 
298
299
  erb = ERB.new(File.open(template).read)
299
- values = config # must be 'values' for legacy files
300
+ values = @config # must be 'values' for legacy files
300
301
  erb.result(binding)
301
302
  end
302
303
 
303
304
  def copyStyToDir(dirname, copybase, extname = "sty")
304
305
  unless File.directory?(dirname)
305
- $stderr.puts "No such directory - #{dirname}"
306
+ warn "No such directory - #{dirname}"
306
307
  return
307
308
  end
308
309
 
309
- Dir.open(dirname) {|dir|
310
- dir.each {|fname|
311
- next if fname =~ /^\./
312
- if fname =~ /\.(#{extname})$/i
313
- Dir.mkdir(copybase) unless File.exist?(copybase)
314
- FileUtils.cp "#{dirname}/#{fname}", copybase
310
+ Dir.open(dirname) do |dir|
311
+ dir.each do |fname|
312
+ if File.extname(fname).downcase == "."+extname
313
+ FileUtils.mkdir_p(copybase)
314
+ FileUtils.cp File.join(dirname, fname), copybase
315
315
  end
316
- }
317
- }
316
+ end
317
+ end
318
318
  end
319
319
 
320
- def call_hook(hookname, config)
321
- if config["pdfmaker"].instance_of?(Hash) && config["pdfmaker"][hookname]
322
- hook = File.absolute_path(config["pdfmaker"][hookname], @basedir)
320
+ def call_hook(hookname)
321
+ if @config["pdfmaker"].instance_of?(Hash) && @config["pdfmaker"][hookname]
322
+ hook = File.absolute_path(@config["pdfmaker"][hookname], @basedir)
323
323
  if ENV["REVIEW_SAFE_MODE"].to_i & 1 > 0
324
324
  warn "hook configuration is prohibited in safe mode. ignored."
325
325
  else
@@ -24,24 +24,10 @@ module ReVIEW
24
24
  end
25
25
 
26
26
  def warn(msg)
27
- if @config["outencoding"] =~ /^EUC$/
28
- msg = NKF.nkf("-W -e", msg)
29
- elsif @config["outencoding"] =~ /^SJIS$/
30
- msg = NKF.nkf("-W -s", msg)
31
- elsif @config["outencoding"] =~ /^JIS$/
32
- msg = NKF.nkf("-W -j", msg)
33
- end
34
27
  $stderr.puts "#{location()}: warning: #{msg}"
35
28
  end
36
29
 
37
30
  def error(msg)
38
- if @config["outencoding"] =~ /^EUC$/
39
- msg = NKF.nkf("-W -e", msg)
40
- elsif @config["outencoding"] =~ /^SJIS$/
41
- msg = NKF.nkf("-W -s", msg)
42
- elsif @config["outencoding"] =~ /^JIS$/
43
- msg = NKF.nkf("-W -j", msg)
44
- end
45
31
  @errutils_err = true
46
32
  raise ApplicationError, "#{location()}: #{msg}"
47
33
  end
@@ -148,7 +134,7 @@ module ReVIEW
148
134
  path = expand(direc.arg)
149
135
  ent = @repository.fetch_file(path)
150
136
  ent = evaluate(path, ent) if direc['eval']
151
- replace_block f, line, ent, false # FIXME: turn off lineno: tmp
137
+ replace_block(f, line, ent, false) # FIXME: turn off lineno: tmp
152
138
 
153
139
  when /\A\#@map(?:range)?/
154
140
  direc = parse_directive(line, 2, 'unindent')
@@ -156,7 +142,7 @@ module ReVIEW
156
142
  ent = @repository.fetch_range(path, direc.args[1]) or
157
143
  error "unknown range: #{path}: #{direc.args[1]}"
158
144
  ent = (direc['unindent'] ? unindent(ent, direc['unindent']) : ent)
159
- replace_block f, line, ent, false # FIXME: turn off lineno: tmp
145
+ replace_block(f, line, ent, false) # FIXME: turn off lineno: tmp
160
146
 
161
147
  when /\A\#@end/
162
148
  error 'unbaranced #@end'
@@ -167,7 +153,7 @@ module ReVIEW
167
153
  warn "unkown directive: #{line.strip}" unless known_directive?(op)
168
154
  @f.print line
169
155
 
170
- when /\A\s*\z/ # empty line
156
+ when /\A\s*\z/ # empty line
171
157
  @f.puts
172
158
  else
173
159
  @f.print line
@@ -183,34 +169,11 @@ module ReVIEW
183
169
  KNOWN_DIRECTIVES.index(op)
184
170
  end
185
171
 
186
- def convert_outencoding(*s)
187
- ine = ""
188
- if @config["inencoding"] =~ /^EUC$/i
189
- ine = "-E,"
190
- elsif @config["inencoding"] =~ /^SJIS$/i
191
- ine = "-S,"
192
- elsif @config["inencoding"] =~ /^JIS$/i
193
- ine = "-J,"
194
- elsif @config["inencoding"] =~ /^UTF\-8$/i
195
- ine = "-W,"
196
- end
197
-
198
- if @config["outencoding"] =~ /^EUC$/i
199
- NKF.nkf("#{ine} -m0x -e", *s)
200
- elsif @config["outencoding"] =~ /^SJIS$/i
201
- NKF.nkf("#{ine} -m0x -s", *s)
202
- elsif @config["outencoding"] =~ /^JIS$/i
203
- NKF.nkf("#{ine} -m0x -j", *s)
204
- else
205
- NKF.nkf("#{ine} -m0x -w", *s)
206
- end
207
- end
208
-
209
172
  def replace_block(f, directive_line, newlines, with_lineno)
210
173
  @f.print directive_line
211
174
  newlines.each do |line|
212
175
  print_number line.number if with_lineno
213
- @f.print convert_outencoding(line.string)
176
+ @f.print line.string
214
177
  end
215
178
  skip_list f
216
179
  end
@@ -243,8 +206,8 @@ module ReVIEW
243
206
  class Directive
244
207
  def initialize(op, args, opts)
245
208
  @op = op
246
- @args = args
247
- @opts = opts
209
+ @args = args
210
+ @opts = opts
248
211
  end
249
212
 
250
213
  attr_reader :op
@@ -297,12 +260,12 @@ module ReVIEW
297
260
 
298
261
  def optarg_value(spec)
299
262
  case spec
300
- when 'true' then true # [name=true]
301
- when 'false' then false # [name=false]
302
- when 'nil' then nil # [name=nil]
303
- when nil then true # [name]
304
- when /^\d+$/ then $&.to_i # [name=8]
305
- else # [name=val]
263
+ when 'true' then true # [name=true]
264
+ when 'false' then false # [name=false]
265
+ when 'nil' then nil # [name=nil]
266
+ when nil then true # [name]
267
+ when /^\d+$/ then $&.to_i # [name=8]
268
+ else # [name=val]
306
269
  spec
307
270
  end
308
271
  end
@@ -465,7 +428,7 @@ module ReVIEW
465
428
  repo = {'file' => whole}
466
429
  curr = {'WHOLE' => whole}
467
430
  lineno = 1
468
- yacchack = false # remove ';'-only lines.
431
+ yacchack = false # remove ';'-only lines.
469
432
  opened = [['(not opened)', '(not opened)']] * 3
470
433
 
471
434
  f.each do |line|
@@ -510,7 +473,7 @@ module ReVIEW
510
473
  when /(?:\A\#@|\#@@)yacchack/
511
474
  yacchack = true
512
475
 
513
- when /\A\#@-/ # does not increment line number.
476
+ when /\A\#@-/ # does not increment line number.
514
477
  line = canonical($')
515
478
  curr.each_value do |list|
516
479
  list.push Line.new(nil, line)
@@ -0,0 +1,21 @@
1
+ require 'erb'
2
+ module ReVIEW
3
+ class Template
4
+ TEMPLATE_DIR = File.join(File.dirname(__FILE__), "../../templates")
5
+
6
+ def self.load(filename, mode = 1)
7
+ self.new(filename, mode)
8
+ end
9
+
10
+ def initialize(filename = nil, mode = nil)
11
+ if filename
12
+ content = File.read(filename)
13
+ @erb = ERB.new(content, nil, mode)
14
+ end
15
+ end
16
+
17
+ def result(bind_data = nil)
18
+ @erb.result(bind_data)
19
+ end
20
+ end
21
+ end