Skip to content

Commit

Permalink
Merge branch 'master' into news320
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed May 26, 2019
2 parents 9eeb641 + 9e8b09d commit 6d6d497
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 74 deletions.
31 changes: 16 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ language: ruby
sudo: false
dist: trusty

os:
- linux
- osx

addons:
apt:
packages:
Expand All @@ -12,23 +16,20 @@ 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:
- 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

rvm:
- 2.1
- 2.2.10
- 2.3.8
- 2.4.5
- 2.5.3
- 2.6.0
- 2.4.6
- 2.5.5
- 2.6.3
## - ruby-head

branches:
Expand Down
22 changes: 20 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
- ruby_version: "24"
- ruby_version: "24-x64"
- ruby_version: "25"
- ruby_version: "25-x64"
- ruby_version: "26"
- ruby_version: "26-x64"
2 changes: 1 addition & 1 deletion lib/epubmaker/epubv2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def opf_metainfo
if @producer.config[item].is_a?(Array)
s << @producer.config.names_of(item).map { |i| %Q( <dc:#{item}>#{CGI.escapeHTML(i)}</dc:#{item}>\n) }.join
else
s << %Q( <dc:#{item}>#{CGI.escapeHTML(@producer.config.name_of(item))}</dc:#{item}>\n)
s << %Q( <dc:#{item}>#{CGI.escapeHTML(@producer.config.name_of(item).to_s)}</dc:#{item}>\n)
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/epubmaker/producer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 0 additions & 22 deletions lib/review/preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 23 additions & 16 deletions lib/review/yamlloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions templates/latex/review-jlreq/review-base.sty
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

%% @<del> is ignored in LaTeX with default style
%% \DeclareRobustCommand{\reviewstrike}[1]{#1}
Expand Down
1 change: 1 addition & 0 deletions templates/latex/review-jsbook/review-base.sty
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

%% @<del> is ignored in LaTeX with default style
\DeclareRobustCommand{\reviewstrike}[1]{#1}
Expand Down
5 changes: 5 additions & 0 deletions test/test_latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def test_inline_u
assert_equal 'abc\\reviewunderline{def}ghi', actual
end

def test_inline_bou
actual = compile_inline('傍点の@<bou>{テスト}です。')
assert_equal '傍点の\\reviewbou{テスト}です。', actual
end

def test_inline_m
@config['review_version'] = '3.0'
actual = compile_inline('abc@<m>{\\alpha^n = \\inf < 2}ghi')
Expand Down
18 changes: 2 additions & 16 deletions test/test_preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6d6d497

Please sign in to comment.