Skip to content

Commit

Permalink
Merge pull request #1548 from kmuto/remove-book-load
Browse files Browse the repository at this point in the history
remove ReVIEW::Book.load, modify ReVIEW::Book::Base.load
  • Loading branch information
takahashim authored Aug 18, 2020
2 parents 2883d60 + 4d3c1a0 commit 2d89aa0
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bin/review-compile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _main
end
end
when :dir
book = @basedir ? ReVIEW::Book.load(@basedir) : ReVIEW::Book::Base.load
book = @basedir ? ReVIEW::Book::Base.load(@basedir) : ReVIEW::Book::Base.load
book.config = @config
compiler = ReVIEW::Compiler.new(load_builder_class(@target, @check_only))
book.chapters.each do |chap|
Expand Down
4 changes: 2 additions & 2 deletions lib/review/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

module ReVIEW
module Book
def self.load(dir)
Base.load(dir)
def self.load(_dir)
raise NotImplementedError, 'ReVIEW::Book.load is obsoleted. Please use ReVIEW::Book::Base.load.'
end
end
end
8 changes: 4 additions & 4 deletions lib/review/book/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class Base
attr_writer :catalog
attr_reader :basedir

def self.load(dir = '.')
new(dir)
def self.load(basedir = '.', config: nil)
new(basedir, config: config)
end

def initialize(basedir = '.')
def initialize(basedir = '.', config: nil)
@basedir = basedir
@logger = ReVIEW.logger
@parts = nil
@chapter_index = nil
@config = ReVIEW::Configure.values
@config = config || ReVIEW::Configure.values
@catalog = nil
@warn_old_files = {} # XXX for checking CHAPS, PREDEF, POSTDEF
@basedir_seen = {}
Expand Down
3 changes: 1 addition & 2 deletions lib/review/epubmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ def build_body(basetmpdir, yamlfile)

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

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

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

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

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

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

build_body(@path, yamlfile)
end
Expand Down
3 changes: 1 addition & 2 deletions 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
@book = ReVIEW::Book::Base.load('.', config: @config)
@upper = 4
@indent = true
@buildonly = nil
Expand All @@ -59,7 +59,6 @@ def initialize

def execute(*args)
parse_options(args)
@book.config = ReVIEW::Configure.values
unless File.readable?(@yamlfile)
@logger.error("No such fiile or can't open #{@yamlfile}.")
exit 1
Expand Down
3 changes: 1 addition & 2 deletions lib/review/volumeprinter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def initialize

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

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

copy_stylesheet(@path)
copy_frontmatter(@path)
Expand Down
3 changes: 1 addition & 2 deletions test/book_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def mktmpbookdir(files = {})
File.open(path, 'w') { |o| o.print content }
created_files[basename] = path
end
book = Book::Base.load(dir)
book.config = ReVIEW::Configure.values
book = Book::Base.load(dir, config: ReVIEW::Configure.values)
yield(dir, book, created_files)
end
end
Expand Down

0 comments on commit 2d89aa0

Please sign in to comment.