lib/axlsx/package.rb in axlsx-1.0.0 vs lib/axlsx/package.rb in axlsx-1.0.1

- old
+ new

@@ -22,16 +22,15 @@ # Initializes your package # # @param [Hash] options A hash that you can use to specify the author and workbook for this package. # @option options [String] :author The author of the document - # @option options [Workbook] :workbook The workbook associated with this package. # @example Package.new :author => 'you!', :workbook => Workbook.new def initialize(options={}) @core, @app = Core.new, App.new @core.creator = options[:author] || @core.creator - self.workbook= options[:workbook] if options[:workbook] + yield self if block_given? end def workbook=(workbook) DataTypeValidator.validate "Package.workbook", Workbook, workbook; @workbook = workbook; end def workbook @@ -53,10 +52,11 @@ # Package.new.serialize(f) # # # You will find a file called test.xlsx def serialize(output, confirm_valid=false) return false unless !confirm_valid || self.validate.empty? - Zip::ZipOutputStream.open(output.path) do |zip| + f = File.new(output, "w") + Zip::ZipOutputStream.open(f.path) do |zip| parts.each{ |part| zip.put_next_entry(part[:entry]); zip.puts(part[:doc]) } end true end