diff options
| author | Zsolt Kozaroczy <[email protected]> | 2023-05-05 11:45:59 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-05 11:45:59 +0200 |
| commit | 916ba45a77302bcd6e81f2a61a6cff6a2f1f8367 (patch) | |
| tree | cf28aa1a8ca2c39e03ddca16086ec85b77410269 | |
| parent | 3d10ac1e1b067de94e4344b25cbfeecd7bf4bdde (diff) | |
| parent | 816ca05a3903fa4595c4e8382c6201e2615e72f4 (diff) | |
| download | caxlsx-916ba45a77302bcd6e81f2a61a6cff6a2f1f8367.tar.gz caxlsx-916ba45a77302bcd6e81f2a61a6cff6a2f1f8367.zip | |
Merge pull request #219 from pkmiec/frozenStrings
Frozen strings
269 files changed, 968 insertions, 444 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fbe7cb50..5cfa24bf 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -266,12 +266,6 @@ Style/FormatString: Style/FormatStringToken: EnforcedStyle: unannotated -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Enabled: false - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: diff --git a/CHANGELOG.md b/CHANGELOG.md index ec38447e..49cae46a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ CHANGELOG --------- - **Unreleased**: 4.0.0 - Drop support for Ruby versions < 2.6 + - Added frozen string literals - **April.23.23**: 3.4.1 - [PR #209](https://github.com/caxlsx/caxlsx/pull/209) - Revert characters other than `=` being considered as formulas. @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require File.expand_path(File.dirname(__FILE__) + '/lib/axlsx/version.rb') task :build => :gendoc do diff --git a/axlsx.gemspec b/axlsx.gemspec index a15f4129..34942176 100644 --- a/axlsx.gemspec +++ b/axlsx.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require File.expand_path('../lib/axlsx/version', __FILE__) Gem::Specification.new do |s| diff --git a/lib/axlsx.rb b/lib/axlsx.rb index 0fd8260c..912be81d 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'htmlentities' require 'axlsx/version.rb' require 'marcel' @@ -109,7 +111,7 @@ module Axlsx # @note This follows the standard spreadsheet convention of naming columns A to Z, followed by AA to AZ etc. # @return [String] def self.col_ref(index) - chars = '' + chars = +'' while index >= 26 do index, char = index.divmod(26) chars.prepend((char + 65).chr) diff --git a/lib/axlsx/content_type/abstract_content_type.rb b/lib/axlsx/content_type/abstract_content_type.rb index 45bd4853..58ca8b2c 100644 --- a/lib/axlsx/content_type/abstract_content_type.rb +++ b/lib/axlsx/content_type/abstract_content_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class extracts the common parts from Default and Override class AbstractContentType @@ -20,7 +22,7 @@ module Axlsx alias :ContentType= :content_type= # Serialize the contenty type to xml - def to_xml_string(node_name = '', str = '') + def to_xml_string(node_name = '', str = +'') str << "<#{node_name} " str << Axlsx.instance_values_for(self).map { |key, value| Axlsx::camel(key) << '="' << value.to_s << '"' }.join(' ') str << '/>' diff --git a/lib/axlsx/content_type/content_type.rb b/lib/axlsx/content_type/content_type.rb index 48b5b6a9..15751b17 100644 --- a/lib/axlsx/content_type/content_type.rb +++ b/lib/axlsx/content_type/content_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx require 'axlsx/content_type/abstract_content_type.rb' require 'axlsx/content_type/default.rb' @@ -12,9 +14,9 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<Types xmlns="' << XML_NS_T << '">') + str << (+'<Types xmlns="' << XML_NS_T << '">') each { |type| type.to_xml_string(str) } str << '</Types>' end diff --git a/lib/axlsx/content_type/default.rb b/lib/axlsx/content_type/default.rb index d5901456..16189fc6 100644 --- a/lib/axlsx/content_type/default.rb +++ b/lib/axlsx/content_type/default.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # An default content part. These parts are automatically created by for you based on the content of your package. class Default < AbstractContentType @@ -14,7 +16,7 @@ module Axlsx alias :Extension= :extension= # Serializes this object to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') super(NODE_NAME, str) end end diff --git a/lib/axlsx/content_type/override.rb b/lib/axlsx/content_type/override.rb index 5fb98d4c..be45db3c 100644 --- a/lib/axlsx/content_type/override.rb +++ b/lib/axlsx/content_type/override.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # An override content part. These parts are automatically created by for you based on the content of your package. class Override < AbstractContentType @@ -14,7 +16,7 @@ module Axlsx alias :PartName= :part_name= # Serializes this object to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') super(NODE_NAME, str) end end diff --git a/lib/axlsx/doc_props/app.rb b/lib/axlsx/doc_props/app.rb index 965b34dc..3eae1e28 100644 --- a/lib/axlsx/doc_props/app.rb +++ b/lib/axlsx/doc_props/app.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # App represents the app.xml document. The attributes for this object are primarily managed by the application the end user uses to edit the document. None of the attributes are required to serialize a valid xlsx object. # @see shared-documentPropertiesExtended.xsd @@ -217,9 +219,9 @@ module Axlsx # Serialize the app.xml document # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">') + str << (+'<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">') Axlsx.instance_values_for(self).each do |key, value| node_name = Axlsx.camel(key) str << "<#{node_name}>#{value}</#{node_name}>" diff --git a/lib/axlsx/doc_props/core.rb b/lib/axlsx/doc_props/core.rb index 0f3b6333..8d3292e9 100644 --- a/lib/axlsx/doc_props/core.rb +++ b/lib/axlsx/doc_props/core.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The core object for the package. # @note Packages manage their own core object. @@ -20,13 +22,13 @@ module Axlsx # serializes the core.xml document # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ') - str << ('xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ') - str << ('xmlns:xsi="' << CORE_NS_XSI << '">') - str << ('<dc:creator>' << self.creator << '</dc:creator>') - str << ('<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>') + str << (+'<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ') + str << (+'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ') + str << (+'xmlns:xsi="' << CORE_NS_XSI << '">') + str << (+'<dc:creator>' << self.creator << '</dc:creator>') + str << (+'<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>') str << '<cp:revision>0</cp:revision>' str << '</cp:coreProperties>' end diff --git a/lib/axlsx/drawing/area_chart.rb b/lib/axlsx/drawing/area_chart.rb index 0c5193c6..8339c255 100644 --- a/lib/axlsx/drawing/area_chart.rb +++ b/lib/axlsx/drawing/area_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The AreaChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet. # @example Creating a chart @@ -72,16 +74,16 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do - str << ("<c:" << node_name << ">") - str << ('<c:grouping val="' << grouping.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+"<c:" << node_name << ">") + str << (+'<c:grouping val="' << grouping.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls yield if block_given? axes.to_xml_string(str, :ids => true) - str << ("</c:" << node_name << ">") + str << (+"</c:" << node_name << ">") axes.to_xml_string(str) end end diff --git a/lib/axlsx/drawing/area_series.rb b/lib/axlsx/drawing/area_series.rb index 7995c5bc..9d87d078 100644 --- a/lib/axlsx/drawing/area_series.rb +++ b/lib/axlsx/drawing/area_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A AreaSeries defines the title, data and labels for line charts # @note The recommended way to manage series is to use Chart#add_series @@ -69,15 +71,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do if color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln w="28800">' str << '<a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '</a:ln>' str << '<a:round/>' @@ -92,7 +94,7 @@ module Axlsx @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? - str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') + str << (+'<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') end end diff --git a/lib/axlsx/drawing/ax_data_source.rb b/lib/axlsx/drawing/ax_data_source.rb index b8aafc5e..c9d4300f 100644 --- a/lib/axlsx/drawing/ax_data_source.rb +++ b/lib/axlsx/drawing/ax_data_source.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # An axis data source that can contain referenced or literal strings or numbers # @note only string data types are supported - mainly because we have not implemented a chart type that requires a numerical axis value diff --git a/lib/axlsx/drawing/axes.rb b/lib/axlsx/drawing/axes.rb index 314f28c3..0baad85f 100644 --- a/lib/axlsx/drawing/axes.rb +++ b/lib/axlsx/drawing/axes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Axes class creates and manages axis information and # serialization for charts. @@ -27,11 +29,11 @@ module Axlsx # @option options ids # If the ids option is specified only the axis identifier is # serialized. Otherwise, each axis is serialized in full. - def to_xml_string(str = '', options = {}) + def to_xml_string(str = +'', options = {}) if options[:ids] # CatAxis must come first in the XML (for Microsoft Excel at least) sorted = axes.sort_by { |name, axis| axis.kind_of?(CatAxis) ? 0 : 1 } - sorted.each { |axis| str << ('<c:axId val="' << axis[1].id.to_s << '"/>') } + sorted.each { |axis| str << (+'<c:axId val="' << axis[1].id.to_s << '"/>') } else axes.each { |axis| axis[1].to_xml_string(str) } end diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb index 601a7c85..38e57da5 100644 --- a/lib/axlsx/drawing/axis.rb +++ b/lib/axlsx/drawing/axis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # the access class defines common properties and values for a chart axis. class Axis @@ -146,11 +148,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<c:axId val="' << @id.to_s << '"/>') + def to_xml_string(str = +'') + str << (+'<c:axId val="' << @id.to_s << '"/>') @scaling.to_xml_string str - str << ('<c:delete val="' << @delete.to_s << '"/>') - str << ('<c:axPos val="' << @ax_pos.to_s << '"/>') + str << (+'<c:delete val="' << @delete.to_s << '"/>') + str << (+'<c:axPos val="' << @ax_pos.to_s << '"/>') str << '<c:majorGridlines>' # TODO: shape properties need to be extracted into a class if gridlines == false @@ -165,21 +167,21 @@ module Axlsx # Need to set sourceLinked to 0 if we're setting a format code on this row # otherwise it will never take, as it will always prefer the 'General' formatting # of the cells themselves - str << ('<c:numFmt formatCode="' << @format_code << '" sourceLinked="' << (@format_code.eql?('General') ? '1' : '0') << '"/>') + str << (+'<c:numFmt formatCode="' << @format_code << '" sourceLinked="' << (@format_code.eql?('General') ? '1' : '0') << '"/>') str << '<c:majorTickMark val="none"/>' str << '<c:minorTickMark val="none"/>' - str << ('<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>') + str << (+'<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>') # TODO: this is also being used for series colors # time to extract this into a class spPr - Shape Properties if @color str << '<c:spPr><a:ln><a:solidFill>' - str << ('<a:srgbClr val="' << @color << '"/>') + str << (+'<a:srgbClr val="' << @color << '"/>') str << '</a:solidFill></a:ln></c:spPr>' end # some potential value in implementing this in full. Very detailed! - str << ('<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>') - str << ('<c:crossAx val="' << @cross_axis.id.to_s << '"/>') - str << ('<c:crosses val="' << @crosses.to_s << '"/>') + str << (+'<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>') + str << (+'<c:crossAx val="' << @cross_axis.id.to_s << '"/>') + str << (+'<c:crosses val="' << @crosses.to_s << '"/>') end end end diff --git a/lib/axlsx/drawing/bar_3D_chart.rb b/lib/axlsx/drawing/bar_3D_chart.rb index 89544be0..37ac7dab 100644 --- a/lib/axlsx/drawing/bar_3D_chart.rb +++ b/lib/axlsx/drawing/bar_3D_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Bar3DChart is a three dimentional barchart (who would have guessed?) that you can add to your worksheet. # @see Worksheet#add_chart @@ -118,17 +120,17 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:bar3DChart>' - str << ('<c:barDir val="' << bar_dir.to_s << '"/>') - str << ('<c:grouping val="' << grouping.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:barDir val="' << bar_dir.to_s << '"/>') + str << (+'<c:grouping val="' << grouping.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls - str << ('<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? - str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil? - str << ('<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? + str << (+'<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? + str << (+'<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil? + str << (+'<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? axes.to_xml_string(str, :ids => true) str << '</c:bar3DChart>' axes.to_xml_string(str) diff --git a/lib/axlsx/drawing/bar_chart.rb b/lib/axlsx/drawing/bar_chart.rb index 1ed38332..eca54dfc 100644 --- a/lib/axlsx/drawing/bar_chart.rb +++ b/lib/axlsx/drawing/bar_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The BarChart is a two dimentional barchart that you can add to your worksheet. # @see Worksheet#add_chart @@ -108,17 +110,17 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:barChart>' - str << ('<c:barDir val="' << bar_dir.to_s << '"/>') - str << ('<c:grouping val="' << grouping.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:barDir val="' << bar_dir.to_s << '"/>') + str << (+'<c:grouping val="' << grouping.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls - str << ('<c:overlap val="' << @overlap.to_s << '"/>') unless @overlap.nil? - str << ('<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? - str << ('<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? + str << (+'<c:overlap val="' << @overlap.to_s << '"/>') unless @overlap.nil? + str << (+'<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? + str << (+'<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? axes.to_xml_string(str, :ids => true) str << '</c:barChart>' axes.to_xml_string(str) diff --git a/lib/axlsx/drawing/bar_series.rb b/lib/axlsx/drawing/bar_series.rb index 0b4d9614..c744175f 100644 --- a/lib/axlsx/drawing/bar_series.rb +++ b/lib/axlsx/drawing/bar_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A BarSeries defines the title, data and labels for bar charts # @note The recommended way to manage series is to use Chart#add_series @@ -56,19 +58,19 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do colors.each_with_index do |c, index| str << '<c:dPt>' - str << ('<c:idx val="' << index.to_s << '"/>') + str << (+'<c:idx val="' << index.to_s << '"/>') str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << c << '"/>') + str << (+'<a:srgbClr val="' << c << '"/>') str << '</a:solidFill></c:spPr></c:dPt>' end if series_color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << series_color << '"/>') + str << (+'<a:srgbClr val="' << series_color << '"/>') str << '</a:solidFill>' str << '</c:spPr>' end @@ -76,7 +78,7 @@ module Axlsx @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? # this is actually only required for shapes other than box - str << ('<c:shape val="' << shape.to_s << '"></c:shape>') + str << (+'<c:shape val="' << shape.to_s << '"></c:shape>') end end diff --git a/lib/axlsx/drawing/bubble_chart.rb b/lib/axlsx/drawing/bubble_chart.rb index 084d0477..b4932042 100644 --- a/lib/axlsx/drawing/bubble_chart.rb +++ b/lib/axlsx/drawing/bubble_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The BubbleChart allows you to insert a bubble chart into your worksheet # @see Worksheet#add_chart @@ -33,10 +35,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:bubbleChart>' - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } d_lbls.to_xml_string(str) if @d_lbls axes.to_xml_string(str, :ids => true) diff --git a/lib/axlsx/drawing/bubble_series.rb b/lib/axlsx/drawing/bubble_series.rb index 78b44bf1..25335270 100644 --- a/lib/axlsx/drawing/bubble_series.rb +++ b/lib/axlsx/drawing/bubble_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A BubbleSeries defines the x/y position and bubble size of data in the chart # @note The recommended way to manage series is to use Chart#add_series @@ -39,15 +41,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do # needs to override the super color here to push in ln/and something else! if color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') + str << (+'<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') str << '</c:spPr>' end @xData.to_xml_string(str) unless @xData.nil? diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb index 75290da0..a36f62d1 100644 --- a/lib/axlsx/drawing/cat_axis.rb +++ b/lib/axlsx/drawing/cat_axis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A CatAxis object defines a chart category axis class CatAxis < Axis @@ -66,14 +68,14 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:catAx>' super(str) - str << ('<c:auto val="' << @auto.to_s << '"/>') - str << ('<c:lblAlgn val="' << @lbl_algn.to_s << '"/>') - str << ('<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>') - str << ('<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') - str << ('<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') + str << (+'<c:auto val="' << @auto.to_s << '"/>') + str << (+'<c:lblAlgn val="' << @lbl_algn.to_s << '"/>') + str << (+'<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>') + str << (+'<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') + str << (+'<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') str << '</c:catAx>' end end diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index 0c68ff4b..300a5086 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A Chart is the superclass for specific charts # @note Worksheet#add_chart is the recommended way to create charts for your worksheets. @@ -202,15 +204,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '" xmlns:r="' << XML_NS_R << '">') - str << ('<c:date1904 val="' << Axlsx::Workbook.date1904.to_s << '"/>') - str << ('<c:roundedCorners val="' << rounded_corners.to_s << '"/>') - str << ('<c:style val="' << style.to_s << '"/>') + str << (+'<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '" xmlns:r="' << XML_NS_R << '">') + str << (+'<c:date1904 val="' << Axlsx::Workbook.date1904.to_s << '"/>') + str << (+'<c:roundedCorners val="' << rounded_corners.to_s << '"/>') + str << (+'<c:style val="' << style.to_s << '"/>') str << '<c:chart>' @title.to_xml_string(str) unless @title.empty? - str << ('<c:autoTitleDeleted val="' << @title.nil?.to_s << '"/>') + str << (+'<c:autoTitleDeleted val="' << @title.nil?.to_s << '"/>') @view_3D.to_xml_string(str) if @view_3D str << '<c:floor><c:thickness val="0"/></c:floor>' str << '<c:sideWall><c:thickness val="0"/></c:sideWall>' @@ -221,13 +223,13 @@ module Axlsx str << '</c:plotArea>' if @show_legend str << '<c:legend>' - str << ('<c:legendPos val="' << @legend_position.to_s << '"/>') + str << (+'<c:legendPos val="' << @legend_position.to_s << '"/>') str << '<c:layout/>' str << '<c:overlay val="0"/>' str << '</c:legend>' end - str << ('<c:plotVisOnly val="' << @plot_visible_only.to_s << '"/>') - str << ('<c:dispBlanksAs val="' << display_blanks_as.to_s << '"/>') + str << (+'<c:plotVisOnly val="' << @plot_visible_only.to_s << '"/>') + str << (+'<c:dispBlanksAs val="' << display_blanks_as.to_s << '"/>') str << '<c:showDLblsOverMax val="1"/>' str << '</c:chart>' if bg_color diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb index 358378c5..4e2bd40c 100644 --- a/lib/axlsx/drawing/d_lbls.rb +++ b/lib/axlsx/drawing/d_lbls.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # There are more elements in the dLbls spec that allow for # customizations and formatting. For now, I am just implementing the @@ -69,7 +71,7 @@ module Axlsx # serializes the data labels # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') validate_attributes_for_chart_type str << '<c:dLbls>' instance_vals = Axlsx.instance_values_for(self) diff --git a/lib/axlsx/drawing/drawing.rb b/lib/axlsx/drawing/drawing.rb index bc6dd1cf..7be169be 100644 --- a/lib/axlsx/drawing/drawing.rb +++ b/lib/axlsx/drawing/drawing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx require 'axlsx/drawing/d_lbls.rb' require 'axlsx/drawing/title.rb' @@ -153,9 +155,9 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' - str << ('<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">') + str << (+'<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">') anchors.each { |anchor| anchor.to_xml_string(str) } str << '</xdr:wsDr>' end diff --git a/lib/axlsx/drawing/graphic_frame.rb b/lib/axlsx/drawing/graphic_frame.rb index 006b3b0f..7d0e818c 100644 --- a/lib/axlsx/drawing/graphic_frame.rb +++ b/lib/axlsx/drawing/graphic_frame.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A graphic frame defines a container for a chart object # @note The recommended way to manage charts is Worksheet#add_chart @@ -29,11 +31,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') # macro attribute should be optional! str << '<xdr:graphicFrame>' str << '<xdr:nvGraphicFramePr>' - str << ('<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>') + str << (+'<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>') str << '<xdr:cNvGraphicFramePr/>' str << '</xdr:nvGraphicFramePr>' str << '<xdr:xfrm>' @@ -41,8 +43,8 @@ module Axlsx str << '<a:ext cx="0" cy="0"/>' str << '</xdr:xfrm>' str << '<a:graphic>' - str << ('<a:graphicData uri="' << XML_NS_C << '">') - str << ('<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="' << rId << '"/>') + str << (+'<a:graphicData uri="' << XML_NS_C << '">') + str << (+'<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="' << rId << '"/>') str << '</a:graphicData>' str << '</a:graphic>' str << '</xdr:graphicFrame>' diff --git a/lib/axlsx/drawing/hyperlink.rb b/lib/axlsx/drawing/hyperlink.rb index 4d3b343d..3fb97069 100644 --- a/lib/axlsx/drawing/hyperlink.rb +++ b/lib/axlsx/drawing/hyperlink.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # a hyperlink object adds an action to an image when clicked so that when the image is clicked the link is fecthed. # @note using the hyperlink option when calling add_image on a drawing object is the recommended way to manage hyperlinks @@ -90,7 +92,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag 'a:hlinkClick', str, { :'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R } end end diff --git a/lib/axlsx/drawing/line_3D_chart.rb b/lib/axlsx/drawing/line_3D_chart.rb index 85d04b06..6a659550 100644 --- a/lib/axlsx/drawing/line_3D_chart.rb +++ b/lib/axlsx/drawing/line_3D_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Line3DChart is a three dimentional line chart (who would have guessed?) that you can add to your worksheet. # @example Creating a chart @@ -55,9 +57,9 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do - str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil? + str << (+'<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil? end end end diff --git a/lib/axlsx/drawing/line_chart.rb b/lib/axlsx/drawing/line_chart.rb index 1ff2bde5..ab2012c7 100644 --- a/lib/axlsx/drawing/line_chart.rb +++ b/lib/axlsx/drawing/line_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The LineChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet. # @example Creating a chart @@ -72,16 +74,16 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do - str << ("<c:" << node_name << ">") - str << ('<c:grouping val="' << grouping.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+"<c:" << node_name << ">") + str << (+'<c:grouping val="' << grouping.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls yield if block_given? axes.to_xml_string(str, :ids => true) - str << ("</c:" << node_name << ">") + str << (+"</c:" << node_name << ">") axes.to_xml_string(str) end end diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb index 18719277..42c86873 100644 --- a/lib/axlsx/drawing/line_series.rb +++ b/lib/axlsx/drawing/line_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A LineSeries defines the title, data and labels for line charts # @note The recommended way to manage series is to use Chart#add_series @@ -69,15 +71,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do if color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln w="28800">' str << '<a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '</a:ln>' str << '<a:round/>' @@ -92,7 +94,7 @@ module Axlsx @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? - str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') + str << (+'<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') end end diff --git a/lib/axlsx/drawing/marker.rb b/lib/axlsx/drawing/marker.rb index a4933c33..987af605 100644 --- a/lib/axlsx/drawing/marker.rb +++ b/lib/axlsx/drawing/marker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Marker class defines a point in the worksheet that drawing anchors attach to. # @note The recommended way to manage markers is Worksheet#add_chart Markers are created for a two cell anchor based on the :start and :end options. @@ -54,9 +56,9 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') [:col, :colOff, :row, :rowOff].each do |k| - str << ('<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>') + str << (+'<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>') end end diff --git a/lib/axlsx/drawing/num_data.rb b/lib/axlsx/drawing/num_data.rb index 7239ac5f..79108777 100644 --- a/lib/axlsx/drawing/num_data.rb +++ b/lib/axlsx/drawing/num_data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class specifies data for a particular data point. It is used for both numCache and numLit object class NumData @@ -34,14 +36,14 @@ module Axlsx end # serialize the object - def to_xml_string(str = "") - str << ('<c:' << @tag_name.to_s << '>') - str << ('<c:formatCode>' << format_code.to_s << '</c:formatCode>') - str << ('<c:ptCount val="' << @pt.size.to_s << '"/>') + def to_xml_string(str = +'') + str << (+'<c:' << @tag_name.to_s << '>') + str << (+'<c:formatCode>' << format_code.to_s << '</c:formatCode>') + str << (+'<c:ptCount val="' << @pt.size.to_s << '"/>') @pt.each_with_index do |num_val, index| num_val.to_xml_string index, str end - str << ('</c:' << @tag_name.to_s << '>') + str << (+'</c:' << @tag_name.to_s << '>') end end end diff --git a/lib/axlsx/drawing/num_data_source.rb b/lib/axlsx/drawing/num_data_source.rb index 46f6ba71..af5e31ab 100644 --- a/lib/axlsx/drawing/num_data_source.rb +++ b/lib/axlsx/drawing/num_data_source.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A numeric data source for use by charts. class NumDataSource @@ -42,17 +44,17 @@ module Axlsx # serialize the object # @param [String] str - def to_xml_string(str = "") - str << ('<c:' << tag_name.to_s << '>') + def to_xml_string(str = +'') + str << (+'<c:' << tag_name.to_s << '>') if @f - str << ('<c:' << @ref_tag_name.to_s << '>') - str << ('<c:f>' << @f.to_s << '</c:f>') + str << (+'<c:' << @ref_tag_name.to_s << '>') + str << (+'<c:f>' << @f.to_s << '</c:f>') end @data.to_xml_string str if @f - str << ('</c:' << @ref_tag_name.to_s << '>') + str << (+'</c:' << @ref_tag_name.to_s << '>') end - str << ('</c:' << tag_name.to_s << '>') + str << (+'</c:' << tag_name.to_s << '>') end end end diff --git a/lib/axlsx/drawing/num_val.rb b/lib/axlsx/drawing/num_val.rb index f4b2c399..b614f561 100644 --- a/lib/axlsx/drawing/num_val.rb +++ b/lib/axlsx/drawing/num_val.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class specifies data for a particular data point. class NumVal < StrVal @@ -21,10 +23,10 @@ module Axlsx end # serialize the object - def to_xml_string(idx, str = "") + def to_xml_string(idx, str = +'') Axlsx::validate_unsigned_int(idx) if !v.to_s.empty? - str << ('<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>') + str << (+'<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>') end end end diff --git a/lib/axlsx/drawing/one_cell_anchor.rb b/lib/axlsx/drawing/one_cell_anchor.rb index 52cf2244..f98d65a1 100644 --- a/lib/axlsx/drawing/one_cell_anchor.rb +++ b/lib/axlsx/drawing/one_cell_anchor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class details a single cell anchor for drawings. # @note The recommended way to manage drawings, images and charts is Worksheet#add_chart or Worksheet#add_image. @@ -72,12 +74,12 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<xdr:oneCellAnchor>' str << '<xdr:from>' from.to_xml_string(str) str << '</xdr:from>' - str << ('<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>') + str << (+'<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>') @object.to_xml_string(str) str << '<xdr:clientData/>' str << '</xdr:oneCellAnchor>' diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb index e31876bf..eec92a9c 100644 --- a/lib/axlsx/drawing/pic.rb +++ b/lib/axlsx/drawing/pic.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # a Pic object represents an image in your worksheet # Worksheet#add_image is the recommended way to manage images in your sheets @@ -187,10 +189,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<xdr:pic>' str << '<xdr:nvPicPr>' - str << ('<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">') + str << (+'<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">') hyperlink.to_xml_string(str) if hyperlink.is_a?(Hyperlink) str << '</xdr:cNvPr><xdr:cNvPicPr>' picture_locking.to_xml_string(str) @@ -211,9 +213,9 @@ module Axlsx # Return correct xml relationship string portion def relationship_xml_portion if remote? - ('<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">') + (+'<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">') else - ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">') + (+'<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">') end end diff --git a/lib/axlsx/drawing/picture_locking.rb b/lib/axlsx/drawing/picture_locking.rb index efd85f97..9511cb15 100644 --- a/lib/axlsx/drawing/picture_locking.rb +++ b/lib/axlsx/drawing/picture_locking.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The picture locking class defines the locking properties for pictures in your workbook. class PictureLocking @@ -32,7 +34,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('a:picLocks', str) end end diff --git a/lib/axlsx/drawing/pie_3D_chart.rb b/lib/axlsx/drawing/pie_3D_chart.rb index 1772c537..1c68dbb7 100644 --- a/lib/axlsx/drawing/pie_3D_chart.rb +++ b/lib/axlsx/drawing/pie_3D_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Pie3DChart is a three dimentional piechart (who would have guessed?) that you can add to your worksheet. # @see Worksheet#add_chart @@ -29,10 +31,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:pie3DChart>' - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } d_lbls.to_xml_string(str) if @d_lbls str << '</c:pie3DChart>' diff --git a/lib/axlsx/drawing/pie_series.rb b/lib/axlsx/drawing/pie_series.rb index 29b71e36..52cd2b66 100644 --- a/lib/axlsx/drawing/pie_series.rb +++ b/lib/axlsx/drawing/pie_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A PieSeries defines the data and labels and explosion for pie charts series. # @note The recommended way to manage series is to use Chart#add_series @@ -42,14 +44,14 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:explosion val="' + @explosion.to_s + '"/>' unless @explosion.nil? colors.each_with_index do |c, index| str << '<c:dPt>' - str << ('<c:idx val="' << index.to_s << '"/>') + str << (+'<c:idx val="' << index.to_s << '"/>') str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << c << '"/>') + str << (+'<a:srgbClr val="' << c << '"/>') str << '</a:solidFill></c:spPr></c:dPt>' end @labels.to_xml_string str unless @labels.nil? diff --git a/lib/axlsx/drawing/scaling.rb b/lib/axlsx/drawing/scaling.rb index 8d2d8ed7..fc4b9d10 100644 --- a/lib/axlsx/drawing/scaling.rb +++ b/lib/axlsx/drawing/scaling.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Scaling class defines axis scaling class Scaling @@ -45,12 +47,12 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:scaling>' - str << ('<c:logBase val="' << @logBase.to_s << '"/>') unless @logBase.nil? - str << ('<c:orientation val="' << @orientation.to_s << '"/>') unless @orientation.nil? - str << ('<c:min val="' << @min.to_s << '"/>') unless @min.nil? - str << ('<c:max val="' << @max.to_s << '"/>') unless @max.nil? + str << (+'<c:logBase val="' << @logBase.to_s << '"/>') unless @logBase.nil? + str << (+'<c:orientation val="' << @orientation.to_s << '"/>') unless @orientation.nil? + str << (+'<c:min val="' << @min.to_s << '"/>') unless @min.nil? + str << (+'<c:max val="' << @max.to_s << '"/>') unless @max.nil? str << '</c:scaling>' end end diff --git a/lib/axlsx/drawing/scatter_chart.rb b/lib/axlsx/drawing/scatter_chart.rb index b118a09a..b518c594 100644 --- a/lib/axlsx/drawing/scatter_chart.rb +++ b/lib/axlsx/drawing/scatter_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The ScatterChart allows you to insert a scatter chart into your worksheet # @see Worksheet#add_chart @@ -47,11 +49,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:scatterChart>' - str << ('<c:scatterStyle val="' << scatter_style.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:scatterStyle val="' << scatter_style.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } d_lbls.to_xml_string(str) if @d_lbls axes.to_xml_string(str, :ids => true) diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb index e4e1f27a..e52306f5 100644 --- a/lib/axlsx/drawing/scatter_series.rb +++ b/lib/axlsx/drawing/scatter_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A ScatterSeries defines the x and y position of data in the chart # @note The recommended way to manage series is to use Chart#add_series @@ -78,22 +80,22 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do # needs to override the super color here to push in ln/and something else! if color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') + str << (+'<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') str << '</c:spPr>' str << '<c:marker>' str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') + str << (+'<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') str << '</c:spPr>' str << marker_symbol_xml str << '</c:marker>' @@ -108,7 +110,7 @@ module Axlsx end @xData.to_xml_string(str) unless @xData.nil? @yData.to_xml_string(str) unless @yData.nil? - str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') + str << (+'<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') end str end diff --git a/lib/axlsx/drawing/ser_axis.rb b/lib/axlsx/drawing/ser_axis.rb index f49c1301..63628b14 100644 --- a/lib/axlsx/drawing/ser_axis.rb +++ b/lib/axlsx/drawing/ser_axis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A SerAxis object defines a series axis class SerAxis < Axis @@ -30,11 +32,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:serAx>' super(str) - str << ('<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') unless @tick_lbl_skip.nil? - str << ('<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') unless @tick_mark_skip.nil? + str << (+'<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') unless @tick_lbl_skip.nil? + str << (+'<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') unless @tick_mark_skip.nil? str << '</c:serAx>' end end diff --git a/lib/axlsx/drawing/series.rb b/lib/axlsx/drawing/series.rb index 86b85f4c..a468a6b7 100644 --- a/lib/axlsx/drawing/series.rb +++ b/lib/axlsx/drawing/series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A Series defines the common series attributes and is the super class for all concrete series types. # @note The recommended way to manage series is to use Chart#add_series @@ -55,10 +57,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:ser>' - str << ('<c:idx val="' << index.to_s << '"/>') - str << ('<c:order val="' << (order || index).to_s << '"/>') + str << (+'<c:idx val="' << index.to_s << '"/>') + str << (+'<c:order val="' << (order || index).to_s << '"/>') title.to_xml_string(str) unless title.nil? yield if block_given? str << '</c:ser>' diff --git a/lib/axlsx/drawing/series_title.rb b/lib/axlsx/drawing/series_title.rb index f18be178..2887495c 100644 --- a/lib/axlsx/drawing/series_title.rb +++ b/lib/axlsx/drawing/series_title.rb @@ -1,19 +1,21 @@ +# frozen_string_literal: true + module Axlsx # A series title is a Title with a slightly different serialization than chart titles. class SeriesTitle < Title # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') clean_value = Axlsx::trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@text.to_s)) str << '<c:tx>' str << '<c:strRef>' - str << ('<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>') + str << (+'<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>') str << '<c:strCache>' str << '<c:ptCount val="1"/>' str << '<c:pt idx="0">' - str << ('<c:v>' << clean_value << '</c:v>') + str << (+'<c:v>' << clean_value << '</c:v>') str << '</c:pt>' str << '</c:strCache>' str << '</c:strRef>' diff --git a/lib/axlsx/drawing/str_data.rb b/lib/axlsx/drawing/str_data.rb index 5ea8a892..0765671f 100644 --- a/lib/axlsx/drawing/str_data.rb +++ b/lib/axlsx/drawing/str_data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This specifies the last string data used for a chart. (e.g. strLit and strCache) # This class is extended for NumData to include the formatCode attribute required for numLit and numCache @@ -25,13 +27,13 @@ module Axlsx end # serialize the object - def to_xml_string(str = "") - str << ('<c:' << @tag_name.to_s << '>') - str << ('<c:ptCount val="' << @pt.size.to_s << '"/>') + def to_xml_string(str = +'') + str << (+'<c:' << @tag_name.to_s << '>') + str << (+'<c:ptCount val="' << @pt.size.to_s << '"/>') @pt.each_with_index do |value, index| value.to_xml_string index, str end - str << ('</c:' << @tag_name.to_s << '>') + str << (+'</c:' << @tag_name.to_s << '>') end end end diff --git a/lib/axlsx/drawing/str_val.rb b/lib/axlsx/drawing/str_val.rb index e5c851ee..821c7037 100644 --- a/lib/axlsx/drawing/str_val.rb +++ b/lib/axlsx/drawing/str_val.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class specifies data for a particular data point. class StrVal @@ -21,10 +23,10 @@ module Axlsx end # serialize the object - def to_xml_string(idx, str = "") + def to_xml_string(idx, str = +'') Axlsx::validate_unsigned_int(idx) if !v.to_s.empty? - str << ('<c:pt idx="' << idx.to_s << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>') + str << (+'<c:pt idx="' << idx.to_s << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>') end end end diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb index 92294a06..7bd41b17 100644 --- a/lib/axlsx/drawing/title.rb +++ b/lib/axlsx/drawing/title.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A Title stores information about the title of a chart class Title @@ -67,18 +69,18 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:title>' unless empty? clean_value = Axlsx::trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@text.to_s)) str << '<c:tx>' if @cell.is_a?(Cell) str << '<c:strRef>' - str << ('<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>') + str << (+'<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>') str << '<c:strCache>' str << '<c:ptCount val="1"/>' str << '<c:pt idx="0">' - str << ('<c:v>' << clean_value << '</c:v>') + str << (+'<c:v>' << clean_value << '</c:v>') str << '</c:pt>' str << '</c:strCache>' str << '</c:strRef>' @@ -88,8 +90,8 @@ module Axlsx str << '<a:lstStyle/>' str << '<a:p>' str << '<a:r>' - str << ('<a:rPr sz="' << @text_size.to_s << '"/>') - str << ('<a:t>' << clean_value << '</a:t>') + str << (+'<a:rPr sz="' << @text_size.to_s << '"/>') + str << (+'<a:t>' << clean_value << '</a:t>') str << '</a:r>' str << '</a:p>' str << '</c:rich>' diff --git a/lib/axlsx/drawing/two_cell_anchor.rb b/lib/axlsx/drawing/two_cell_anchor.rb index 7b77de13..bebfd28c 100644 --- a/lib/axlsx/drawing/two_cell_anchor.rb +++ b/lib/axlsx/drawing/two_cell_anchor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class details the anchor points for drawings. # @note The recommended way to manage drawings and charts is Worksheet#add_chart. Anchors are specified by the :start_at and :end_at options to that method. @@ -79,7 +81,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<xdr:twoCellAnchor>' str << '<xdr:from>' from.to_xml_string str diff --git a/lib/axlsx/drawing/val_axis.rb b/lib/axlsx/drawing/val_axis.rb index 8cd131cc..1200eb5d 100644 --- a/lib/axlsx/drawing/val_axis.rb +++ b/lib/axlsx/drawing/val_axis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # the ValAxis class defines a chart value axis. class ValAxis < Axis @@ -24,10 +26,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:valAx>' super(str) - str << ('<c:crossBetween val="' << @cross_between.to_s << '"/>') + str << (+'<c:crossBetween val="' << @cross_between.to_s << '"/>') str << '</c:valAx>' end end diff --git a/lib/axlsx/drawing/view_3D.rb b/lib/axlsx/drawing/view_3D.rb index ff26deb9..9b1b5cb2 100644 --- a/lib/axlsx/drawing/view_3D.rb +++ b/lib/axlsx/drawing/view_3D.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # 3D attributes for a chart. class View3D @@ -94,7 +96,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:view3D>' %w(rot_x h_percent rot_y depth_percent r_ang_ax perspective).each do |key| str << element_for_attribute(key, 'c') diff --git a/lib/axlsx/drawing/vml_drawing.rb b/lib/axlsx/drawing/vml_drawing.rb index 63c42457..322ec680 100644 --- a/lib/axlsx/drawing/vml_drawing.rb +++ b/lib/axlsx/drawing/vml_drawing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # a vml drawing used for comments in excel. class VmlDrawing @@ -18,7 +20,7 @@ module Axlsx # serialize the vml_drawing to xml. # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << <<~XML <xml xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" diff --git a/lib/axlsx/drawing/vml_shape.rb b/lib/axlsx/drawing/vml_shape.rb index 7f196974..f1cd8951 100644 --- a/lib/axlsx/drawing/vml_shape.rb +++ b/lib/axlsx/drawing/vml_shape.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A VmlShape is used to position and render a comment. class VmlShape @@ -35,7 +37,7 @@ module Axlsx # serialize the shape to a string # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << <<~XML <v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto" diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb index f22ad2ac..dd0432cd 100644 --- a/lib/axlsx/package.rb +++ b/lib/axlsx/package.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Package is responsible for managing all the bits and peices that Open Office XML requires to make a valid # xlsx document including validation and serialization. diff --git a/lib/axlsx/rels/relationship.rb b/lib/axlsx/rels/relationship.rb index aff9fa55..d9393b15 100644 --- a/lib/axlsx/rels/relationship.rb +++ b/lib/axlsx/rels/relationship.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A relationship defines a reference between package parts. # @note Packages automatically manage relationships. @@ -100,10 +102,10 @@ module Axlsx # serialize relationship # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') h = Axlsx.instance_values_for(self).reject { |k, _| k == "source_obj" } str << '<Relationship ' - str << (h.map { |key, value| '' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"' }.join(' ')) + str << (h.map { |key, value| +'' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"' }.join(' ')) str << '/>' end diff --git a/lib/axlsx/rels/relationships.rb b/lib/axlsx/rels/relationships.rb index 71c4bf1e..ec5b16e9 100644 --- a/lib/axlsx/rels/relationships.rb +++ b/lib/axlsx/rels/relationships.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx require 'axlsx/rels/relationship.rb' @@ -19,9 +21,9 @@ module Axlsx # serialize relationships # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<Relationships xmlns="' << RELS_R << '">') + str << (+'<Relationships xmlns="' << RELS_R << '">') each { |rel| rel.to_xml_string(str) } str << '</Relationships>' end diff --git a/lib/axlsx/stylesheet/border.rb b/lib/axlsx/stylesheet/border.rb index af564b22..163479b1 100644 --- a/lib/axlsx/stylesheet/border.rb +++ b/lib/axlsx/stylesheet/border.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class details a border used in Office Open XML spreadsheet styles. class Border @@ -54,7 +56,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<border ' serialized_attributes str str << '>' diff --git a/lib/axlsx/stylesheet/border_pr.rb b/lib/axlsx/stylesheet/border_pr.rb index 3f1054f2..154b25f4 100644 --- a/lib/axlsx/stylesheet/border_pr.rb +++ b/lib/axlsx/stylesheet/border_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A border part. class BorderPr @@ -60,10 +62,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<' << @name.to_s << ' style="' << @style.to_s << '">') + def to_xml_string(str = +'') + str << (+'<' << @name.to_s << ' style="' << @style.to_s << '">') @color.to_xml_string(str) if @color.is_a?(Color) - str << ('</' << @name.to_s << '>') + str << (+'</' << @name.to_s << '>') end end end diff --git a/lib/axlsx/stylesheet/cell_alignment.rb b/lib/axlsx/stylesheet/cell_alignment.rb index 906c7870..4a0c0686 100644 --- a/lib/axlsx/stylesheet/cell_alignment.rb +++ b/lib/axlsx/stylesheet/cell_alignment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # CellAlignment stores information about the cell alignment of a style Xf Object. # @note Using Styles#add_style is the recommended way to manage cell alignment. @@ -117,7 +119,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('alignment', str) end end diff --git a/lib/axlsx/stylesheet/cell_protection.rb b/lib/axlsx/stylesheet/cell_protection.rb index f040f207..caa01ced 100644 --- a/lib/axlsx/stylesheet/cell_protection.rb +++ b/lib/axlsx/stylesheet/cell_protection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # CellProtection stores information about locking or hiding cells in spreadsheet. # @note Using Styles#add_style is the recommended way to manage cell protection. @@ -31,7 +33,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('protection', str) end end diff --git a/lib/axlsx/stylesheet/cell_style.rb b/lib/axlsx/stylesheet/cell_style.rb index 20f88133..5dc9a90d 100644 --- a/lib/axlsx/stylesheet/cell_style.rb +++ b/lib/axlsx/stylesheet/cell_style.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # CellStyle defines named styles that reference defined formatting records and can be used in your worksheet. # @note Using Styles#add_style is the recommended way to manage cell styling. @@ -61,7 +63,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('cellStyle', str) end end diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb index d6d204bf..47617da5 100644 --- a/lib/axlsx/stylesheet/color.rb +++ b/lib/axlsx/stylesheet/color.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The color class represents a color used for borders, fills an fonts class Color @@ -70,7 +72,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '', tag_name = 'color') + def to_xml_string(str = +'', tag_name = 'color') serialized_tag('' + tag_name + '', str) end end diff --git a/lib/axlsx/stylesheet/dxf.rb b/lib/axlsx/stylesheet/dxf.rb index 516894df..8c32a75f 100644 --- a/lib/axlsx/stylesheet/dxf.rb +++ b/lib/axlsx/stylesheet/dxf.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Dxf class defines an incremental formatting record for use in Styles. The recommended way to manage styles for your workbook is with Styles#add_style # @see Styles#add_style @@ -62,7 +64,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<dxf>' # Dxf elements have no attributes. All of the instance variables # are child elements. diff --git a/lib/axlsx/stylesheet/fill.rb b/lib/axlsx/stylesheet/fill.rb index aeff4867..313a24a3 100644 --- a/lib/axlsx/stylesheet/fill.rb +++ b/lib/axlsx/stylesheet/fill.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Fill is a formatting object that manages the background color, and pattern for cells. # @note The recommended way to manage styles in your workbook is to use Styles#add_style. @@ -19,7 +21,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<fill>' @fill_type.to_xml_string(str) str << '</fill>' diff --git a/lib/axlsx/stylesheet/font.rb b/lib/axlsx/stylesheet/font.rb index 0f432d58..463b8fc0 100644 --- a/lib/axlsx/stylesheet/font.rb +++ b/lib/axlsx/stylesheet/font.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Font class details a font instance for use in styling cells. # @note The recommended way to manage fonts, and other styles is Styles#add_style @@ -146,10 +148,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<font>' Axlsx.instance_values_for(self).each do |k, v| - v.is_a?(Color) ? v.to_xml_string(str) : (str << ('<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>')) + v.is_a?(Color) ? v.to_xml_string(str) : (str << (+'<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>')) end str << '</font>' end diff --git a/lib/axlsx/stylesheet/gradient_fill.rb b/lib/axlsx/stylesheet/gradient_fill.rb index f90a15d6..6cd0a052 100644 --- a/lib/axlsx/stylesheet/gradient_fill.rb +++ b/lib/axlsx/stylesheet/gradient_fill.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A GradientFill defines the color and positioning for gradiant cell fill. # @see Open Office XML Part 1 §18.8.24 @@ -90,7 +92,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<gradientFill ' serialized_attributes str str << '>' diff --git a/lib/axlsx/stylesheet/gradient_stop.rb b/lib/axlsx/stylesheet/gradient_stop.rb index 2325ee66..83f39a55 100644 --- a/lib/axlsx/stylesheet/gradient_stop.rb +++ b/lib/axlsx/stylesheet/gradient_stop.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The GradientStop object represents a color point in a gradient. # @see Open Office XML Part 1 §18.8.24 @@ -27,8 +29,8 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<stop position="' << position.to_s << '">') + def to_xml_string(str = +'') + str << (+'<stop position="' << position.to_s << '">') self.color.to_xml_string(str) str << '</stop>' end diff --git a/lib/axlsx/stylesheet/num_fmt.rb b/lib/axlsx/stylesheet/num_fmt.rb index 388f0d59..1a7add0e 100644 --- a/lib/axlsx/stylesheet/num_fmt.rb +++ b/lib/axlsx/stylesheet/num_fmt.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A NumFmt object defines an identifier and formatting code for data in cells. # @note The recommended way to manage styles is Styles#add_style @@ -67,12 +69,12 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('numFmt', str) end # Override to avoid removing underscores - def serialized_attributes(str = '', additional_attributes = {}) + def serialized_attributes(str = +'', additional_attributes = {}) attributes = declared_attributes.merge! additional_attributes attributes.each do |key, value| str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.booleanize(value)}\" " diff --git a/lib/axlsx/stylesheet/pattern_fill.rb b/lib/axlsx/stylesheet/pattern_fill.rb index 3ebd4ff6..cabce9f5 100644 --- a/lib/axlsx/stylesheet/pattern_fill.rb +++ b/lib/axlsx/stylesheet/pattern_fill.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A PatternFill is the pattern and solid fill styling for a cell. # @note The recommended way to manage styles is with Styles#add_style @@ -56,8 +58,8 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<patternFill patternType="' << patternType.to_s << '">') + def to_xml_string(str = +'') + str << (+'<patternFill patternType="' << patternType.to_s << '">') if fgColor.is_a?(Color) fgColor.to_xml_string str, "fgColor" end diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index 3b462d37..809630f2 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx require 'axlsx/stylesheet/border.rb' require 'axlsx/stylesheet/border_pr.rb' @@ -483,8 +485,8 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<styleSheet xmlns="' << XML_NS << '">') + def to_xml_string(str = +'') + str << (+'<styleSheet xmlns="' << XML_NS << '">') instance_vals = Axlsx.instance_values_for(self) [:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key| instance_vals[key.to_s].to_xml_string(str) unless instance_vals[key.to_s].nil? diff --git a/lib/axlsx/stylesheet/table_style.rb b/lib/axlsx/stylesheet/table_style.rb index f656ce3d..4423c518 100644 --- a/lib/axlsx/stylesheet/table_style.rb +++ b/lib/axlsx/stylesheet/table_style.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A single table style definition and is a collection for tableStyleElements # @note Table are not supported in this version and only the defaults required for a valid workbook are created. @@ -40,7 +42,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<tableStyle ' serialized_attributes str, { :count => self.size } str << '>' diff --git a/lib/axlsx/stylesheet/table_style_element.rb b/lib/axlsx/stylesheet/table_style_element.rb index 845d6bac..2e64d9a3 100644 --- a/lib/axlsx/stylesheet/table_style_element.rb +++ b/lib/axlsx/stylesheet/table_style_element.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # an element of style that belongs to a table style. # @note tables and table styles are not supported in this version. This class exists in preparation for that support. @@ -67,7 +69,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('tableStyleElement', str) end end diff --git a/lib/axlsx/stylesheet/table_styles.rb b/lib/axlsx/stylesheet/table_styles.rb index a55180a5..49f6e601 100644 --- a/lib/axlsx/stylesheet/table_styles.rb +++ b/lib/axlsx/stylesheet/table_styles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # TableStyles represents a collection of style definitions for table styles and pivot table styles. # @note Support for custom table styles does not exist in this version. Many of the classes required are defined in preparation for future release. Please do not attempt to add custom table styles. @@ -31,7 +33,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<tableStyles ' serialized_attributes str, { :count => self.size } str << '>' diff --git a/lib/axlsx/stylesheet/xf.rb b/lib/axlsx/stylesheet/xf.rb index e58608f7..45d362ca 100644 --- a/lib/axlsx/stylesheet/xf.rb +++ b/lib/axlsx/stylesheet/xf.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Xf class defines a formatting record for use in Styles. The recommended way to manage styles for your workbook is with Styles#add_style # @see Styles#add_style @@ -132,7 +134,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<xf ' serialized_attributes str str << '>' diff --git a/lib/axlsx/util/accessors.rb b/lib/axlsx/util/accessors.rb index 8f481e37..d653e32f 100644 --- a/lib/axlsx/util/accessors.rb +++ b/lib/axlsx/util/accessors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This module defines some of the more common validating attribute # accessors that we use in Axlsx @@ -43,7 +45,7 @@ module Axlsx end # Template for defining validated write accessors - SETTER = "def %s=(value) Axlsx::%s(value); @%s = value; end".freeze + SETTER = "def %s=(value) Axlsx::%s(value); @%s = value; end" # Creates the reader and writer access methods # @param [Array] symbols The names of the attributes to create diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb index 55e2b58f..4697bb3a 100644 --- a/lib/axlsx/util/constants.rb +++ b/lib/axlsx/util/constants.rb @@ -1,240 +1,242 @@ +# frozen_string_literal: true + module Axlsx # XML Encoding - ENCODING = "UTF-8".freeze + ENCODING = "UTF-8" # spreadsheetML namespace - XML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main".freeze + XML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main" # content-types namespace - XML_NS_T = "http://schemas.openxmlformats.org/package/2006/content-types".freeze + XML_NS_T = "http://schemas.openxmlformats.org/package/2006/content-types" # extended-properties namespace - APP_NS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties".freeze + APP_NS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" # doc props namespace - APP_NS_VT = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes".freeze + APP_NS_VT = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes" # core properties namespace - CORE_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties".freeze + CORE_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties" # dc elements (core) namespace - CORE_NS_DC = "http://purl.org/dc/elements/1.1/".freeze + CORE_NS_DC = "http://purl.org/dc/elements/1.1/" # dcmit (core) namespcace - CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/".freeze + CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/" # dc terms namespace - CORE_NS_DCT = "http://purl.org/dc/terms/".freeze + CORE_NS_DCT = "http://purl.org/dc/terms/" # xml schema namespace - CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance".freeze + CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance" # Digital signature namespace - DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature".freeze + DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature" # spreadsheet drawing namespace - XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing".freeze + XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" # drawing namespace - XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main".freeze + XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main" # chart namespace - XML_NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart".freeze + XML_NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart" # relationships namespace - XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships".freeze + XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships" # relationships name space - RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships".freeze + RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships" # table rels namespace - TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table".freeze + TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table" # pivot table rels namespace - PIVOT_TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable".freeze + PIVOT_TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable" # pivot table cache definition namespace - PIVOT_TABLE_CACHE_DEFINITION_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition".freeze + PIVOT_TABLE_CACHE_DEFINITION_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" # workbook rels namespace - WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument".freeze + WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" # worksheet rels namespace - WORKSHEET_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet".freeze + WORKSHEET_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" # app rels namespace - APP_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties".freeze + APP_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" # core rels namespace - CORE_R = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties".freeze + CORE_R = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" # digital signature rels namespace - DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature".freeze + DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature" # styles rels namespace - STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles".freeze + STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" # shared strings namespace - SHARED_STRINGS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings".freeze + SHARED_STRINGS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" # drawing rels namespace - DRAWING_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing".freeze + DRAWING_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing" # chart rels namespace - CHART_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart".freeze + CHART_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" # image rels namespace - IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image".freeze + IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" # hyperlink rels namespace - HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink".freeze + HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" # comment rels namespace - COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments".freeze + COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" # comment relation for nil target - COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments".freeze + COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments" # vml drawing relation namespace VML_DRAWING_R = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing' # VML Drawing content type - VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing".freeze + VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing" # table content type - TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml".freeze + TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml" # pivot table content type - PIVOT_TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml".freeze + PIVOT_TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml" # pivot table cache definition content type - PIVOT_TABLE_CACHE_DEFINITION_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml".freeze + PIVOT_TABLE_CACHE_DEFINITION_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml" # workbook content type - WORKBOOK_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml".freeze + WORKBOOK_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" # app content type - APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml".freeze + APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml" # rels content type - RELS_CT = "application/vnd.openxmlformats-package.relationships+xml".freeze + RELS_CT = "application/vnd.openxmlformats-package.relationships+xml" # styles content type - STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml".freeze + STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" # xml content type - XML_CT = "application/xml".freeze + XML_CT = "application/xml" # worksheet content type - WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml".freeze + WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" # shared strings content type - SHARED_STRINGS_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml".freeze + SHARED_STRINGS_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" # core content type - CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml".freeze + CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml" # digital signature xml content type - DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml".freeze + DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml" # digital signature origin content type - DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin".freeze + DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin" # digital signature certificate content type - DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate".freeze + DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate" # chart content type - CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml".freeze + CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml" # comments content type - COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml".freeze + COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml" # jpeg content type - JPEG_CT = "image/jpeg".freeze + JPEG_CT = "image/jpeg" # gif content type - GIF_CT = "image/gif".freeze + GIF_CT = "image/gif" # png content type - PNG_CT = "image/png".freeze + PNG_CT = "image/png" # drawing content type - DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml".freeze + DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml" # xml content type extensions - XML_EX = "xml".freeze + XML_EX = "xml" # jpeg extension - JPEG_EX = "jpeg".freeze + JPEG_EX = "jpeg" # gif extension - GIF_EX = "gif".freeze + GIF_EX = "gif" # png extension - PNG_EX = "png".freeze + PNG_EX = "png" # rels content type extension - RELS_EX = "rels".freeze + RELS_EX = "rels" # workbook part - WORKBOOK_PN = "xl/workbook.xml".freeze + WORKBOOK_PN = "xl/workbook.xml" # styles part - STYLES_PN = "styles.xml".freeze + STYLES_PN = "styles.xml" # shared_strings part - SHARED_STRINGS_PN = "sharedStrings.xml".freeze + SHARED_STRINGS_PN = "sharedStrings.xml" # app part - APP_PN = "docProps/app.xml".freeze + APP_PN = "docProps/app.xml" # core part - CORE_PN = "docProps/core.xml".freeze + CORE_PN = "docProps/core.xml" # content types part - CONTENT_TYPES_PN = "[Content_Types].xml".freeze + CONTENT_TYPES_PN = "[Content_Types].xml" # rels part - RELS_PN = "_rels/.rels".freeze + RELS_PN = "_rels/.rels" # workbook rels part - WORKBOOK_RELS_PN = "xl/_rels/workbook.xml.rels".freeze + WORKBOOK_RELS_PN = "xl/_rels/workbook.xml.rels" # worksheet part - WORKSHEET_PN = "worksheets/sheet%d.xml".freeze + WORKSHEET_PN = "worksheets/sheet%d.xml" # worksheet rels part - WORKSHEET_RELS_PN = "worksheets/_rels/sheet%d.xml.rels".freeze + WORKSHEET_RELS_PN = "worksheets/_rels/sheet%d.xml.rels" # drawing part - DRAWING_PN = "drawings/drawing%d.xml".freeze + DRAWING_PN = "drawings/drawing%d.xml" # drawing rels part - DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels".freeze + DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels" # vml drawing part - VML_DRAWING_PN = "drawings/vmlDrawing%d.vml".freeze + VML_DRAWING_PN = "drawings/vmlDrawing%d.vml" # drawing part - TABLE_PN = "tables/table%d.xml".freeze + TABLE_PN = "tables/table%d.xml" # pivot table parts - PIVOT_TABLE_PN = "pivotTables/pivotTable%d.xml".freeze + PIVOT_TABLE_PN = "pivotTables/pivotTable%d.xml" # pivot table cache definition part name - PIVOT_TABLE_CACHE_DEFINITION_PN = "pivotCache/pivotCacheDefinition%d.xml".freeze + PIVOT_TABLE_CACHE_DEFINITION_PN = "pivotCache/pivotCacheDefinition%d.xml" # pivot table rels parts - PIVOT_TABLE_RELS_PN = "pivotTables/_rels/pivotTable%d.xml.rels".freeze + PIVOT_TABLE_RELS_PN = "pivotTables/_rels/pivotTable%d.xml.rels" # chart part - CHART_PN = "charts/chart%d.xml".freeze + CHART_PN = "charts/chart%d.xml" # chart part - IMAGE_PN = "media/image%d.%s".freeze + IMAGE_PN = "media/image%d.%s" # comment part - COMMENT_PN = "comments%d.xml".freeze + COMMENT_PN = "comments%d.xml" # location of schema files for validation SCHEMA_BASE = (File.dirname(__FILE__) + '/../../schema/').freeze @@ -279,46 +281,46 @@ module Axlsx WORKSHEET_NAME_FORBIDDEN_CHARS = '[]*/\?:'.chars.freeze # error messages RestrictionValidor - ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s.".freeze + ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s." # error message DataTypeValidator - ERR_TYPE = "Invalid Data %s for %s. must be %s.".freeze + ERR_TYPE = "Invalid Data %s for %s. must be %s." # error message for RegexValidator - ERR_REGEX = "Invalid Data. %s does not match %s.".freeze + ERR_REGEX = "Invalid Data. %s does not match %s." # error message for RangeValidator - ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s".freeze + ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s" # error message for sheets that use explicit empty string name - ERR_SHEET_NAME_EMPTY = "Your worksheet name is empty. Worksheet name can't be empty. Please assign name of your sheet or don't use name option at all.".freeze + ERR_SHEET_NAME_EMPTY = "Your worksheet name is empty. Worksheet name can't be empty. Please assign name of your sheet or don't use name option at all." # error message for sheets that use a name which is longer than 31 bytes - ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be #{WORKSHEET_MAX_NAME_LENGTH} characters (bytes) or less".freeze + ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be #{WORKSHEET_MAX_NAME_LENGTH} characters (bytes) or less" # error message for sheets that use a name which include invalid characters - ERR_SHEET_NAME_CHARACTER_FORBIDDEN = "Your worksheet name '%s' contains a character which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet.".freeze + ERR_SHEET_NAME_CHARACTER_FORBIDDEN = "Your worksheet name '%s' contains a character which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet." # error message for duplicate sheet names - ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name".freeze + ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name" # error message when user does not provide color and or style options for border in Style#add_sytle - ERR_INVALID_BORDER_OPTIONS = "border hash must include both style and color. e.g. :border => { :color => 'FF000000', :style => :thin }. You provided: %s".freeze + ERR_INVALID_BORDER_OPTIONS = "border hash must include both style and color. e.g. :border => { :color => 'FF000000', :style => :thin }. You provided: %s" # error message for invalid border id reference - ERR_INVALID_BORDER_ID = "The border id you specified (%s) does not exist. Please add a border with Style#add_style before referencing its index.".freeze + ERR_INVALID_BORDER_ID = "The border id you specified (%s) does not exist. Please add a border with Style#add_style before referencing its index." # error message for invalid angles - ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s".freeze + ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s" # error message for non 'integerish' value - ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s".freeze + ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s" # error message for invalid cell reference - ERR_CELL_REFERENCE_INVALID = "Invalid cell definition `%s`".freeze + ERR_CELL_REFERENCE_INVALID = "Invalid cell definition `%s`" # error message for cell reference with last cell missing - ERR_CELL_REFERENCE_MISSING_CELL = "Missing cell `%s` for the specified range `%s`".freeze + ERR_CELL_REFERENCE_MISSING_CELL = "Missing cell `%s` for the specified range `%s`" # Regex to match forbidden control characters # The following will be automatically stripped from worksheets. diff --git a/lib/axlsx/util/mime_type_utils.rb b/lib/axlsx/util/mime_type_utils.rb index f0c3afb1..5dbe0ac5 100644 --- a/lib/axlsx/util/mime_type_utils.rb +++ b/lib/axlsx/util/mime_type_utils.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'open-uri' module Axlsx diff --git a/lib/axlsx/util/options_parser.rb b/lib/axlsx/util/options_parser.rb index 3f2c1937..526a3aed 100644 --- a/lib/axlsx/util/options_parser.rb +++ b/lib/axlsx/util/options_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This module defines a single method for parsing options in class # initializers. diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index eeac6e74..b7247e0d 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This module allows us to define a list of symbols defining which # attributes will be serialized for a class. @@ -47,7 +49,7 @@ module Axlsx # serialization to. # @param [Hash] additional_attributes An option key value hash for # defining values that are not serializable attributes list. - def serialized_attributes(str = '', additional_attributes = {}) + def serialized_attributes(str = +'', additional_attributes = {}) attributes = declared_attributes.merge! additional_attributes attributes.each do |key, value| str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.camel(Axlsx.booleanize(value), false)}\" " @@ -71,7 +73,7 @@ module Axlsx # @param [String] str The string instance to which serialized data is appended # @param [Array] additional_attributes An array of additional attribute names. # @return [String] The serialized output. - def serialized_element_attributes(str = '', additional_attributes = [], &block) + def serialized_element_attributes(str = +'', additional_attributes = [], &block) attrs = self.class.xml_element_attributes + additional_attributes values = Axlsx.instance_values_for(self) attrs.each do |attribute_name| diff --git a/lib/axlsx/util/simple_typed_list.rb b/lib/axlsx/util/simple_typed_list.rb index 59b25564..2bd6b648 100644 --- a/lib/axlsx/util/simple_typed_list.rb +++ b/lib/axlsx/util/simple_typed_list.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A SimpleTypedList is a type restrictive collection that allows some of the methods from Array and supports basic xml serialization. # @private @@ -169,12 +171,12 @@ module Axlsx }, __FILE__, __LINE__ - 4 end - def to_xml_string(str = '') + def to_xml_string(str = +'') classname = @allowed_types[0].name.split('::').last el_name = serialize_as.to_s || (classname[0, 1].downcase + classname[1..-1]) - str << ('<' << el_name << ' count="' << size.to_s << '">') + str << (+'<' << el_name << ' count="' << size.to_s << '">') each { |item| item.to_xml_string(str) } - str << ('</' << el_name << '>') + str << (+'</' << el_name << '>') end end end diff --git a/lib/axlsx/util/storage.rb b/lib/axlsx/util/storage.rb index 4932c93c..2ce0d8f5 100644 --- a/lib/axlsx/util/storage.rb +++ b/lib/axlsx/util/storage.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + module Axlsx # The Storage class represents a storage object or stream in a compound file. class Storage # Packing for the Storage when pushing an array of items into a byte stream # Name, name length, type, color, left sibling, right sibling, child, classid, state, created, modified, sector, size - PACKING = "s32 s1 c2 l3 x16 x4 q2 l q".freeze + PACKING = "s32 s1 c2 l3 x16 x4 q2 l q" # storage types TYPES = { diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb index b6877a48..952827e9 100644 --- a/lib/axlsx/util/validators.rb +++ b/lib/axlsx/util/validators.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Validate a value against a specific list of allowed values. class RestrictionValidator diff --git a/lib/axlsx/util/zip_command.rb b/lib/axlsx/util/zip_command.rb index 23fd7cf6..00faa942 100644 --- a/lib/axlsx/util/zip_command.rb +++ b/lib/axlsx/util/zip_command.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'open3' require 'shellwords' diff --git a/lib/axlsx/version.rb b/lib/axlsx/version.rb index 3a06c284..4c284c7f 100644 --- a/lib/axlsx/version.rb +++ b/lib/axlsx/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The current version VERSION = "3.4.1" diff --git a/lib/axlsx/workbook/defined_name.rb b/lib/axlsx/workbook/defined_name.rb index d3b6e1ef..4ddcff2c 100644 --- a/lib/axlsx/workbook/defined_name.rb +++ b/lib/axlsx/workbook/defined_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # <definedNames> # <definedName name="_xlnm.Print_Titles" localSheetId="0">Sheet1!$1:$1</definedName> # </definedNames> @@ -118,12 +120,12 @@ module Axlsx serializable_attributes :short_cut_key, :status_bar, :help, :description, :custom_menu, :comment, :workbook_parameter, :publish_to_server, :xlm, :vb_proceedure, :function, :hidden, :local_sheet_id - def to_xml_string(str = '') + def to_xml_string(str = +'') raise ArgumentError, 'you must specify the name for this defined name. Please read the documentation for Axlsx::DefinedName for more details' unless name - str << ('<definedName ' << 'name="' << name << '" ') + str << (+'<definedName ' << 'name="' << name << '" ') serialized_attributes str - str << ('>' << @formula << '</definedName>') + str << (+'>' << @formula << '</definedName>') end end end diff --git a/lib/axlsx/workbook/defined_names.rb b/lib/axlsx/workbook/defined_names.rb index 017c6d96..e59acf4b 100644 --- a/lib/axlsx/workbook/defined_names.rb +++ b/lib/axlsx/workbook/defined_names.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # a simple types list of DefinedName objects class DefinedNames < SimpleTypedList @@ -9,7 +11,7 @@ module Axlsx # Serialize to xml # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << '<definedNames>' diff --git a/lib/axlsx/workbook/shared_strings_table.rb b/lib/axlsx/workbook/shared_strings_table.rb index b8502206..17007b08 100644 --- a/lib/axlsx/workbook/shared_strings_table.rb +++ b/lib/axlsx/workbook/shared_strings_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Shared String Table class is responsible for managing and serializing common strings in a workbook. # While the ECMA-376 spec allows for both inline and shared strings it seems that at least some applications like iWorks Numbers @@ -34,7 +36,7 @@ module Axlsx @index = 0 @xml_space = xml_space @unique_cells = {} - @shared_xml_string = "" + @shared_xml_string = +'' shareable_cells = cells.flatten.select { |cell| cell.plain_string? || cell.contains_rich_text? } @count = shareable_cells.size resolve(shareable_cells) @@ -43,11 +45,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') Axlsx::sanitize(@shared_xml_string) - str << ('<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '"') - str << (' count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '"') - str << (' xml:space="' << xml_space.to_s << '">' << @shared_xml_string << '</sst>') + str << (+'<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '"') + str << (+' count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '"') + str << (+' xml:space="' << xml_space.to_s << '">' << @shared_xml_string << '</sst>') end private diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index 71a3c375..ab16a4ed 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx require 'axlsx/workbook/worksheet/sheet_calc_pr.rb' require 'axlsx/workbook/worksheet/auto_filter/auto_filter.rb' @@ -403,11 +405,11 @@ module Axlsx # Serialize the workbook # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') add_worksheet(name: 'Sheet1') unless worksheets.size > 0 str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">') - str << ('<workbookPr date1904="' << @@date1904.to_s << '"/>') + str << (+'<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">') + str << (+'<workbookPr date1904="' << @@date1904.to_s << '"/>') views.to_xml_string(str) str << '<sheets>' if is_reversed @@ -420,7 +422,7 @@ module Axlsx unless pivot_tables.empty? str << '<pivotCaches>' pivot_tables.each do |pivot_table| - str << ('<pivotCache cacheId="' << pivot_table.cache_definition.cache_id.to_s << '" r:id="' << pivot_table.cache_definition.rId << '"/>') + str << (+'<pivotCache cacheId="' << pivot_table.cache_definition.cache_id.to_s << '" r:id="' << pivot_table.cache_definition.rId << '"/>') end str << '</pivotCaches>' end diff --git a/lib/axlsx/workbook/workbook_view.rb b/lib/axlsx/workbook/workbook_view.rb index 27a46dcc..398563f9 100644 --- a/lib/axlsx/workbook/workbook_view.rb +++ b/lib/axlsx/workbook/workbook_view.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # <xsd:complexType name="CT_BookView"> # <xsd:sequence> # <xsd:element name="extLst" type="CT_ExtensionList" minOccurs="0" maxOccurs="1"/> @@ -66,7 +68,7 @@ module Axlsx # Serialize the WorkbookView # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<workbookView ' serialized_attributes str str << '></workbookView>' diff --git a/lib/axlsx/workbook/workbook_views.rb b/lib/axlsx/workbook/workbook_views.rb index 41010d0d..45d146f1 100644 --- a/lib/axlsx/workbook/workbook_views.rb +++ b/lib/axlsx/workbook/workbook_views.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # a simple types list of BookView objects class WorkbookViews < SimpleTypedList @@ -9,7 +11,7 @@ module Axlsx # Serialize to xml # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << "<bookViews>" diff --git a/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb b/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb index bf3426b6..5a74d79a 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'axlsx/workbook/worksheet/auto_filter/filter_column.rb' require 'axlsx/workbook/worksheet/auto_filter/filters.rb' @@ -67,7 +69,7 @@ module Axlsx # serialize the object # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return unless range str << "<autoFilter ref='#{range}'>" diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb index 32a9df26..f014eb18 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The filterColumn collection identifies a particular column in the AutoFilter # range and specifies filter information that has been applied to this column. @@ -85,7 +87,7 @@ module Axlsx end # Serialize the object to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<filterColumn #{serialized_attributes}>" @filter.to_xml_string(str) str << "</filterColumn>" diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb index 90a5ff48..0fc5c968 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # When multiple values are chosen to filter by, or when a group of date values are chosen to filter by, # this object groups those criteria together. @@ -74,7 +76,7 @@ module Axlsx end # Serialize the object to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<filters #{serialized_attributes}>" filter_items.each { |filter| filter.to_xml_string(str) } date_group_items.each { |date_group_item| date_group_item.to_xml_string(str) } @@ -118,7 +120,7 @@ module Axlsx # Serializes the filter value object # @param [String] str The string to concact the serialization information to. - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<filter val='#{@val}' />" end end @@ -235,7 +237,7 @@ module Axlsx # Serialize the object to xml # @param [String] str The string object this serialization will be concatenated to. - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('dateGroupItem', str) end end diff --git a/lib/axlsx/workbook/worksheet/border_creator.rb b/lib/axlsx/workbook/worksheet/border_creator.rb index 0e2fa87b..6321916f 100644 --- a/lib/axlsx/workbook/worksheet/border_creator.rb +++ b/lib/axlsx/workbook/worksheet/border_creator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx class BorderCreator def initialize(worksheet:, cells:, edges: nil, style: nil, color: nil) diff --git a/lib/axlsx/workbook/worksheet/break.rb b/lib/axlsx/workbook/worksheet/break.rb index f8cc452e..ca99a661 100644 --- a/lib/axlsx/workbook/worksheet/break.rb +++ b/lib/axlsx/workbook/worksheet/break.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Break class stores the details for row and column page breaks. # @see RowBreaks, ColBreaks @@ -25,7 +27,7 @@ module Axlsx serializable_attributes :id, :min, :max, :man, :pt # serializes the break to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('brk', str) end end diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 13c762ef..929a7c28 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cgi' module Axlsx # A cell in a worksheet. @@ -72,13 +74,13 @@ module Axlsx # Leading characters that indicate a formula. # See: https://owasp.org/www-community/attacks/CSV_Injection - FORMULA_PREFIXES = ['='.freeze].freeze + FORMULA_PREFIXES = ['='].freeze # Leading characters that indicate an array formula. - ARRAY_FORMULA_PREFIXES = ['{='.freeze].freeze + ARRAY_FORMULA_PREFIXES = ['{='].freeze # Trailing character that indicates an array formula. - ARRAY_FORMULA_SUFFIX = '}'.freeze + ARRAY_FORMULA_SUFFIX = '}' # The index of the cellXfs item to be applied to this cell. # @return [Integer] @@ -386,7 +388,7 @@ module Axlsx # @param [Integer] c_index The cell index in the row. # @param [String] str The string index the cell content will be appended to. Defaults to empty string. # @return [String] xml text for the cell - def to_xml_string(r_index, c_index, str = '') + def to_xml_string(r_index, c_index, str = +'') CellSerializer.to_xml_string r_index, c_index, self, str end diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb index 94a1f93a..b4c16b57 100644 --- a/lib/axlsx/workbook/worksheet/cell_serializer.rb +++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Cell Serializer class contains the logic for serializing cells based on their type. class CellSerializer @@ -7,8 +9,8 @@ module Axlsx # @param [Integer] column_index The index of the cell's column # @param [String] str The string to apend serialization to. # @return [String] - def to_xml_string(row_index, column_index, cell, str = '') - str << ('<c r="' << Axlsx::cell_r(column_index, row_index) << '" s="' << cell.style.to_s << '" ') + def to_xml_string(row_index, column_index, cell, str = +'') + str << (+'<c r="' << Axlsx::cell_r(column_index, row_index) << '" s="' << cell.style.to_s << '" ') return str << '/>' if cell.value.nil? method = cell.type @@ -19,7 +21,7 @@ module Axlsx # builds an xml text run based on this cells attributes. # @param [String] str The string instance this run will be concated to. # @return [String] - def run_xml_string(cell, str = '') + def run_xml_string(cell, str = +'') if cell.is_text_run? valid = RichTextRun::INLINE_STYLES - [:value, :type] data = Hash[Axlsx.instance_values_for(cell).map { |k, v| [k.to_sym, v] }] @@ -28,7 +30,7 @@ module Axlsx elsif cell.contains_rich_text? cell.value.to_xml_string(str) else - str << ('<t>' << cell.clean_value << '</t>') + str << (+'<t>' << cell.clean_value << '</t>') end str end @@ -37,7 +39,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def iso_8601(cell, str = '') + def iso_8601(cell, str = +'') value_serialization 'd', cell.value, str end @@ -45,7 +47,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def date(cell, str = '') + def date(cell, str = +'') value_serialization false, DateTimeConverter::date_to_serial(cell.value).to_s, str end @@ -53,7 +55,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def time(cell, str = '') + def time(cell, str = +'') value_serialization false, DateTimeConverter::time_to_serial(cell.value).to_s, str end @@ -61,7 +63,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def boolean(cell, str = '') + def boolean(cell, str = +'') value_serialization 'b', cell.value.to_s, str end @@ -69,7 +71,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def float(cell, str = '') + def float(cell, str = +'') numeric cell, str end @@ -77,7 +79,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def integer(cell, str = '') + def integer(cell, str = +'') numeric cell, str end @@ -85,25 +87,25 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def formula_serialization(cell, str = '') - str << ('t="str"><f>' << cell.clean_value.to_s.sub('=', '') << '</f>') - str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil? + def formula_serialization(cell, str = +'') + str << (+'t="str"><f>' << cell.clean_value.to_s.sub('=', '') << '</f>') + str << (+'<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil? end # Serializes cells that are type array formula # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def array_formula_serialization(cell, str = '') - str << ('t="str">' << '<f t="array" ref="' << cell.r << '">' << cell.clean_value.to_s.sub('{=', '').sub(/}$/, '') << '</f>') - str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil? + def array_formula_serialization(cell, str = +'') + str << (+'t="str">' << '<f t="array" ref="' << cell.r << '">' << cell.clean_value.to_s.sub('{=', '').sub(/}$/, '') << '</f>') + str << (+'<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil? end # Serializes cells that are type inline_string # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def inline_string_serialization(cell, str = '') + def inline_string_serialization(cell, str = +'') str << 't="inlineStr"><is>' run_xml_string cell, str str << '</is>' @@ -113,7 +115,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def string(cell, str = '') + def string(cell, str = +'') if cell.is_array_formula? array_formula_serialization cell, str elsif cell.is_formula? @@ -151,13 +153,13 @@ module Axlsx private - def numeric(cell, str = '') + def numeric(cell, str = +'') value_serialization 'n', cell.value, str end - def value_serialization(serialization_type, serialization_value, str = '') - str << ('t="' << serialization_type.to_s << '"') if serialization_type - str << ('><v>' << serialization_value.to_s << '</v>') + def value_serialization(serialization_type, serialization_value, str = +'') + str << (+'t="' << serialization_type.to_s << '"') if serialization_type + str << (+'><v>' << serialization_value.to_s << '</v>') end end end diff --git a/lib/axlsx/workbook/worksheet/cfvo.rb b/lib/axlsx/workbook/worksheet/cfvo.rb index faa5d88a..9aeb55ed 100644 --- a/lib/axlsx/workbook/worksheet/cfvo.rb +++ b/lib/axlsx/workbook/worksheet/cfvo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Conditional Format Value Object # Describes the values of the interpolation points in a gradient scale. This object is used by ColorScale, DataBar and IconSet classes @@ -53,7 +55,7 @@ module Axlsx # serialize the Csvo object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('cfvo', str) end end diff --git a/lib/axlsx/workbook/worksheet/cfvos.rb b/lib/axlsx/workbook/worksheet/cfvos.rb index c5fa80f3..3c41953a 100644 --- a/lib/axlsx/workbook/worksheet/cfvos.rb +++ b/lib/axlsx/workbook/worksheet/cfvos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A collection of Cfvo objects that initializes with the required # first two items @@ -9,7 +11,7 @@ module Axlsx # Serialize the Cfvo object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') each { |cfvo| cfvo.to_xml_string(str) } end end diff --git a/lib/axlsx/workbook/worksheet/col.rb b/lib/axlsx/workbook/worksheet/col.rb index 37c38365..539a6007 100644 --- a/lib/axlsx/workbook/worksheet/col.rb +++ b/lib/axlsx/workbook/worksheet/col.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Col class defines column attributes for columns in sheets. class Col @@ -135,7 +137,7 @@ module Axlsx # Serialize this columns data to an xml string # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('col', str) end end diff --git a/lib/axlsx/workbook/worksheet/col_breaks.rb b/lib/axlsx/workbook/worksheet/col_breaks.rb index 78ccc565..2e176f0d 100644 --- a/lib/axlsx/workbook/worksheet/col_breaks.rb +++ b/lib/axlsx/workbook/worksheet/col_breaks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A collection of Brake objects. # Please do not use this class directly. Instead use @@ -23,10 +25,10 @@ module Axlsx # <colBreaks count="1" manualBreakCount="1"> # <brk id="3" max="1048575" man="1"/> # </colBreaks> - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? - str << ('<colBreaks count="' << size.to_s << '" manualBreakCount="' << size.to_s << '">') + str << (+'<colBreaks count="' << size.to_s << '" manualBreakCount="' << size.to_s << '">') each { |brk| brk.to_xml_string(str) } str << '</colBreaks>' end diff --git a/lib/axlsx/workbook/worksheet/color_scale.rb b/lib/axlsx/workbook/worksheet/color_scale.rb index 75877915..fb84668b 100644 --- a/lib/axlsx/workbook/worksheet/color_scale.rb +++ b/lib/axlsx/workbook/worksheet/color_scale.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Conditional Format Rule color scale object # Describes a gradated color scale in this conditional formatting rule. @@ -82,7 +84,7 @@ module Axlsx # Serialize this color_scale object data to an xml string # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<colorScale>' value_objects.to_xml_string(str) colors.each { |color| color.to_xml_string(str) } diff --git a/lib/axlsx/workbook/worksheet/cols.rb b/lib/axlsx/workbook/worksheet/cols.rb index 27b1f508..7dd3f175 100644 --- a/lib/axlsx/workbook/worksheet/cols.rb +++ b/lib/axlsx/workbook/worksheet/cols.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The cols class manages the col object used to manage column widths. # This is where the magic happens with autowidth @@ -12,7 +14,7 @@ module Axlsx # Serialize the Cols object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << '<cols>' diff --git a/lib/axlsx/workbook/worksheet/comment.rb b/lib/axlsx/workbook/worksheet/comment.rb index aa35feef..1da779aa 100644 --- a/lib/axlsx/workbook/worksheet/comment.rb +++ b/lib/axlsx/workbook/worksheet/comment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A comment is the text data for a comment class Comment @@ -59,17 +61,17 @@ module Axlsx # serialize the object # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') author = @comments.authors[author_index] - str << ('<comment ref="' << ref << '" authorId="' << author_index.to_s << '">') + str << (+'<comment ref="' << ref << '" authorId="' << author_index.to_s << '">') str << '<text>' unless author.to_s == "" str << '<r><rPr><b/><color indexed="81"/></rPr>' - str << ("<t>" << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>") + str << (+"<t>" << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>") end str << '<r>' str << '<rPr><color indexed="81"/></rPr>' - str << ('<t>' << ::CGI.escapeHTML(text) << '</t></r></text>') + str << (+'<t>' << ::CGI.escapeHTML(text) << '</t></r></text>') str << '</comment>' end diff --git a/lib/axlsx/workbook/worksheet/comments.rb b/lib/axlsx/workbook/worksheet/comments.rb index f6f3071b..b121ccd7 100644 --- a/lib/axlsx/workbook/worksheet/comments.rb +++ b/lib/axlsx/workbook/worksheet/comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Comments is a collection of Comment objects for a worksheet class Comments < SimpleTypedList @@ -62,11 +64,11 @@ module Axlsx # serialize the object # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<comments xmlns="' << XML_NS << '"><authors>') + str << (+'<comments xmlns="' << XML_NS << '"><authors>') authors.each do |author| - str << ('<author>' << author.to_s << '</author>') + str << (+'<author>' << author.to_s << '</author>') end str << '</authors><commentList>' each do |comment| diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting.rb b/lib/axlsx/workbook/worksheet/conditional_formatting.rb index 419e6684..bd5f5bc6 100644 --- a/lib/axlsx/workbook/worksheet/conditional_formatting.rb +++ b/lib/axlsx/workbook/worksheet/conditional_formatting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Conditional formatting allows styling of ranges based on functions # @@ -72,8 +74,8 @@ module Axlsx # </conditionalFormatting> # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<conditionalFormatting sqref="' << sqref << '">') + def to_xml_string(str = +'') + str << (+'<conditionalFormatting sqref="' << sqref << '">') str << rules.collect { |rule| rule.to_xml_string }.join(' ') str << '</conditionalFormatting>' end diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb b/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb index 4f84080b..1845f327 100644 --- a/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +++ b/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Conditional formatting rules specify formulas whose evaluations # format cells @@ -202,11 +204,11 @@ module Axlsx # Serializes the conditional formatting rule # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<cfRule ' serialized_attributes str str << '>' - str << ('<formula>' << [*self.formula].join('</formula><formula>') << '</formula>') if @formula + str << (+'<formula>' << [*self.formula].join('</formula><formula>') << '</formula>') if @formula @color_scale.to_xml_string(str) if @color_scale && @type == :colorScale @data_bar.to_xml_string(str) if @data_bar && @type == :dataBar @icon_set.to_xml_string(str) if @icon_set && @type == :iconSet diff --git a/lib/axlsx/workbook/worksheet/conditional_formattings.rb b/lib/axlsx/workbook/worksheet/conditional_formattings.rb index 8b510ab9..16ee1e99 100644 --- a/lib/axlsx/workbook/worksheet/conditional_formattings.rb +++ b/lib/axlsx/workbook/worksheet/conditional_formattings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A simple, self serializing class for storing conditional formattings class ConditionalFormattings < SimpleTypedList @@ -14,7 +16,7 @@ module Axlsx attr_reader :worksheet # serialize the conditional formattings - def to_xml_string(str = "") + def to_xml_string(str = +'') return if empty? each { |item| item.to_xml_string(str) } diff --git a/lib/axlsx/workbook/worksheet/data_bar.rb b/lib/axlsx/workbook/worksheet/data_bar.rb index c9f99dcc..108a5c16 100644 --- a/lib/axlsx/workbook/worksheet/data_bar.rb +++ b/lib/axlsx/workbook/worksheet/data_bar.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Conditional Format Rule data bar object # Describes a data bar conditional formatting rule. @@ -105,7 +107,7 @@ module Axlsx # Serialize this object to an xml string # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') serialized_tag('dataBar', str) do value_objects.to_xml_string(str) self.color.to_xml_string(str) diff --git a/lib/axlsx/workbook/worksheet/data_validation.rb b/lib/axlsx/workbook/worksheet/data_validation.rb index 741dee86..1b9cb46a 100644 --- a/lib/axlsx/workbook/worksheet/data_validation.rb +++ b/lib/axlsx/workbook/worksheet/data_validation.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Data validation allows the validation of cell data # @@ -231,16 +233,16 @@ module Axlsx # Serializes the data validation # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') valid_attributes = get_valid_attributes str << '<dataValidation ' str << Axlsx.instance_values_for(self).map do |key, value| - '' << key << '="' << Axlsx.booleanize(value).to_s << '"' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym)) + +'' << key << '="' << Axlsx.booleanize(value).to_s << '"' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym)) end.join(' ') str << '>' - str << ('<formula1>' << self.formula1 << '</formula1>') if @formula1 and valid_attributes.include?(:formula1) - str << ('<formula2>' << self.formula2 << '</formula2>') if @formula2 and valid_attributes.include?(:formula2) + str << (+'<formula1>' << self.formula1 << '</formula1>') if @formula1 and valid_attributes.include?(:formula1) + str << (+'<formula2>' << self.formula2 << '</formula2>') if @formula2 and valid_attributes.include?(:formula2) str << '</dataValidation>' end diff --git a/lib/axlsx/workbook/worksheet/data_validations.rb b/lib/axlsx/workbook/worksheet/data_validations.rb index 9c07da42..a8c2a5b3 100644 --- a/lib/axlsx/workbook/worksheet/data_validations.rb +++ b/lib/axlsx/workbook/worksheet/data_validations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A simple, self serializing class for storing conditional formattings class DataValidations < SimpleTypedList @@ -14,7 +16,7 @@ module Axlsx attr_reader :worksheet # serialize the conditional formattings - def to_xml_string(str = "") + def to_xml_string(str = +'') return if empty? str << "<dataValidations count='#{size}'>" diff --git a/lib/axlsx/workbook/worksheet/date_time_converter.rb b/lib/axlsx/workbook/worksheet/date_time_converter.rb index ff85c64f..ffa2831a 100644 --- a/lib/axlsx/workbook/worksheet/date_time_converter.rb +++ b/lib/axlsx/workbook/worksheet/date_time_converter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "date" module Axlsx diff --git a/lib/axlsx/workbook/worksheet/dimension.rb b/lib/axlsx/workbook/worksheet/dimension.rb index 013097c8..42e02e72 100644 --- a/lib/axlsx/workbook/worksheet/dimension.rb +++ b/lib/axlsx/workbook/worksheet/dimension.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class manages the dimensions for a worksheet. # While this node is optional in the specification some readers like @@ -34,7 +36,7 @@ module Axlsx # serialize the object # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if worksheet.rows.empty? str << "<dimension ref=\"%s\"></dimension>" % sqref diff --git a/lib/axlsx/workbook/worksheet/header_footer.rb b/lib/axlsx/workbook/worksheet/header_footer.rb index 5ad00565..c60d6678 100644 --- a/lib/axlsx/workbook/worksheet/header_footer.rb +++ b/lib/axlsx/workbook/worksheet/header_footer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Header/Footer options for printing a worksheet. All settings are optional. # @@ -40,7 +42,7 @@ module Axlsx # Serializes the header/footer object. # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('headerFooter', str) do serialized_element_attributes(str) do |value| value = ::CGI.escapeHTML(value) diff --git a/lib/axlsx/workbook/worksheet/icon_set.rb b/lib/axlsx/workbook/worksheet/icon_set.rb index 4e7064e9..c4b5f2ff 100644 --- a/lib/axlsx/workbook/worksheet/icon_set.rb +++ b/lib/axlsx/workbook/worksheet/icon_set.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Conditional Format Rule icon sets # Describes an icon set conditional formatting rule. @@ -61,7 +63,7 @@ module Axlsx # Serialize this object to an xml string # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') serialized_tag('iconSet', str) do @value_objects.each { |cfvo| cfvo.to_xml_string(str) } end diff --git a/lib/axlsx/workbook/worksheet/merged_cells.rb b/lib/axlsx/workbook/worksheet/merged_cells.rb index f54fd252..c0ca1ebe 100644 --- a/lib/axlsx/workbook/worksheet/merged_cells.rb +++ b/lib/axlsx/workbook/worksheet/merged_cells.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A simple list of merged cells class MergedCells < SimpleTypedList @@ -26,7 +28,7 @@ module Axlsx # serialize the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << "<mergeCells count='#{size}'>" diff --git a/lib/axlsx/workbook/worksheet/outline_pr.rb b/lib/axlsx/workbook/worksheet/outline_pr.rb index 5db0d825..4cfeea2d 100644 --- a/lib/axlsx/workbook/worksheet/outline_pr.rb +++ b/lib/axlsx/workbook/worksheet/outline_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The OutlinePr class manages serialization of a worksheet's outlinePr element, which provides various # options to control outlining. @@ -25,7 +27,7 @@ module Axlsx # Serialize the object # @param [String] str serialized output will be appended to this object if provided. # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<outlinePr #{serialized_attributes} />" end end diff --git a/lib/axlsx/workbook/worksheet/page_margins.rb b/lib/axlsx/workbook/worksheet/page_margins.rb index a0967817..4d133c5a 100644 --- a/lib/axlsx/workbook/worksheet/page_margins.rb +++ b/lib/axlsx/workbook/worksheet/page_margins.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # PageMargins specify the margins when printing a worksheet. # @@ -90,7 +92,7 @@ module Axlsx # @return [String] # @note For compatibility, this is a noop unless custom margins have been specified. # @see #custom_margins_specified? - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('pageMargins', str) end end diff --git a/lib/axlsx/workbook/worksheet/page_set_up_pr.rb b/lib/axlsx/workbook/worksheet/page_set_up_pr.rb index 819c5fa7..9a2b778b 100644 --- a/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +++ b/lib/axlsx/workbook/worksheet/page_set_up_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Page setup properties of the worksheet # This class name is not a typo, its spec. @@ -35,8 +37,8 @@ module Axlsx end # serialize to xml - def to_xml_string(str = '') - str << ('<pageSetUpPr ' << serialized_attributes << '/>') + def to_xml_string(str = +'') + str << (+'<pageSetUpPr ' << serialized_attributes << '/>') end end end diff --git a/lib/axlsx/workbook/worksheet/page_setup.rb b/lib/axlsx/workbook/worksheet/page_setup.rb index c10e28ce..0bd0cdb8 100644 --- a/lib/axlsx/workbook/worksheet/page_setup.rb +++ b/lib/axlsx/workbook/worksheet/page_setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Page setup settings for printing a worksheet. All settings are optional. # @@ -230,7 +232,7 @@ module Axlsx # Serializes the page settings element. # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('pageSetup', str) end end diff --git a/lib/axlsx/workbook/worksheet/pane.rb b/lib/axlsx/workbook/worksheet/pane.rb index e752ab22..a018dc74 100644 --- a/lib/axlsx/workbook/worksheet/pane.rb +++ b/lib/axlsx/workbook/worksheet/pane.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Pane options for a worksheet. # @@ -120,7 +122,7 @@ module Axlsx # Serializes the data validation # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') finalize serialized_tag 'pane', str end diff --git a/lib/axlsx/workbook/worksheet/pivot_table.rb b/lib/axlsx/workbook/worksheet/pivot_table.rb index ff131dfb..e97b8119 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Table # @note Worksheet#add_pivot_table is the recommended way to create tables for your worksheets. @@ -184,13 +186,13 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<pivotTableDefinition xmlns="' << XML_NS << '" name="' << name << '" cacheId="' << cache_definition.cache_id.to_s << '"' << (data.size <= 1 ? ' dataOnRows="1"' : '') << ' applyNumberFormats="0" applyBorderFormats="0" applyFontFormats="0" applyPatternFormats="0" applyAlignmentFormats="0" applyWidthHeightFormats="1" dataCaption="Data" showMultipleLabel="0" showMemberPropertyTips="0" useAutoFormatting="1" indent="0" compact="0" compactData="0" gridDropZones="1" multipleFieldFilters="0">') + str << (+'<pivotTableDefinition xmlns="' << XML_NS << '" name="' << name << '" cacheId="' << cache_definition.cache_id.to_s << '"' << (data.size <= 1 ? ' dataOnRows="1"' : '') << ' applyNumberFormats="0" applyBorderFormats="0" applyFontFormats="0" applyPatternFormats="0" applyAlignmentFormats="0" applyWidthHeightFormats="1" dataCaption="Data" showMultipleLabel="0" showMemberPropertyTips="0" useAutoFormatting="1" indent="0" compact="0" compactData="0" gridDropZones="1" multipleFieldFilters="0">') - str << ('<location firstDataCol="1" firstDataRow="1" firstHeaderRow="1" ref="' << ref << '"/>') - str << ('<pivotFields count="' << header_cells_count.to_s << '">') + str << (+'<location firstDataCol="1" firstDataRow="1" firstHeaderRow="1" ref="' << ref << '"/>') + str << (+'<pivotFields count="' << header_cells_count.to_s << '">') header_cell_values.each do |cell_value| subtotal = !no_subtotals_on_headers.include?(cell_value) @@ -203,12 +205,12 @@ module Axlsx str << '<rowFields count="1"><field x="-2"/></rowFields>' str << '<rowItems count="2"><i><x/></i> <i i="1"><x v="1"/></i></rowItems>' else - str << ('<rowFields count="' << rows.size.to_s << '">') + str << (+'<rowFields count="' << rows.size.to_s << '">') rows.each do |row_value| - str << ('<field x="' << header_index_of(row_value).to_s << '"/>') + str << (+'<field x="' << header_index_of(row_value).to_s << '"/>') end str << '</rowFields>' - str << ('<rowItems count="' << rows.size.to_s << '">') + str << (+'<rowItems count="' << rows.size.to_s << '">') rows.size.times do |i| str << '<i/>' end @@ -227,16 +229,16 @@ module Axlsx str << '<colItems count="1"><i/></colItems>' end else - str << ('<colFields count="' << columns.size.to_s << '">') + str << (+'<colFields count="' << columns.size.to_s << '">') columns.each do |column_value| - str << ('<field x="' << header_index_of(column_value).to_s << '"/>') + str << (+'<field x="' << header_index_of(column_value).to_s << '"/>') end str << '</colFields>' end unless pages.empty? - str << ('<pageFields count="' << pages.size.to_s << '">') + str << (+'<pageFields count="' << pages.size.to_s << '">') pages.each do |page_value| - str << ('<pageField fld="' << header_index_of(page_value).to_s << '"/>') + str << (+'<pageField fld="' << header_index_of(page_value).to_s << '"/>') end str << '</pageFields>' end diff --git a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb index 8813c84b..d42c1fda 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Table # @note Worksheet#add_pivot_table is the recommended way to create tables for your worksheets. @@ -43,15 +45,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<pivotCacheDefinition xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '" invalid="1" refreshOnLoad="1" recordCount="0">') + str << (+'<pivotCacheDefinition xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '" invalid="1" refreshOnLoad="1" recordCount="0">') str << '<cacheSource type="worksheet">' - str << ('<worksheetSource ref="' << pivot_table.range << '" sheet="' << pivot_table.data_sheet.name << '"/>') + str << (+'<worksheetSource ref="' << pivot_table.range << '" sheet="' << pivot_table.data_sheet.name << '"/>') str << '</cacheSource>' - str << ('<cacheFields count="' << pivot_table.header_cells_count.to_s << '">') + str << (+'<cacheFields count="' << pivot_table.header_cells_count.to_s << '">') pivot_table.header_cells.each do |cell| - str << ('<cacheField name="' << cell.clean_value << '" numFmtId="0">') + str << (+'<cacheField name="' << cell.clean_value << '" numFmtId="0">') str << '<sharedItems count="0">' str << '</sharedItems>' str << '</cacheField>' diff --git a/lib/axlsx/workbook/worksheet/pivot_tables.rb b/lib/axlsx/workbook/worksheet/pivot_tables.rb index c27162c3..7ba09b09 100644 --- a/lib/axlsx/workbook/worksheet/pivot_tables.rb +++ b/lib/axlsx/workbook/worksheet/pivot_tables.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A simple, self serializing class for storing pivot tables class PivotTables < SimpleTypedList diff --git a/lib/axlsx/workbook/worksheet/print_options.rb b/lib/axlsx/workbook/worksheet/print_options.rb index 7ba52861..6e1b2bfd 100644 --- a/lib/axlsx/workbook/worksheet/print_options.rb +++ b/lib/axlsx/workbook/worksheet/print_options.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Options for printing a worksheet. All options are boolean and false by default. # @@ -31,7 +33,7 @@ module Axlsx # @note As all attributes default to "false" according to the xml schema definition, the generated xml includes only those attributes that are set to true. # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag 'printOptions', str end end diff --git a/lib/axlsx/workbook/worksheet/protected_range.rb b/lib/axlsx/workbook/worksheet/protected_range.rb index e4eb83e5..64a5795c 100644 --- a/lib/axlsx/workbook/worksheet/protected_range.rb +++ b/lib/axlsx/workbook/worksheet/protected_range.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The Protected Range class represents a set of cells in the worksheet # @note the recommended way to manage protected ranges with via Worksheet#protect_range @@ -39,7 +41,7 @@ module Axlsx # @param [String] str if this string object is provided we append # our output to that object. Use this - it helps limit the number of # objects created during serialization - def to_xml_string(str = "") + def to_xml_string(str = +'') serialized_tag 'protectedRange', str end end diff --git a/lib/axlsx/workbook/worksheet/protected_ranges.rb b/lib/axlsx/workbook/worksheet/protected_ranges.rb index 75b3aee5..f8ce82c5 100644 --- a/lib/axlsx/workbook/worksheet/protected_ranges.rb +++ b/lib/axlsx/workbook/worksheet/protected_ranges.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A self serializing collection of ranges that should be protected in # the worksheet @@ -26,7 +28,7 @@ module Axlsx # Serializes the protected ranges # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << '<protectedRanges>' diff --git a/lib/axlsx/workbook/worksheet/rich_text.rb b/lib/axlsx/workbook/worksheet/rich_text.rb index 4b643470..e1a3ad4b 100644 --- a/lib/axlsx/workbook/worksheet/rich_text.rb +++ b/lib/axlsx/workbook/worksheet/rich_text.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A simple, self serializing class for storing TextRuns class RichText < SimpleTypedList @@ -45,7 +47,7 @@ module Axlsx # renders the RichTextRuns in this collection # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') each { |run| run.to_xml_string(str) } str end diff --git a/lib/axlsx/workbook/worksheet/rich_text_run.rb b/lib/axlsx/workbook/worksheet/rich_text_run.rb index f9d2932f..ee988318 100644 --- a/lib/axlsx/workbook/worksheet/rich_text_run.rb +++ b/lib/axlsx/workbook/worksheet/rich_text_run.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The RichTextRun class creates and self serializing text run. class RichTextRun @@ -203,7 +205,7 @@ module Axlsx # Serializes the RichTextRun # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') valid = RichTextRun::INLINE_STYLES data = Hash[Axlsx.instance_values_for(self).map { |k, v| [k.to_sym, v] }] data = data.select { |key, value| valid.include?(key) && !value.nil? } @@ -212,15 +214,15 @@ module Axlsx data.keys.each do |key| case key when :font_name - str << ('<rFont val="' << font_name << '"/>') + str << (+'<rFont val="' << font_name << '"/>') when :color str << data[key].to_xml_string else - str << ('<' << key.to_s << ' val="' << xml_value(data[key]) << '"/>') + str << (+'<' << key.to_s << ' val="' << xml_value(data[key]) << '"/>') end end clean_value = Axlsx::trust_input ? @value.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@value.to_s)) - str << ('</rPr><t>' << clean_value << '</t></r>') + str << (+'</rPr><t>' << clean_value << '</t></r>') end private diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb index 119cd10b..0c139164 100644 --- a/lib/axlsx/workbook/worksheet/row.rb +++ b/lib/axlsx/workbook/worksheet/row.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A Row is a single row in a worksheet. # @note The recommended way to manage rows and cells is to use Worksheet#add_row @@ -86,10 +88,9 @@ module Axlsx # @param [Integer] r_index The row index, 0 based. # @param [String] str The string this rows xml will be appended to. # @return [String] - def to_xml_string(r_index, str = '') + def to_xml_string(r_index, str = +'') serialized_tag('row', str, :r => r_index + 1) do - tmp = '' # time / memory tradeoff, lots of calls to rubyzip costs more - # time.. + tmp = +'' # time / memory tradeoff, lots of calls to rubyzip costs more time.. each_with_index { |cell, c_index| cell.to_xml_string(r_index, c_index, tmp) } str << tmp end diff --git a/lib/axlsx/workbook/worksheet/row_breaks.rb b/lib/axlsx/workbook/worksheet/row_breaks.rb index 2da31719..3e945b78 100644 --- a/lib/axlsx/workbook/worksheet/row_breaks.rb +++ b/lib/axlsx/workbook/worksheet/row_breaks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A collection of break objects that define row breaks (page breaks) for printing and preview @@ -21,10 +23,10 @@ module Axlsx # <brk id="7" max="16383" man="1"/> # <brk id="13" max="16383" man="1"/> # </rowBreaks> - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? - str << ('<rowBreaks count="' << self.size.to_s << '" manualBreakCount="' << self.size.to_s << '">') + str << (+'<rowBreaks count="' << self.size.to_s << '" manualBreakCount="' << self.size.to_s << '">') each { |brk| brk.to_xml_string(str) } str << '</rowBreaks>' end diff --git a/lib/axlsx/workbook/worksheet/selection.rb b/lib/axlsx/workbook/worksheet/selection.rb index 82538fce..556651e3 100644 --- a/lib/axlsx/workbook/worksheet/selection.rb +++ b/lib/axlsx/workbook/worksheet/selection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Selection options for worksheet panes. # @@ -92,7 +94,7 @@ module Axlsx # Serializes the data validation # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag 'selection', str end end diff --git a/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb b/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb index d692d461..e85cbf2c 100644 --- a/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +++ b/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # the SheetCalcPr object for the worksheet # This object contains calculation properties for the worksheet. @@ -21,7 +23,7 @@ module Axlsx # @param [String] str the string to append this objects serialized # content to. # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<sheetCalcPr #{serialized_attributes}/>" end end diff --git a/lib/axlsx/workbook/worksheet/sheet_data.rb b/lib/axlsx/workbook/worksheet/sheet_data.rb index f6a27b0e..611da1aa 100644 --- a/lib/axlsx/workbook/worksheet/sheet_data.rb +++ b/lib/axlsx/workbook/worksheet/sheet_data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This class manages the serialization of rows for worksheets class SheetData @@ -14,7 +16,7 @@ module Axlsx # Serialize the sheet data # @param [String] str the string this objects serializaton will be concacted to. # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<sheetData>' worksheet.rows.each_with_index do |row, index| row.to_xml_string(index, str) diff --git a/lib/axlsx/workbook/worksheet/sheet_format_pr.rb b/lib/axlsx/workbook/worksheet/sheet_format_pr.rb index ad4e4fab..227b9037 100644 --- a/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +++ b/lib/axlsx/workbook/worksheet/sheet_format_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Sheet formatting properties # <xsd:complexType name="CT_SheetFormatPr"> @@ -46,7 +48,7 @@ module Axlsx # serializes this object to an xml string # @param [String] str The string this objects serialization will be appended to # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<sheetFormatPr #{serialized_attributes}/>" end diff --git a/lib/axlsx/workbook/worksheet/sheet_pr.rb b/lib/axlsx/workbook/worksheet/sheet_pr.rb index 4fccf662..f90e7d6c 100644 --- a/lib/axlsx/workbook/worksheet/sheet_pr.rb +++ b/lib/axlsx/workbook/worksheet/sheet_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The SheetPr class manages serialization of a worksheet's sheetPr element. class SheetPr @@ -48,7 +50,7 @@ module Axlsx # Serialize the object # @param [String] str serialized output will be appended to this object if provided. # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') update_properties str << "<sheetPr #{serialized_attributes}>" tab_color.to_xml_string(str, 'tabColor') if tab_color diff --git a/lib/axlsx/workbook/worksheet/sheet_protection.rb b/lib/axlsx/workbook/worksheet/sheet_protection.rb index 42d74695..faf34f97 100644 --- a/lib/axlsx/workbook/worksheet/sheet_protection.rb +++ b/lib/axlsx/workbook/worksheet/sheet_protection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The SheetProtection object manages worksheet protection options per sheet. class SheetProtection @@ -73,7 +75,7 @@ module Axlsx # Serialize the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('sheetProtection', str) end diff --git a/lib/axlsx/workbook/worksheet/sheet_view.rb b/lib/axlsx/workbook/worksheet/sheet_view.rb index dc41d01a..d06715fe 100644 --- a/lib/axlsx/workbook/worksheet/sheet_view.rb +++ b/lib/axlsx/workbook/worksheet/sheet_view.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # View options for a worksheet. # @@ -190,7 +192,7 @@ module Axlsx # Serializes the data validation # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<sheetViews>' str << '<sheetView ' serialized_attributes str diff --git a/lib/axlsx/workbook/worksheet/table.rb b/lib/axlsx/workbook/worksheet/table.rb index 4f446491..430ef489 100644 --- a/lib/axlsx/workbook/worksheet/table.rb +++ b/lib/axlsx/workbook/worksheet/table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # Table # @note Worksheet#add_table is the recommended way to create tables for your worksheets. @@ -71,14 +73,14 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<table xmlns="' << XML_NS << '" id="' << (index + 1).to_s << '" name="' << @name << '" displayName="' << @name.gsub(/\s/, '_') << '" ') - str << ('ref="' << @ref << '" totalsRowShown="0">') - str << ('<autoFilter ref="' << @ref << '"/>') - str << ('<tableColumns count="' << header_cells.length.to_s << '">') + str << (+'<table xmlns="' << XML_NS << '" id="' << (index + 1).to_s << '" name="' << @name << '" displayName="' << @name.gsub(/\s/, '_') << '" ') + str << (+'ref="' << @ref << '" totalsRowShown="0">') + str << (+'<autoFilter ref="' << @ref << '"/>') + str << (+'<tableColumns count="' << header_cells.length.to_s << '">') header_cells.each_with_index do |cell, index| - str << ('<tableColumn id ="' << (index + 1).to_s << '" name="' << cell.clean_value << '"/>') + str << (+'<tableColumn id ="' << (index + 1).to_s << '" name="' << cell.clean_value << '"/>') end str << '</tableColumns>' table_style_info.to_xml_string(str) diff --git a/lib/axlsx/workbook/worksheet/table_style_info.rb b/lib/axlsx/workbook/worksheet/table_style_info.rb index 537b2eea..3793d488 100644 --- a/lib/axlsx/workbook/worksheet/table_style_info.rb +++ b/lib/axlsx/workbook/worksheet/table_style_info.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # The table style info class manages style attributes for defined tables in # a worksheet @@ -41,7 +43,7 @@ module Axlsx # seralizes this object to an xml string # @param [String] str the string to contact this objects serialization to. - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('tableStyleInfo', str) end end diff --git a/lib/axlsx/workbook/worksheet/tables.rb b/lib/axlsx/workbook/worksheet/tables.rb index 20ba4789..121a0d7f 100644 --- a/lib/axlsx/workbook/worksheet/tables.rb +++ b/lib/axlsx/workbook/worksheet/tables.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A simple, self serializing class for storing tables class Tables < SimpleTypedList @@ -23,7 +25,7 @@ module Axlsx # renders the tables xml # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') return if empty? str << "<tableParts count='#{size}'>" diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 1fb55ff2..0a44027f 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "border_creator" module Axlsx @@ -626,18 +628,18 @@ module Axlsx end # Returns a sheet node serialization for this sheet in the workbook. - def to_sheet_node_xml_string(str = '') + def to_sheet_node_xml_string(str = +'') add_autofilter_defined_name_to_workbook str << '<sheet ' serialized_attributes str - str << ('name="' << name << '" ') - str << ('r:id="' << rId << '"></sheet>') + str << (+'name="' << name << '" ') + str << (+'r:id="' << rId << '"></sheet>') end # Serializes the worksheet object to an xml string # This intentionally does not use nokogiri for performance reasons # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') add_autofilter_defined_name_to_workbook auto_filter.apply if auto_filter.range str << '<?xml version="1.0" encoding="UTF-8"?>' diff --git a/lib/axlsx/workbook/worksheet/worksheet_comments.rb b/lib/axlsx/workbook/worksheet/worksheet_comments.rb index 29ea6fc8..c5f5ad13 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_comments.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A wraper class for comments that defines its on worksheet # serailization @@ -49,7 +51,7 @@ module Axlsx # Seraalize the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return unless has_comments? str << "<legacyDrawing r:id='#{drawing_rId}' />" diff --git a/lib/axlsx/workbook/worksheet/worksheet_drawing.rb b/lib/axlsx/workbook/worksheet/worksheet_drawing.rb index c2819393..18c7189a 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_drawing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # This is a utility class for serialing the drawing node in a # worksheet. Drawing objects have their own serialization that exports @@ -50,7 +52,7 @@ module Axlsx # Serialize the drawing for the worksheet # @param [String] str - def to_xml_string(str = '') + def to_xml_string(str = +'') return unless has_drawing? str << "<drawing r:id='#{relationship.Id}'/>" diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb index 60615f1c..c4cb8983 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A worksheet hyperlink object. Note that this is not the same as a drawing hyperlink object. class WorksheetHyperlink @@ -56,7 +58,7 @@ module Axlsx # Seralize the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<hyperlink ' serialized_attributes str, location_or_id str << '/>' diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb index 44c6125a..f19630f8 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Axlsx # A collection of hyperlink objects for a worksheet class WorksheetHyperlinks < SimpleTypedList @@ -27,7 +29,7 @@ module Axlsx # seralize the collection of hyperlinks # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << '<hyperlinks>' diff --git a/lib/caxlsx.rb b/lib/caxlsx.rb index 047ed28f..e97cd68c 100644 --- a/lib/caxlsx.rb +++ b/lib/caxlsx.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'axlsx.rb' diff --git a/test/benchmark.rb b/test/benchmark.rb index 9e651596..38dcc8fc 100755 --- a/test/benchmark.rb +++ b/test/benchmark.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby -s +# frozen_string_literal: true $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" require 'axlsx' diff --git a/test/content_type/tc_content_type.rb b/test/content_type/tc_content_type.rb index e94f311e..a3c6603f 100644 --- a/test/content_type/tc_content_type.rb +++ b/test/content_type/tc_content_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestContentType < Test::Unit::TestCase diff --git a/test/content_type/tc_default.rb b/test/content_type/tc_default.rb index e3d8d75e..89125bf1 100644 --- a/test/content_type/tc_default.rb +++ b/test/content_type/tc_default.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestDefault < Test::Unit::TestCase diff --git a/test/content_type/tc_override.rb b/test/content_type/tc_override.rb index ad0699b5..73a13410 100644 --- a/test/content_type/tc_override.rb +++ b/test/content_type/tc_override.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestOverride < Test::Unit::TestCase diff --git a/test/doc_props/tc_app.rb b/test/doc_props/tc_app.rb index fbbe0b67..d96723db 100644 --- a/test/doc_props/tc_app.rb +++ b/test/doc_props/tc_app.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestApp < Test::Unit::TestCase diff --git a/test/doc_props/tc_core.rb b/test/doc_props/tc_core.rb index 6d0ce604..9714a6eb 100644 --- a/test/doc_props/tc_core.rb +++ b/test/doc_props/tc_core.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestCore < Test::Unit::TestCase diff --git a/test/drawing/tc_area_chart.rb b/test/drawing/tc_area_chart.rb index 14449349..5829149a 100644 --- a/test/drawing/tc_area_chart.rb +++ b/test/drawing/tc_area_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestAreaChart < Test::Unit::TestCase diff --git a/test/drawing/tc_area_series.rb b/test/drawing/tc_area_series.rb index d77e241d..c9b9a949 100644 --- a/test/drawing/tc_area_series.rb +++ b/test/drawing/tc_area_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestAreaSeries < Test::Unit::TestCase @@ -61,7 +63,7 @@ class TestAreaSeries < Test::Unit::TestCase end def wrap_with_namespaces(series) - '<c:chartSpace xmlns:c="' << + +'<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << diff --git a/test/drawing/tc_axes.rb b/test/drawing/tc_axes.rb index 27a90b0b..2e9aab90 100644 --- a/test/drawing/tc_axes.rb +++ b/test/drawing/tc_axes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestAxes < Test::Unit::TestCase diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb index d62f4fbd..59f48d1d 100644 --- a/test/drawing/tc_axis.rb +++ b/test/drawing/tc_axis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestAxis < Test::Unit::TestCase @@ -17,7 +19,7 @@ class TestAxis < Test::Unit::TestCase def test_color @axis.color = "00FF00" @axis.cross_axis = Axlsx::CatAxis.new - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '">' doc = Nokogiri::XML(@axis.to_xml_string(str)) @@ -101,7 +103,7 @@ class TestAxis < Test::Unit::TestCase def test_to_xml_string @axis.cross_axis = Axlsx::CatAxis.new - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '">' doc = Nokogiri::XML(@axis.to_xml_string(str)) diff --git a/test/drawing/tc_bar_3D_chart.rb b/test/drawing/tc_bar_3D_chart.rb index aaef0312..d825ce94 100644 --- a/test/drawing/tc_bar_3D_chart.rb +++ b/test/drawing/tc_bar_3D_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBar3DChart < Test::Unit::TestCase diff --git a/test/drawing/tc_bar_chart.rb b/test/drawing/tc_bar_chart.rb index 9fd52530..0d4fd341 100644 --- a/test/drawing/tc_bar_chart.rb +++ b/test/drawing/tc_bar_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBarChart < Test::Unit::TestCase diff --git a/test/drawing/tc_bar_series.rb b/test/drawing/tc_bar_series.rb index bbc18b1d..450b67e5 100644 --- a/test/drawing/tc_bar_series.rb +++ b/test/drawing/tc_bar_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBarSeries < Test::Unit::TestCase diff --git a/test/drawing/tc_bubble_chart.rb b/test/drawing/tc_bubble_chart.rb index e596c095..b38e636b 100644 --- a/test/drawing/tc_bubble_chart.rb +++ b/test/drawing/tc_bubble_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBubbleChart < Test::Unit::TestCase diff --git a/test/drawing/tc_bubble_series.rb b/test/drawing/tc_bubble_series.rb index ef7875ac..78ac1b23 100644 --- a/test/drawing/tc_bubble_series.rb +++ b/test/drawing/tc_bubble_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBubbleSeries < Test::Unit::TestCase diff --git a/test/drawing/tc_cat_axis.rb b/test/drawing/tc_cat_axis.rb index bae314da..db3272e5 100644 --- a/test/drawing/tc_cat_axis.rb +++ b/test/drawing/tc_cat_axis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestCatAxis < Test::Unit::TestCase diff --git a/test/drawing/tc_cat_axis_data.rb b/test/drawing/tc_cat_axis_data.rb index 09b14be6..23d78090 100644 --- a/test/drawing/tc_cat_axis_data.rb +++ b/test/drawing/tc_cat_axis_data.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # require 'tc_helper.rb' # class TestCatAxisData < Test::Unit::TestCase diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb index f91bfbbd..c7527e15 100644 --- a/test/drawing/tc_chart.rb +++ b/test/drawing/tc_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestChart < Test::Unit::TestCase diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb index ef391824..b7d664b4 100644 --- a/test/drawing/tc_d_lbls.rb +++ b/test/drawing/tc_d_lbls.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestDLbls < Test::Unit::TestCase @@ -44,7 +46,7 @@ class TestDLbls < Test::Unit::TestCase end def test_to_xml_string - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '" xmlns:r="' << Axlsx::XML_NS_R << '">' @d_lbls.to_xml_string(str) str << '</c:chartSpace>' diff --git a/test/drawing/tc_data_source.rb b/test/drawing/tc_data_source.rb index 4148439b..fd500819 100644 --- a/test/drawing/tc_data_source.rb +++ b/test/drawing/tc_data_source.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestNumDataSource < Test::Unit::TestCase @@ -12,7 +14,7 @@ class TestNumDataSource < Test::Unit::TestCase end def test_to_xml_string_strLit - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @data_source.to_xml_string doc = Nokogiri::XML(str) diff --git a/test/drawing/tc_drawing.rb b/test/drawing/tc_drawing.rb index d8c5d1e9..1e72b462 100644 --- a/test/drawing/tc_drawing.rb +++ b/test/drawing/tc_drawing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestDrawing < Test::Unit::TestCase diff --git a/test/drawing/tc_graphic_frame.rb b/test/drawing/tc_graphic_frame.rb index 8b69040a..fc5743be 100644 --- a/test/drawing/tc_graphic_frame.rb +++ b/test/drawing/tc_graphic_frame.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestGraphicFrame < Test::Unit::TestCase diff --git a/test/drawing/tc_hyperlink.rb b/test/drawing/tc_hyperlink.rb index b9df3ad9..cad418f8 100644 --- a/test/drawing/tc_hyperlink.rb +++ b/test/drawing/tc_hyperlink.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestHyperlink < Test::Unit::TestCase diff --git a/test/drawing/tc_line_3d_chart.rb b/test/drawing/tc_line_3d_chart.rb index 618439ff..2107f1a0 100644 --- a/test/drawing/tc_line_3d_chart.rb +++ b/test/drawing/tc_line_3d_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestLine3DChart < Test::Unit::TestCase diff --git a/test/drawing/tc_line_chart.rb b/test/drawing/tc_line_chart.rb index 98fecc72..460b2055 100644 --- a/test/drawing/tc_line_chart.rb +++ b/test/drawing/tc_line_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestLineChart < Test::Unit::TestCase diff --git a/test/drawing/tc_line_series.rb b/test/drawing/tc_line_series.rb index b0435488..7223fca3 100644 --- a/test/drawing/tc_line_series.rb +++ b/test/drawing/tc_line_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestLineSeries < Test::Unit::TestCase @@ -61,7 +63,7 @@ class TestLineSeries < Test::Unit::TestCase end def wrap_with_namespaces(series) - '<c:chartSpace xmlns:c="' << + +'<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << diff --git a/test/drawing/tc_marker.rb b/test/drawing/tc_marker.rb index 8f521128..3341f8cc 100644 --- a/test/drawing/tc_marker.rb +++ b/test/drawing/tc_marker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestMarker < Test::Unit::TestCase diff --git a/test/drawing/tc_named_axis_data.rb b/test/drawing/tc_named_axis_data.rb index 63fb4610..01c08784 100644 --- a/test/drawing/tc_named_axis_data.rb +++ b/test/drawing/tc_named_axis_data.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # require 'tc_helper.rb' # class TestNamedAxisData < Test::Unit::TestCase diff --git a/test/drawing/tc_num_data.rb b/test/drawing/tc_num_data.rb index b169faef..c794faf8 100644 --- a/test/drawing/tc_num_data.rb +++ b/test/drawing/tc_num_data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestNumData < Test::Unit::TestCase @@ -17,7 +19,7 @@ class TestNumData < Test::Unit::TestCase end def test_to_xml_string - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @num_data.to_xml_string doc = Nokogiri::XML(str) diff --git a/test/drawing/tc_num_val.rb b/test/drawing/tc_num_val.rb index 3168bd89..7ad6ace4 100644 --- a/test/drawing/tc_num_val.rb +++ b/test/drawing/tc_num_val.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestNumVal < Test::Unit::TestCase @@ -16,7 +18,7 @@ class TestNumVal < Test::Unit::TestCase end def test_to_xml_string - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @num_val.to_xml_string(0) doc = Nokogiri::XML(str) diff --git a/test/drawing/tc_one_cell_anchor.rb b/test/drawing/tc_one_cell_anchor.rb index 1c28ef52..7f0a7c4a 100644 --- a/test/drawing/tc_one_cell_anchor.rb +++ b/test/drawing/tc_one_cell_anchor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestOneCellAnchor < Test::Unit::TestCase diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb index 45014f53..daa8b4a3 100644 --- a/test/drawing/tc_pic.rb +++ b/test/drawing/tc_pic.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPic < Test::Unit::TestCase diff --git a/test/drawing/tc_picture_locking.rb b/test/drawing/tc_picture_locking.rb index a7daf79b..e6db9f59 100644 --- a/test/drawing/tc_picture_locking.rb +++ b/test/drawing/tc_picture_locking.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPictureLocking < Test::Unit::TestCase diff --git a/test/drawing/tc_pie_3D_chart.rb b/test/drawing/tc_pie_3D_chart.rb index 3a1236db..889e383f 100644 --- a/test/drawing/tc_pie_3D_chart.rb +++ b/test/drawing/tc_pie_3D_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPie3DChart < Test::Unit::TestCase diff --git a/test/drawing/tc_pie_series.rb b/test/drawing/tc_pie_series.rb index 96c61f94..a0d63cfc 100644 --- a/test/drawing/tc_pie_series.rb +++ b/test/drawing/tc_pie_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPieSeries < Test::Unit::TestCase diff --git a/test/drawing/tc_scaling.rb b/test/drawing/tc_scaling.rb index cc02ee92..eae1950d 100644 --- a/test/drawing/tc_scaling.rb +++ b/test/drawing/tc_scaling.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestScaling < Test::Unit::TestCase diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb index 2712da99..92bc8486 100644 --- a/test/drawing/tc_scatter_chart.rb +++ b/test/drawing/tc_scatter_chart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestScatterChart < Test::Unit::TestCase diff --git a/test/drawing/tc_scatter_series.rb b/test/drawing/tc_scatter_series.rb index f9f5aad0..a550271b 100644 --- a/test/drawing/tc_scatter_series.rb +++ b/test/drawing/tc_scatter_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestScatterSeries < Test::Unit::TestCase diff --git a/test/drawing/tc_ser_axis.rb b/test/drawing/tc_ser_axis.rb index 3b752635..6d26b182 100644 --- a/test/drawing/tc_ser_axis.rb +++ b/test/drawing/tc_ser_axis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSerAxis < Test::Unit::TestCase diff --git a/test/drawing/tc_series.rb b/test/drawing/tc_series.rb index fad4e763..2215d398 100644 --- a/test/drawing/tc_series.rb +++ b/test/drawing/tc_series.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSeries < Test::Unit::TestCase diff --git a/test/drawing/tc_series_title.rb b/test/drawing/tc_series_title.rb index 14eb0fba..8950ab6a 100644 --- a/test/drawing/tc_series_title.rb +++ b/test/drawing/tc_series_title.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSeriesTitle < Test::Unit::TestCase diff --git a/test/drawing/tc_str_data.rb b/test/drawing/tc_str_data.rb index 408e4b98..f80bf24b 100644 --- a/test/drawing/tc_str_data.rb +++ b/test/drawing/tc_str_data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestStrData < Test::Unit::TestCase @@ -6,7 +8,7 @@ class TestStrData < Test::Unit::TestCase end def test_to_xml_string_strLit - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @str_data.to_xml_string doc = Nokogiri::XML(str) diff --git a/test/drawing/tc_str_val.rb b/test/drawing/tc_str_val.rb index 39b96e08..c094c450 100644 --- a/test/drawing/tc_str_val.rb +++ b/test/drawing/tc_str_val.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestStrVal < Test::Unit::TestCase @@ -11,7 +13,7 @@ class TestStrVal < Test::Unit::TestCase end def test_to_xml_string - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @str_val.to_xml_string(0) doc = Nokogiri::XML(str) @@ -20,7 +22,7 @@ class TestStrVal < Test::Unit::TestCase end def test_to_xml_string_special_characters - str = '<?xml version="1.0" encoding="UTF-8"?>' + str = +'<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @str_val_with_special_characters.to_xml_string(0) doc = Nokogiri::XML(str) diff --git a/test/drawing/tc_title.rb b/test/drawing/tc_title.rb index 330a48e6..ee4d12c9 100644 --- a/test/drawing/tc_title.rb +++ b/test/drawing/tc_title.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestTitle < Test::Unit::TestCase diff --git a/test/drawing/tc_two_cell_anchor.rb b/test/drawing/tc_two_cell_anchor.rb index 321cc45a..bfdaf4de 100644 --- a/test/drawing/tc_two_cell_anchor.rb +++ b/test/drawing/tc_two_cell_anchor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestTwoCellAnchor < Test::Unit::TestCase diff --git a/test/drawing/tc_val_axis.rb b/test/drawing/tc_val_axis.rb index b3a6fb39..bb464048 100644 --- a/test/drawing/tc_val_axis.rb +++ b/test/drawing/tc_val_axis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestValAxis < Test::Unit::TestCase diff --git a/test/drawing/tc_view_3D.rb b/test/drawing/tc_view_3D.rb index d5550a73..e09edc13 100644 --- a/test/drawing/tc_view_3D.rb +++ b/test/drawing/tc_view_3D.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestView3D < Test::Unit::TestCase diff --git a/test/drawing/tc_vml_drawing.rb b/test/drawing/tc_vml_drawing.rb index ad12642a..815cc556 100644 --- a/test/drawing/tc_vml_drawing.rb +++ b/test/drawing/tc_vml_drawing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestVmlDrawing < Test::Unit::TestCase diff --git a/test/drawing/tc_vml_shape.rb b/test/drawing/tc_vml_shape.rb index 188114b6..8e415cc1 100644 --- a/test/drawing/tc_vml_shape.rb +++ b/test/drawing/tc_vml_shape.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestVmlShape < Test::Unit::TestCase diff --git a/test/profile.rb b/test/profile.rb index 7b671831..498f2619 100755 --- a/test/profile.rb +++ b/test/profile.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby -s +# frozen_string_literal: true $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" require 'axlsx' diff --git a/test/rels/tc_relationship.rb b/test/rels/tc_relationship.rb index b38c47e1..04dab810 100644 --- a/test/rels/tc_relationship.rb +++ b/test/rels/tc_relationship.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestRelationships < Test::Unit::TestCase diff --git a/test/rels/tc_relationships.rb b/test/rels/tc_relationships.rb index 488880b4..b1ad7995 100644 --- a/test/rels/tc_relationships.rb +++ b/test/rels/tc_relationships.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestRelationships < Test::Unit::TestCase diff --git a/test/stylesheet/tc_border.rb b/test/stylesheet/tc_border.rb index 132dc68a..96bef927 100644 --- a/test/stylesheet/tc_border.rb +++ b/test/stylesheet/tc_border.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBorder < Test::Unit::TestCase diff --git a/test/stylesheet/tc_border_pr.rb b/test/stylesheet/tc_border_pr.rb index c82b282d..a1069f5d 100644 --- a/test/stylesheet/tc_border_pr.rb +++ b/test/stylesheet/tc_border_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBorderPr < Test::Unit::TestCase diff --git a/test/stylesheet/tc_cell_alignment.rb b/test/stylesheet/tc_cell_alignment.rb index 79ed858d..2e95db54 100644 --- a/test/stylesheet/tc_cell_alignment.rb +++ b/test/stylesheet/tc_cell_alignment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestCellAlignment < Test::Unit::TestCase diff --git a/test/stylesheet/tc_cell_protection.rb b/test/stylesheet/tc_cell_protection.rb index e70bb1b8..a6cc9a5b 100644 --- a/test/stylesheet/tc_cell_protection.rb +++ b/test/stylesheet/tc_cell_protection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestCellProtection < Test::Unit::TestCase diff --git a/test/stylesheet/tc_cell_style.rb b/test/stylesheet/tc_cell_style.rb index a2990967..d280ccd1 100644 --- a/test/stylesheet/tc_cell_style.rb +++ b/test/stylesheet/tc_cell_style.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestCellStyle < Test::Unit::TestCase diff --git a/test/stylesheet/tc_color.rb b/test/stylesheet/tc_color.rb index 1c14278a..0b23daff 100644 --- a/test/stylesheet/tc_color.rb +++ b/test/stylesheet/tc_color.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestColor < Test::Unit::TestCase diff --git a/test/stylesheet/tc_dxf.rb b/test/stylesheet/tc_dxf.rb index 014f794e..5e25a133 100644 --- a/test/stylesheet/tc_dxf.rb +++ b/test/stylesheet/tc_dxf.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestDxf < Test::Unit::TestCase diff --git a/test/stylesheet/tc_fill.rb b/test/stylesheet/tc_fill.rb index 89e746da..3990a92b 100644 --- a/test/stylesheet/tc_fill.rb +++ b/test/stylesheet/tc_fill.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestFill < Test::Unit::TestCase diff --git a/test/stylesheet/tc_font.rb b/test/stylesheet/tc_font.rb index d3d5fdff..3cee3e63 100644 --- a/test/stylesheet/tc_font.rb +++ b/test/stylesheet/tc_font.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestFont < Test::Unit::TestCase diff --git a/test/stylesheet/tc_gradient_fill.rb b/test/stylesheet/tc_gradient_fill.rb index fa7ca434..a150a01b 100644 --- a/test/stylesheet/tc_gradient_fill.rb +++ b/test/stylesheet/tc_gradient_fill.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestGradientFill < Test::Unit::TestCase diff --git a/test/stylesheet/tc_gradient_stop.rb b/test/stylesheet/tc_gradient_stop.rb index 34b18e36..23a1d58e 100644 --- a/test/stylesheet/tc_gradient_stop.rb +++ b/test/stylesheet/tc_gradient_stop.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestGradientStop < Test::Unit::TestCase diff --git a/test/stylesheet/tc_num_fmt.rb b/test/stylesheet/tc_num_fmt.rb index 33d91f97..490bf59f 100644 --- a/test/stylesheet/tc_num_fmt.rb +++ b/test/stylesheet/tc_num_fmt.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestNumFmt < Test::Unit::TestCase diff --git a/test/stylesheet/tc_pattern_fill.rb b/test/stylesheet/tc_pattern_fill.rb index b2e77b7a..120f5f33 100644 --- a/test/stylesheet/tc_pattern_fill.rb +++ b/test/stylesheet/tc_pattern_fill.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPatternFill < Test::Unit::TestCase diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb index 31c8cfb1..3b77616f 100644 --- a/test/stylesheet/tc_styles.rb +++ b/test/stylesheet/tc_styles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestStyles < Test::Unit::TestCase diff --git a/test/stylesheet/tc_table_style.rb b/test/stylesheet/tc_table_style.rb index cd07733a..ea3334b7 100644 --- a/test/stylesheet/tc_table_style.rb +++ b/test/stylesheet/tc_table_style.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestTableStyle < Test::Unit::TestCase diff --git a/test/stylesheet/tc_table_style_element.rb b/test/stylesheet/tc_table_style_element.rb index febb8b65..93ad9453 100644 --- a/test/stylesheet/tc_table_style_element.rb +++ b/test/stylesheet/tc_table_style_element.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestTableStyleElement < Test::Unit::TestCase diff --git a/test/stylesheet/tc_table_styles.rb b/test/stylesheet/tc_table_styles.rb index f09f4e2d..a02cb09b 100644 --- a/test/stylesheet/tc_table_styles.rb +++ b/test/stylesheet/tc_table_styles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestTableStyles < Test::Unit::TestCase diff --git a/test/stylesheet/tc_xf.rb b/test/stylesheet/tc_xf.rb index a381c976..b678ce15 100644 --- a/test/stylesheet/tc_xf.rb +++ b/test/stylesheet/tc_xf.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestXf < Test::Unit::TestCase diff --git a/test/support/capture_warnings.rb b/test/support/capture_warnings.rb index c327a145..632f87a3 100644 --- a/test/support/capture_warnings.rb +++ b/test/support/capture_warnings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module CaptureWarnings def capture_warnings # Turn off warnings with setting $VERBOSE to nil diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb index 21c0c82a..95c77d88 100644 --- a/test/tc_axlsx.rb +++ b/test/tc_axlsx.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestAxlsx < Test::Unit::TestCase @@ -92,13 +94,13 @@ class TestAxlsx < Test::Unit::TestCase end def test_sanitize_frozen_control_strippped - needs_sanitize = "legit\x08".freeze # Backspace control char + needs_sanitize = "legit\x08" # Backspace control char assert_equal('legit', Axlsx.sanitize(needs_sanitize), 'should strip control chars') end def test_sanitize_unfrozen_control_strippped - needs_sanitize = "legit\x08" # Backspace control char + needs_sanitize = +"legit\x08" # Backspace control char sanitized_str = Axlsx.sanitize(needs_sanitize) assert_equal('legit', sanitized_str, 'should strip control chars') @@ -106,7 +108,7 @@ class TestAxlsx < Test::Unit::TestCase end def test_sanitize_unfrozen_no_sanitize - legit_str = 'legit' + legit_str = +'legit' sanitized_str = Axlsx.sanitize(legit_str) assert_equal(sanitized_str, legit_str, 'should preserve value') diff --git a/test/tc_helper.rb b/test/tc_helper.rb index cd3b3262..f0e55df7 100644 --- a/test/tc_helper.rb +++ b/test/tc_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" require 'simplecov' SimpleCov.start do diff --git a/test/tc_package.rb b/test/tc_package.rb index d4581792..f4087c4d 100644 --- a/test/tc_package.rb +++ b/test/tc_package.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' require 'support/capture_warnings' diff --git a/test/util/tc_mime_type_utils.rb b/test/util/tc_mime_type_utils.rb index ee7f447a..568aa61d 100644 --- a/test/util/tc_mime_type_utils.rb +++ b/test/util/tc_mime_type_utils.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestMimeTypeUtils < Test::Unit::TestCase diff --git a/test/util/tc_serialized_attributes.rb b/test/util/tc_serialized_attributes.rb index 4ba90b29..02036bab 100644 --- a/test/util/tc_serialized_attributes.rb +++ b/test/util/tc_serialized_attributes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class Funk diff --git a/test/util/tc_simple_typed_list.rb b/test/util/tc_simple_typed_list.rb index e1ac6d99..ac65529d 100644 --- a/test/util/tc_simple_typed_list.rb +++ b/test/util/tc_simple_typed_list.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSimpleTypedList < Test::Unit::TestCase diff --git a/test/util/tc_validators.rb b/test/util/tc_validators.rb index 59e4f559..86e2182c 100644 --- a/test/util/tc_validators.rb +++ b/test/util/tc_validators.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestValidators < Test::Unit::TestCase diff --git a/test/workbook/tc_defined_name.rb b/test/workbook/tc_defined_name.rb index 25db45db..4fbd2e58 100644 --- a/test/workbook/tc_defined_name.rb +++ b/test/workbook/tc_defined_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestDefinedNames < Test::Unit::TestCase diff --git a/test/workbook/tc_shared_strings_table.rb b/test/workbook/tc_shared_strings_table.rb index 2f7de9a7..4aa308f1 100644 --- a/test/workbook/tc_shared_strings_table.rb +++ b/test/workbook/tc_shared_strings_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSharedStringsTable < Test::Unit::TestCase diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb index 0bd84d2d..d85c17d9 100644 --- a/test/workbook/tc_workbook.rb +++ b/test/workbook/tc_workbook.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestWorkbook < Test::Unit::TestCase diff --git a/test/workbook/tc_workbook_view.rb b/test/workbook/tc_workbook_view.rb index 07f21f6a..c8909713 100644 --- a/test/workbook/tc_workbook_view.rb +++ b/test/workbook/tc_workbook_view.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestWorkbookView < Test::Unit::TestCase diff --git a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb index ead6c43a..85ba32b7 100644 --- a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +++ b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestAutoFilter < Test::Unit::TestCase diff --git a/test/workbook/worksheet/auto_filter/tc_filter_column.rb b/test/workbook/worksheet/auto_filter/tc_filter_column.rb index 84cb41ca..d89446c6 100644 --- a/test/workbook/worksheet/auto_filter/tc_filter_column.rb +++ b/test/workbook/worksheet/auto_filter/tc_filter_column.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestFilterColumn < Test::Unit::TestCase diff --git a/test/workbook/worksheet/auto_filter/tc_filters.rb b/test/workbook/worksheet/auto_filter/tc_filters.rb index 35f17a7b..4cd8ca00 100644 --- a/test/workbook/worksheet/auto_filter/tc_filters.rb +++ b/test/workbook/worksheet/auto_filter/tc_filters.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestFilters < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_border_creator.rb b/test/workbook/worksheet/tc_border_creator.rb index 7dff4f0f..46891e8b 100644 --- a/test/workbook/worksheet/tc_border_creator.rb +++ b/test/workbook/worksheet/tc_border_creator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBorderCreator < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_break.rb b/test/workbook/worksheet/tc_break.rb index 638dcd8d..a441abe0 100644 --- a/test/workbook/worksheet/tc_break.rb +++ b/test/workbook/worksheet/tc_break.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestBreak < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index 28a074ae..a534a8dc 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestCell < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_cfvo.rb b/test/workbook/worksheet/tc_cfvo.rb index 6098add1..0e2e5332 100644 --- a/test/workbook/worksheet/tc_cfvo.rb +++ b/test/workbook/worksheet/tc_cfvo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestCfvo < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb index d34b84ec..e795c301 100644 --- a/test/workbook/worksheet/tc_col.rb +++ b/test/workbook/worksheet/tc_col.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestCol < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_color_scale.rb b/test/workbook/worksheet/tc_color_scale.rb index 6cba553b..335e8057 100644 --- a/test/workbook/worksheet/tc_color_scale.rb +++ b/test/workbook/worksheet/tc_color_scale.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestColorScale < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb index d6fd41d1..65b2ca1d 100644 --- a/test/workbook/worksheet/tc_comment.rb +++ b/test/workbook/worksheet/tc_comment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestComment < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb index e96a581c..445f2342 100644 --- a/test/workbook/worksheet/tc_comments.rb +++ b/test/workbook/worksheet/tc_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestComments < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_conditional_formatting.rb b/test/workbook/worksheet/tc_conditional_formatting.rb index 9eee820b..f706dae3 100644 --- a/test/workbook/worksheet/tc_conditional_formatting.rb +++ b/test/workbook/worksheet/tc_conditional_formatting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestConditionalFormatting < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_data_bar.rb b/test/workbook/worksheet/tc_data_bar.rb index 35cf5c11..62c6fc34 100644 --- a/test/workbook/worksheet/tc_data_bar.rb +++ b/test/workbook/worksheet/tc_data_bar.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestDataBar < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb index 90fea502..4be68673 100644 --- a/test/workbook/worksheet/tc_data_validation.rb +++ b/test/workbook/worksheet/tc_data_validation.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' require 'support/capture_warnings' diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb index 669dee06..5cc9d619 100644 --- a/test/workbook/worksheet/tc_date_time_converter.rb +++ b/test/workbook/worksheet/tc_date_time_converter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestDateTimeConverter < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_header_footer.rb b/test/workbook/worksheet/tc_header_footer.rb index 45a90825..8a62b281 100644 --- a/test/workbook/worksheet/tc_header_footer.rb +++ b/test/workbook/worksheet/tc_header_footer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestHeaderFooter < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_icon_set.rb b/test/workbook/worksheet/tc_icon_set.rb index f065c399..beb69919 100644 --- a/test/workbook/worksheet/tc_icon_set.rb +++ b/test/workbook/worksheet/tc_icon_set.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestIconSet < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_outline_pr.rb b/test/workbook/worksheet/tc_outline_pr.rb index cd806d17..95b52530 100644 --- a/test/workbook/worksheet/tc_outline_pr.rb +++ b/test/workbook/worksheet/tc_outline_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestOutlinePr < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_page_margins.rb b/test/workbook/worksheet/tc_page_margins.rb index 820c65be..8c580204 100644 --- a/test/workbook/worksheet/tc_page_margins.rb +++ b/test/workbook/worksheet/tc_page_margins.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPageMargins < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_page_set_up_pr.rb b/test/workbook/worksheet/tc_page_set_up_pr.rb index ab39f038..36a2a6f4 100644 --- a/test/workbook/worksheet/tc_page_set_up_pr.rb +++ b/test/workbook/worksheet/tc_page_set_up_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPageSetUpPr < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_page_setup.rb b/test/workbook/worksheet/tc_page_setup.rb index 494db40b..95703c1c 100644 --- a/test/workbook/worksheet/tc_page_setup.rb +++ b/test/workbook/worksheet/tc_page_setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPageSetup < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_pane.rb b/test/workbook/worksheet/tc_pane.rb index 5afc142e..59d411a0 100644 --- a/test/workbook/worksheet/tc_pane.rb +++ b/test/workbook/worksheet/tc_pane.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPane < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_pivot_table.rb b/test/workbook/worksheet/tc_pivot_table.rb index 4fafa04d..f5b23a96 100644 --- a/test/workbook/worksheet/tc_pivot_table.rb +++ b/test/workbook/worksheet/tc_pivot_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' def shared_test_pivot_table_xml_validity(pivot_table) diff --git a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb index f629940f..108fa297 100644 --- a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +++ b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPivotTableCacheDefinition < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_print_options.rb b/test/workbook/worksheet/tc_print_options.rb index e568d739..10639bcf 100644 --- a/test/workbook/worksheet/tc_print_options.rb +++ b/test/workbook/worksheet/tc_print_options.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestPrintOptions < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_protected_range.rb b/test/workbook/worksheet/tc_protected_range.rb index 1f39ec12..44fe8333 100644 --- a/test/workbook/worksheet/tc_protected_range.rb +++ b/test/workbook/worksheet/tc_protected_range.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestProtectedRange < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_rich_text.rb b/test/workbook/worksheet/tc_rich_text.rb index 77d74ab6..ed3ec9ca 100644 --- a/test/workbook/worksheet/tc_rich_text.rb +++ b/test/workbook/worksheet/tc_rich_text.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class RichText < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_rich_text_run.rb b/test/workbook/worksheet/tc_rich_text_run.rb index ef2a520c..e9011832 100644 --- a/test/workbook/worksheet/tc_rich_text_run.rb +++ b/test/workbook/worksheet/tc_rich_text_run.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class RichTextRun < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb index cd805315..273487ac 100644 --- a/test/workbook/worksheet/tc_row.rb +++ b/test/workbook/worksheet/tc_row.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestRow < Test::Unit::TestCase @@ -131,7 +133,7 @@ class TestRow < Test::Unit::TestCase @row.outlineLevel = 2 @row.collapsed = true @row.hidden = true - r_s_xml = Nokogiri::XML(@row.to_xml_string(0, '')) + r_s_xml = Nokogiri::XML(@row.to_xml_string(0)) assert_equal(1, r_s_xml.xpath(".//row[@r=1]").size) end @@ -139,7 +141,7 @@ class TestRow < Test::Unit::TestCase def test_to_xml_string_with_custom_height @row.add_cell 1 @row.height = 20 - r_s_xml = Nokogiri::XML(@row.to_xml_string(0, '')) + r_s_xml = Nokogiri::XML(@row.to_xml_string(0)) assert_equal(1, r_s_xml.xpath(".//row[@r=1][@ht=20][@customHeight=1]").size) end diff --git a/test/workbook/worksheet/tc_selection.rb b/test/workbook/worksheet/tc_selection.rb index d2edc669..d68500a5 100644 --- a/test/workbook/worksheet/tc_selection.rb +++ b/test/workbook/worksheet/tc_selection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSelection < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_sheet_calc_pr.rb b/test/workbook/worksheet/tc_sheet_calc_pr.rb index 0d810378..cd1f6506 100644 --- a/test/workbook/worksheet/tc_sheet_calc_pr.rb +++ b/test/workbook/worksheet/tc_sheet_calc_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSheetCalcPr < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_sheet_format_pr.rb b/test/workbook/worksheet/tc_sheet_format_pr.rb index 5de2fc53..18d62249 100644 --- a/test/workbook/worksheet/tc_sheet_format_pr.rb +++ b/test/workbook/worksheet/tc_sheet_format_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSheetFormatPr < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_sheet_pr.rb b/test/workbook/worksheet/tc_sheet_pr.rb index 7bff60b7..be87ebf7 100644 --- a/test/workbook/worksheet/tc_sheet_pr.rb +++ b/test/workbook/worksheet/tc_sheet_pr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSheetPr < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_sheet_protection.rb b/test/workbook/worksheet/tc_sheet_protection.rb index 3305b044..4a5e22e8 100644 --- a/test/workbook/worksheet/tc_sheet_protection.rb +++ b/test/workbook/worksheet/tc_sheet_protection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' # <xsd:complexType name="CT_SheetProtection"> diff --git a/test/workbook/worksheet/tc_sheet_view.rb b/test/workbook/worksheet/tc_sheet_view.rb index 1098f42a..b52b6954 100644 --- a/test/workbook/worksheet/tc_sheet_view.rb +++ b/test/workbook/worksheet/tc_sheet_view.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestSheetView < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_table.rb b/test/workbook/worksheet/tc_table.rb index 2a3a56db..38f909b9 100644 --- a/test/workbook/worksheet/tc_table.rb +++ b/test/workbook/worksheet/tc_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestTable < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb index 1da1068d..60a4c113 100644 --- a/test/workbook/worksheet/tc_table_style_info.rb +++ b/test/workbook/worksheet/tc_table_style_info.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestTableStyleInfo < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index fc671a59..3c54e3fc 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestWorksheet < Test::Unit::TestCase diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb index 82f6689b..19bacc0e 100644 --- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb +++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'tc_helper' class TestWorksheetHyperlink < Test::Unit::TestCase |
