diff options
| author | Randy Morgan <[email protected]> | 2012-10-27 12:28:27 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-10-27 12:28:27 +0900 |
| commit | 2feca4f74f21e6a3e63bd3badd02267be4062047 (patch) | |
| tree | ade7ff9fc3ef2613a4a6634021251de2eaef86b1 | |
| parent | b95a97ad56debbfffa08e72a1428c1b78689d689 (diff) | |
| download | caxlsx-2feca4f74f21e6a3e63bd3badd02267be4062047.tar.gz caxlsx-2feca4f74f21e6a3e63bd3badd02267be4062047.zip | |
removed instance caching for package parts
Some users have reported that they are repeatedly serializing the
package. They need to know that it is not additive, and I need to
remove the instance variable as there is no reason to maintain
completed parts list since it is only used for serialization.
| -rw-r--r-- | lib/axlsx/package.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb index 829eb199..e3981d62 100644 --- a/lib/axlsx/package.rb +++ b/lib/axlsx/package.rb @@ -173,7 +173,7 @@ module Axlsx # @return [Array] An array of hashes that define the entry, document and schema for each part of the package. # @private def parts - @parts = [ + parts = [ {:entry => RELS_PN, :doc => relationships.to_xml_string, :schema => RELS_XSD}, {:entry => "xl/#{STYLES_PN}", :doc => workbook.styles.to_xml_string, :schema => SML_XSD}, {:entry => CORE_PN, :doc => @core.to_xml_string, :schema => CORE_XSD}, @@ -184,39 +184,39 @@ module Axlsx ] workbook.drawings.each do |drawing| - @parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships.to_xml_string, :schema => RELS_XSD} - @parts << {:entry => "xl/#{drawing.pn}", :doc => drawing.to_xml_string, :schema => DRAWING_XSD} + parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships.to_xml_string, :schema => RELS_XSD} + parts << {:entry => "xl/#{drawing.pn}", :doc => drawing.to_xml_string, :schema => DRAWING_XSD} end workbook.tables.each do |table| - @parts << {:entry => "xl/#{table.pn}", :doc => table.to_xml_string, :schema => SML_XSD} + parts << {:entry => "xl/#{table.pn}", :doc => table.to_xml_string, :schema => SML_XSD} end workbook.comments.each do|comment| if comment.size > 0 - @parts << { :entry => "xl/#{comment.pn}", :doc => comment.to_xml_string, :schema => SML_XSD } - @parts << { :entry => "xl/#{comment.vml_drawing.pn}", :doc => comment.vml_drawing.to_xml_string, :schema => nil } + parts << { :entry => "xl/#{comment.pn}", :doc => comment.to_xml_string, :schema => SML_XSD } + parts << { :entry => "xl/#{comment.vml_drawing.pn}", :doc => comment.vml_drawing.to_xml_string, :schema => nil } end end workbook.charts.each do |chart| - @parts << {:entry => "xl/#{chart.pn}", :doc => chart.to_xml_string, :schema => DRAWING_XSD} + parts << {:entry => "xl/#{chart.pn}", :doc => chart.to_xml_string, :schema => DRAWING_XSD} end workbook.images.each do |image| - @parts << {:entry => "xl/#{image.pn}", :path => image.image_src} + parts << {:entry => "xl/#{image.pn}", :path => image.image_src} end if use_shared_strings - @parts << {:entry => "xl/#{SHARED_STRINGS_PN}", :doc => workbook.shared_strings.to_xml_string, :schema => SML_XSD} + parts << {:entry => "xl/#{SHARED_STRINGS_PN}", :doc => workbook.shared_strings.to_xml_string, :schema => SML_XSD} end workbook.worksheets.each do |sheet| - @parts << {:entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships.to_xml_string, :schema => RELS_XSD} - @parts << {:entry => "xl/#{sheet.pn}", :doc => sheet.to_xml_string, :schema => SML_XSD} + parts << {:entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships.to_xml_string, :schema => RELS_XSD} + parts << {:entry => "xl/#{sheet.pn}", :doc => sheet.to_xml_string, :schema => SML_XSD} end - @parts + parts end # Performs xsd validation for a signle document |
