lib/epub/parser.rb in epub-parser-0.0.3 vs lib/epub/parser.rb in epub-parser-0.0.4
- old
+ new
@@ -1,6 +1,5 @@
-require 'epub/book'
require 'epub/constants'
require 'epub/parser/version'
require 'epub/parser/ocf'
require 'epub/parser/publication'
require 'epub/parser/content_document'
@@ -21,22 +20,22 @@
@filepath = File.realpath filepath
Dir.mkdir(root_directory) unless File.directory? root_directory
@dir = File.realpath root_directory
- @book = Book.new
+ @book = create_book options
unzip_cmd = options['unzip-command'] || 'unzip'
unzip_cmd << " #{@filepath.to_s.shellescape} -d #{@dir.to_s.shellescape}"
system unzip_cmd
puts unzip_cmd
end
def parse
@book.ocf = parse_ocf
@book.package = parse_publication
- @book.content_document = parse_content_document
+ # @book.content_document =??? parse_content_document
# ...
@book
end
@@ -48,8 +47,22 @@
Publication.parse File.join(@dir, @book.rootfile_path)
end
def parse_content_document
# ContentDocument.parse @dir
+ end
+
+ private
+
+ def create_book(params)
+ case
+ when params[:book]
+ options[:book]
+ when params[:class]
+ options[:class].new
+ else
+ require 'epub/book'
+ Book.new
+ end
end
end
end