summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPaul Kmiec <[email protected]>2023-05-07 16:09:03 -0700
committerPaul Kmiec <[email protected]>2023-05-09 08:21:58 -0700
commit88c26606594a2024e17adff9dd9853812dc839cc (patch)
treea2206699b97209f5648092f9ceb08dced035a998
parent3b4509a56c9f2fce8bf3194062458ce74c0d41ca (diff)
downloadcaxlsx-88c26606594a2024e17adff9dd9853812dc839cc.tar.gz
caxlsx-88c26606594a2024e17adff9dd9853812dc839cc.zip
Do not change the whitespace that is produced by to_xml_string's
-rw-r--r--.rubocop_todo.yml1
-rw-r--r--lib/axlsx/content_type/abstract_content_type.rb7
-rw-r--r--lib/axlsx/rels/relationship.rb5
-rw-r--r--lib/axlsx/workbook/worksheet/conditional_formatting.rb5
-rw-r--r--lib/axlsx/workbook/worksheet/data_validation.rb6
5 files changed, 17 insertions, 7 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index ad151878..8f8f4bd7 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -441,7 +441,6 @@ Style/ParenthesesAroundCondition:
- 'lib/axlsx/stylesheet/font.rb'
- 'lib/axlsx/util/validators.rb'
- 'lib/axlsx/workbook/worksheet/cell.rb'
- - 'lib/axlsx/workbook/worksheet/data_validation.rb'
- 'lib/axlsx/workbook/worksheet/rich_text_run.rb'
# This cop supports safe autocorrection (--autocorrect).
diff --git a/lib/axlsx/content_type/abstract_content_type.rb b/lib/axlsx/content_type/abstract_content_type.rb
index bca08b7e..6aae8c4b 100644
--- a/lib/axlsx/content_type/abstract_content_type.rb
+++ b/lib/axlsx/content_type/abstract_content_type.rb
@@ -23,8 +23,11 @@ module Axlsx
# Serialize the contenty type to xml
def to_xml_string(node_name = '', str = +'')
- str << "<#{node_name} "
- Axlsx.instance_values_for(self).each { |key, value| str << Axlsx::camel(key) << '="' << value.to_s << '" ' }
+ str << '<' << node_name << ' '
+ Axlsx.instance_values_for(self).each_with_index do |key_value, index|
+ str << ' ' unless index.zero?
+ str << Axlsx::camel(key_value.first) << '="' << key_value.last.to_s << '"'
+ end
str << '/>'
end
end
diff --git a/lib/axlsx/rels/relationship.rb b/lib/axlsx/rels/relationship.rb
index e379fa41..14d15457 100644
--- a/lib/axlsx/rels/relationship.rb
+++ b/lib/axlsx/rels/relationship.rb
@@ -105,7 +105,10 @@ module Axlsx
def to_xml_string(str = +'')
h = Axlsx.instance_values_for(self).reject { |k, _| k == "source_obj" }
str << '<Relationship '
- h.each { |key, value| str << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '" ' }
+ h.each_with_index do |key_value, index|
+ str << ' ' unless index.zero?
+ str << key_value.first.to_s << '="' << Axlsx::coder.encode(key_value.last.to_s) << '"'
+ end
str << '/>'
end
diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting.rb b/lib/axlsx/workbook/worksheet/conditional_formatting.rb
index 7c05c77e..5f8f2474 100644
--- a/lib/axlsx/workbook/worksheet/conditional_formatting.rb
+++ b/lib/axlsx/workbook/worksheet/conditional_formatting.rb
@@ -76,7 +76,10 @@ module Axlsx
# @return [String]
def to_xml_string(str = +'')
str << '<conditionalFormatting sqref="' << sqref << '">'
- rules.each { |rule| rule.to_xml_string(str) }
+ rules.each_with_index do |rule, index|
+ str << ' ' unless index.zero?
+ rule.to_xml_string(str)
+ end
str << '</conditionalFormatting>'
end
end
diff --git a/lib/axlsx/workbook/worksheet/data_validation.rb b/lib/axlsx/workbook/worksheet/data_validation.rb
index d5fa5908..eca90743 100644
--- a/lib/axlsx/workbook/worksheet/data_validation.rb
+++ b/lib/axlsx/workbook/worksheet/data_validation.rb
@@ -235,10 +235,12 @@ module Axlsx
# @return [String]
def to_xml_string(str = +'')
valid_attributes = get_valid_attributes
+ h = Axlsx.instance_values_for(self).select { |key, _| valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym) }
str << '<dataValidation '
- Axlsx.instance_values_for(self).each do |key, value|
- str << key << '="' << Axlsx.booleanize(value).to_s << '" ' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym))
+ h.each_with_index do |key_value, index|
+ str << ' ' unless index.zero?
+ str << key_value.first << '="' << Axlsx.booleanize(key_value.last).to_s << '"'
end
str << '>'
str << '<formula1>' << self.formula1 << '</formula1>' if @formula1 and valid_attributes.include?(:formula1)