lib/epub/maker.rb in epub-maker-0.0.9 vs lib/epub/maker.rb in epub-maker-0.1.0

- old
+ new

@@ -4,12 +4,10 @@ require 'tempfile' require 'tmpdir' require 'time' require 'archive/zip' require 'epub' -require 'epub/constants' -require 'epub/book' require 'epub/parser' require "epub/maker/version" require 'epub/maker/ocf' require 'epub/maker/publication' require 'epub/maker/content_document' @@ -59,23 +57,25 @@ error.set_backtrace backtrace raise error end # Substance of +epub-archive+ command - # @param source_file [Pathname, String] + # @param source_dir [Pathname, String] # @param epub_file [Pathname, String, nil] # @return [Pathname] Path to generated EPUB file # @raise [RuntimeError] if directory +source_dir+ doesn't exist # @raise [Archive::Zip::Error] if something goes wrong around ZIP archive manipulation # @todo Accept usage that +epub-archive path/to/boo .+ generates ./book.epub # @todo Abstract ZIP library # @todo Accept compression method option # @todo Accept compression level option def archive(source_dir, epub_file = nil) + source_dir = source_dir.to_s + source_dir = source_dir.to_s[0..-2] if source_dir.to_s.end_with? "/" + epub_file ||= source_dir + ".epub" source_dir = Pathname(source_dir) raise "source directory #{source_dir} not exist" unless source_dir.exist? - epub_file ||= source_dir.sub_ext(".epub") epub_file = Pathname(epub_file) temp_dest = Pathname(Tempfile.create(epub_file.basename.to_path, epub_file.dirname.to_path)) Pathname.mktmpdir "epub-maker" do |dir| temp_container = dir/source_dir.basename