lib/massive_sitemap/writer/file.rb in massive_sitemap-2.0.0.rc2 vs lib/massive_sitemap/writer/file.rb in massive_sitemap-2.0.0.rc3

- old
+ new

@@ -1,26 +1,27 @@ require 'fileutils' -require "massive_sitemap/writer/base" +require 'massive_sitemap/writer/base' # Write into File module MassiveSitemap module Writer class File < Base class FileExistsException < IOError; end OPTS = Base::OPTS.merge( - :document_full => '.', + :root => '.', :force_overwrite => false, :filename => "sitemap.xml", :index_filename => "sitemap_index.xml", ) def open_stream - dir = ::File.dirname(tmp_filename) - Dir.mkdir(dir) unless ::File.exists?(dir) + ::File.dirname(tmp_filename).tap do |dir| + FileUtils.mkdir_p(dir) unless ::File.exists?(dir) + end ::File.open(tmp_filename, 'w:ASCII-8BIT') end def close_stream(stream) stream.close @@ -43,18 +44,18 @@ end.compact end private def filename - ::File.join options[:document_full], options[:filename] + ::File.join options[:root], options[:filename] end def tmp_filename filename + ".tmp" end def files - Dir[::File.join(options[:document_full], "*.xml")] + Dir[::File.join(options[:root], "*.xml")] end end end end