Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Book::Base.new (with :config) instead of Book::Base.load #1563

Merged
merged 1 commit into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions bin/review-check
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ end

def main
@config = ReVIEW::Configure.values
@book = ReVIEW::Book::Base.load
@book.config = @config

@book = ReVIEW::Book::Base.new(config: @config)
@logger = ReVIEW.logger

modes = nil
Expand Down
6 changes: 2 additions & 4 deletions bin/review-compile
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def _main
error('no input') if ARGV.empty?

@basedir = File.dirname(ARGV[0])
book = ReVIEW::Book::Base.load(@basedir)
book.config = @config # needs only at the first time
book = ReVIEW::Book::Base.new(@basedir, config: @config)
ARGV.each do |item|
error("file not found: #{item}") unless File.exist?(File.join(book.config['contentdir'], item))
chap_name = File.basename(item, '.*')
Expand All @@ -94,8 +93,7 @@ def _main
end
end
when :dir
book = @basedir ? ReVIEW::Book::Base.load(@basedir) : ReVIEW::Book::Base.load
book.config = @config
book = @basedir ? ReVIEW::Book::Base.new(@basedir, config: @config) : ReVIEW::Book::Base.new(config: @config)
compiler = ReVIEW::Compiler.new(load_builder_class(@target, @check_only))
book.chapters.each do |chap|
str = compiler.compile(chap)
Expand Down
2 changes: 1 addition & 1 deletion lib/review/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
module ReVIEW
module Book
def self.load(_dir)
raise NotImplementedError, 'ReVIEW::Book.load is obsoleted. Please use ReVIEW::Book::Base.load.'
raise NotImplementedError, 'ReVIEW::Book.load is obsoleted. Please use ReVIEW::Book::Base.new.'
end
end
end
2 changes: 1 addition & 1 deletion lib/review/epubmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def build_body(basetmpdir, yamlfile)

basedir = File.dirname(yamlfile)
base_path = Pathname.new(basedir)
book = ReVIEW::Book::Base.load(basedir, config: @config)
book = ReVIEW::Book::Base.new(basedir, config: @config)
@converter = ReVIEW::Converter.new(book, ReVIEW::HTMLBuilder.new)
@compile_errors = nil

Expand Down
2 changes: 1 addition & 1 deletion lib/review/idgxmlmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def generate_idgxml_files(yamlfile)
remove_old_files(@path)
Dir.mkdir(@path)

@book = ReVIEW::Book::Base.load(@basedir, config: @config)
@book = ReVIEW::Book::Base.new(@basedir, config: @config)
if @table
@book.config['tableopt'] = @table
end
Expand Down
2 changes: 1 addition & 1 deletion lib/review/pdfmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def generate_pdf
begin
@compile_errors = nil

book = ReVIEW::Book::Base.load(@basedir, config: @config)
book = ReVIEW::Book::Base.new(@basedir, config: @config)
@converter = ReVIEW::Converter.new(book, ReVIEW::LATEXBuilder.new)

@input_files = make_input_files(book)
Expand Down
2 changes: 1 addition & 1 deletion lib/review/textmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def generate_text_files(yamlfile)
remove_old_files(@path)
Dir.mkdir(@path)

@book = ReVIEW::Book::Base.load(@basedir, config: @config)
@book = ReVIEW::Book::Base.new(@basedir, config: @config)

build_body(@path, yamlfile)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/review/tocprinter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def initialize
@logger = ReVIEW.logger
@config = ReVIEW::Configure.values
@yamlfile = 'config.yml'
@book = ReVIEW::Book::Base.load('.', config: @config)
@book = ReVIEW::Book::Base.new('.', config: @config)
@upper = 4
@indent = true
@buildonly = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/review/volumeprinter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def initialize

def execute(*args)
parse_options(args)
@book = ReVIEW::Book::Base.load('.', config: @config)
@book = ReVIEW::Book::Base.new('.', config: @config)
unless File.readable?(@yamlfile)
@logger.error("No such fiile or can't open #{@yamlfile}.")
exit 1
Expand Down
2 changes: 1 addition & 1 deletion lib/review/webmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def generate_html_files(yamlfile)
remove_old_files(@path)
Dir.mkdir(@path)

@book = ReVIEW::Book::Base.load(@basedir, config: @config)
@book = ReVIEW::Book::Base.new(@basedir, config: @config)

copy_stylesheet(@path)
copy_frontmatter(@path)
Expand Down
2 changes: 1 addition & 1 deletion test/book_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def mktmpbookdir(files = {})
else
config = ReVIEW::Configure.values
end
book = Book::Base.load(dir, config: config)
book = Book::Base.new(dir, config: config)
yield(dir, book, created_files)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_update_rubyenv
begin
Dir.mktmpdir do |dir|
File.write(File.join(dir, 'review-ext.rb'), "#{test_const} = #{num}")
Book::Base.load(dir)
Book::Base.new(dir)
assert_equal num, (Object.class_eval { const_get(test_const) })
end
ensure
Expand Down
6 changes: 3 additions & 3 deletions test/test_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_initialize

def test_bind
b = Builder.new
chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, nil, '-', nil)
chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, nil, '-', nil)
assert_nothing_raised do
b.bind(nil, chap, nil)
end
Expand All @@ -37,7 +37,7 @@ def test_result
end

b = Builder.new
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, nil, '-', nil)
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, nil, '-', nil)
b.bind(nil, chapter, nil)
assert_equal '', b.result
end
Expand Down Expand Up @@ -82,7 +82,7 @@ def test_compile_inline_backslash

def test_inline_missing_ref
b = Builder.new
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, 1, 'chap1', nil, StringIO.new)
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.new, 1, 'chap1', nil, StringIO.new)
b.bind(nil, chapter, nil)
e = assert_raises(ReVIEW::ApplicationError) { b.inline_list('unknown|list1') }
assert_equal ': error: unknown list: unknown|list1', e.message
Expand Down
6 changes: 3 additions & 3 deletions test/test_htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def @chapter.list(_id)
end

def test_inline_list_href
book = ReVIEW::Book::Base.load
book = ReVIEW::Book::Base.new
book.config['chapterlink'] = true
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
io1 = StringIO.new("//list[sampletest][a]{\nfoo\n//}\n")
Expand Down Expand Up @@ -2220,7 +2220,7 @@ def test_inline_fn
end

def test_inline_hd
book = ReVIEW::Book::Base.load
book = ReVIEW::Book::Base.new
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
Expand All @@ -2242,7 +2242,7 @@ def test_inline_hd
end

def test_inline_hd_for_part
book = ReVIEW::Book::Base.load
book = ReVIEW::Book::Base.new
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
Expand Down
2 changes: 1 addition & 1 deletion test/test_webtocprinter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def setup
end

def test_webtocprinter_null
dummy_book = ReVIEW::Book::Base.load
dummy_book = ReVIEW::Book::Base.new
# chap = ReVIEW::Book::Chapter.new(dummy_book, 1, '-', nil, StringIO.new)
str = WEBTOCPrinter.book_to_string(dummy_book)
expect = <<-EOB
Expand Down