Sha256: 0db7d1de240a83f43353cb3aac6d15723eb79ef5618f308c036559af0fad0ca2
Contents?: true
Size: 1.81 KB
Versions: 7
Compression:
Stored size: 1.81 KB
Contents
$LOAD_PATH.unshift(File.realpath('../lib', __dir__)) require 'test/unit' require 'fileutils' require 'review/yamlloader' require 'review/extentions' def touch_file(path) FileUtils.touch(path) end def assets_dir File.join(__dir__, 'assets') end def prepare_samplebook(srcdir, bookdir, latextemplatedir, configfile) samplebook_dir = File.expand_path("../samples/#{bookdir}/", __dir__) files = Dir.glob(File.join(samplebook_dir, '*')) # ignore temporary built files files.delete_if { |file| file =~ /.*-(pdf|epub|text)/ || file == 'webroot' } FileUtils.cp_r(files, srcdir) if latextemplatedir # copy from review-jsbook or review-jlreq template_dir = File.expand_path("../templates/latex/#{latextemplatedir}/", __dir__) FileUtils.cp(Dir.glob(File.join(template_dir, '*')), File.join(srcdir, 'sty')) end loader = ReVIEW::YAMLLoader.new loader.load_file(File.open(File.join(srcdir, configfile))) end def compile_inline(text) @builder.compile_inline(text) end def compile_block(text) method_name = "compile_block_#{@builder.target_name}" method_name = 'compile_block_default' unless self.respond_to?(method_name, true) self.__send__(method_name, text) end def compile_block_default(text) @chapter.content = text @chapter.execute_indexer(force: true) @compiler.compile(@chapter) end def compile_block_html(text) @chapter.content = text @chapter.execute_indexer(force: true) matched = @compiler.compile(@chapter).match(Regexp.new(%Q(<body>\n(.+)</body>), Regexp::MULTILINE)) if matched && matched.size > 1 matched[1] else '' end end def compile_block_idgxml(text) @chapter.content = text @chapter.execute_indexer(force: true) @compiler.compile(@chapter).gsub(Regexp.new(%Q(.*<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">), Regexp::MULTILINE), '').gsub("</doc>\n", '') end
Version data entries
7 entries across 7 versions & 1 rubygems