From 70f54467c58f1673ea014a5825b65e26d190cea5 Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Tue, 21 May 2019 22:52:33 +0900 Subject: [PATCH 1/8] fix handling date metadata in EPUBv2 --- lib/epubmaker/epubv2.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/epubmaker/epubv2.rb b/lib/epubmaker/epubv2.rb index 00eb04454..d7a998ac5 100644 --- a/lib/epubmaker/epubv2.rb +++ b/lib/epubmaker/epubv2.rb @@ -39,7 +39,7 @@ def opf_metainfo if @producer.config[item].is_a?(Array) s << @producer.config.names_of(item).map { |i| %Q( #{CGI.escapeHTML(i)}\n) }.join else - s << %Q( #{CGI.escapeHTML(@producer.config.name_of(item))}\n) + s << %Q( #{CGI.escapeHTML(@producer.config.name_of(item).to_s)}\n) end end From 61082613387a4f5cb1b8ed6260a3cea9304ae7a1 Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Wed, 22 May 2019 21:21:24 +0900 Subject: [PATCH 2/8] workaround for Windows path resolution. The patch is contributed by @mitsuo0114, thanks. Closes: #1011 --- lib/epubmaker/producer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/epubmaker/producer.rb b/lib/epubmaker/producer.rb index d67455e90..6fa8d622d 100644 --- a/lib/epubmaker/producer.rb +++ b/lib/epubmaker/producer.rb @@ -192,7 +192,8 @@ def produce(epubfile, basedir = nil, tmpdir = nil) current = Dir.pwd basedir ||= current - new_tmpdir = tmpdir.nil? ? Dir.mktmpdir : tmpdir + # use Dir to solve a path for Windows (see #1011) + new_tmpdir = Dir[File.join(tmpdir.nil? ? Dir.mktmpdir : tmpdir)][0] if epubfile !~ %r{\A/} epubfile = "#{current}/#{epubfile}" end From 6f4fcdc1137787eb8d4c3750661120d519d30f17 Mon Sep 17 00:00:00 2001 From: takahiro ono Date: Wed, 22 May 2019 22:38:53 +0900 Subject: [PATCH 3/8] Add Travius and appveryor test code and Fix epubv2 (#1300) * Add Travius and appveryor test code and Fix epubv2 * Remove ended Ruby version(2.1 - 2.3) test environments --- .travis.yml | 24 ++++++++++++------------ appveyor.yml | 22 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5e5f6c90..18168d77e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: ruby sudo: false dist: trusty +os: + - linux + - osx + addons: apt: packages: @@ -12,20 +16,16 @@ addons: before_install: - |- - RUBY_VER=`ruby -e "print RUBY_VERSION"` - if [ "$RUBY_VER" = "2.1.10" ]; then - gem install bundler -v '< 2' - elif [ "$RUBY_VER" = "2.2.10" ]; then - gem install bundler -v '< 2' - else - gem update --system - gem install bundler - fi + gem update --system + gem install bundler + gem install epubcheck-ruby + +script: + - ruby bin/review-init hello && cd hello && ruby ../bin/review-epubmaker config.yml && epubcheck book.epub + - cd .. + - ruby bin/review-init hello2 --epub-version 2 && cd hello2 && ruby ../bin/review-epubmaker config.yml && epubcheck book.epub rvm: - - 2.1 - - 2.2.10 - - 2.3.8 - 2.4.5 - 2.5.3 - 2.6.0 diff --git a/appveyor.yml b/appveyor.yml index 775f98717..9b5ee87bf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,11 +8,29 @@ build_script: - bundle exec rake test --trace --verbose - bundle exec rubocop +before_test: + - gem install -N epubcheck-ruby + +test_script: + - ruby bin/review-init hello + - cd hello + - ruby ../bin/review-epubmaker config.yml + - epubcheck book.epub + - cd .. + - ruby bin/review-init hello2 --epub-version 2 + - cd hello2 + - ruby ../bin/review-epubmaker config.yml + - epubcheck book.epub + branches: only: - master environment: matrix: - - ruby_version: "23" - - ruby_version: "23-x64" \ No newline at end of file + - ruby_version: "24" + - ruby_version: "24-x64" + - ruby_version: "25" + - ruby_version: "25-x64" + - ruby_version: "26" + - ruby_version: "26-x64" From 824695ec6051e675e5e7aea75c3e1d49f7866782 Mon Sep 17 00:00:00 2001 From: takahashim Date: Wed, 22 May 2019 22:44:48 +0900 Subject: [PATCH 4/8] travis: update ruby versions --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18168d77e..2b2a56204 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,9 @@ script: - ruby bin/review-init hello2 --epub-version 2 && cd hello2 && ruby ../bin/review-epubmaker config.yml && epubcheck book.epub rvm: - - 2.4.5 - - 2.5.3 - - 2.6.0 + - 2.4.6 + - 2.5.5 + - 2.6.3 ## - ruby-head branches: From 727ad7855ff8950e737d483aaa9ecd62cc147928 Mon Sep 17 00:00:00 2001 From: takahashim Date: Fri, 24 May 2019 12:34:09 +0900 Subject: [PATCH 5/8] remove ReVIEW::Preprocessor::Strip; not used now related: #1257, #1261 --- lib/review/preprocessor.rb | 22 ---------------------- test/test_preprocessor.rb | 18 ++---------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/lib/review/preprocessor.rb b/lib/review/preprocessor.rb index 5b7ac8cc2..b21b37f85 100644 --- a/lib/review/preprocessor.rb +++ b/lib/review/preprocessor.rb @@ -43,28 +43,6 @@ def lineno class Preprocessor include ErrorUtils - class Strip - def initialize(f) - @f = f - end - - def path - @f.path - end - - def lineno - @f.lineno - end - - def gets - @f.each_line do |line| - return "\#@\#\n" if /\A\#@/ =~ line - return line - end - nil - end - end - def initialize(repo, param) @repository = repo @config = param diff --git a/test/test_preprocessor.rb b/test/test_preprocessor.rb index d5a710a5d..a2c7e90a9 100644 --- a/test/test_preprocessor.rb +++ b/test/test_preprocessor.rb @@ -2,22 +2,8 @@ require 'review/preprocessor' require 'stringio' -class PreprocessorStripTest < Test::Unit::TestCase +class PreprocessorTest < Test::Unit::TestCase include ReVIEW - def test_gets - f = StringIO.new '= Header' - s = Preprocessor::Strip.new(f) - expect = '= Header' - actual = s.gets - assert_equal expect, actual - end - - def test_gets_with_comment - f = StringIO.new '#@warn(write it later)' - s = Preprocessor::Strip.new(f) - expect = '#@#' + "\n" - actual = s.gets - assert_equal expect, actual - end + ## TODO: add tests end From c0dde0e18107658861c302fc77cd447617966305 Mon Sep 17 00:00:00 2001 From: Masayoshi Takahashi Date: Sat, 25 May 2019 11:39:20 +0900 Subject: [PATCH 6/8] YAMLLoader: extract parse_inherit from load_file (#1304) * YAMLLoader: extract parse_inherit from load_file * refactor: checking exit condition should be done in while --- lib/review/yamlloader.rb | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/lib/review/yamlloader.rb b/lib/review/yamlloader.rb index 932088bc9..2bd83d931 100644 --- a/lib/review/yamlloader.rb +++ b/lib/review/yamlloader.rb @@ -15,31 +15,38 @@ def load_file(yamlfile) loaded_files = {} yaml = {} - loop do - # Check exit condition - return yaml if file_queue.empty? - + while file_queue.present? current_file = file_queue.shift current_yaml = YAML.load_file(current_file) yaml = current_yaml.deep_merge(yaml) - next unless yaml.key?('inherit') + if yaml.key?('inherit') + inherit_files = parse_inherit(yaml, yamlfile, loaded_files) + file_queue = inherit_files + file_queue + end + end + + yaml + end - buf = [] - yaml['inherit'].reverse_each do |item| - inherit_file = File.expand_path(item, File.dirname(yamlfile)) + def parse_inherit(yaml, yamlfile, loaded_files) + files = [] - # Check loop - if loaded_files[inherit_file] - raise "Found circular YAML inheritance '#{inherit_file}' in #{yamlfile}." - end + yaml['inherit'].reverse_each do |item| + inherit_file = File.expand_path(item, File.dirname(yamlfile)) - loaded_files[inherit_file] = true - buf << inherit_file + # Check loop + if loaded_files[inherit_file] + raise "Found circular YAML inheritance '#{inherit_file}' in #{yamlfile}." end - yaml.delete('inherit') - file_queue = buf + file_queue + + loaded_files[inherit_file] = true + files << inherit_file end + + yaml.delete('inherit') + + files end end end From 6f0a8fbc54f8a138c901b188a29be08c7699b0ca Mon Sep 17 00:00:00 2001 From: takahashim Date: Sat, 25 May 2019 17:11:59 +0900 Subject: [PATCH 7/8] LATEXBuilder: support `@{...}` --- lib/review/latexbuilder.rb | 2 +- templates/latex/review-jlreq/review-base.sty | 1 + templates/latex/review-jsbook/review-base.sty | 1 + test/test_latexbuilder.rb | 5 +++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/review/latexbuilder.rb b/lib/review/latexbuilder.rb index 570abe4f0..8d4892a92 100644 --- a/lib/review/latexbuilder.rb +++ b/lib/review/latexbuilder.rb @@ -997,7 +997,7 @@ def inline_fn(id) BOUTEN = '・'.freeze def inline_bou(str) - str.split(//).map { |c| macro('ruby', escape(c), macro('textgt', BOUTEN)) }.join('\allowbreak') + macro('reviewbou', escape(str)) end def compile_ruby(base, ruby) diff --git a/templates/latex/review-jlreq/review-base.sty b/templates/latex/review-jlreq/review-base.sty index 16b2ea694..2010a47db 100644 --- a/templates/latex/review-jlreq/review-base.sty +++ b/templates/latex/review-jlreq/review-base.sty @@ -165,6 +165,7 @@ \DeclareRobustCommand{\reviewtt}[1]{\texttt{#1}} \DeclareRobustCommand{\reviewtti}[1]{\texttt{\textit{#1}}} \DeclareRobustCommand{\reviewttb}[1]{\texttt{\textbf{#1}}} +\DeclareRobustCommand{\reviewbou}[1]{\kenten{#1}} %% @ is ignored in LaTeX with default style %% \DeclareRobustCommand{\reviewstrike}[1]{#1} diff --git a/templates/latex/review-jsbook/review-base.sty b/templates/latex/review-jsbook/review-base.sty index 2f4381e25..a4a26a380 100644 --- a/templates/latex/review-jsbook/review-base.sty +++ b/templates/latex/review-jsbook/review-base.sty @@ -265,6 +265,7 @@ \DeclareRobustCommand{\reviewtt}[1]{\texttt{#1}} \DeclareRobustCommand{\reviewtti}[1]{\texttt{\textit{#1}}} \DeclareRobustCommand{\reviewttb}[1]{\texttt{\textbf{#1}}} +\DeclareRobustCommand{\reviewbou}[1]{\kenten{#1}} %% @ is ignored in LaTeX with default style \DeclareRobustCommand{\reviewstrike}[1]{#1} diff --git a/test/test_latexbuilder.rb b/test/test_latexbuilder.rb index 598756ef8..3a6293827 100644 --- a/test/test_latexbuilder.rb +++ b/test/test_latexbuilder.rb @@ -169,6 +169,11 @@ def test_inline_u assert_equal 'abc\\reviewunderline{def}ghi', actual end + def test_inline_bou + actual = compile_inline('傍点の@{テスト}です。') + assert_equal '傍点の\\reviewbou{テスト}です。', actual + end + def test_inline_m @config['review_version'] = '3.0' actual = compile_inline('abc@{\\alpha^n = \\inf < 2}ghi') From 571f16dab30b04963e56b38e884d8b880516c58f Mon Sep 17 00:00:00 2001 From: takahashim Date: Sat, 25 May 2019 17:22:57 +0900 Subject: [PATCH 8/8] travis: exec rake --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2b2a56204..928217843 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ before_install: gem install epubcheck-ruby script: + - bundle exec rake - ruby bin/review-init hello && cd hello && ruby ../bin/review-epubmaker config.yml && epubcheck book.epub - cd .. - ruby bin/review-init hello2 --epub-version 2 && cd hello2 && ruby ../bin/review-epubmaker config.yml && epubcheck book.epub