summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/package.rb
diff options
context:
space:
mode:
authorRyan Winograd <[email protected]>2020-08-29 09:42:47 -0500
committerRyan Winograd <[email protected]>2020-08-29 09:42:47 -0500
commit216996bd076f4f3549155774dbccab4b3c634cd0 (patch)
tree460bed7aab51d69c88b8d6487c259bb92d6997aa /lib/axlsx/package.rb
parentc2ac23536dd73ae631f65a45145be170a1186e70 (diff)
downloadcaxlsx-216996bd076f4f3549155774dbccab4b3c634cd0.tar.gz
caxlsx-216996bd076f4f3549155774dbccab4b3c634cd0.zip
Update #serialize to accept 3 arguments
Diffstat (limited to 'lib/axlsx/package.rb')
-rw-r--r--lib/axlsx/package.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb
index 6b55091b..d9865a48 100644
--- a/lib/axlsx/package.rb
+++ b/lib/axlsx/package.rb
@@ -100,8 +100,8 @@ module Axlsx
# # Serialize to a stream
# s = p.to_stream()
# File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
- def serialize(output, options = {})
- confirm_valid, zip_command = parse_serialize_options(options)
+ def serialize(output, options = {}, secondary_options = nil)
+ confirm_valid, zip_command = parse_serialize_options(options, secondary_options)
return false unless !confirm_valid || self.validate.empty?
zip_provider = if zip_command
ZipCommand.new(zip_command)
@@ -366,8 +366,13 @@ module Axlsx
# @return [Boolean, (String or nil)] Returns an array where the first value is
# `confirm_valid` and the second is the `zip_command`.
# @private
- def parse_serialize_options(options)
+ def parse_serialize_options(options, secondary_options)
+ if secondary_options
+ warn "[DEPRECATION] Axlsx::Package#serialize with 3 arguments is deprecated. " +
+ "Use keyword args instead e.g., package.serialize(output, confirm_valid: false, zip_command: 'zip')"
+ end
if options.is_a?(Hash)
+ options.merge!(secondary_options || {})
invalid_keys = options.keys - [:confirm_valid, :zip_command]
if invalid_keys.any?
raise ArgumentError.new("Invalid keyword arguments: #{invalid_keys}")
@@ -376,7 +381,7 @@ module Axlsx
else
warn "[DEPRECATION] Axlsx::Package#serialize with confirm_valid as a boolean is deprecated. " +
"Use keyword args instead e.g., package.serialize(output, confirm_valid: false)"
- [options, nil]
+ parse_serialize_options((secondary_options || {}).merge(confirm_valid: options), nil)
end
end
end