lib/epub/maker.rb in epub-maker-0.0.2 vs lib/epub/maker.rb in epub-maker-0.0.3

- old
+ new

@@ -33,20 +33,20 @@ Archive::Zip.open temp_path.to_path, :w do |archive| file = Archive::Zip::Entry.from_file(mimetype.to_path, compression_codec: Archive::Zip::Codec::Store) archive.add_entry file end - Zip::Archive.open temp_path.to_path do |archive| - yield book if block_given? - book.save archive - end + book.epub_file = temp_path.to_path + yield book if block_given? + book.save path.open 'wb' do |file| raise Error, "File locked by other process: #{path}" unless file.flock File::LOCK_SH|File::LOCK_NB ($VERBOSE ? ::FileUtils::Verbose : ::FileUtils).move temp_path.to_path, path.to_path end dir.remove_entry_secure + book.epub_file = path.to_path book # validate # build_xml # archive @@ -76,16 +76,16 @@ yield package if block_given? end package end - # @param archive [Zip::Archive] - def save(archive) - ocf.save archive - package.save archive + # @param archive [OCF::PhysicalContainer] + def save + ocf.save + package.save resources.each do |item| - item.save archive + item.save end end end end @@ -111,17 +111,9 @@ end end def remove_entry_secure FileUtils.remove_entry_secure to_path - end - - unless method_defined? :write - def write(string, mode='w', perm=0666) - open mode, perm do |file| - file << string - end - end end unless method_defined? :/ alias / + end