summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-04-08 11:53:12 +0200
committerGeremia Taglialatela <[email protected]>2023-04-08 11:53:12 +0200
commit55526805cf28cc91a22df5811b26cd23bdefa8d3 (patch)
tree2cbc6403b385078b0ed5e275c49f0c60522bdd16
parentacf00d356494ef504c3de0e4a0db6b25f2bd7636 (diff)
downloadcaxlsx-55526805cf28cc91a22df5811b26cd23bdefa8d3.tar.gz
caxlsx-55526805cf28cc91a22df5811b26cd23bdefa8d3.zip
Fix space-related offenses
- Layout/SpaceAfterComma - Layout/SpaceAroundEqualsInParameterDefault - Layout/SpaceAroundOperators - Layout/SpaceBeforeBlockBraces - Layout/SpaceInsideBlockBraces - Layout/SpaceInsideHashLiteralBraces - Layout/SpaceInsideParens
-rw-r--r--.rubocop_todo.yml50
-rw-r--r--lib/axlsx.rb10
-rw-r--r--lib/axlsx/content_type/abstract_content_type.rb2
-rw-r--r--lib/axlsx/content_type/default.rb2
-rw-r--r--lib/axlsx/doc_props/app.rb2
-rw-r--r--lib/axlsx/doc_props/core.rb2
-rw-r--r--lib/axlsx/drawing/area_chart.rb4
-rw-r--r--lib/axlsx/drawing/area_series.rb2
-rw-r--r--lib/axlsx/drawing/ax_data_source.rb2
-rw-r--r--lib/axlsx/drawing/axes.rb2
-rw-r--r--lib/axlsx/drawing/axis.rb6
-rw-r--r--lib/axlsx/drawing/bar_3D_chart.rb8
-rw-r--r--lib/axlsx/drawing/bar_chart.rb6
-rw-r--r--lib/axlsx/drawing/bar_series.rb4
-rw-r--r--lib/axlsx/drawing/bubble_chart.rb2
-rw-r--r--lib/axlsx/drawing/bubble_series.rb6
-rw-r--r--lib/axlsx/drawing/cat_axis.rb2
-rw-r--r--lib/axlsx/drawing/chart.rb12
-rw-r--r--lib/axlsx/drawing/d_lbls.rb4
-rw-r--r--lib/axlsx/drawing/drawing.rb8
-rw-r--r--lib/axlsx/drawing/hyperlink.rb4
-rw-r--r--lib/axlsx/drawing/line_3D_chart.rb6
-rw-r--r--lib/axlsx/drawing/line_chart.rb4
-rw-r--r--lib/axlsx/drawing/line_series.rb2
-rw-r--r--lib/axlsx/drawing/marker.rb6
-rw-r--r--lib/axlsx/drawing/num_data.rb6
-rw-r--r--lib/axlsx/drawing/num_data_source.rb4
-rw-r--r--lib/axlsx/drawing/num_val.rb2
-rw-r--r--lib/axlsx/drawing/one_cell_anchor.rb6
-rw-r--r--lib/axlsx/drawing/pic.rb10
-rw-r--r--lib/axlsx/drawing/picture_locking.rb2
-rw-r--r--lib/axlsx/drawing/pie_3D_chart.rb4
-rw-r--r--lib/axlsx/drawing/pie_series.rb2
-rw-r--r--lib/axlsx/drawing/scaling.rb4
-rw-r--r--lib/axlsx/drawing/scatter_chart.rb2
-rw-r--r--lib/axlsx/drawing/scatter_series.rb4
-rw-r--r--lib/axlsx/drawing/ser_axis.rb2
-rw-r--r--lib/axlsx/drawing/series.rb2
-rw-r--r--lib/axlsx/drawing/str_data.rb4
-rw-r--r--lib/axlsx/drawing/str_val.rb2
-rw-r--r--lib/axlsx/drawing/title.rb2
-rw-r--r--lib/axlsx/drawing/two_cell_anchor.rb10
-rw-r--r--lib/axlsx/drawing/val_axis.rb2
-rw-r--r--lib/axlsx/drawing/view_3D.rb4
-rw-r--r--lib/axlsx/drawing/vml_drawing.rb2
-rw-r--r--lib/axlsx/drawing/vml_shape.rb6
-rw-r--r--lib/axlsx/package.rb42
-rw-r--r--lib/axlsx/rels/relationship.rb10
-rw-r--r--lib/axlsx/rels/relationships.rb4
-rw-r--r--lib/axlsx/stylesheet/border.rb2
-rw-r--r--lib/axlsx/stylesheet/border_pr.rb2
-rw-r--r--lib/axlsx/stylesheet/cell_alignment.rb2
-rw-r--r--lib/axlsx/stylesheet/cell_protection.rb2
-rw-r--r--lib/axlsx/stylesheet/cell_style.rb2
-rw-r--r--lib/axlsx/stylesheet/color.rb2
-rw-r--r--lib/axlsx/stylesheet/dxf.rb2
-rw-r--r--lib/axlsx/stylesheet/font.rb6
-rw-r--r--lib/axlsx/stylesheet/gradient_fill.rb4
-rw-r--r--lib/axlsx/stylesheet/gradient_stop.rb4
-rw-r--r--lib/axlsx/stylesheet/num_fmt.rb2
-rw-r--r--lib/axlsx/stylesheet/pattern_fill.rb6
-rw-r--r--lib/axlsx/stylesheet/styles.rb56
-rw-r--r--lib/axlsx/stylesheet/table_style.rb10
-rw-r--r--lib/axlsx/stylesheet/table_style_element.rb2
-rw-r--r--lib/axlsx/stylesheet/table_styles.rb4
-rw-r--r--lib/axlsx/stylesheet/xf.rb2
-rw-r--r--lib/axlsx/util/constants.rb2
-rw-r--r--lib/axlsx/util/options_parser.rb2
-rw-r--r--lib/axlsx/util/serialized_attributes.rb2
-rw-r--r--lib/axlsx/util/simple_typed_list.rb6
-rw-r--r--lib/axlsx/util/storage.rb14
-rw-r--r--lib/axlsx/util/validators.rb2
-rw-r--r--lib/axlsx/workbook/defined_name.rb4
-rw-r--r--lib/axlsx/workbook/shared_strings_table.rb6
-rw-r--r--lib/axlsx/workbook/workbook.rb20
-rw-r--r--lib/axlsx/workbook/workbook_view.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/auto_filter/filters.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/border_creator.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/break.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/cell_serializer.rb20
-rw-r--r--lib/axlsx/workbook/worksheet/cfvo.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/cfvos.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/col.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/col_breaks.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/color_scale.rb16
-rw-r--r--lib/axlsx/workbook/worksheet/comment.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/comments.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/conditional_formatting.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/data_bar.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/data_validation.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/date_time_converter.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/icon_set.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/page_margins.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/page_set_up_pr.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/page_setup.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/pane.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/pivot_table.rb16
-rw-r--r--lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb16
-rw-r--r--lib/axlsx/workbook/worksheet/pivot_tables.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/protected_range.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/rich_text.rb8
-rw-r--r--lib/axlsx/workbook/worksheet/rich_text_run.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/row.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/row_breaks.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/selection.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/sheet_calc_pr.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/sheet_format_pr.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/sheet_pr.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/sheet_protection.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/sheet_view.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/table.rb12
-rw-r--r--lib/axlsx/workbook/worksheet/tables.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet.rb42
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet_comments.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb2
-rw-r--r--test/benchmark.rb2
-rw-r--r--test/content_type/tc_content_type.rb4
-rw-r--r--test/content_type/tc_default.rb4
-rw-r--r--test/content_type/tc_override.rb4
-rw-r--r--test/doc_props/tc_app.rb2
-rw-r--r--test/doc_props/tc_core.rb2
-rw-r--r--test/drawing/tc_area_series.rb4
-rw-r--r--test/drawing/tc_axis.rb10
-rw-r--r--test/drawing/tc_bar_series.rb6
-rw-r--r--test/drawing/tc_bubble_series.rb6
-rw-r--r--test/drawing/tc_chart.rb8
-rw-r--r--test/drawing/tc_d_lbls.rb16
-rw-r--r--test/drawing/tc_drawing.rb18
-rw-r--r--test/drawing/tc_hyperlink.rb12
-rw-r--r--test/drawing/tc_line_series.rb4
-rw-r--r--test/drawing/tc_marker.rb16
-rw-r--r--test/drawing/tc_num_data.rb4
-rw-r--r--test/drawing/tc_num_val.rb4
-rw-r--r--test/drawing/tc_one_cell_anchor.rb6
-rw-r--r--test/drawing/tc_pic.rb8
-rw-r--r--test/drawing/tc_picture_locking.rb18
-rw-r--r--test/drawing/tc_pie_3D_chart.rb2
-rw-r--r--test/drawing/tc_pie_series.rb4
-rw-r--r--test/drawing/tc_scaling.rb16
-rw-r--r--test/drawing/tc_scatter_series.rb22
-rw-r--r--test/drawing/tc_series.rb4
-rw-r--r--test/drawing/tc_two_cell_anchor.rb4
-rw-r--r--test/drawing/tc_view_3D.rb24
-rw-r--r--test/drawing/tc_vml_drawing.rb2
-rw-r--r--test/profile.rb2
-rw-r--r--test/rels/tc_relationship.rb2
-rw-r--r--test/stylesheet/tc_border.rb8
-rw-r--r--test/stylesheet/tc_border_pr.rb2
-rw-r--r--test/stylesheet/tc_cell_alignment.rb22
-rw-r--r--test/stylesheet/tc_cell_protection.rb4
-rw-r--r--test/stylesheet/tc_cell_style.rb12
-rw-r--r--test/stylesheet/tc_color.rb6
-rw-r--r--test/stylesheet/tc_dxf.rb6
-rw-r--r--test/stylesheet/tc_font.rb2
-rw-r--r--test/stylesheet/tc_gradient_fill.rb2
-rw-r--r--test/stylesheet/tc_gradient_stop.rb4
-rw-r--r--test/stylesheet/tc_pattern_fill.rb2
-rw-r--r--test/stylesheet/tc_styles.rb82
-rw-r--r--test/tc_axlsx.rb20
-rw-r--r--test/tc_package.rb68
-rw-r--r--test/util/tc_simple_typed_list.rb22
-rw-r--r--test/util/tc_validators.rb6
-rw-r--r--test/workbook/tc_shared_strings_table.rb6
-rw-r--r--test/workbook/tc_workbook.rb28
-rw-r--r--test/workbook/tc_workbook_view.rb4
-rw-r--r--test/workbook/worksheet/auto_filter/tc_auto_filter.rb2
-rw-r--r--test/workbook/worksheet/auto_filter/tc_filters.rb2
-rw-r--r--test/workbook/worksheet/tc_border_creator.rb6
-rw-r--r--test/workbook/worksheet/tc_break.rb2
-rw-r--r--test/workbook/worksheet/tc_cell.rb28
-rw-r--r--test/workbook/worksheet/tc_col.rb4
-rw-r--r--test/workbook/worksheet/tc_color_scale.rb14
-rw-r--r--test/workbook/worksheet/tc_comment.rb2
-rw-r--r--test/workbook/worksheet/tc_comments.rb4
-rw-r--r--test/workbook/worksheet/tc_conditional_formatting.rb24
-rw-r--r--test/workbook/worksheet/tc_data_bar.rb8
-rw-r--r--test/workbook/worksheet/tc_data_validation.rb20
-rw-r--r--test/workbook/worksheet/tc_date_time_converter.rb4
-rw-r--r--test/workbook/worksheet/tc_icon_set.rb8
-rw-r--r--test/workbook/worksheet/tc_page_margins.rb2
-rw-r--r--test/workbook/worksheet/tc_page_setup.rb4
-rw-r--r--test/workbook/worksheet/tc_pivot_table.rb54
-rw-r--r--test/workbook/worksheet/tc_pivot_table_cache_definition.rb2
-rw-r--r--test/workbook/worksheet/tc_protected_range.rb4
-rw-r--r--test/workbook/worksheet/tc_rich_text.rb6
-rw-r--r--test/workbook/worksheet/tc_rich_text_run.rb4
-rw-r--r--test/workbook/worksheet/tc_row.rb24
-rw-r--r--test/workbook/worksheet/tc_sheet_format_pr.rb12
-rw-r--r--test/workbook/worksheet/tc_sheet_pr.rb2
-rw-r--r--test/workbook/worksheet/tc_sheet_protection.rb2
-rw-r--r--test/workbook/worksheet/tc_table.rb2
-rw-r--r--test/workbook/worksheet/tc_table_style_info.rb2
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb100
198 files changed, 785 insertions, 835 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 86b99a38..08ae966d 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -100,56 +100,6 @@ Layout/IndentationWidth:
Layout/LeadingCommentSpace:
Enabled: false
-# Offense count: 264
-# This cop supports safe autocorrection (--autocorrect).
-Layout/SpaceAfterComma:
- Enabled: false
-
-# Offense count: 184
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: space, no_space
-Layout/SpaceAroundEqualsInParameterDefault:
- Enabled: false
-
-# Offense count: 342
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
-# SupportedStylesForExponentOperator: space, no_space
-Layout/SpaceAroundOperators:
- Enabled: false
-
-# Offense count: 55
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
-# SupportedStyles: space, no_space
-# SupportedStylesForEmptyBraces: space, no_space
-Layout/SpaceBeforeBlockBraces:
- Enabled: false
-
-# Offense count: 139
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
-# SupportedStyles: space, no_space
-# SupportedStylesForEmptyBraces: space, no_space
-Layout/SpaceInsideBlockBraces:
- Enabled: false
-
-# Offense count: 227
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
-# SupportedStyles: space, no_space, compact
-# SupportedStylesForEmptyBraces: space, no_space
-Layout/SpaceInsideHashLiteralBraces:
- Enabled: false
-
-# Offense count: 82
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: space, compact, no_space
-Layout/SpaceInsideParens:
- Enabled: false
-
# Offense count: 1
Lint/AmbiguousAssignment:
Exclude:
diff --git a/lib/axlsx.rb b/lib/axlsx.rb
index 931feb2d..df847a18 100644
--- a/lib/axlsx.rb
+++ b/lib/axlsx.rb
@@ -54,7 +54,7 @@ module Axlsx
end
# determines the cell range for the items provided
- def self.cell_range(cells, absolute=true)
+ def self.cell_range(cells, absolute = true)
return "" unless cells.first.is_a? Cell
first_cell, last_cell = cells.minmax_by(&:pos)
@@ -88,7 +88,7 @@ module Axlsx
letters_str = name[/[A-Z]+/]
# capitalization?!?
- v = letters_str.reverse.chars.reduce({:base=>1, :i=>0}) do |val, c|
+ v = letters_str.reverse.chars.reduce({ :base => 1, :i => 0 }) do |val, c|
val[:i] += ((c.bytes.first - 64) * val[:base])
val[:base] *= 26
@@ -123,7 +123,7 @@ module Axlsx
# @example Relative Cell Reference
# ws.rows.first.cells.first.r #=> "A1"
def self.cell_r(c_index, r_index)
- col_ref(c_index) << (r_index+1).to_s
+ col_ref(c_index) << (r_index + 1).to_s
end
# Creates an array of individual cell references based on an excel reference range.
@@ -143,10 +143,10 @@ module Axlsx
# performs the increadible feat of changing snake_case to CamelCase
# @param [String] s The snake case string to camelize
# @return [String]
- def self.camel(s="", all_caps = true)
+ def self.camel(s = "", all_caps = true)
s = s.to_s
s = s.capitalize if all_caps
- s.gsub(/_(.)/){ $1.upcase }
+ s.gsub(/_(.)/) { $1.upcase }
end
# returns the provided string with all invalid control charaters
diff --git a/lib/axlsx/content_type/abstract_content_type.rb b/lib/axlsx/content_type/abstract_content_type.rb
index 73d8a678..023c9086 100644
--- a/lib/axlsx/content_type/abstract_content_type.rb
+++ b/lib/axlsx/content_type/abstract_content_type.rb
@@ -5,7 +5,7 @@ module Axlsx
# Initializes an abstract content type
# @see Default, Override
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
diff --git a/lib/axlsx/content_type/default.rb b/lib/axlsx/content_type/default.rb
index 691b7e87..d5901456 100644
--- a/lib/axlsx/content_type/default.rb
+++ b/lib/axlsx/content_type/default.rb
@@ -14,7 +14,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/doc_props/app.rb b/lib/axlsx/doc_props/app.rb
index ed46cf56..965b34dc 100644
--- a/lib/axlsx/doc_props/app.rb
+++ b/lib/axlsx/doc_props/app.rb
@@ -33,7 +33,7 @@ module Axlsx
# @option options [String] application
# @option options [String] app_version
# @option options [Integer] doc_security
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
diff --git a/lib/axlsx/doc_props/core.rb b/lib/axlsx/doc_props/core.rb
index 279b7493..0f3b6333 100644
--- a/lib/axlsx/doc_props/core.rb
+++ b/lib/axlsx/doc_props/core.rb
@@ -6,7 +6,7 @@ module Axlsx
# Creates a new Core object.
# @option options [String] creator
# @option options [Time] created
- def initialize(options={})
+ def initialize(options = {})
@creator = options[:creator] || 'axlsx'
@created = options[:created]
end
diff --git a/lib/axlsx/drawing/area_chart.rb b/lib/axlsx/drawing/area_chart.rb
index 7e831447..0c5193c6 100644
--- a/lib/axlsx/drawing/area_chart.rb
+++ b/lib/axlsx/drawing/area_chart.rb
@@ -42,7 +42,7 @@ module Axlsx
# @option options [Boolean] show_legend
# @option options [Symbol] grouping
# @see Chart
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@vary_colors = false
@grouping = :standard
super(frame, options)
@@ -63,7 +63,7 @@ module Axlsx
def node_name
path = self.class.to_s
if i = path.rindex('::')
- path = path[(i+2)..-1]
+ path = path[(i + 2)..-1]
end
path[0] = path[0].chr.downcase
path
diff --git a/lib/axlsx/drawing/area_series.rb b/lib/axlsx/drawing/area_series.rb
index fd3dd501..7995c5bc 100644
--- a/lib/axlsx/drawing/area_series.rb
+++ b/lib/axlsx/drawing/area_series.rb
@@ -33,7 +33,7 @@ module Axlsx
# @option options [Array, SimpleTypedList] data
# @option options [Array, SimpleTypedList] labels
# @param [Chart] chart
- def initialize(chart, options={})
+ def initialize(chart, options = {})
@show_marker = false
@marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
@smooth = false
diff --git a/lib/axlsx/drawing/ax_data_source.rb b/lib/axlsx/drawing/ax_data_source.rb
index 10eb6c5e..b8aafc5e 100644
--- a/lib/axlsx/drawing/ax_data_source.rb
+++ b/lib/axlsx/drawing/ax_data_source.rb
@@ -5,7 +5,7 @@ module Axlsx
# creates a new NumDataSource object
# @option options [Array] data An array of Cells or Numeric objects
# @option options [Symbol] tag_name see tag_name
- def initialize(options={})
+ def initialize(options = {})
@tag_name = :cat
@data_type = StrData
@ref_tag_name = :strRef
diff --git a/lib/axlsx/drawing/axes.rb b/lib/axlsx/drawing/axes.rb
index 146d566e..0e4403ab 100644
--- a/lib/axlsx/drawing/axes.rb
+++ b/lib/axlsx/drawing/axes.rb
@@ -6,7 +6,7 @@ module Axlsx
# should be an axis name like :val_axis and its value should be the
# class of the axis type to construct. The :cat_axis, if there is one,
# must come first (we assume a Ruby 1.9+ Hash or an OrderedHash).
- def initialize(options={})
+ def initialize(options = {})
raise(ArgumentError, "CatAxis must come first") if options.keys.include?(:cat_axis) && options.keys.first != :cat_axis
options.each do |name, axis_class|
add_axis(name, axis_class)
diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb
index 6f65f147..89915b68 100644
--- a/lib/axlsx/drawing/axis.rb
+++ b/lib/axlsx/drawing/axis.rb
@@ -9,11 +9,11 @@ module Axlsx
# @option options [Symbol] crosses
# @option options [Symbol] tick_lbl_pos
# @raise [ArgumentError] If axi_id or cross_ax are not unsigned integers
- def initialize(options={})
- @id = rand(8 ** 8)
+ def initialize(options = {})
+ @id = rand(8**8)
@format_code = "General"
@delete = @label_rotation = 0
- @scaling = Scaling.new(:orientation=>:minMax)
+ @scaling = Scaling.new(:orientation => :minMax)
@title = @color = nil
self.ax_pos = :b
self.tick_lbl_pos = :nextTo
diff --git a/lib/axlsx/drawing/bar_3D_chart.rb b/lib/axlsx/drawing/bar_3D_chart.rb
index 1bb47da7..f8dca9ad 100644
--- a/lib/axlsx/drawing/bar_3D_chart.rb
+++ b/lib/axlsx/drawing/bar_3D_chart.rb
@@ -70,12 +70,12 @@ module Axlsx
# @option options [Integer] perspective
# @see Chart
# @see View3D
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@vary_colors = true
@gap_width, @gap_depth, @shape = nil, nil, nil
super(frame, options)
@series_type = BarSeries
- @view_3D = View3D.new({:r_ang_ax=>1}.merge(options))
+ @view_3D = View3D.new({ :r_ang_ax => 1 }.merge(options))
@d_lbls = nil
end
@@ -97,14 +97,14 @@ module Axlsx
# space between bar or column clusters, as a percentage of the bar or column width.
def gap_width=(v)
RangeValidator.validate "Bar3DChart.gap_width", 0, 500, v
- @gap_width=(v)
+ @gap_width = (v)
end
alias :gapWidth= :gap_width=
# space between bar or column clusters, as a percentage of the bar or column width.
def gap_depth=(v)
RangeValidator.validate "Bar3DChart.gap_depth", 0, 500, v
- @gap_depth=(v)
+ @gap_depth = (v)
end
alias :gapDepth= :gap_depth=
diff --git a/lib/axlsx/drawing/bar_chart.rb b/lib/axlsx/drawing/bar_chart.rb
index 84b9faa1..51046533 100644
--- a/lib/axlsx/drawing/bar_chart.rb
+++ b/lib/axlsx/drawing/bar_chart.rb
@@ -63,7 +63,7 @@ module Axlsx
# @option options [String] gap_width
# @option options [Symbol] shape
# @see Chart
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@vary_colors = true
@gap_width, @overlap, @shape = nil, nil, nil
super(frame, options)
@@ -89,13 +89,13 @@ module Axlsx
# space between bar or column clusters, as a percentage of the bar or column width.
def gap_width=(v)
RangeValidator.validate "BarChart.gap_width", 0, 500, v
- @gap_width=(v)
+ @gap_width = (v)
end
alias :gapWidth= :gap_width=
def overlap=(v)
RangeValidator.validate "BarChart.overlap", -100, 100, v
- @overlap=(v)
+ @overlap = (v)
end
# The shape of the bars or columns
diff --git a/lib/axlsx/drawing/bar_series.rb b/lib/axlsx/drawing/bar_series.rb
index fcf7d98f..0b4d9614 100644
--- a/lib/axlsx/drawing/bar_series.rb
+++ b/lib/axlsx/drawing/bar_series.rb
@@ -32,11 +32,11 @@ module Axlsx
# @option options [String] colors an array of colors to use when rendering each data point
# @option options [String] series_color a color to use when rendering series
# @param [Chart] chart
- def initialize(chart, options={})
+ def initialize(chart, options = {})
@shape = :box
@colors = []
super(chart, options)
- self.labels = AxDataSource.new({:data => options[:labels]}) unless options[:labels].nil?
+ self.labels = AxDataSource.new({ :data => options[:labels] }) unless options[:labels].nil?
self.data = NumDataSource.new(options) unless options[:data].nil?
end
diff --git a/lib/axlsx/drawing/bubble_chart.rb b/lib/axlsx/drawing/bubble_chart.rb
index 9d0f3ff1..edd1a9b5 100644
--- a/lib/axlsx/drawing/bubble_chart.rb
+++ b/lib/axlsx/drawing/bubble_chart.rb
@@ -21,7 +21,7 @@ module Axlsx
alias :yValAxis :y_val_axis
# Creates a new bubble chart
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@vary_colors = 0
super(frame, options)
diff --git a/lib/axlsx/drawing/bubble_series.rb b/lib/axlsx/drawing/bubble_series.rb
index 7d6e7bf6..78b44bf1 100644
--- a/lib/axlsx/drawing/bubble_series.rb
+++ b/lib/axlsx/drawing/bubble_series.rb
@@ -23,12 +23,12 @@ module Axlsx
attr_reader :color
# Creates a new BubbleSeries
- def initialize(chart, options={})
+ def initialize(chart, options = {})
@xData, @yData, @bubbleSize = nil
super(chart, options)
@xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil?
- @yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil?
- @bubbleSize = NumDataSource.new({:tag_name => :bubbleSize, :data => options[:bubbleSize]}) unless options[:bubbleSize].nil?
+ @yData = NumDataSource.new({ :tag_name => :yVal, :data => options[:yData] }) unless options[:yData].nil?
+ @bubbleSize = NumDataSource.new({ :tag_name => :bubbleSize, :data => options[:bubbleSize] }) unless options[:bubbleSize].nil?
end
# @see color
diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb
index 925d6ad6..ded05ee8 100644
--- a/lib/axlsx/drawing/cat_axis.rb
+++ b/lib/axlsx/drawing/cat_axis.rb
@@ -4,7 +4,7 @@ module Axlsx
# Creates a new CatAxis object
# @option options [Integer] tick_lbl_skip
# @option options [Integer] tick_mark_skip
- def initialize(options={})
+ def initialize(options = {})
@tick_lbl_skip = 1
@tick_mark_skip = 1
self.auto = 1
diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb
index 49c72b58..e64163d9 100644
--- a/lib/axlsx/drawing/chart.rb
+++ b/lib/axlsx/drawing/chart.rb
@@ -13,10 +13,10 @@ module Axlsx
# @option options [Array|String|Cell] end_at The X, Y coordinates defining the bottom right corner of the chart.
# @option options [Boolean] plot_visible_only (true) Whether only data from visible cells should be plotted.
# @option options [Boolean] rounded_corners (true) Whether the chart area shall have rounded corners.
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@style = 18
@view_3D = nil
- @graphic_frame=frame
+ @graphic_frame = frame
@graphic_frame.anchor.drawing.worksheet.workbook.charts << self
@series = SimpleTypedList.new Series
@show_legend = true
@@ -122,7 +122,7 @@ module Axlsx
# The part name for this chart
# @return [String]
def pn
- "#{CHART_PN % (index+1)}"
+ "#{CHART_PN % (index + 1)}"
end
# The title object for the chart.
@@ -178,7 +178,7 @@ module Axlsx
# Adds a new series to the chart's series collection.
# @return [Series]
# @see Series
- def add_series(options={})
+ def add_series(options = {})
@series_type.new(self, options)
@series.last
end
@@ -272,7 +272,7 @@ module Axlsx
# reference or cell to use in setting the start marker position.
# @param [Integer] y The row
# @return [Marker]
- def start_at(x=0, y=0)
+ def start_at(x = 0, y = 0)
@graphic_frame.anchor.start_at(x, y)
end
@@ -283,7 +283,7 @@ module Axlsx
# @param [Integer] y The row - default 10
# @return [Marker]
# @see start_at
- def end_at(x=10, y=10)
+ def end_at(x = 10, y = 10)
@graphic_frame.anchor.end_at(x, y)
end
diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb
index fe204ddc..d997d9a9 100644
--- a/lib/axlsx/drawing/d_lbls.rb
+++ b/lib/axlsx/drawing/d_lbls.rb
@@ -8,7 +8,7 @@ module Axlsx
include Axlsx::Accessors
include Axlsx::OptionsParser
# creates a new DLbls object
- def initialize(chart_type, options={})
+ def initialize(chart_type, options = {})
raise ArgumentError, 'chart_type must inherit from Chart' unless [Chart, LineChart].include?(chart_type.superclass)
@chart_type = chart_type
initialize_defaults
@@ -72,7 +72,7 @@ module Axlsx
instance_vals = Axlsx.instance_values_for(self)
%w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
next unless instance_vals.keys.include?(key) && instance_vals[key] != nil
- str << "<c:#{Axlsx::camel(key, false)} val='#{instance_vals[key]}' />"
+ str << "<c:#{Axlsx::camel(key, false)} val='#{instance_vals[key]}' />"
end
str << '</c:dLbls>'
end
diff --git a/lib/axlsx/drawing/drawing.rb b/lib/axlsx/drawing/drawing.rb
index 0de5dc15..bc6dd1cf 100644
--- a/lib/axlsx/drawing/drawing.rb
+++ b/lib/axlsx/drawing/drawing.rb
@@ -79,7 +79,7 @@ module Axlsx
# @note The recommended way to manage images is to use Worksheet.add_image. Please refer to that method for documentation.
# @see Worksheet#add_image
# @return [Pic]
- def add_image(options={})
+ def add_image(options = {})
if options[:end_at]
TwoCellAnchor.new(self, options).add_pic(options)
else
@@ -91,7 +91,7 @@ module Axlsx
# Adds a chart to the drawing.
# @note The recommended way to manage charts is to use Worksheet.add_chart. Please refer to that method for documentation.
# @see Worksheet#add_chart
- def add_chart(chart_type, options={})
+ def add_chart(chart_type, options = {})
TwoCellAnchor.new(self, options)
@anchors.last.add_chart(chart_type, options)
end
@@ -126,14 +126,14 @@ module Axlsx
# The part name for this drawing
# @return [String]
def pn
- "#{DRAWING_PN % (index+1)}"
+ "#{DRAWING_PN % (index + 1)}"
end
# The relational part name for this drawing
# #NOTE This should be rewritten to return an Axlsx::Relationship object.
# @return [String]
def rels_pn
- "#{DRAWING_RELS_PN % (index+1)}"
+ "#{DRAWING_RELS_PN % (index + 1)}"
end
# A list of objects this drawing holds.
diff --git a/lib/axlsx/drawing/hyperlink.rb b/lib/axlsx/drawing/hyperlink.rb
index 9ff9ee4a..979fdd6a 100644
--- a/lib/axlsx/drawing/hyperlink.rb
+++ b/lib/axlsx/drawing/hyperlink.rb
@@ -17,7 +17,7 @@ module Axlsx
# @option options [Boolean] endSnd terminate any sound events when processing this link
# @option options [Boolean] history include this link in the list of visited links for the applications history.
# @option options [Boolean] highlightClick indicate that the link has already been visited.
- def initialize(parent, options={})
+ def initialize(parent, options = {})
DataTypeValidator.validate "Hyperlink.parent", [Pic], parent
@parent = parent
parse_options options
@@ -91,7 +91,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- serialized_tag 'a:hlinkClick', str, {:'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R }
+ serialized_tag 'a:hlinkClick', str, { :'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R }
end
end
end
diff --git a/lib/axlsx/drawing/line_3D_chart.rb b/lib/axlsx/drawing/line_3D_chart.rb
index da62851f..d45a417f 100644
--- a/lib/axlsx/drawing/line_3D_chart.rb
+++ b/lib/axlsx/drawing/line_3D_chart.rb
@@ -38,9 +38,9 @@ module Axlsx
# @see Chart
# @see lineChart
# @see View3D
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@gap_depth = nil
- @view_3D = View3D.new({:r_ang_ax=>1}.merge(options))
+ @view_3D = View3D.new({ :r_ang_ax => 1 }.merge(options))
super(frame, options)
axes.add_axis :ser_axis, SerAxis
end
@@ -48,7 +48,7 @@ module Axlsx
# @see gapDepth
def gap_depth=(v)
RegexValidator.validate "Line3DChart.gapWidth", GAP_AMOUNT_PERCENT, v
- @gap_depth=(v)
+ @gap_depth = (v)
end
alias :gapDepth= :gap_depth=
diff --git a/lib/axlsx/drawing/line_chart.rb b/lib/axlsx/drawing/line_chart.rb
index a1734dea..1ff2bde5 100644
--- a/lib/axlsx/drawing/line_chart.rb
+++ b/lib/axlsx/drawing/line_chart.rb
@@ -42,7 +42,7 @@ module Axlsx
# @option options [Boolean] show_legend
# @option options [Symbol] grouping
# @see Chart
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@vary_colors = false
@grouping = :standard
super(frame, options)
@@ -63,7 +63,7 @@ module Axlsx
def node_name
path = self.class.to_s
if i = path.rindex('::')
- path = path[(i+2)..-1]
+ path = path[(i + 2)..-1]
end
path[0] = path[0].chr.downcase
path
diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb
index 2ef18484..18719277 100644
--- a/lib/axlsx/drawing/line_series.rb
+++ b/lib/axlsx/drawing/line_series.rb
@@ -33,7 +33,7 @@ module Axlsx
# @option options [Array, SimpleTypedList] data
# @option options [Array, SimpleTypedList] labels
# @param [Chart] chart
- def initialize(chart, options={})
+ def initialize(chart, options = {})
@show_marker = false
@marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
@smooth = false
diff --git a/lib/axlsx/drawing/marker.rb b/lib/axlsx/drawing/marker.rb
index 53a52dd1..a4933c33 100644
--- a/lib/axlsx/drawing/marker.rb
+++ b/lib/axlsx/drawing/marker.rb
@@ -10,7 +10,7 @@ module Axlsx
# @option options [Integer] colOff
# @option options [Integer] row
# @option options [Integer] rowOff
- def initialize(options={})
+ def initialize(options = {})
@col, @colOff, @row, @rowOff = 0, 0, 0, 0
parse_options options
end
@@ -45,7 +45,7 @@ module Axlsx
# or an Array.
# @param row the row of the marker. This is ignored if the col parameter is a Cell or
# String or Array.
- def coord(col, row=0)
+ def coord(col, row = 0)
coordinates = parse_coord_args(col, row)
self.col = coordinates[0]
self.row = coordinates[1]
@@ -64,7 +64,7 @@ module Axlsx
# handles multiple inputs for setting the position of a marker
# @see Chart#start_at
- def parse_coord_args(x, y=0)
+ def parse_coord_args(x, y = 0)
if x.is_a?(String)
x, y = *Axlsx::name_to_indices(x)
end
diff --git a/lib/axlsx/drawing/num_data.rb b/lib/axlsx/drawing/num_data.rb
index 9374dac3..140cfb9f 100644
--- a/lib/axlsx/drawing/num_data.rb
+++ b/lib/axlsx/drawing/num_data.rb
@@ -7,7 +7,7 @@ module Axlsx
# @option options [String] formatCode
# @option options [Array] :data
# @see StrData
- def initialize(options={})
+ def initialize(options = {})
@format_code = "General"
@pt = SimpleTypedList.new NumVal
parse_options options
@@ -19,7 +19,7 @@ module Axlsx
# Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types.
# @param [Array] values An array of cells or values.
- def data=(values=[])
+ def data=(values = [])
@tag_name = values.first.is_a?(Cell) ? :numCache : :numLit
values.each do |value|
value = value.is_formula? ? 0 : value.value if value.is_a?(Cell)
@@ -28,7 +28,7 @@ module Axlsx
end
# @see format_code
- def format_code=(v='General')
+ def format_code=(v = 'General')
Axlsx::validate_string(v)
@format_code = v
end
diff --git a/lib/axlsx/drawing/num_data_source.rb b/lib/axlsx/drawing/num_data_source.rb
index bf5ad9ad..46f6ba71 100644
--- a/lib/axlsx/drawing/num_data_source.rb
+++ b/lib/axlsx/drawing/num_data_source.rb
@@ -6,7 +6,7 @@ module Axlsx
# creates a new NumDataSource object
# @option options [Array] data An array of Cells or Numeric objects
# @option options [Symbol] tag_name see tag_name
- def initialize(options={})
+ def initialize(options = {})
# override these three in child classes
@data_type ||= NumData
@tag_name ||= :val
@@ -42,7 +42,7 @@ module Axlsx
# serialize the object
# @param [String] str
- def to_xml_string(str="")
+ def to_xml_string(str = "")
str << ('<c:' << tag_name.to_s << '>')
if @f
str << ('<c:' << @ref_tag_name.to_s << '>')
diff --git a/lib/axlsx/drawing/num_val.rb b/lib/axlsx/drawing/num_val.rb
index 113fe865..c03a0fa1 100644
--- a/lib/axlsx/drawing/num_val.rb
+++ b/lib/axlsx/drawing/num_val.rb
@@ -9,7 +9,7 @@ module Axlsx
# creates a new NumVal object
# @option options [String] formatCode
# @option options [Integer] v
- def initialize(options={})
+ def initialize(options = {})
@format_code = "General"
super(options)
end
diff --git a/lib/axlsx/drawing/one_cell_anchor.rb b/lib/axlsx/drawing/one_cell_anchor.rb
index c17f4a25..52cf2244 100644
--- a/lib/axlsx/drawing/one_cell_anchor.rb
+++ b/lib/axlsx/drawing/one_cell_anchor.rb
@@ -14,7 +14,7 @@ module Axlsx
# @option options [String] image_src the file location of the image you will render
# @option options [String] name the name attribute for the rendered image
# @option options [String] descr the description of the image rendered
- def initialize(drawing, options={})
+ def initialize(drawing, options = {})
@drawing = drawing
@width = 0
@height = 0
@@ -52,7 +52,7 @@ module Axlsx
# We just 'figure it out' for you.
# @param [Array, String, Cell, Integer] x Accepts many inputs for defining the starting position of the cell.
# @param [Integer] y When x is an integer, this value is used for the row index at which the anchor starts.
- def start_at(x, y=0)
+ def start_at(x, y = 0)
from.coord x, y
end
@@ -91,7 +91,7 @@ module Axlsx
def ext
cy = @height * 914400 / 96
cx = @width * 914400 / 96
- {:cy=>cy, :cx=>cx}
+ { :cy => cy, :cx => cx }
end
end
end
diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb
index 869dde4a..7d9cb532 100644
--- a/lib/axlsx/drawing/pic.rb
+++ b/lib/axlsx/drawing/pic.rb
@@ -14,7 +14,7 @@ module Axlsx
# @option options [Integer] :width
# @option options [Integer] :height
# @option options [Float] :opacity - set the picture opacity, accepts a value between 0.0 and 1.0
- def initialize(anchor, options={})
+ def initialize(anchor, options = {})
@anchor = anchor
@hyperlink = nil
@anchor.drawing.worksheet.workbook.images << self
@@ -57,7 +57,7 @@ module Axlsx
# sets or updates a hyperlink for this image.
# @param [String] v The href value for the hyper link
# @option options @see Hyperlink#initialize All options available to the Hyperlink class apply - however href will be overridden with the v parameter value.
- def hyperlink=(v, options={})
+ def hyperlink=(v, options = {})
options[:href] = v
if hyperlink.is_a?(Hyperlink)
options.each do |o|
@@ -103,7 +103,7 @@ module Axlsx
# The part name for this image used in serialization and relationship building
# @return [String]
def pn
- "#{IMAGE_PN % [(index+1), extname]}"
+ "#{IMAGE_PN % [(index + 1), extname]}"
end
# The relationship object for this pic.
@@ -145,7 +145,7 @@ module Axlsx
# @param [Integer] x The column
# @param [Integer] y The row
# @return [Marker]
- def start_at(x, y=nil)
+ def start_at(x, y = nil)
@anchor.start_at x, y
@anchor.from
end
@@ -154,7 +154,7 @@ module Axlsx
# @param [Integer] x The column
# @param [Integer] y The row
# @return [Marker]
- def end_at(x, y=nil)
+ def end_at(x, y = nil)
use_two_cell_anchor unless @anchor.is_a?(TwoCellAnchor)
@anchor.end_at x, y
@anchor.to
diff --git a/lib/axlsx/drawing/picture_locking.rb b/lib/axlsx/drawing/picture_locking.rb
index e230ec89..2e68a957 100644
--- a/lib/axlsx/drawing/picture_locking.rb
+++ b/lib/axlsx/drawing/picture_locking.rb
@@ -24,7 +24,7 @@ module Axlsx
# @option options [Boolean] noAdjustHandles
# @option options [Boolean] noChangeArrowheads
# @option options [Boolean] noChangeShapeType
- def initialize(options={})
+ def initialize(options = {})
@noChangeAspect = true
parse_options options
end
diff --git a/lib/axlsx/drawing/pie_3D_chart.rb b/lib/axlsx/drawing/pie_3D_chart.rb
index 5c2b57ac..1772c537 100644
--- a/lib/axlsx/drawing/pie_3D_chart.rb
+++ b/lib/axlsx/drawing/pie_3D_chart.rb
@@ -18,11 +18,11 @@ module Axlsx
# @option options [Integer] perspective
# @see Chart
# @see View3D
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@vary_colors = true
super(frame, options)
@series_type = PieSeries
- @view_3D = View3D.new({:rot_x =>30, :perspective=>30}.merge(options))
+ @view_3D = View3D.new({ :rot_x => 30, :perspective => 30 }.merge(options))
@d_lbls = nil
end
diff --git a/lib/axlsx/drawing/pie_series.rb b/lib/axlsx/drawing/pie_series.rb
index 4c1b37fb..29b71e36 100644
--- a/lib/axlsx/drawing/pie_series.rb
+++ b/lib/axlsx/drawing/pie_series.rb
@@ -25,7 +25,7 @@ module Axlsx
# @option options [String] title
# @option options [Integer] explosion
# @param [Chart] chart
- def initialize(chart, options={})
+ def initialize(chart, options = {})
@explosion = nil
@colors = []
super(chart, options)
diff --git a/lib/axlsx/drawing/scaling.rb b/lib/axlsx/drawing/scaling.rb
index 82811c11..8d2d8ed7 100644
--- a/lib/axlsx/drawing/scaling.rb
+++ b/lib/axlsx/drawing/scaling.rb
@@ -8,7 +8,7 @@ module Axlsx
# @option options [Symbol] orientation
# @option options [Float] max
# @option options [Float] min
- def initialize(options={})
+ def initialize(options = {})
@orientation = :minMax
@logBase, @min, @max = nil, nil, nil
parse_options options
@@ -33,7 +33,7 @@ module Axlsx
attr_reader :min
# @see logBase
- def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
+ def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, lambda { |arg| arg >= 2 && arg <= 1000 }; @logBase = v; end
# @see orientation
def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end
# @see max
diff --git a/lib/axlsx/drawing/scatter_chart.rb b/lib/axlsx/drawing/scatter_chart.rb
index fd6fa3d7..e43647a0 100644
--- a/lib/axlsx/drawing/scatter_chart.rb
+++ b/lib/axlsx/drawing/scatter_chart.rb
@@ -27,7 +27,7 @@ module Axlsx
alias :yValAxis :y_val_axis
# Creates a new scatter chart
- def initialize(frame, options={})
+ def initialize(frame, options = {})
@vary_colors = 0
@scatter_style = :lineMarker
diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb
index dba1fdf5..e4e1f27a 100644
--- a/lib/axlsx/drawing/scatter_series.rb
+++ b/lib/axlsx/drawing/scatter_series.rb
@@ -34,7 +34,7 @@ module Axlsx
attr_reader :marker_symbol
# Creates a new ScatterSeries
- def initialize(chart, options={})
+ def initialize(chart, options = {})
@xData, @yData = nil
if options[:smooth].nil?
# If caller hasn't specified smoothing or not, turn smoothing on or off based on scatter style
@@ -50,7 +50,7 @@ module Axlsx
super(chart, options)
@xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil?
- @yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil?
+ @yData = NumDataSource.new({ :tag_name => :yVal, :data => options[:yData] }) unless options[:yData].nil?
end
# @see color
diff --git a/lib/axlsx/drawing/ser_axis.rb b/lib/axlsx/drawing/ser_axis.rb
index f1da6037..b5844454 100644
--- a/lib/axlsx/drawing/ser_axis.rb
+++ b/lib/axlsx/drawing/ser_axis.rb
@@ -14,7 +14,7 @@ module Axlsx
# Creates a new SerAxis object
# @option options [Integer] tick_lbl_skip
# @option options [Integer] tick_mark_skip
- def initialize(options={})
+ def initialize(options = {})
@tick_lbl_skip, @tick_mark_skip = 1, 1
super(options)
end
diff --git a/lib/axlsx/drawing/series.rb b/lib/axlsx/drawing/series.rb
index e2445bc9..e5c66b59 100644
--- a/lib/axlsx/drawing/series.rb
+++ b/lib/axlsx/drawing/series.rb
@@ -18,7 +18,7 @@ module Axlsx
# @param [Chart] chart
# @option options [Integer] order
# @option options [String] title
- def initialize(chart, options={})
+ def initialize(chart, options = {})
@order = nil
self.chart = chart
@chart.series << self
diff --git a/lib/axlsx/drawing/str_data.rb b/lib/axlsx/drawing/str_data.rb
index e4f94e89..843c90a7 100644
--- a/lib/axlsx/drawing/str_data.rb
+++ b/lib/axlsx/drawing/str_data.rb
@@ -7,7 +7,7 @@ module Axlsx
# creates a new StrVal object
# @option options [Array] :data
# @option options [String] :tag_name
- def initialize(options={})
+ def initialize(options = {})
@tag_prefix = :str
@type = StrVal
@pt = SimpleTypedList.new(@type)
@@ -16,7 +16,7 @@ module Axlsx
# Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types.
# @param [Array] values An array of cells or values.
- def data=(values=[])
+ def data=(values = [])
@tag_name = values.first.is_a?(Cell) ? :strCache : :strLit
values.each do |value|
v = value.is_a?(Cell) ? value.value : value
diff --git a/lib/axlsx/drawing/str_val.rb b/lib/axlsx/drawing/str_val.rb
index 26f12e26..4a85d256 100644
--- a/lib/axlsx/drawing/str_val.rb
+++ b/lib/axlsx/drawing/str_val.rb
@@ -5,7 +5,7 @@ module Axlsx
# creates a new StrVal object
# @option options [String] v
- def initialize(options={})
+ def initialize(options = {})
@v = ""
@idx = 0
parse_options options
diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb
index 0c613e13..1a43ba80 100644
--- a/lib/axlsx/drawing/title.rb
+++ b/lib/axlsx/drawing/title.rb
@@ -15,7 +15,7 @@ module Axlsx
# Creates a new Title object
# @param [String, Cell] title The cell or string to be used for the chart's title
- def initialize(title="", title_size="")
+ def initialize(title = "", title_size = "")
self.cell = title if title.is_a?(Cell)
self.text = title.to_s unless title.is_a?(Cell)
if title_size.to_s.empty?
diff --git a/lib/axlsx/drawing/two_cell_anchor.rb b/lib/axlsx/drawing/two_cell_anchor.rb
index aa38c3db..7b77de13 100644
--- a/lib/axlsx/drawing/two_cell_anchor.rb
+++ b/lib/axlsx/drawing/two_cell_anchor.rb
@@ -30,10 +30,10 @@ module Axlsx
# @param [Drawing] drawing
# @option options [Array] :start_at the col, row to start at THIS IS DOCUMENTED BUT NOT IMPLEMENTED HERE!
# @option options [Array] :end_at the col, row to end at
- def initialize(drawing, options={})
+ def initialize(drawing, options = {})
@drawing = drawing
drawing.anchors << self
- @from, @to = Marker.new, Marker.new(:col => 5, :row=>10)
+ @from, @to = Marker.new, Marker.new(:col => 5, :row => 10)
parse_options options
# bit of a hack to work around the fact that the coords for start at and end at
@@ -46,7 +46,7 @@ module Axlsx
# @note The recommended way to set the start position for graphical
# objects is directly thru the object.
# @see Chart#start_at
- def start_at(x, y=nil)
+ def start_at(x, y = nil)
from.coord x, y
end
@@ -54,7 +54,7 @@ module Axlsx
# @note the recommended way to set the to position for graphical
# objects is directly thru the object
# @see Char#end_at
- def end_at(x, y=nil)
+ def end_at(x, y = nil)
to.coord x, y
end
@@ -66,7 +66,7 @@ module Axlsx
end
# Creates an image associated with this anchor.
- def add_pic(options={})
+ def add_pic(options = {})
@object = Pic.new(self, options)
end
diff --git a/lib/axlsx/drawing/val_axis.rb b/lib/axlsx/drawing/val_axis.rb
index ead09ff8..8cd131cc 100644
--- a/lib/axlsx/drawing/val_axis.rb
+++ b/lib/axlsx/drawing/val_axis.rb
@@ -9,7 +9,7 @@ module Axlsx
# Creates a new ValAxis object
# @option options [Symbol] crosses_between
- def initialize(options={})
+ def initialize(options = {})
self.cross_between = :between
super(options)
end
diff --git a/lib/axlsx/drawing/view_3D.rb b/lib/axlsx/drawing/view_3D.rb
index 250f53f2..1adf9e28 100644
--- a/lib/axlsx/drawing/view_3D.rb
+++ b/lib/axlsx/drawing/view_3D.rb
@@ -10,7 +10,7 @@ module Axlsx
# @option options [String] depth_percent
# @option options [Boolean] r_ang_ax
# @option options [Integer] perspective
- def initialize(options={})
+ def initialize(options = {})
@rot_x, @h_percent, @rot_y, @depth_percent, @r_ang_ax, @perspective = nil, nil, nil, nil, nil, nil
parse_options options
end
@@ -105,7 +105,7 @@ module Axlsx
private
# Note: move this to Axlsx module if we find the smae pattern elsewhere.
- def element_for_attribute(name, namespace='')
+ def element_for_attribute(name, namespace = '')
val = Axlsx.instance_values_for(self)[name]
return "" if val == nil
"<%s:%s val='%s'/>" % [namespace, Axlsx::camel(name, false), val]
diff --git a/lib/axlsx/drawing/vml_drawing.rb b/lib/axlsx/drawing/vml_drawing.rb
index ccf3e421..e314b736 100644
--- a/lib/axlsx/drawing/vml_drawing.rb
+++ b/lib/axlsx/drawing/vml_drawing.rb
@@ -23,7 +23,7 @@ module Axlsx
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel">
<o:shapelayout v:ext="edit">
- <o:idmap v:ext="edit" data="#{@comments.worksheet.index+1}"/>
+ <o:idmap v:ext="edit" data="#{@comments.worksheet.index + 1}"/>
</o:shapelayout>
<v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202"
path="m0,0l0,21600,21600,21600,21600,0xe">
diff --git a/lib/axlsx/drawing/vml_shape.rb b/lib/axlsx/drawing/vml_shape.rb
index 951cd58d..2ba388b3 100644
--- a/lib/axlsx/drawing/vml_shape.rb
+++ b/lib/axlsx/drawing/vml_shape.rb
@@ -15,14 +15,14 @@ module Axlsx
# @option options [Integer] right_offset
# @option options [Integer] bottom_row
# @option options [Integer] bottom_offset
- def initialize(options={})
+ def initialize(options = {})
@row = @column = @left_column = @top_row = @right_column = @bottom_row = 0
@left_offset = 15
@top_offset = 2
@right_offset = 50
@bottom_offset = 5
@visible = true
- @id = (0...8).map{65.+(rand(25)).chr}.join
+ @id = (0...8).map { 65.+(rand(25)).chr }.join
parse_options options
yield self if block_given?
end
@@ -35,7 +35,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 << <<SHAME_ON_YOU
<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 0c03b1a2..f249073c 100644
--- a/lib/axlsx/package.rb
+++ b/lib/axlsx/package.rb
@@ -19,7 +19,7 @@ module Axlsx
# @option options [Time] :created_at Timestamp in the document properties (defaults to current time).
# @option options [Boolean] :use_shared_strings This is passed to the workbook to specify that shared strings should be used when serializing the package.
# @example Package.new :author => 'you!', :workbook => Workbook.new
- def initialize(options={})
+ def initialize(options = {})
@workbook = nil
@core, @app = Core.new, App.new
@core.creator = options[:author] || @core.creator
@@ -122,7 +122,7 @@ module Axlsx
# Serialize your workbook to a StringIO instance
# @param [Boolean] confirm_valid Validate the package prior to serialization.
# @return [StringIO|Boolean] False if confirm_valid and validation errors exist. rewound string IO if not.
- def to_stream(confirm_valid=false)
+ def to_stream(confirm_valid = false)
if !workbook.styles_applied
workbook.apply_styles
end
@@ -211,26 +211,26 @@ module Axlsx
# @private
def parts
parts = [
- {:entry => "xl/#{STYLES_PN}", :doc => workbook.styles, :schema => SML_XSD},
- {:entry => CORE_PN, :doc => @core, :schema => CORE_XSD},
- {:entry => APP_PN, :doc => @app, :schema => APP_XSD},
- {:entry => WORKBOOK_RELS_PN, :doc => workbook.relationships, :schema => RELS_XSD},
- {:entry => WORKBOOK_PN, :doc => workbook, :schema => SML_XSD}
+ { :entry => "xl/#{STYLES_PN}", :doc => workbook.styles, :schema => SML_XSD },
+ { :entry => CORE_PN, :doc => @core, :schema => CORE_XSD },
+ { :entry => APP_PN, :doc => @app, :schema => APP_XSD },
+ { :entry => WORKBOOK_RELS_PN, :doc => workbook.relationships, :schema => RELS_XSD },
+ { :entry => WORKBOOK_PN, :doc => workbook, :schema => SML_XSD }
]
workbook.drawings.each do |drawing|
- parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships, :schema => RELS_XSD}
- parts << {:entry => "xl/#{drawing.pn}", :doc => drawing, :schema => DRAWING_XSD}
+ parts << { :entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships, :schema => RELS_XSD }
+ parts << { :entry => "xl/#{drawing.pn}", :doc => drawing, :schema => DRAWING_XSD }
end
workbook.tables.each do |table|
- parts << {:entry => "xl/#{table.pn}", :doc => table, :schema => SML_XSD}
+ parts << { :entry => "xl/#{table.pn}", :doc => table, :schema => SML_XSD }
end
workbook.pivot_tables.each do |pivot_table|
cache_definition = pivot_table.cache_definition
- parts << {:entry => "xl/#{pivot_table.rels_pn}", :doc => pivot_table.relationships, :schema => RELS_XSD}
- parts << {:entry => "xl/#{pivot_table.pn}", :doc => pivot_table} #, :schema => SML_XSD}
- parts << {:entry => "xl/#{cache_definition.pn}", :doc => cache_definition} #, :schema => SML_XSD}
+ parts << { :entry => "xl/#{pivot_table.rels_pn}", :doc => pivot_table.relationships, :schema => RELS_XSD }
+ parts << { :entry => "xl/#{pivot_table.pn}", :doc => pivot_table } #, :schema => SML_XSD}
+ parts << { :entry => "xl/#{cache_definition.pn}", :doc => cache_definition } #, :schema => SML_XSD}
end
workbook.comments.each do |comment|
@@ -241,26 +241,26 @@ module Axlsx
end
workbook.charts.each do |chart|
- parts << {:entry => "xl/#{chart.pn}", :doc => chart, :schema => DRAWING_XSD}
+ parts << { :entry => "xl/#{chart.pn}", :doc => chart, :schema => DRAWING_XSD }
end
workbook.images.each do |image|
- parts << {:entry => "xl/#{image.pn}", :path => image.image_src}
+ parts << { :entry => "xl/#{image.pn}", :path => image.image_src }
end
if use_shared_strings
- parts << {:entry => "xl/#{SHARED_STRINGS_PN}", :doc => workbook.shared_strings, :schema => SML_XSD}
+ parts << { :entry => "xl/#{SHARED_STRINGS_PN}", :doc => workbook.shared_strings, :schema => SML_XSD }
end
workbook.worksheets.each do |sheet|
- parts << {:entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships, :schema => RELS_XSD}
- parts << {:entry => "xl/#{sheet.pn}", :doc => sheet, :schema => SML_XSD}
+ parts << { :entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships, :schema => RELS_XSD }
+ parts << { :entry => "xl/#{sheet.pn}", :doc => sheet, :schema => SML_XSD }
end
# Sort parts for correct MIME detection
[
- {:entry => CONTENT_TYPES_PN, :doc => content_types, :schema => CONTENT_TYPES_XSD},
- {:entry => RELS_PN, :doc => relationships, :schema => RELS_XSD},
+ { :entry => CONTENT_TYPES_PN, :doc => content_types, :schema => CONTENT_TYPES_XSD },
+ { :entry => RELS_PN, :doc => relationships, :schema => RELS_XSD },
*(parts.sort_by { |part| part[:entry] }.reverse)
]
end
@@ -332,7 +332,7 @@ module Axlsx
elsif ext == 'png'
PNG_CT
end
- c_types << Axlsx::Default.new(:ContentType => ct, :Extension => ext )
+ c_types << Axlsx::Default.new(:ContentType => ct, :Extension => ext)
end
if use_shared_strings
c_types << Axlsx::Override.new(:PartName => "/xl/#{SHARED_STRINGS_PN}",
diff --git a/lib/axlsx/rels/relationship.rb b/lib/axlsx/rels/relationship.rb
index f1759649..aff9fa55 100644
--- a/lib/axlsx/rels/relationship.rb
+++ b/lib/axlsx/rels/relationship.rb
@@ -81,10 +81,10 @@ module Axlsx
# @param [String] type The type of the relationship
# @param [String] target The target for the relationship
# @option [Symbol] :target_mode only accepts :external.
- def initialize(source_obj, type, target, options={})
+ def initialize(source_obj, type, target, options = {})
@source_obj = source_obj
- self.Target=target
- self.Type=type
+ self.Target = target
+ self.Type = type
self.TargetMode = options[:target_mode] if options[:target_mode]
@Id = (self.class.ids_cache[ids_cache_key] ||= self.class.next_free_id)
end
@@ -101,9 +101,9 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- h = Axlsx.instance_values_for(self).reject{|k, _| k == "source_obj"}
+ 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 8f3b62cc..686059fb 100644
--- a/lib/axlsx/rels/relationships.rb
+++ b/lib/axlsx/rels/relationships.rb
@@ -13,7 +13,7 @@ require 'axlsx/rels/relationship.rb'
# @see Relationship#source_obj
# @return [Relationship]
def for(source_obj)
- find{ |rel| rel.source_obj == source_obj }
+ find { |rel| rel.source_obj == source_obj }
end
# serialize relationships
@@ -22,7 +22,7 @@ require 'axlsx/rels/relationship.rb'
def to_xml_string(str = '')
str << '<?xml version="1.0" encoding="UTF-8"?>'
str << ('<Relationships xmlns="' << RELS_R << '">')
- each{ |rel| rel.to_xml_string(str) }
+ each { |rel| rel.to_xml_string(str) }
str << '</Relationships>'
end
end
diff --git a/lib/axlsx/stylesheet/border.rb b/lib/axlsx/stylesheet/border.rb
index b9ff785b..af564b22 100644
--- a/lib/axlsx/stylesheet/border.rb
+++ b/lib/axlsx/stylesheet/border.rb
@@ -19,7 +19,7 @@ module Axlsx
#
# @note The recommended way to manage borders is with Style#add_style
# @see Style#add_style
- def initialize(options={})
+ def initialize(options = {})
@prs = SimpleTypedList.new BorderPr
parse_options options
end
diff --git a/lib/axlsx/stylesheet/border_pr.rb b/lib/axlsx/stylesheet/border_pr.rb
index 630cf42e..8300f4bc 100644
--- a/lib/axlsx/stylesheet/border_pr.rb
+++ b/lib/axlsx/stylesheet/border_pr.rb
@@ -43,7 +43,7 @@ module Axlsx
# @option options [Symbol] name
# @option options [Symbol] style
# @see Axlsx::Border
- def initialize(options={})
+ def initialize(options = {})
parse_options(options)
#options.each do |o|
# self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
diff --git a/lib/axlsx/stylesheet/cell_alignment.rb b/lib/axlsx/stylesheet/cell_alignment.rb
index cf03c171..906c7870 100644
--- a/lib/axlsx/stylesheet/cell_alignment.rb
+++ b/lib/axlsx/stylesheet/cell_alignment.rb
@@ -17,7 +17,7 @@ module Axlsx
# @option options [Boolean] justify_last_line
# @option options [Boolean] shrink_to_fit
# @option options [Integer] reading_order
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
diff --git a/lib/axlsx/stylesheet/cell_protection.rb b/lib/axlsx/stylesheet/cell_protection.rb
index 6d98ff19..f040f207 100644
--- a/lib/axlsx/stylesheet/cell_protection.rb
+++ b/lib/axlsx/stylesheet/cell_protection.rb
@@ -19,7 +19,7 @@ module Axlsx
# Creates a new CellProtection
# @option options [Boolean] hidden value for hidden protection
# @option options [Boolean] locked value for locked protection
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
diff --git a/lib/axlsx/stylesheet/cell_style.rb b/lib/axlsx/stylesheet/cell_style.rb
index e2c3a09e..1e35a1a4 100644
--- a/lib/axlsx/stylesheet/cell_style.rb
+++ b/lib/axlsx/stylesheet/cell_style.rb
@@ -13,7 +13,7 @@ module Axlsx
# @option options [Integer] iLevel
# @option options [Boolean] hidden
# @option options [Boolean] customBuiltIn
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb
index 709d22c3..28afaf11 100644
--- a/lib/axlsx/stylesheet/color.rb
+++ b/lib/axlsx/stylesheet/color.rb
@@ -8,7 +8,7 @@ module Axlsx
# @option options [Boolean] auto
# @option options [String] rgb
# @option options [Float] tint
- def initialize(options={})
+ def initialize(options = {})
@rgb = "FF000000"
parse_options options
end
diff --git a/lib/axlsx/stylesheet/dxf.rb b/lib/axlsx/stylesheet/dxf.rb
index 637e3d54..a3f15581 100644
--- a/lib/axlsx/stylesheet/dxf.rb
+++ b/lib/axlsx/stylesheet/dxf.rb
@@ -42,7 +42,7 @@ module Axlsx
# @option options [Font] font
# @option options [CellAlignment] alignment
# @option options [CellProtection] protection
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
diff --git a/lib/axlsx/stylesheet/font.rb b/lib/axlsx/stylesheet/font.rb
index 9ce5ae4a..0f432d58 100644
--- a/lib/axlsx/stylesheet/font.rb
+++ b/lib/axlsx/stylesheet/font.rb
@@ -20,7 +20,7 @@ module Axlsx
# @option options [Boolean] extend
# @option options [Color] color
# @option options [Integer] sz
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
@@ -139,9 +139,9 @@ module Axlsx
# @see extend
def extend=(v) Axlsx::validate_boolean v; @extend = v end
# @see color
- def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color=v end
+ def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color = v end
# @see sz
- def sz=(v) Axlsx::validate_unsigned_int v; @sz=v end
+ def sz=(v) Axlsx::validate_unsigned_int v; @sz = v end
# Serializes the object
# @param [String] str
diff --git a/lib/axlsx/stylesheet/gradient_fill.rb b/lib/axlsx/stylesheet/gradient_fill.rb
index 8d88f373..dc4e562b 100644
--- a/lib/axlsx/stylesheet/gradient_fill.rb
+++ b/lib/axlsx/stylesheet/gradient_fill.rb
@@ -12,7 +12,7 @@ module Axlsx
# @option options [Float] right
# @option options [Float] top
# @option options [Float] bottom
- def initialize(options={})
+ def initialize(options = {})
options[:type] ||= :linear
parse_options options
@stop = SimpleTypedList.new GradientStop
@@ -84,7 +84,7 @@ module Axlsx
# validates that the value provided is between 0.0 and 1.0
def validate_format_percentage(name, value)
- DataTypeValidator.validate name, Float, value, lambda { |arg| arg >= 0.0 && arg <= 1.0}
+ DataTypeValidator.validate name, Float, value, lambda { |arg| arg >= 0.0 && arg <= 1.0 }
end
# Serializes the object
diff --git a/lib/axlsx/stylesheet/gradient_stop.rb b/lib/axlsx/stylesheet/gradient_stop.rb
index 63778b58..2325ee66 100644
--- a/lib/axlsx/stylesheet/gradient_stop.rb
+++ b/lib/axlsx/stylesheet/gradient_stop.rb
@@ -20,9 +20,9 @@ module Axlsx
end
# @see color
- def color=(v) DataTypeValidator.validate "GradientStop.color", Color, v; @color=v end
+ def color=(v) DataTypeValidator.validate "GradientStop.color", Color, v; @color = v end
# @see position
- def position=(v) DataTypeValidator.validate "GradientStop.position", Float, v, lambda { |arg| arg >= 0 && arg <= 1}; @position = v end
+ def position=(v) DataTypeValidator.validate "GradientStop.position", Float, v, lambda { |arg| arg >= 0 && arg <= 1 }; @position = v end
# Serializes the object
# @param [String] str
diff --git a/lib/axlsx/stylesheet/num_fmt.rb b/lib/axlsx/stylesheet/num_fmt.rb
index ed239dfc..388f0d59 100644
--- a/lib/axlsx/stylesheet/num_fmt.rb
+++ b/lib/axlsx/stylesheet/num_fmt.rb
@@ -9,7 +9,7 @@ module Axlsx
# @param [Hash] options Options for the number format object
# @option [Integer] numFmtId The predefined format id or new format id for this format
# @option [String] formatCode The format code for this number format
- def initialize(options={})
+ def initialize(options = {})
@numFmtId = 0
@formatCode = ""
parse_options options
diff --git a/lib/axlsx/stylesheet/pattern_fill.rb b/lib/axlsx/stylesheet/pattern_fill.rb
index 0bcef74b..3ebd4ff6 100644
--- a/lib/axlsx/stylesheet/pattern_fill.rb
+++ b/lib/axlsx/stylesheet/pattern_fill.rb
@@ -8,7 +8,7 @@ module Axlsx
# @option options [Symbol] patternType
# @option options [Color] fgColor
# @option options [Color] bgColor
- def initialize(options={})
+ def initialize(options = {})
@patternType = :none
parse_options options
end
@@ -47,9 +47,9 @@ module Axlsx
attr_reader :patternType
# @see fgColor
- def fgColor=(v) DataTypeValidator.validate "PatternFill.fgColor", Color, v; @fgColor=v end
+ def fgColor=(v) DataTypeValidator.validate "PatternFill.fgColor", Color, v; @fgColor = v end
# @see bgColor
- def bgColor=(v) DataTypeValidator.validate "PatternFill.bgColor", Color, v; @bgColor=v end
+ def bgColor=(v) DataTypeValidator.validate "PatternFill.bgColor", Color, v; @bgColor = v end
# @see patternType
def patternType=(v) Axlsx::validate_pattern_type v; @patternType = v end
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb
index a1f541c9..e55e2c95 100644
--- a/lib/axlsx/stylesheet/styles.rb
+++ b/lib/axlsx/stylesheet/styles.rb
@@ -224,11 +224,11 @@ module Axlsx
#
# An index for cell styles where keys are styles codes as per Axlsx::Style and values are Cell#raw_style
# The reason for the backward key/value ordering is that style lookup must be most efficient, while `add_style` can be less efficient
- def add_style(options={})
+ def add_style(options = {})
# Default to :xf
options[:type] ||= :xf
- raise ArgumentError, "Type must be one of [:xf, :dxf]" unless [:xf, :dxf].include?(options[:type] )
+ raise ArgumentError, "Type must be one of [:xf, :dxf]" unless [:xf, :dxf].include?(options[:type])
if options[:border].is_a?(Hash)
if options[:border][:edges] == :all
@@ -241,9 +241,9 @@ module Axlsx
if options[:type] == :xf
# Check to see if style in cache already
- font_defaults = {name: @fonts.first.name, sz: @fonts.first.sz, family: @fonts.first.family}
+ font_defaults = { name: @fonts.first.name, sz: @fonts.first.sz, family: @fonts.first.family }
- raw_style = {type: :xf}.merge(font_defaults).merge(options)
+ raw_style = { type: :xf }.merge(font_defaults).merge(options)
if raw_style[:format_code]
raw_style.delete(:num_fmt)
@@ -267,7 +267,7 @@ module Axlsx
when :dxf
style = Dxf.new :fill => fill, :font => font, :numFmt => numFmt, :border => border, :alignment => alignment, :protection => protection
else
- style = Xf.new :fillId=>fill || 0, :fontId=>font || 0, :numFmtId=>numFmt || 0, :borderId=>border || 0, :alignment => alignment, :protection => protection, :applyFill=>!fill.nil?, :applyFont=>!font.nil?, :applyNumberFormat =>!numFmt.nil?, :applyBorder=>!border.nil?, :applyAlignment => !alignment.nil?, :applyProtection => !protection.nil?
+ style = Xf.new :fillId => fill || 0, :fontId => font || 0, :numFmtId => numFmt || 0, :borderId => border || 0, :alignment => alignment, :protection => protection, :applyFill => !fill.nil?, :applyFont => !font.nil?, :applyNumberFormat => !numFmt.nil?, :applyBorder => !border.nil?, :applyAlignment => !alignment.nil?, :applyProtection => !protection.nil?
end
if options[:type] == :xf
@@ -290,7 +290,7 @@ module Axlsx
# @option options [Boolean] hide boolean value defining cell protection attribute for hiding.
# @option options [Boolean] locked boolean value defining cell protection attribute for locking.
# @return [CellProtection]
- def parse_protection_options(options={})
+ def parse_protection_options(options = {})
return if (options.keys & [:hidden, :locked]).empty?
CellProtection.new(options)
end
@@ -300,7 +300,7 @@ module Axlsx
# @option options [Hash] alignment A hash of options to prive the CellAlignment intializer
# @return [CellAlignment]
# @see CellAlignment
- def parse_alignment_options(options={})
+ def parse_alignment_options(options = {})
return unless options[:alignment]
CellAlignment.new options[:alignment]
end
@@ -320,7 +320,7 @@ module Axlsx
# @option options [Integer] family The font family to use.
# @option options [String] font_name The name of the font to use
# @return [Font|Integer]
- def parse_font_options(options={})
+ def parse_font_options(options = {})
return if (options.keys & [:fg_color, :sz, :b, :i, :u, :strike, :outline, :shadow, :charset, :family, :font_name]).empty?
Axlsx.instance_values_for(fonts.first).each do |key, value|
# Thanks for that 1.8.7 - cant do a simple merge...
@@ -336,12 +336,12 @@ module Axlsx
# @note noop if :bg_color is not specified in options
# @option options [String] bg_color The rgb color to apply to the fill
# @return [Fill|Integer]
- def parse_fill_options(options={})
+ def parse_fill_options(options = {})
return unless options[:bg_color]
- color = Color.new(:rgb=>options[:bg_color])
+ color = Color.new(:rgb => options[:bg_color])
dxf = options[:type] == :dxf
color_key = dxf ? :bgColor : :fgColor
- pattern = PatternFill.new(:patternType =>:solid, color_key=>color)
+ pattern = PatternFill.new(:patternType => :solid, color_key => color)
fill = Fill.new(pattern)
dxf ? fill : fills << fill
end
@@ -359,8 +359,8 @@ module Axlsx
# #apply a thick red border to the top and bottom
# { :border => { :style => :thick, :color => "FFFF0000", :edges => [:top, :bottom] }
# @return [Border|Integer]
- def parse_border_options(options={})
- if options[:border].nil? && Border::EDGES.all?{|x| options["border_#{x}".to_sym].nil? }
+ def parse_border_options(options = {})
+ if options[:border].nil? && Border::EDGES.all? { |x| options["border_#{x}".to_sym].nil? }
return nil
end
@@ -376,7 +376,7 @@ module Axlsx
end
end
- validate_border_hash = ->(val){
+ validate_border_hash = ->(val) {
if !(val.keys.include?(:style) && val.keys.include?(:color))
raise ArgumentError, (ERR_INVALID_BORDER_OPTIONS % options[:border])
end
@@ -461,15 +461,15 @@ module Axlsx
# noop if neither :format_code or :num_format options are set.
# @option options [Hash] A hash describing the :format_code and/or :num_fmt integer for the style.
# @return [NumFmt|Integer]
- def parse_num_fmt_options(options={})
+ def parse_num_fmt_options(options = {})
return if (options.keys & [:format_code, :num_fmt]).empty?
#When the user provides format_code - we always need to create a new numFmt object
#When the type is :dxf we always need to create a new numFmt object
if options[:format_code] || options[:type] == :dxf
#If this is a standard xf we pull from numFmts the highest current and increment for num_fmt
- options[:num_fmt] ||= (@numFmts.map{ |num_fmt| num_fmt.numFmtId }.max + 1) if options[:type] != :dxf
- numFmt = NumFmt.new(:numFmtId => options[:num_fmt] || 0, :formatCode=> options[:format_code].to_s)
+ options[:num_fmt] ||= (@numFmts.map { |num_fmt| num_fmt.numFmtId }.max + 1) if options[:type] != :dxf
+ numFmt = NumFmt.new(:numFmtId => options[:num_fmt] || 0, :formatCode => options[:format_code].to_s)
options[:type] == :dxf ? numFmt : (numFmts << numFmt; numFmt.numFmtId)
else
options[:num_fmt]
@@ -494,42 +494,42 @@ module Axlsx
# Axlsx::STYLE_THIN_BORDER
def load_default_styles
@numFmts = SimpleTypedList.new NumFmt, 'numFmts'
- @numFmts << NumFmt.new(:numFmtId => NUM_FMT_YYYYMMDD, :formatCode=> "yyyy/mm/dd")
- @numFmts << NumFmt.new(:numFmtId => NUM_FMT_YYYYMMDDHHMMSS, :formatCode=> "yyyy/mm/dd hh:mm:ss")
+ @numFmts << NumFmt.new(:numFmtId => NUM_FMT_YYYYMMDD, :formatCode => "yyyy/mm/dd")
+ @numFmts << NumFmt.new(:numFmtId => NUM_FMT_YYYYMMDDHHMMSS, :formatCode => "yyyy/mm/dd hh:mm:ss")
@numFmts.lock
@fonts = SimpleTypedList.new Font, 'fonts'
- @fonts << Font.new(:name => "Arial", :sz => 11, :family=>1)
+ @fonts << Font.new(:name => "Arial", :sz => 11, :family => 1)
@fonts.lock
@fills = SimpleTypedList.new Fill, 'fills'
- @fills << Fill.new(Axlsx::PatternFill.new(:patternType=>:none))
- @fills << Fill.new(Axlsx::PatternFill.new(:patternType=>:gray125))
+ @fills << Fill.new(Axlsx::PatternFill.new(:patternType => :none))
+ @fills << Fill.new(Axlsx::PatternFill.new(:patternType => :gray125))
@fills.lock
@borders = SimpleTypedList.new Border, 'borders'
@borders << Border.new
black_border = Border.new
[:left, :right, :top, :bottom].each do |item|
- black_border.prs << BorderPr.new(:name=>item, :style=>:thin, :color=>Color.new(:rgb=>"FF000000"))
+ black_border.prs << BorderPr.new(:name => item, :style => :thin, :color => Color.new(:rgb => "FF000000"))
end
@borders << black_border
@borders.lock
@cellStyleXfs = SimpleTypedList.new Xf, "cellStyleXfs"
- @cellStyleXfs << Xf.new(:borderId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0)
+ @cellStyleXfs << Xf.new(:borderId => 0, :numFmtId => 0, :fontId => 0, :fillId => 0)
@cellStyleXfs.lock
@cellStyles = SimpleTypedList.new CellStyle, 'cellStyles'
- @cellStyles << CellStyle.new(:name =>"Normal", :builtinId =>0, :xfId=>0)
+ @cellStyles << CellStyle.new(:name => "Normal", :builtinId => 0, :xfId => 0)
@cellStyles.lock
@cellXfs = SimpleTypedList.new Xf, "cellXfs"
- @cellXfs << Xf.new(:borderId=>0, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0)
- @cellXfs << Xf.new(:borderId=>1, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0)
+ @cellXfs << Xf.new(:borderId => 0, :xfId => 0, :numFmtId => 0, :fontId => 0, :fillId => 0)
+ @cellXfs << Xf.new(:borderId => 1, :xfId => 0, :numFmtId => 0, :fontId => 0, :fillId => 0)
# default date formatting
- @cellXfs << Xf.new(:borderId=>0, :xfId=>0, :numFmtId=>14, :fontId=>0, :fillId=>0, :applyNumberFormat=>1)
+ @cellXfs << Xf.new(:borderId => 0, :xfId => 0, :numFmtId => 14, :fontId => 0, :fillId => 0, :applyNumberFormat => 1)
@cellXfs.lock
@dxfs = SimpleTypedList.new(Dxf, "dxfs"); @dxfs.lock
diff --git a/lib/axlsx/stylesheet/table_style.rb b/lib/axlsx/stylesheet/table_style.rb
index edef6216..f656ce3d 100644
--- a/lib/axlsx/stylesheet/table_style.rb
+++ b/lib/axlsx/stylesheet/table_style.rb
@@ -10,7 +10,7 @@ module Axlsx
# @param [String] name
# @option options [Boolean] pivot
# @option options [Boolean] table
- def initialize(name, options={})
+ def initialize(name, options = {})
self.name = name
parse_options options
super TableStyleElement
@@ -31,18 +31,18 @@ module Axlsx
attr_reader :table
# @see name
- def name=(v) Axlsx::validate_string v; @name=v end
+ def name=(v) Axlsx::validate_string v; @name = v end
# @see pivot
- def pivot=(v) Axlsx::validate_boolean v; @pivot=v end
+ def pivot=(v) Axlsx::validate_boolean v; @pivot = v end
# @see table
- def table=(v) Axlsx::validate_boolean v; @table=v end
+ def table=(v) Axlsx::validate_boolean v; @table = v end
# Serializes the object
# @param [String] str
# @return [String]
def to_xml_string(str = '')
str << '<tableStyle '
- serialized_attributes str, {:count => self.size}
+ serialized_attributes str, { :count => self.size }
str << '>'
each { |table_style_el| table_style_el.to_xml_string(str) }
str << '</tableStyle>'
diff --git a/lib/axlsx/stylesheet/table_style_element.rb b/lib/axlsx/stylesheet/table_style_element.rb
index 4bc2a787..845d6bac 100644
--- a/lib/axlsx/stylesheet/table_style_element.rb
+++ b/lib/axlsx/stylesheet/table_style_element.rb
@@ -9,7 +9,7 @@ module Axlsx
# @option options [Symbol] type
# @option options [Integer] size
# @option options [Integer] dxfId
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
diff --git a/lib/axlsx/stylesheet/table_styles.rb b/lib/axlsx/stylesheet/table_styles.rb
index 27c75609..a55180a5 100644
--- a/lib/axlsx/stylesheet/table_styles.rb
+++ b/lib/axlsx/stylesheet/table_styles.rb
@@ -7,7 +7,7 @@ module Axlsx
# Creates a new TableStyles object that is a container for TableStyle objects
# @option options [String] defaultTableStyle
# @option options [String] defaultPivotStyle
- def initialize(options={})
+ def initialize(options = {})
@defaultTableStyle = options[:defaultTableStyle] || "TableStyleMedium9"
@defaultPivotStyle = options[:defaultPivotStyle] || "PivotStyleLight16"
super TableStyle
@@ -33,7 +33,7 @@ module Axlsx
# @return [String]
def to_xml_string(str = '')
str << '<tableStyles '
- serialized_attributes str, {:count => self.size }
+ serialized_attributes str, { :count => self.size }
str << '>'
each { |table_style| table_style.to_xml_string(str) }
str << '</tableStyles>'
diff --git a/lib/axlsx/stylesheet/xf.rb b/lib/axlsx/stylesheet/xf.rb
index 8b3b11b6..e7a84a46 100644
--- a/lib/axlsx/stylesheet/xf.rb
+++ b/lib/axlsx/stylesheet/xf.rb
@@ -22,7 +22,7 @@ module Axlsx
# @option options [Boolean] applyProtection
# @option options [CellAlignment] alignment
# @option options [CellProtection] protection
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb
index 401db1b8..7a49a0eb 100644
--- a/lib/axlsx/util/constants.rb
+++ b/lib/axlsx/util/constants.rb
@@ -237,7 +237,7 @@ module Axlsx
COMMENT_PN = "comments%d.xml".freeze
# location of schema files for validation
- SCHEMA_BASE = (File.dirname(__FILE__)+'/../../schema/').freeze
+ SCHEMA_BASE = (File.dirname(__FILE__) + '/../../schema/').freeze
# App validation schema
APP_XSD = (SCHEMA_BASE + "shared-documentPropertiesExtended.xsd").freeze
diff --git a/lib/axlsx/util/options_parser.rb b/lib/axlsx/util/options_parser.rb
index 01a1b29b..3f2c1937 100644
--- a/lib/axlsx/util/options_parser.rb
+++ b/lib/axlsx/util/options_parser.rb
@@ -5,7 +5,7 @@ module Axlsx
# Parses an options hash by calling any defined method by the same
# name of the key postfixed with an '='
# @param [Hash] options Options to parse.
- def parse_options(options={})
+ def parse_options(options = {})
options.each do |key, value|
key = :"#{key}="
self.send(key, value) if !value.nil? && self.respond_to?(key)
diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb
index 2ac5c05f..9d46de75 100644
--- a/lib/axlsx/util/serialized_attributes.rb
+++ b/lib/axlsx/util/serialized_attributes.rb
@@ -71,7 +71,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 ddab916e..36651f1f 100644
--- a/lib/axlsx/util/simple_typed_list.rb
+++ b/lib/axlsx/util/simple_typed_list.rb
@@ -6,7 +6,7 @@ module Axlsx
# @param [Array, Class] type An array of Class objects or a single Class object
# @param [String] serialize_as The tag name to use in serialization
# @raise [ArgumentError] if all members of type are not Class objects
- def initialize type, serialize_as=nil, start_size = 0
+ def initialize type, serialize_as = nil, start_size = 0
if type.is_a? Array
type.each { |item| raise ArgumentError, "All members of type must be Class objects" unless item.is_a? Class }
@allowed_types = type
@@ -38,7 +38,7 @@ module Axlsx
def transpose
return @list.clone if @list.size == 0
row_count = @list.size
- max_column_count = @list.map{|row| row.cells.size}.max
+ max_column_count = @list.map { |row| row.cells.size }.max
result = Array.new(max_column_count) { Array.new(row_count) }
# yes, I know it is silly, but that warning is really annoying
row_count.times do |row_index|
@@ -164,7 +164,7 @@ module Axlsx
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])
+ el_name = serialize_as.to_s || (classname[0, 1].downcase + classname[1..-1])
str << ('<' << el_name << ' count="' << size.to_s << '">')
each { |item| item.to_xml_string(str) }
str << ('</' << el_name << '>')
diff --git a/lib/axlsx/util/storage.rb b/lib/axlsx/util/storage.rb
index 9712c563..c2f0739c 100644
--- a/lib/axlsx/util/storage.rb
+++ b/lib/axlsx/util/storage.rb
@@ -7,15 +7,15 @@ module Axlsx
# storage types
TYPES = {
- :root=>5,
- :stream=>2,
- :storage=>1
+ :root => 5,
+ :stream => 2,
+ :storage => 1
}.freeze
# Creates a byte string for this storage
# @return [String]
def to_s
- data = [@name.concat(Array.new([email protected], 0)),
+ data = [@name.concat(Array.new(32 - @name.size, 0)),
@name_size,
@type,
@color,
@@ -31,8 +31,8 @@ module Axlsx
# storage colors
COLORS = {
- :red=>0,
- :black=>1
+ :red => 0,
+ :black => 1
}
# The color of this node in the directory tree. Defaults to black if not specified
@@ -128,7 +128,7 @@ module Axlsx
# @option options [Integer] created (0)
# @option options [Integer] modified (0)
# @option options [Integer] sector (0)
- def initialize(name, options= {})
+ def initialize(name, options = {})
@left = @right = @child = -1
@sector = @size = @created = @modified = 0
options.each do |o|
diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb
index ebf8a280..266709b0 100644
--- a/lib/axlsx/util/validators.rb
+++ b/lib/axlsx/util/validators.rb
@@ -51,7 +51,7 @@ module Axlsx
# @raise [ArugumentError] Raised if the class of the value provided is not in the specified array of types or the block passed returns false
# @return [Boolean] true if validation succeeds.
# @see validate_boolean
- def self.validate(name, types, v, other=false)
+ def self.validate(name, types, v, other = false)
if other.is_a?(Proc)
raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect]) unless other.call(v)
end
diff --git a/lib/axlsx/workbook/defined_name.rb b/lib/axlsx/workbook/defined_name.rb
index 283a8e9d..4b819d4c 100644
--- a/lib/axlsx/workbook/defined_name.rb
+++ b/lib/axlsx/workbook/defined_name.rb
@@ -97,7 +97,7 @@ module Axlsx
# version of the workbook that is published to or rendered on a Web or application server.
# @option [Boolean] workbook_parameter - Specifies a boolean value that indicates that the name is used as a workbook parameter on a
# version of the workbook that is published to or rendered on a Web or application server.
- def initialize(formula, options={})
+ def initialize(formula, options = {})
@formula = formula
parse_options options
end
@@ -118,7 +118,7 @@ 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 << '" ')
serialized_attributes str
diff --git a/lib/axlsx/workbook/shared_strings_table.rb b/lib/axlsx/workbook/shared_strings_table.rb
index 55040bc5..b8502206 100644
--- a/lib/axlsx/workbook/shared_strings_table.rb
+++ b/lib/axlsx/workbook/shared_strings_table.rb
@@ -30,12 +30,12 @@ module Axlsx
# Creates a new Shared Strings Table agains an array of cells
# @param [Array] cells This is an array of all of the cells in the workbook
# @param [Symbol] xml_space The xml:space behavior for the shared string table.
- def initialize(cells, xml_space=:preserve)
+ def initialize(cells, xml_space = :preserve)
@index = 0
@xml_space = xml_space
@unique_cells = {}
@shared_xml_string = ""
- shareable_cells = cells.flatten.select{ |cell| cell.plain_string? || cell.contains_rich_text? }
+ shareable_cells = cells.flatten.select { |cell| cell.plain_string? || cell.contains_rich_text? }
@count = shareable_cells.size
resolve(shareable_cells)
end
@@ -43,7 +43,7 @@ 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 << '"')
diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb
index f2d9eab5..fde5d259 100644
--- a/lib/axlsx/workbook/workbook.rb
+++ b/lib/axlsx/workbook/workbook.rb
@@ -226,7 +226,7 @@ require 'axlsx/workbook/worksheet/selection.rb'
# Creates a new Workbook
# The recomended way to work with workbooks is via Package#workbook
# @option options [Boolean] date1904. If this is not specified, date1904 is set to false. Office 2011 for Mac defaults to false.
- def initialize(options={})
+ def initialize(options = {})
@styles = Styles.new
@worksheets = SimpleTypedList.new Worksheet
@drawings = SimpleTypedList.new Drawing
@@ -241,7 +241,7 @@ require 'axlsx/workbook/worksheet/selection.rb'
@bold_font_multiplier = BOLD_FONT_MULTIPLIER
@font_scale_divisor = FONT_SCALE_DIVISOR
- self.date1904= !options[:date1904].nil? && options[:date1904]
+ self.date1904 = !options[:date1904].nil? && options[:date1904]
yield self if block_given?
end
@@ -268,7 +268,7 @@ require 'axlsx/workbook/worksheet/selection.rb'
def use_autowidth() @use_autowidth; end
# see @use_autowidth
- def use_autowidth=(v=true) Axlsx::validate_boolean v; @use_autowidth = v; end
+ def use_autowidth=(v = true) Axlsx::validate_boolean v; @use_autowidth = v; end
# Font size of bold fonts is multiplied with this
# Used for automatic calculation of cell widths with bold text
@@ -298,7 +298,7 @@ require 'axlsx/workbook/worksheet/selection.rb'
# @param [Hash] options Options to pass into the worksheed during initialization.
# @option options [String] name The name of the worksheet
# @option options [Hash] page_margins The page margins for the worksheet
- def insert_worksheet(index=0, options={})
+ def insert_worksheet(index = 0, options = {})
worksheet = Worksheet.new(self, options)
@worksheets.delete_at(@worksheets.size - 1)
@worksheets.insert(index, worksheet)
@@ -312,7 +312,7 @@ require 'axlsx/workbook/worksheet/selection.rb'
# @option options [String] name The name of the worksheet.
# @option options [Hash] page_margins The page margins for the worksheet.
# @see Worksheet#initialize
- def add_worksheet(options={})
+ def add_worksheet(options = {})
worksheet = Worksheet.new(self, options)
yield worksheet if block_given?
worksheet
@@ -322,7 +322,7 @@ require 'axlsx/workbook/worksheet/selection.rb'
# @return WorkbookViews
# @option options [Hash] options passed into the added WorkbookView
# @see WorkbookView#initialize
- def add_view(options={})
+ def add_view(options = {})
views << WorkbookView.new(options)
end
@@ -339,10 +339,10 @@ require 'axlsx/workbook/worksheet/selection.rb'
def relationships
r = Relationships.new
@worksheets.each do |sheet|
- r << Relationship.new(sheet, WORKSHEET_R, WORKSHEET_PN % (r.size+1))
+ r << Relationship.new(sheet, WORKSHEET_R, WORKSHEET_PN % (r.size + 1))
end
pivot_tables.each_with_index do |pivot_table, index|
- r << Relationship.new(pivot_table.cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, PIVOT_TABLE_CACHE_DEFINITION_PN % (index+1))
+ r << Relationship.new(pivot_table.cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, PIVOT_TABLE_CACHE_DEFINITION_PN % (index + 1))
end
r << Relationship.new(self, STYLES_R, STYLES_PN)
if use_shared_strings
@@ -383,13 +383,13 @@ require 'axlsx/workbook/worksheet/selection.rb'
sheet_name = cell_def.split('!')[0] if cell_def.match('!')
worksheet = self.worksheets.select { |s| s.name == sheet_name }.first
raise ArgumentError, 'Unknown Sheet' unless sheet_name && worksheet.is_a?(Worksheet)
- worksheet[cell_def.gsub(/.+!/,"")]
+ worksheet[cell_def.gsub(/.+!/, "")]
end
# 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 << '">')
diff --git a/lib/axlsx/workbook/workbook_view.rb b/lib/axlsx/workbook/workbook_view.rb
index b2656d00..5b6d5bfb 100644
--- a/lib/axlsx/workbook/workbook_view.rb
+++ b/lib/axlsx/workbook/workbook_view.rb
@@ -44,7 +44,7 @@ module Axlsx
# @option [Integer] window_width Specifies the width of the workbook window. The unit of measurement for this value is twips.
# @option [Integer] window_height Specifies the height of the workbook window. The unit of measurement for this value is twips.
# @option [Boolean] auto_filter_date_grouping Specifies a boolean value that indicates whether to group dates when presenting the user with filtering options in the user interface.
- def initialize(options={})
+ def initialize(options = {})
parse_options options
yield self if block_given?
end
diff --git a/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb b/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb
index fa0716a2..ac630f69 100644
--- a/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb
+++ b/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb
@@ -24,7 +24,7 @@ module Axlsx
# @return [String]
def defined_name
return unless range
- Axlsx.cell_range(range.split(':').collect { |name| worksheet.name_to_cell(name)})
+ Axlsx.cell_range(range.split(':').collect { |name| worksheet.name_to_cell(name) })
end
# A collection of filterColumns for this auto_filter
@@ -51,7 +51,7 @@ module Axlsx
start_point = Axlsx::name_to_indices(first_cell)
end_point = Axlsx::name_to_indices(last_cell)
# The +1 is so we skip the header row with the filter drop downs
- rows = worksheet.rows[(start_point.last+1)..end_point.last] || []
+ rows = worksheet.rows[(start_point.last + 1)..end_point.last] || []
column_offset = start_point.first
columns.each do |column|
@@ -64,7 +64,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}'>"
columns.each { |filter_column| filter_column.to_xml_string(str) }
diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
index 54d43acf..1fa2ff78 100644
--- a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
+++ b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
@@ -26,7 +26,7 @@ module Axlsx
serializable_attributes :col_id, :hidden_button, :show_button
# Allowed filters
- FILTERS = [:filters] #, :top10, :custom_filters, :dynamic_filters, :color_filters, :icon_filters]
+ FILTERS = [:filters] #, :top10, :custom_filters, :dynamic_filters, :color_filters, :icon_filters]
# Zero-based index indicating the AutoFilter column to which this filter information applies.
# @return [Integer]
@@ -64,7 +64,7 @@ module Axlsx
# @param [Array] row A row from a worksheet that needs to be
# filtered.
def apply(row, offset)
- row.hidden = @filter.apply(row.cells[offset+col_id.to_i])
+ row.hidden = @filter.apply(row.cells[offset + col_id.to_i])
end
# @param [Boolean] hidden Flag indicating whether the AutoFilter button for this column is hidden.
@@ -85,7 +85,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 7b503acd..da43a471 100644
--- a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb
+++ b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb
@@ -15,7 +15,7 @@ module Axlsx
# @note The recommended way to interact with filter objects is via AutoFilter#add_column
# @example
# ws.auto_filter.add_column(0, :filters, :blank => true, :calendar_type => 'japan', :filter_items => [100, 'a'])
- def initialize(options={})
+ def initialize(options = {})
parse_options options
end
@@ -141,7 +141,7 @@ include Axlsx::SerializedAttributes
# @option [Integer] hour @see hour
# @option [Integer] minute @see minute
# @option [Integer] second @see second
- def initialize(options={})
+ def initialize(options = {})
raise ArgumentError, "You must specify a year for date time grouping" unless options[:year]
raise ArgumentError, "You must specify a date_time_grouping when creating a DateGroupItem for auto filter" unless options[:date_time_grouping]
parse_options options
diff --git a/lib/axlsx/workbook/worksheet/border_creator.rb b/lib/axlsx/workbook/worksheet/border_creator.rb
index 2dcbdf0f..0e2fa87b 100644
--- a/lib/axlsx/workbook/worksheet/border_creator.rb
+++ b/lib/axlsx/workbook/worksheet/border_creator.rb
@@ -13,7 +13,7 @@ module Axlsx
elsif [email protected]_a?(Array)
raise ArgumentError.new("Invalid edges provided, #{@edges}")
else
- @edges = @edges.map{|x| x&.to_sym}.uniq
+ @edges = @edges.map { |x| x&.to_sym }.uniq
if !(@edges - Axlsx::Border::EDGES).empty?
raise ArgumentError.new("Invalid edges provided, #{edges}")
@@ -26,7 +26,7 @@ module Axlsx
@worksheet.add_style(
first_cell,
{
- border: {style: @style, color: @color, edges: @edges}
+ border: { style: @style, color: @color, edges: @edges }
}
)
else
@@ -34,7 +34,7 @@ module Axlsx
@worksheet.add_style(
border_cells[edge],
{
- border: {style: @style, color: @color, edges: [edge]}
+ border: { style: @style, color: @color, edges: [edge] }
}
)
end
diff --git a/lib/axlsx/workbook/worksheet/break.rb b/lib/axlsx/workbook/worksheet/break.rb
index a9e5fb11..f8cc452e 100644
--- a/lib/axlsx/workbook/worksheet/break.rb
+++ b/lib/axlsx/workbook/worksheet/break.rb
@@ -13,7 +13,7 @@ module Axlsx
# @option options [Integer] max Zero-based index of end row or column of the break. For row breaks, specifies column index; for column breaks, specifies row index.
# @option options [Boolean] man Manual Break flag. 1 means the break is a manually inserted break.
# @option option [Boolean] pt Flag indicating that a PivotTable created this break.
- def initialize(options={})
+ def initialize(options = {})
parse_options options
yield self if block_given?
end
@@ -25,7 +25,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 725b1a39..a9685dac 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -289,7 +289,7 @@ module Axlsx
# @param [String] v The 8 character representation for an rgb color #FFFFFFFF"
def color=(v)
- @color = v.is_a?(Color) ? v : Color.new(:rgb=>v)
+ @color = v.is_a?(Color) ? v : Color.new(:rgb => v)
@is_text_run = true
end
@@ -342,7 +342,7 @@ module Axlsx
# @example Absolute Cell Reference
# ws.rows.first.cells.first.r #=> "$A$1"
def r_abs
- "$#{r.match(%r{([A-Z]+)([0-9]+)})[1,2].join('$')}"
+ "$#{r.match(%r{([A-Z]+)([0-9]+)})[1, 2].join('$')}"
end
# @return [Integer] The cellXfs item index applied to this cell.
@@ -395,7 +395,7 @@ module Axlsx
# @param [Boolean] absolute -when false a relative reference will be
# returned.
# @return [String]
- def reference(absolute=true)
+ def reference(absolute = true)
absolute ? r_abs : r
end
diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb
index b1ac8207..15113fcd 100644
--- a/lib/axlsx/workbook/worksheet/cell_serializer.rb
+++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb
@@ -7,7 +7,7 @@ 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='')
+ 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
@@ -21,7 +21,7 @@ module Axlsx
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] }]
+ data = Hash[Axlsx.instance_values_for(cell).map { |k, v| [k.to_sym, v] }]
data = data.select { |key, value| valid.include?(key) && !value.nil? }
RichText.new(cell.value.to_s, data).to_xml_string(str)
elsif cell.contains_rich_text?
@@ -36,7 +36,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
@@ -44,7 +44,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
@@ -52,7 +52,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
@@ -60,7 +60,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
@@ -68,7 +68,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
@@ -84,7 +84,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 formula_serialization(cell, str='')
+ 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
@@ -93,7 +93,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 array_formula_serialization(cell, str='')
+ 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
@@ -112,7 +112,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?
diff --git a/lib/axlsx/workbook/worksheet/cfvo.rb b/lib/axlsx/workbook/worksheet/cfvo.rb
index c9eb8d3d..773745f4 100644
--- a/lib/axlsx/workbook/worksheet/cfvo.rb
+++ b/lib/axlsx/workbook/worksheet/cfvo.rb
@@ -14,7 +14,7 @@ module Axlsx
# @option options [Symbol] type The type of conditional formatting value object
# @option options [Boolean] gte threshold value usage indicator
# @option options [String] val The value of the conditional formatting object
- def initialize(options={})
+ def initialize(options = {})
@gte = true
parse_options options
end
diff --git a/lib/axlsx/workbook/worksheet/cfvos.rb b/lib/axlsx/workbook/worksheet/cfvos.rb
index 2fc2e65a..44db4dfd 100644
--- a/lib/axlsx/workbook/worksheet/cfvos.rb
+++ b/lib/axlsx/workbook/worksheet/cfvos.rb
@@ -9,7 +9,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 6305b8c9..0b39024f 100644
--- a/lib/axlsx/workbook/worksheet/col.rb
+++ b/lib/axlsx/workbook/worksheet/col.rb
@@ -16,7 +16,7 @@ module Axlsx
# @option options [Boolean] phonetic see Col#phonetic
# @option options [Integer] style see Col#style
# @option options [Numeric] width see Col#width
- def initialize(min, max, options={})
+ def initialize(min, max, options = {})
Axlsx.validate_unsigned_int(max)
Axlsx.validate_unsigned_int(min)
@min = min
diff --git a/lib/axlsx/workbook/worksheet/col_breaks.rb b/lib/axlsx/workbook/worksheet/col_breaks.rb
index df7da37b..763e4268 100644
--- a/lib/axlsx/workbook/worksheet/col_breaks.rb
+++ b/lib/axlsx/workbook/worksheet/col_breaks.rb
@@ -23,7 +23,7 @@ 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 << '">')
each { |brk| brk.to_xml_string(str) }
diff --git a/lib/axlsx/workbook/worksheet/color_scale.rb b/lib/axlsx/workbook/worksheet/color_scale.rb
index 60b0e183..75877915 100644
--- a/lib/axlsx/workbook/worksheet/color_scale.rb
+++ b/lib/axlsx/workbook/worksheet/color_scale.rb
@@ -10,8 +10,8 @@ module Axlsx
# These are the default conditional formatting value objects
# that define a two tone color gradient.
def default_cfvos
- [{:type => :min, :val => 0, :color => 'FFFF7128'},
- {:type => :max, :val => 0, :color => 'FFFFEF9C'}]
+ [{ :type => :min, :val => 0, :color => 'FFFF7128' },
+ { :type => :max, :val => 0, :color => 'FFFFEF9C' }]
end
# A builder for two tone color gradient
@@ -29,9 +29,9 @@ module Axlsx
# color_scale = Axlsx::ColorScale.three_tone
# @see examples/example.rb conditional formatting examples.
def three_tone
- self.new({:type => :min, :val => 0, :color => 'FFF8696B'},
- {:type => :percent, :val => '50', :color => 'FFFFEB84'},
- {:type => :max, :val => 0, :color => 'FF63BE7B'})
+ self.new({ :type => :min, :val => 0, :color => 'FFF8696B' },
+ { :type => :percent, :val => '50', :color => 'FFFFEB84' },
+ { :type => :max, :val => 0, :color => 'FF63BE7B' })
end
end
# A simple typed list of cfvos
@@ -65,16 +65,16 @@ module Axlsx
# @option [Symbol] type The type of cfvo you to add
# @option [Any] val The value of the cfvo to add
# @option [String] The rgb color for the cfvo
- def add(options={})
+ def add(options = {})
value_objects << Cfvo.new(:type => options[:type] || :min, :val => options[:val] || 0)
colors << Color.new(:rgb => options[:color] || "FF000000")
- {:cfvo => value_objects.last, :color => colors.last}
+ { :cfvo => value_objects.last, :color => colors.last }
end
# removes the cfvo and color pair at the index specified.
# @param [Integer] index The index of the cfvo and color object to delete
# @note you cannot remove the first two cfvo and color pairs
- def delete_at(index=2)
+ def delete_at(index = 2)
value_objects.delete_at index
colors.delete_at index
end
diff --git a/lib/axlsx/workbook/worksheet/comment.rb b/lib/axlsx/workbook/worksheet/comment.rb
index 9efdb1f0..c2c94219 100644
--- a/lib/axlsx/workbook/worksheet/comment.rb
+++ b/lib/axlsx/workbook/worksheet/comment.rb
@@ -11,7 +11,7 @@ module Axlsx
# @option [String] text The text for the comment
# @option [String] ref The refence (e.g. 'A3' where this comment will be anchored.
# @option [Boolean] visible This controls the visiblity of the associated vml_shape.
- def initialize(comments, options={})
+ def initialize(comments, options = {})
raise ArgumentError, "A comment needs a parent comments object" unless comments.is_a?(Comments)
@visible = true
@comments = comments
diff --git a/lib/axlsx/workbook/worksheet/comments.rb b/lib/axlsx/workbook/worksheet/comments.rb
index 71a58c46..3ec2ba01 100644
--- a/lib/axlsx/workbook/worksheet/comments.rb
+++ b/lib/axlsx/workbook/worksheet/comments.rb
@@ -18,7 +18,7 @@ module Axlsx
# The part name for this object
# @return [String]
def pn
- "#{COMMENT_PN % (index+1)}"
+ "#{COMMENT_PN % (index + 1)}"
end
# Creates a new Comments object
@@ -35,7 +35,7 @@ module Axlsx
# @option options [String] author The name of the author for this comment
# @option options [String] text The text for this comment
# @option options [Stirng|Cell] ref The cell that this comment is attached to.
- def add_comment(options={})
+ def add_comment(options = {})
raise ArgumentError, "Comment require an author" unless options[:author]
raise ArgumentError, "Comment requires text" unless options[:text]
raise ArgumentError, "Comment requires ref" unless options[:ref]
@@ -60,7 +60,7 @@ 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>')
authors.each do |author|
diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting.rb b/lib/axlsx/workbook/worksheet/conditional_formatting.rb
index 2ff13682..c13113a5 100644
--- a/lib/axlsx/workbook/worksheet/conditional_formatting.rb
+++ b/lib/axlsx/workbook/worksheet/conditional_formatting.rb
@@ -10,7 +10,7 @@ module Axlsx
# Creates a new {ConditionalFormatting} object
# @option options [Array] rules The rules to apply
# @option options [String] sqref The range to apply the rules to
- def initialize(options={})
+ def initialize(options = {})
@rules = []
parse_options options
end
@@ -74,7 +74,7 @@ module Axlsx
# @return [String]
def to_xml_string(str = '')
str << ('<conditionalFormatting sqref="' << sqref << '">')
- str << rules.collect{ |rule| rule.to_xml_string }.join(' ')
+ str << rules.collect { |rule| rule.to_xml_string }.join(' ')
str << '</conditionalFormatting>'
end
end
diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb b/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb
index de1c4032..4f84080b 100644
--- a/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb
+++ b/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb
@@ -24,7 +24,7 @@ module Axlsx
# @option options [Boolean] stopIfTrue Stop evaluating rules after this rule matches
# @option options [Symbol] timePeriod The time period in a date occuring... rule
# @option options [String] formula The formula to match against in i.e. an equal rule. Use a [minimum, maximum] array for cellIs between/notBetween conditionals.
- def initialize(options={})
+ def initialize(options = {})
@color_scale = @data_bar = @icon_set = @formula = nil
parse_options options
end
@@ -179,7 +179,7 @@ module Axlsx
# @see timePeriod
def timePeriod=(v); Axlsx::validate_time_period_type(v); @timePeriod = v end
# @see formula
- def formula=(v); [*v].each {|x| Axlsx::validate_string(x) }; @formula = [*v].map { |form| ::CGI.escapeHTML(form) } end
+ def formula=(v); [*v].each { |x| Axlsx::validate_string(x) }; @formula = [*v].map { |form| ::CGI.escapeHTML(form) } end
# @see color_scale
def color_scale=(v)
diff --git a/lib/axlsx/workbook/worksheet/data_bar.rb b/lib/axlsx/workbook/worksheet/data_bar.rb
index c89c421d..1ff65fd5 100644
--- a/lib/axlsx/workbook/worksheet/data_bar.rb
+++ b/lib/axlsx/workbook/worksheet/data_bar.rb
@@ -12,8 +12,8 @@ module Axlsx
class << self
# This differs from ColorScale. There must be exactly two cfvos one color
def default_cfvos
- [{:type => :min, :val => "0"},
- {:type => :max, :val => "0"}]
+ [{ :type => :min, :val => "0" },
+ { :type => :max, :val => "0" }]
end
end
@@ -105,7 +105,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 d4b86e20..741dee86 100644
--- a/lib/axlsx/workbook/worksheet/data_validation.rb
+++ b/lib/axlsx/workbook/worksheet/data_validation.rb
@@ -22,7 +22,7 @@ module Axlsx
# @option options [Boolean] showInputMessage - A boolean value indicating whether to display the input prompt message.
# @option options [String] sqref - Range over which data validation is applied, in "A1:B2" format.
# @option options [Symbol] type - The type of data validation.
- def initialize(options={})
+ def initialize(options = {})
# defaults
@formula1 = @formula2 = @error = @errorTitle = @operator = @prompt = @promptTitle = @sqref = nil
@allowBlank = @showErrorMessage = true
diff --git a/lib/axlsx/workbook/worksheet/date_time_converter.rb b/lib/axlsx/workbook/worksheet/date_time_converter.rb
index 48d69d94..ff85c64f 100644
--- a/lib/axlsx/workbook/worksheet/date_time_converter.rb
+++ b/lib/axlsx/workbook/worksheet/date_time_converter.rb
@@ -22,7 +22,7 @@ module Axlsx
epoch1904 = -2082844800.0 # Time.utc(1904, 1, 1).to_i
seconds_per_day = 86400.0 # 60*60*24
epoch = Axlsx::Workbook::date1904 ? epoch1904 : epoch1900
- (time.utc_offset + time.to_f - epoch)/seconds_per_day
+ (time.utc_offset + time.to_f - epoch) / seconds_per_day
end
end
end
diff --git a/lib/axlsx/workbook/worksheet/icon_set.rb b/lib/axlsx/workbook/worksheet/icon_set.rb
index 0042e757..4e7064e9 100644
--- a/lib/axlsx/workbook/worksheet/icon_set.rb
+++ b/lib/axlsx/workbook/worksheet/icon_set.rb
@@ -61,7 +61,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/page_margins.rb b/lib/axlsx/workbook/worksheet/page_margins.rb
index 2dec65e6..de0d099b 100644
--- a/lib/axlsx/workbook/worksheet/page_margins.rb
+++ b/lib/axlsx/workbook/worksheet/page_margins.rb
@@ -19,7 +19,7 @@ module Axlsx
# @option options [Numeric] top The top margin in inches
# @option options [Numeric] header The header margin in inches
# @option options [Numeric] footer The footer margin in inches
- def initialize(options={})
+ def initialize(options = {})
# Default values taken from MS Excel for Mac 2011
@left = @right = DEFAULT_LEFT_RIGHT
@top = @bottom = DEFAULT_TOP_BOTTOM
diff --git a/lib/axlsx/workbook/worksheet/page_set_up_pr.rb b/lib/axlsx/workbook/worksheet/page_set_up_pr.rb
index 2242f2bc..819c5fa7 100644
--- a/lib/axlsx/workbook/worksheet/page_set_up_pr.rb
+++ b/lib/axlsx/workbook/worksheet/page_set_up_pr.rb
@@ -35,7 +35,7 @@ module Axlsx
end
# serialize to xml
- def to_xml_string(str='')
+ def to_xml_string(str = '')
str << ('<pageSetUpPr ' << serialized_attributes << '/>')
end
end
diff --git a/lib/axlsx/workbook/worksheet/page_setup.rb b/lib/axlsx/workbook/worksheet/page_setup.rb
index 6281eb74..07dd6817 100644
--- a/lib/axlsx/workbook/worksheet/page_setup.rb
+++ b/lib/axlsx/workbook/worksheet/page_setup.rb
@@ -213,7 +213,7 @@ module Axlsx
# @note This method will overwrite any value you explicitly set via the fit_to_height or fit_to_width methods.
# @option options [Integer] width The number of pages to fit this worksheet on horizontally. Default 999
# @option options [Integer] height The number of pages to fit this worksheet on vertically. Default 999
- def fit_to(options={})
+ def fit_to(options = {})
self.fit_to_width = options[:width] || 999
self.fit_to_height = options[:height] || 999
[@fit_to_width, @fit_to_height]
diff --git a/lib/axlsx/workbook/worksheet/pane.rb b/lib/axlsx/workbook/worksheet/pane.rb
index 9acfa14b..f9323d3e 100644
--- a/lib/axlsx/workbook/worksheet/pane.rb
+++ b/lib/axlsx/workbook/worksheet/pane.rb
@@ -12,7 +12,7 @@ module Axlsx
# @option options [Cell, String] top_left_cell Top Left Visible Cell
# @option options [Integer] x_split Horizontal Split Position
# @option options [Integer] y_split Vertical Split Position
- def initialize(options={})
+ def initialize(options = {})
#defaults
@active_pane = @state = @top_left_cell = nil
@x_split = @y_split = 0
@@ -131,7 +131,7 @@ module Axlsx
if @state == 'frozen' && @top_left_cell.nil?
row = @y_split || 0
column = @x_split || 0
- @top_left_cell = "#{('A'..'ZZ').to_a[column]}#{row+1}"
+ @top_left_cell = "#{('A'..'ZZ').to_a[column]}#{row + 1}"
end
end
end
diff --git a/lib/axlsx/workbook/worksheet/pivot_table.rb b/lib/axlsx/workbook/worksheet/pivot_table.rb
index ed51d5cf..ff131dfb 100644
--- a/lib/axlsx/workbook/worksheet/pivot_table.rb
+++ b/lib/axlsx/workbook/worksheet/pivot_table.rb
@@ -11,12 +11,12 @@ module Axlsx
# @param [Worksheet] sheet The sheet containing the table data.
# @option options [Cell, String] name
# @option options [TableStyle] style
- def initialize(ref, range, sheet, options={})
+ def initialize(ref, range, sheet, options = {})
@ref = ref
self.range = range
@sheet = sheet
@sheet.workbook.pivot_tables << self
- @name = "PivotTable#{index+1}"
+ @name = "PivotTable#{index + 1}"
@data_sheet = nil
@rows = []
@columns = []
@@ -122,7 +122,7 @@ module Axlsx
@data = []
v.each do |data_field|
if data_field.is_a? String
- data_field = {:ref => data_field}
+ data_field = { :ref => data_field }
end
data_field.each do |key, value|
if key == :num_fmt
@@ -158,13 +158,13 @@ module Axlsx
# The part name for this table
# @return [String]
def pn
- "#{PIVOT_TABLE_PN % (index+1)}"
+ "#{PIVOT_TABLE_PN % (index + 1)}"
end
# The relationship part name of this pivot table
# @return [String]
def rels_pn
- "#{PIVOT_TABLE_RELS_PN % (index+1)}"
+ "#{PIVOT_TABLE_RELS_PN % (index + 1)}"
end
# The cache_definition for this pivot table
@@ -219,7 +219,7 @@ module Axlsx
str << '<colFields count="1"><field x="-2"/></colFields>'
str << "<colItems count=\"#{data.size}\">"
str << '<i><x/></i>'
- data[1..-1].each_with_index do |datum_value,i|
+ data[1..-1].each_with_index do |datum_value, i|
str << "<i i=\"#{i + 1}\"><x v=\"#{i + 1}\"/></i>"
end
str << '</colItems>'
@@ -244,7 +244,7 @@ module Axlsx
str << "<dataFields count=\"#{data.size}\">"
data.each do |datum_value|
# The correct name prefix in ["Sum","Average", etc...]
- str << "<dataField name='#{(datum_value[:subtotal]||'')} of #{datum_value[:ref]}' fld='#{header_index_of(datum_value[:ref])}' baseField='0' baseItem='0'"
+ str << "<dataField name='#{(datum_value[:subtotal] || '')} of #{datum_value[:ref]}' fld='#{header_index_of(datum_value[:ref])}' baseField='0' baseItem='0'"
str << " numFmtId='#{datum_value[:num_fmt]}'" if datum_value[:num_fmt]
str << " subtotal='#{datum_value[:subtotal]}' " if datum_value[:subtotal]
str << "/>"
@@ -254,7 +254,7 @@ module Axlsx
# custom pivot table style
unless style_info.empty?
str << '<pivotTableStyleInfo'
- style_info.each do |k,v|
+ style_info.each do |k, v|
str << ' ' << k.to_s << '="' << v.to_s << '"'
end
str << ' />'
diff --git a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb
index 2c7c05e4..8813c84b 100644
--- a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb
+++ b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb
@@ -24,7 +24,7 @@ module Axlsx
# The part name for this table
# @return [String]
def pn
- "#{PIVOT_TABLE_CACHE_DEFINITION_PN % (index+1)}"
+ "#{PIVOT_TABLE_CACHE_DEFINITION_PN % (index + 1)}"
end
# The identifier for this cache
@@ -46,17 +46,17 @@ module Axlsx
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 << '<cacheSource type="worksheet">'
- 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 << '<cacheSource type="worksheet">'
+ str << ('<worksheetSource ref="' << pivot_table.range << '" sheet="' << pivot_table.data_sheet.name << '"/>')
+ str << '</cacheSource>'
+ 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>'
+ str << '</cacheField>'
end
- str << '</cacheFields>'
+ str << '</cacheFields>'
str << '</pivotCacheDefinition>'
end
end
diff --git a/lib/axlsx/workbook/worksheet/pivot_tables.rb b/lib/axlsx/workbook/worksheet/pivot_tables.rb
index 8aaebea2..018fc6a7 100644
--- a/lib/axlsx/workbook/worksheet/pivot_tables.rb
+++ b/lib/axlsx/workbook/worksheet/pivot_tables.rb
@@ -15,7 +15,7 @@ module Axlsx
# returns the relationships required by this collection
def relationships
return [] if empty?
- map{ |pivot_table| Relationship.new(pivot_table, PIVOT_TABLE_R, "../#{pivot_table.pn}") }
+ map { |pivot_table| Relationship.new(pivot_table, PIVOT_TABLE_R, "../#{pivot_table.pn}") }
end
end
end
diff --git a/lib/axlsx/workbook/worksheet/protected_range.rb b/lib/axlsx/workbook/worksheet/protected_range.rb
index 07f9a20c..e4eb83e5 100644
--- a/lib/axlsx/workbook/worksheet/protected_range.rb
+++ b/lib/axlsx/workbook/worksheet/protected_range.rb
@@ -9,7 +9,7 @@ module Axlsx
# Initializes a new protected range object
# @option [String] sqref The cell range reference to protect. This can be an absolute or a relateve range however, it only applies to the current sheet.
# @option [String] name An optional name for the protected name.
- def initialize(options={})
+ def initialize(options = {})
parse_options options
yield self if block_given?
end
@@ -39,7 +39,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/rich_text.rb b/lib/axlsx/workbook/worksheet/rich_text.rb
index e5156047..4b643470 100644
--- a/lib/axlsx/workbook/worksheet/rich_text.rb
+++ b/lib/axlsx/workbook/worksheet/rich_text.rb
@@ -5,7 +5,7 @@ module Axlsx
# @param [String] text -optional The text to use in creating the first RichTextRun
# @param [Object] options -optional The options to use in creating the first RichTextRun
# @yield [RichText] self
- def initialize(text = nil, options={})
+ def initialize(text = nil, options = {})
super(RichTextRun)
add_run(text, options) unless text.nil?
yield self if block_given?
@@ -32,7 +32,7 @@ module Axlsx
# Creates and adds a RichTextRun to this collectino
# @param [String] text The text to use in creating a new RichTextRun
# @param [Object] options The options to use in creating the new RichTextRun
- def add_run(text, options={})
+ def add_run(text, options = {})
self << RichTextRun.new(text, options)
end
@@ -45,8 +45,8 @@ module Axlsx
# renders the RichTextRuns in this collection
# @param [String] str
# @return [String]
- def to_xml_string(str='')
- each{ |run| run.to_xml_string(str) }
+ def to_xml_string(str = '')
+ each { |run| run.to_xml_string(str) }
str
end
end
diff --git a/lib/axlsx/workbook/worksheet/rich_text_run.rb b/lib/axlsx/workbook/worksheet/rich_text_run.rb
index 44046709..368b10ce 100644
--- a/lib/axlsx/workbook/worksheet/rich_text_run.rb
+++ b/lib/axlsx/workbook/worksheet/rich_text_run.rb
@@ -11,7 +11,7 @@ module Axlsx
:shadow, :condense, :extend, :u,
:vertAlign, :sz, :color, :scheme].freeze
- def initialize(value, options={})
+ def initialize(value, options = {})
self.value = value
parse_options(options)
end
@@ -138,7 +138,7 @@ module Axlsx
# @param [String] v The 8 character representation for an rgb color #FFFFFFFF"
def color=(v)
- @color = v.is_a?(Color) ? v : Color.new(:rgb=>v)
+ @color = v.is_a?(Color) ? v : Color.new(:rgb => v)
end
# The inline sz property for the cell
@@ -203,7 +203,7 @@ module Axlsx
# @return [String]
def to_xml_string(str = '')
valid = RichTextRun::INLINE_STYLES
- data = Hash[Axlsx.instance_values_for(self).map{ |k, v| [k.to_sym, v] }]
+ data = Hash[Axlsx.instance_values_for(self).map { |k, v| [k.to_sym, v] }]
data = data.select { |key, value| valid.include?(key) && !value.nil? }
str << '<r><rPr>'
diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb
index fc044124..453e1e66 100644
--- a/lib/axlsx/workbook/worksheet/row.rb
+++ b/lib/axlsx/workbook/worksheet/row.rb
@@ -27,7 +27,7 @@ module Axlsx
# @option options [Integer] offset - add empty columns before values
# @see Row#array_to_cells
# @see Cell
- def initialize(worksheet, values=[], options={})
+ def initialize(worksheet, values = [], options = {})
self.worksheet = worksheet
super(Cell, nil, values.size + options[:offset].to_i)
self.height = options.delete(:height)
@@ -134,7 +134,7 @@ module Axlsx
private
# assigns the owning worksheet for this row
- def worksheet=(v) DataTypeValidator.validate :row_worksheet, Worksheet, v; @worksheet=v; end
+ def worksheet=(v) DataTypeValidator.validate :row_worksheet, Worksheet, v; @worksheet = v; end
# Converts values, types, and style options into cells and associates them with this row.
# A new cell is created for each item in the values array.
@@ -145,7 +145,7 @@ module Axlsx
# @option options [Array] values
# @option options [Array, Symbol] types
# @option options [Array, Integer] style
- def array_to_cells(values, options={})
+ def array_to_cells(values, options = {})
DataTypeValidator.validate :array_to_cells, Array, values
types, style, formula_values, escape_formulas, offset = options.delete(:types), options.delete(:style), options.delete(:formula_values), options.delete(:escape_formulas), options.delete(:offset)
offset.to_i.times { |index| self[index] = Cell.new(self) } if offset
diff --git a/lib/axlsx/workbook/worksheet/row_breaks.rb b/lib/axlsx/workbook/worksheet/row_breaks.rb
index e4cbf4f2..b05e0587 100644
--- a/lib/axlsx/workbook/worksheet/row_breaks.rb
+++ b/lib/axlsx/workbook/worksheet/row_breaks.rb
@@ -21,7 +21,7 @@ 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 << '">')
each { |brk| brk.to_xml_string(str) }
diff --git a/lib/axlsx/workbook/worksheet/selection.rb b/lib/axlsx/workbook/worksheet/selection.rb
index efa56056..82538fce 100644
--- a/lib/axlsx/workbook/worksheet/selection.rb
+++ b/lib/axlsx/workbook/worksheet/selection.rb
@@ -12,7 +12,7 @@ module Axlsx
# @option options [Integer] active_cell_id Active Cell Index
# @option options [Symbol] pane Pane
# @option options [String] sqref Sequence of References
- def initialize(options={})
+ def initialize(options = {})
@active_cell = @active_cell_id = @pane = @sqref = nil
parse_options options
end
diff --git a/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb b/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb
index b42ecb31..58f630d4 100644
--- a/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb
+++ b/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb
@@ -8,7 +8,7 @@ module Axlsx
# creates a new SheetCalcPr
# @param [Hash] options Options for this object
# @option [Boolean] full_calc_on_load @see full_calc_on_load
- def initialize(options={})
+ def initialize(options = {})
@full_calc_on_load = true
parse_options options
end
@@ -21,7 +21,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_format_pr.rb b/lib/axlsx/workbook/worksheet/sheet_format_pr.rb
index de4c6e16..5e06ca5b 100644
--- a/lib/axlsx/workbook/worksheet/sheet_format_pr.rb
+++ b/lib/axlsx/workbook/worksheet/sheet_format_pr.rb
@@ -28,7 +28,7 @@ module Axlsx
# @option [Boolean] thick_bottom 'True' if rows have a thick bottom border by default.
# @option [Integer] outline_level_row Highest number of outline level for rows in this sheet. These values shall be in synch with the actual sheet outline levels.
# @option [Integer] outline_level_col Highest number of outline levels for columns in this sheet. These values shall be in synch with the actual sheet outline levels.
- def initialize(options={})
+ def initialize(options = {})
set_defaults
parse_options options
end
@@ -46,7 +46,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 6f76b580..a870e4a3 100644
--- a/lib/axlsx/workbook/worksheet/sheet_pr.rb
+++ b/lib/axlsx/workbook/worksheet/sheet_pr.rb
@@ -29,7 +29,7 @@ module Axlsx
# Creates a new SheetPr object
# @param [Worksheet] worksheet The worksheet that owns this SheetPr object
- def initialize(worksheet, options={})
+ def initialize(worksheet, options = {})
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
@worksheet = worksheet
@outline_pr = nil
diff --git a/lib/axlsx/workbook/worksheet/sheet_protection.rb b/lib/axlsx/workbook/worksheet/sheet_protection.rb
index c921d381..3ca17737 100644
--- a/lib/axlsx/workbook/worksheet/sheet_protection.rb
+++ b/lib/axlsx/workbook/worksheet/sheet_protection.rb
@@ -23,7 +23,7 @@ module Axlsx
# @option options [Boolean] pivot_tables @see SheetProtection#pivot_tables
# @option options [Boolean] select_unlocked_cells @see SheetProtection#select_unlocked_cells
# @option options [String] password. The password required for unlocking. @see SheetProtection#password=
- def initialize(options={})
+ def initialize(options = {})
@objects = @scenarios = @select_locked_cells = @select_unlocked_cells = false
@sheet = @format_cells = @format_rows = @format_columns = @insert_columns = @insert_rows = @insert_hyperlinks = @delete_columns = @delete_rows = @sort = @auto_filter = @pivot_tables = true
@password = nil
@@ -107,7 +107,7 @@ module Axlsx
char = low_15 | high_15
end
- encoded_password = 0x0000
+ encoded_password = 0x0000
chars.each { |c| encoded_password ^= c }
encoded_password ^= count
encoded_password ^= 0xCE4B
diff --git a/lib/axlsx/workbook/worksheet/sheet_view.rb b/lib/axlsx/workbook/worksheet/sheet_view.rb
index 17a547ea..ab66f800 100644
--- a/lib/axlsx/workbook/worksheet/sheet_view.rb
+++ b/lib/axlsx/workbook/worksheet/sheet_view.rb
@@ -28,7 +28,7 @@ module Axlsx
# @option options [Integer] zoom_scale_normal Zoom Scale Normal View
# @option options [Integer] zoom_scale_page_layout_view Zoom Scale Page Layout View
# @option options [Integer] zoom_scale_sheet_layout_view Zoom Scale Page Break Preview
- def initialize(options={})
+ def initialize(options = {})
#defaults
@color_id = @top_left_cell = @pane = nil
@right_to_left = @show_formulas = @show_outline_symbols = @show_white_space = @tab_selected = @window_protection = false
diff --git a/lib/axlsx/workbook/worksheet/table.rb b/lib/axlsx/workbook/worksheet/table.rb
index 5053c5fd..4f446491 100644
--- a/lib/axlsx/workbook/worksheet/table.rb
+++ b/lib/axlsx/workbook/worksheet/table.rb
@@ -10,13 +10,13 @@ module Axlsx
# @param [Worksheet] sheet The sheet containing the table data.
# @option options [Cell, String] name
# @option options [TableStyle] style
- def initialize(ref, sheet, options={})
+ def initialize(ref, sheet, options = {})
@ref = ref
@sheet = sheet
@style = nil
@sheet.workbook.tables << self
@table_style_info = TableStyleInfo.new(options[:style_info]) if options[:style_info]
- @name = "Table#{index+1}"
+ @name = "Table#{index + 1}"
parse_options options
yield self if block_given?
end
@@ -42,7 +42,7 @@ module Axlsx
# The part name for this table
# @return [String]
def pn
- "#{TABLE_PN % (index+1)}"
+ "#{TABLE_PN % (index + 1)}"
end
# The relationship id for this table.
@@ -73,12 +73,12 @@ module Axlsx
# @return [String]
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 << ('<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 << '"/>')
+ header_cells.each_with_index do |cell, index|
+ 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/tables.rb b/lib/axlsx/workbook/worksheet/tables.rb
index bf6efe0c..69e59fe5 100644
--- a/lib/axlsx/workbook/worksheet/tables.rb
+++ b/lib/axlsx/workbook/worksheet/tables.rb
@@ -15,7 +15,7 @@ module Axlsx
# returns the relationships required by this collection
def relationships
return [] if empty?
- map{ |table| Relationship.new(table, TABLE_R, "../#{table.pn}") }
+ map { |table| Relationship.new(table, TABLE_R, "../#{table.pn}") }
end
# renders the tables xml
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb
index c3960af3..18daaeeb 100644
--- a/lib/axlsx/workbook/worksheet/worksheet.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet.rb
@@ -14,7 +14,7 @@ module Axlsx
# @option options [Hash] print_options A hash containing print options for this worksheet. @see PrintOptions
# @option options [Hash] header_footer A hash containing header/footer options for this worksheet. @see HeaderFooter
# @option options [Boolean] show_gridlines indicates if gridlines should be shown for this sheet.
- def initialize(wb, options={})
+ def initialize(wb, options = {})
self.workbook = wb
@sheet_protection = nil
initialize_page_options(options)
@@ -40,7 +40,7 @@ module Axlsx
# The name of the worksheet
# @return [String]
def name
- @name ||= "Sheet" + (index+1).to_s
+ @name ||= "Sheet" + (index + 1).to_s
end
# Specifies the visible state of this sheet. Allowed states are
@@ -99,13 +99,13 @@ module Axlsx
# The tables in this worksheet
# @return [Array] of Table
def tables
- @tables ||= Tables.new self
+ @tables ||= Tables.new self
end
# The pivot tables in this worksheet
# @return [Array] of Table
def pivot_tables
- @pivot_tables ||= PivotTables.new self
+ @pivot_tables ||= PivotTables.new self
end
# A collection of column breaks added to this worksheet
@@ -307,7 +307,7 @@ module Axlsx
# @param [String] name
def name=(name)
validate_sheet_name name
- @name=Axlsx::coder.encode(name)
+ @name = Axlsx::coder.encode(name)
end
# The auto filter range for the worksheet
@@ -325,13 +325,13 @@ module Axlsx
# The part name of this worksheet
# @return [String]
def pn
- "#{WORKSHEET_PN % (index+1)}"
+ "#{WORKSHEET_PN % (index + 1)}"
end
# The relationship part name of this worksheet
# @return [String]
def rels_pn
- "#{WORKSHEET_RELS_PN % (index+1)}"
+ "#{WORKSHEET_RELS_PN % (index + 1)}"
end
# The relationship id of this worksheet.
@@ -408,7 +408,7 @@ module Axlsx
# sign as formula (default) or as simple string.
# Allowing user generated data to be interpreted as formulas can be dangerous
# (see https://www.owasp.org/index.php/CSV_Injection for details).
- def add_row(values=[], options={})
+ def add_row(values = [], options = {})
row = Row.new(self, values, options)
update_column_info row, options.delete(:widths)
yield row if block_given?
@@ -428,7 +428,7 @@ module Axlsx
# @see ConditionalFormattingRule#initialize
# @see file:examples/example_conditional_formatting.rb
def add_conditional_formatting(cells, rules)
- cf = ConditionalFormatting.new( :sqref => cells )
+ cf = ConditionalFormatting.new(:sqref => cells)
cf.add_rules rules
conditional_formattings << cf
conditional_formattings
@@ -449,7 +449,7 @@ module Axlsx
# @param [Hash] options for the hyperlink
# @see WorksheetHyperlink for a list of options
# @return [WorksheetHyperlink]
- def add_hyperlink(options={})
+ def add_hyperlink(options = {})
hyperlinks.add(options)
end
@@ -466,33 +466,33 @@ module Axlsx
# @see Bar3DChart
# @see Line3DChart
# @see README for examples
- def add_chart(chart_type, options={})
+ def add_chart(chart_type, options = {})
chart = worksheet_drawing.add_chart(chart_type, options)
yield chart if block_given?
chart
end
# needs documentation
- def add_table(ref, options={})
+ def add_table(ref, options = {})
tables << Table.new(ref, self, options)
yield tables.last if block_given?
tables.last
end
- def add_pivot_table(ref, range, options={})
+ def add_pivot_table(ref, range, options = {})
pivot_tables << PivotTable.new(ref, range, self, options)
yield pivot_tables.last if block_given?
pivot_tables.last
end
# Shortcut to worsksheet_comments#add_comment
- def add_comment(options={})
+ def add_comment(options = {})
worksheet_comments.add_comment(options)
end
# Adds a media item to the worksheets drawing
# @option [Hash] options options passed to drawing.add_image
- def add_image(options={})
+ def add_image(options = {})
image = worksheet_drawing.add_image(options)
yield image if block_given?
image
@@ -539,7 +539,7 @@ module Axlsx
# @note You can also specify the style for specific columns in the call to add_row by using an array for the :styles option
# @see Worksheet#add_row
# @see README.md for an example
- def col_style(index, style, options={})
+ def col_style(index, style, options = {})
offset = options.delete(:row_offset) || 0
cells = @rows[(offset..-1)].map { |row| row[index] }.flatten.compact
cells.each { |cell| cell.style = style }
@@ -553,7 +553,7 @@ module Axlsx
# @note You can also specify the style in the add_row call
# @see Worksheet#add_row
# @see README.md for an example
- def row_style(index, style, options={})
+ def row_style(index, style, options = {})
offset = options.delete(:col_offset) || 0
cells = cols[(offset..-1)].map { |column| column[index] }.flatten.compact
cells.each { |cell| cell.style = style }
@@ -583,7 +583,7 @@ module Axlsx
# Set the style for cells in a specific column
# @param [String|Array] cell references
# @param [Hash|Array|Symbol] border options
- def add_border(cell_refs, options=nil)
+ def add_border(cell_refs, options = nil)
if options.is_a?(Hash)
border_edges = options[:edges]
border_style = options[:style]
@@ -606,7 +606,7 @@ 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
@@ -617,7 +617,7 @@ module Axlsx
# 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"?>'
@@ -646,7 +646,7 @@ module Axlsx
def [](cell_def)
return rows[cell_def] if cell_def.is_a?(Integer)
- parts = cell_def.split(':').map{ |part| name_to_cell part }
+ parts = cell_def.split(':').map { |part| name_to_cell part }
if parts.size == 1
parts.first
diff --git a/lib/axlsx/workbook/worksheet/worksheet_comments.rb b/lib/axlsx/workbook/worksheet/worksheet_comments.rb
index d8aed8e0..c40587ae 100644
--- a/lib/axlsx/workbook/worksheet/worksheet_comments.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet_comments.rb
@@ -20,7 +20,7 @@ module Axlsx
# Adds a comment
# @param [Hash] options
# @see Comments#add_comment
- def add_comment(options={})
+ def add_comment(options = {})
comments.add_comment(options)
end
@@ -41,7 +41,7 @@ module Axlsx
# @see Relationship#Id
# @return [String]
def drawing_rId
- comments.relationships.find{ |r| r.Type == VML_DRAWING_R }.Id
+ comments.relationships.find { |r| r.Type == VML_DRAWING_R }.Id
end
# Seraalize the object
diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb
index f79bc814..bda87995 100644
--- a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb
@@ -13,7 +13,7 @@ module Axlsx
# @option [String] tooltip The tip to display when the user positions the mouse cursor over this hyperlink
# @option [Symbol] target This is :external by default. If you set it to anything else, the location is interpreted to be the current workbook.
# @option [String|Cell] ref The location of this hyperlink in the worksheet
- def initialize(worksheet, options={})
+ def initialize(worksheet, options = {})
DataTypeValidator.validate "Hyperlink.worksheet", [Worksheet], worksheet
@worksheet = worksheet
@target = :external
@@ -55,7 +55,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 << '/>'
@@ -66,7 +66,7 @@ module Axlsx
# r:id should only be specified for external targets.
# @return [Hash]
def location_or_id
- @target == :external ? { :"r:id" => relationship.Id } : { :location => Axlsx::coder.encode(location) }
+ @target == :external ? { :"r:id" => relationship.Id } : { :location => Axlsx::coder.encode(location) }
end
end
end
diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb
index 5d5a2186..5c49fdb3 100644
--- a/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb
@@ -26,7 +26,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>'
each { |hyperlink| hyperlink.to_xml_string(str) }
diff --git a/test/benchmark.rb b/test/benchmark.rb
index e9f6c22b..3c0ebc95 100644
--- a/test/benchmark.rb
+++ b/test/benchmark.rb
@@ -6,7 +6,7 @@ require 'benchmark'
Axlsx::trust_input = true
row = []
input = (32..126).to_a.pack('U*').chars.to_a
-20.times { row << input.shuffle.join}
+20.times { row << input.shuffle.join }
times = 3000
Benchmark.bmbm(30) do |x|
x.report('axlsx_noautowidth') {
diff --git a/test/content_type/tc_content_type.rb b/test/content_type/tc_content_type.rb
index 278cd67b..f06554c8 100644
--- a/test/content_type/tc_content_type.rb
+++ b/test/content_type/tc_content_type.rb
@@ -8,7 +8,7 @@ class TestContentType < Test::Unit::TestCase
def test_valid_document
schema = Nokogiri::XML::Schema(File.open(Axlsx::CONTENT_TYPES_XSD))
- assert(schema.validate(@doc).map{ |e| puts e.message; e.message }.empty?)
+ assert(schema.validate(@doc).map { |e| puts e.message; e.message }.empty?)
end
def test_pre_built_types
@@ -22,7 +22,7 @@ class TestContentType < Test::Unit::TestCase
assert_equal(node["Extension"], "#{Axlsx::XML_EX}", "xml content type invalid")
node = @doc.xpath(d_path % Axlsx::RELS_CT).first
- assert_equal(node["Extension"],"#{Axlsx::RELS_EX}", "relationships content type invalid")
+ assert_equal(node["Extension"], "#{Axlsx::RELS_EX}", "relationships content type invalid")
#overrride
assert_equal(@doc.xpath("//xmlns:Override").size, 4, "There should be 4 Override types")
diff --git a/test/content_type/tc_default.rb b/test/content_type/tc_default.rb
index 77915ea0..096a117a 100644
--- a/test/content_type/tc_default.rb
+++ b/test/content_type/tc_default.rb
@@ -2,11 +2,11 @@ require 'tc_helper.rb'
class TestDefault < Test::Unit::TestCase
def test_content_type_restriction
- assert_raise(ArgumentError, "raises argument error if invlalid ContentType is") { Axlsx::Default.new :ContentType=>"asdf" }
+ assert_raise(ArgumentError, "raises argument error if invlalid ContentType is") { Axlsx::Default.new :ContentType => "asdf" }
end
def test_to_xml_string
- type = Axlsx::Default.new :Extension=>"xml", :ContentType=>Axlsx::XML_CT
+ type = Axlsx::Default.new :Extension => "xml", :ContentType => Axlsx::XML_CT
doc = Nokogiri::XML(type.to_xml_string)
assert_equal(doc.xpath("Default[@ContentType='#{Axlsx::XML_CT}']").size, 1)
assert_equal(doc.xpath("Default[@Extension='xml']").size, 1)
diff --git a/test/content_type/tc_override.rb b/test/content_type/tc_override.rb
index c21f9f27..952f40d8 100644
--- a/test/content_type/tc_override.rb
+++ b/test/content_type/tc_override.rb
@@ -1,11 +1,11 @@
require 'tc_helper.rb'
class TestOverride < Test::Unit::TestCase
def test_content_type_restriction
- assert_raise(ArgumentError, "requires known content type") { Axlsx::Override.new :ContentType=>"asdf" }
+ assert_raise(ArgumentError, "requires known content type") { Axlsx::Override.new :ContentType => "asdf" }
end
def test_to_xml
- type = Axlsx::Override.new :PartName=>"somechart.xml", :ContentType=>Axlsx::CHART_CT
+ type = Axlsx::Override.new :PartName => "somechart.xml", :ContentType => Axlsx::CHART_CT
doc = Nokogiri::XML(type.to_xml_string)
assert_equal(doc.xpath("Override[@ContentType='#{Axlsx::CHART_CT}']").size, 1)
assert_equal(doc.xpath("Override[@PartName='somechart.xml']").size, 1)
diff --git a/test/doc_props/tc_app.rb b/test/doc_props/tc_app.rb
index 7718a6c2..a7124be1 100644
--- a/test/doc_props/tc_app.rb
+++ b/test/doc_props/tc_app.rb
@@ -38,6 +38,6 @@ class TestApp < Test::Unit::TestCase
schema.validate(doc).each do |error|
errors << error
end
- assert_equal(errors.size, 0, "app.xml invalid" + errors.map{ |e| e.message }.to_s)
+ assert_equal(errors.size, 0, "app.xml invalid" + errors.map { |e| e.message }.to_s)
end
end
diff --git a/test/doc_props/tc_core.rb b/test/doc_props/tc_core.rb
index 6ba01b5f..b225266a 100644
--- a/test/doc_props/tc_core.rb
+++ b/test/doc_props/tc_core.rb
@@ -15,7 +15,7 @@ class TestCore < Test::Unit::TestCase
puts error.message
errors << error
end
- assert_equal(errors.size, 0, "core.xml Invalid" + errors.map{ |e| e.message }.to_s)
+ assert_equal(errors.size, 0, "core.xml Invalid" + errors.map { |e| e.message }.to_s)
end
def test_populates_created
diff --git a/test/drawing/tc_area_series.rb b/test/drawing/tc_area_series.rb
index efe48256..250c6e13 100644
--- a/test/drawing/tc_area_series.rb
+++ b/test/drawing/tc_area_series.rb
@@ -3,10 +3,10 @@ require 'tc_helper.rb'
class TestAreaSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
+ @ws = p.workbook.add_worksheet :name => "hmmm"
chart = @ws.add_chart Axlsx::AreaChart, :title => "fishery"
@series = chart.add_series(
- :data => [0,1,2],
+ :data => [0, 1, 2],
:labels => ["zero", "one", "two"],
:title => "bob",
:color => "#FF0000",
diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb
index b8be916b..52a066be 100644
--- a/test/drawing/tc_axis.rb
+++ b/test/drawing/tc_axis.rb
@@ -17,7 +17,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))
assert(doc.xpath("//a:srgbClr[@val='00FF00']"))
@@ -25,7 +25,7 @@ class TestAxis < Test::Unit::TestCase
def test_cell_based_axis_title
p = Axlsx::Package.new
- p.workbook.add_worksheet(:name=>'foosheet') do |sheet|
+ p.workbook.add_worksheet(:name => 'foosheet') do |sheet|
sheet.add_row ['battle victories']
sheet.add_row ['bird', 1, 2, 1]
sheet.add_row ['cat', 7, 9, 10]
@@ -60,11 +60,11 @@ class TestAxis < Test::Unit::TestCase
assert_nothing_raised("accepts valid format code") { @axis.format_code = "00.##" }
end
- def create_chart_with_formatting(format_string=nil)
+ def create_chart_with_formatting(format_string = nil)
p = Axlsx::Package.new
p.workbook.add_worksheet(:name => "Formatting Test") do |sheet|
sheet.add_row(['test', 20])
- sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,5], :end_at => [10, 20], :title => "Test Formatting") do |chart|
+ sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0, 5], :end_at => [10, 20], :title => "Test Formatting") do |chart|
chart.add_series :data => sheet["B1:B1"], :labels => sheet["A1:A1"]
chart.val_axis.format_code = format_string if format_string
doc = Nokogiri::XML(chart.to_xml_string)
@@ -99,7 +99,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))
assert(doc.xpath('//a:noFill'))
diff --git a/test/drawing/tc_bar_series.rb b/test/drawing/tc_bar_series.rb
index 81b88683..39d39b96 100644
--- a/test/drawing/tc_bar_series.rb
+++ b/test/drawing/tc_bar_series.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
class TestBarSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
+ @ws = p.workbook.add_worksheet :name => "hmmm"
@chart = @ws.add_chart Axlsx::Bar3DChart, :title => "fishery"
@series = @chart.add_series(
data: [0, 1, 2],
@@ -37,8 +37,8 @@ class TestBarSeries < Test::Unit::TestCase
def test_to_xml_string
doc = Nokogiri::XML(@chart.to_xml_string)
@series.colors.each_with_index do |color, index|
- assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size,1)
- assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size,1)
+ assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size, 1)
+ assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size, 1)
end
assert_equal(doc.xpath('//c:spPr[not(ancestor::c:dPt)]/a:solidFill/a:srgbClr').first.get_attribute('val'), '5A5A5A', 'series color has been applied')
end
diff --git a/test/drawing/tc_bubble_series.rb b/test/drawing/tc_bubble_series.rb
index a784619f..af051d11 100644
--- a/test/drawing/tc_bubble_series.rb
+++ b/test/drawing/tc_bubble_series.rb
@@ -3,9 +3,9 @@ require 'tc_helper.rb'
class TestBubbleSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
+ @ws = p.workbook.add_worksheet :name => "hmmm"
@chart = @ws.add_chart Axlsx::BubbleChart, :title => "Bubble Chart"
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :bubbleSize=>[1,5,7], :title=>"GDP", :color => 'FF0000'
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :bubbleSize => [1, 5, 7], :title => "GDP", :color => 'FF0000'
end
def test_initialize
@@ -14,6 +14,6 @@ class TestBubbleSeries < Test::Unit::TestCase
def test_to_xml_string
doc = Nokogiri::XML(@chart.to_xml_string)
- assert_equal(doc.xpath("//a:srgbClr[@val='#{@series.color}']").size,2)
+ assert_equal(doc.xpath("//a:srgbClr[@val='#{@series.color}']").size, 2)
end
end
diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb
index c322b37a..4f60db17 100644
--- a/test/drawing/tc_chart.rb
+++ b/test/drawing/tc_chart.rb
@@ -14,7 +14,7 @@ class TestChart < Test::Unit::TestCase
end
def test_initialization
- assert_equal(@p.workbook.charts.last,@chart, "the chart is in the workbook")
+ assert_equal(@p.workbook.charts.last, @chart, "the chart is in the workbook")
assert_equal(@chart.title.text, "fishery", "the title option has been applied")
assert((@chart.series.is_a?(Axlsx::SimpleTypedList) && @chart.series.empty?), "The series is initialized and empty")
end
@@ -75,7 +75,7 @@ class TestChart < Test::Unit::TestCase
@chart.start_at @row.cells.first
assert_equal(@chart.graphic_frame.anchor.from.col, 0)
assert_equal(@chart.graphic_frame.anchor.from.row, 0)
- @chart.start_at [5,6]
+ @chart.start_at [5, 6]
assert_equal(@chart.graphic_frame.anchor.from.col, 5)
assert_equal(@chart.graphic_frame.anchor.from.row, 6)
end
@@ -87,13 +87,13 @@ class TestChart < Test::Unit::TestCase
@chart.end_at @row.cells.last
assert_equal(@chart.graphic_frame.anchor.to.col, 2)
assert_equal(@chart.graphic_frame.anchor.to.row, 0)
- @chart.end_at [10,11]
+ @chart.end_at [10, 11]
assert_equal(@chart.graphic_frame.anchor.to.col, 10)
assert_equal(@chart.graphic_frame.anchor.to.row, 11)
end
def test_add_series
- s = @chart.add_series :data=>[0,1,2,3], :labels => ["one", 1, "anything"], :title=>"bob"
+ s = @chart.add_series :data => [0, 1, 2, 3], :labels => ["one", 1, "anything"], :title => "bob"
assert_equal(@chart.series.last, s, "series has been added to chart series collection")
assert_equal(s.title.text, "bob", "series title has been applied")
end
diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb
index ce71a00f..cc96299d 100644
--- a/test/drawing/tc_d_lbls.rb
+++ b/test/drawing/tc_d_lbls.rb
@@ -3,13 +3,13 @@ require 'tc_helper'
class TestDLbls < Test::Unit::TestCase
def setup
@d_lbls = Axlsx::DLbls.new(Axlsx::Pie3DChart)
- @boolean_attributes =[:show_legend_key,
- :show_val,
- :show_cat_name,
- :show_ser_name,
- :show_percent,
- :show_bubble_size,
- :show_leader_lines]
+ @boolean_attributes = [:show_legend_key,
+ :show_val,
+ :show_cat_name,
+ :show_ser_name,
+ :show_percent,
+ :show_bubble_size,
+ :show_leader_lines]
end
def test_initialization
@@ -22,7 +22,7 @@ class TestDLbls < Test::Unit::TestCase
def test_initialization_with_optoins
options_hash = Hash[*[@boolean_attributes.map { |name| [name, true] }]]
- d_lbls = Axlsx::DLbls.new(Axlsx::Pie3DChart, options_hash.merge( { :d_lbl_pos => :t }))
+ d_lbls = Axlsx::DLbls.new(Axlsx::Pie3DChart, options_hash.merge({ :d_lbl_pos => :t }))
@boolean_attributes.each do |attr|
assert_equal(true, d_lbls.send(attr), "boolean attributes set by options")
diff --git a/test/drawing/tc_drawing.rb b/test/drawing/tc_drawing.rb
index 04b6ead6..c5fc98e1 100644
--- a/test/drawing/tc_drawing.rb
+++ b/test/drawing/tc_drawing.rb
@@ -11,19 +11,19 @@ class TestDrawing < Test::Unit::TestCase
end
def test_add_chart
- chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
+ chart = @ws.add_chart(Axlsx::Pie3DChart, :title => "bob", :start_at => [0, 0], :end_at => [1, 1])
assert(chart.is_a?(Axlsx::Pie3DChart), "must create a chart")
assert_equal(@ws.workbook.charts.last, chart, "must be added to workbook charts collection")
assert_equal(@ws.drawing.anchors.last.object.chart, chart, "an anchor has been created and holds a reference to this chart")
anchor = @ws.drawing.anchors.last
- assert_equal([anchor.from.row, anchor.from.col], [0,0], "options for start at are applied")
- assert_equal([anchor.to.row, anchor.to.col], [1,1], "options for start at are applied")
+ assert_equal([anchor.from.row, anchor.from.col], [0, 0], "options for start at are applied")
+ assert_equal([anchor.to.row, anchor.to.col], [1, 1], "options for start at are applied")
assert_equal(chart.title.text, "bob", "option for title is applied")
end
def test_add_image
src = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
- image = @ws.add_image(:image_src => src, :start_at=>[0,0], :width=>600, :height=>400)
+ image = @ws.add_image(:image_src => src, :start_at => [0, 0], :width => 600, :height => 400)
assert(@ws.drawing.anchors.last.is_a?(Axlsx::OneCellAnchor))
assert(image.is_a?(Axlsx::Pic))
assert_equal(600, image.width)
@@ -32,15 +32,15 @@ class TestDrawing < Test::Unit::TestCase
def test_add_two_cell_anchor_image
src = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
- image = @ws.add_image(:image_src => src, :start_at=>[0,0], :end_at => [15,0])
+ image = @ws.add_image(:image_src => src, :start_at => [0, 0], :end_at => [15, 0])
assert(@ws.drawing.anchors.last.is_a?(Axlsx::TwoCellAnchor))
assert(image.is_a?(Axlsx::Pic))
end
def test_charts
- chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
+ chart = @ws.add_chart(Axlsx::Pie3DChart, :title => "bob", :start_at => [0, 0], :end_at => [1, 1])
assert_equal(@ws.drawing.charts.last, chart, "add chart is returned")
- chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"nancy", :start_at=>[1,5], :end_at=>[5,10])
+ chart = @ws.add_chart(Axlsx::Pie3DChart, :title => "nancy", :start_at => [1, 5], :end_at => [5, 10])
assert_equal(@ws.drawing.charts.last, chart, "add chart is returned")
end
@@ -60,9 +60,9 @@ class TestDrawing < Test::Unit::TestCase
end
def test_relationships
- @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
+ @ws.add_chart(Axlsx::Pie3DChart, :title => "bob", :start_at => [0, 0], :end_at => [1, 1])
assert_equal(@ws.drawing.relationships.size, 1, "adding a chart adds a relationship")
- @ws.add_chart(Axlsx::Pie3DChart, :title=>"nancy", :start_at=>[1,5], :end_at=>[5,10])
+ @ws.add_chart(Axlsx::Pie3DChart, :title => "nancy", :start_at => [1, 5], :end_at => [5, 10])
assert_equal(@ws.drawing.relationships.size, 2, "adding a chart adds a relationship")
end
diff --git a/test/drawing/tc_hyperlink.rb b/test/drawing/tc_hyperlink.rb
index ad8299b7..f9deb5b8 100644
--- a/test/drawing/tc_hyperlink.rb
+++ b/test/drawing/tc_hyperlink.rb
@@ -4,7 +4,7 @@ class TestHyperlink < Test::Unit::TestCase
def setup
@p = Axlsx::Package.new
ws = @p.workbook.add_worksheet
- @test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
+ @test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
@image = ws.add_image :image_src => @test_img, :hyperlink => "http://axlsx.blogspot.com"
@hyperlink = @image.hyperlink
end
@@ -39,20 +39,20 @@ class TestHyperlink < Test::Unit::TestCase
def test_endSnd
assert_nothing_raised { @hyperlink.endSnd = "true" }
- assert_raise(ArgumentError) {@hyperlink.endSnd = "bob"}
+ assert_raise(ArgumentError) { @hyperlink.endSnd = "bob" }
assert_equal(@hyperlink.endSnd, "true")
end
def test_highlightClick
assert_nothing_raised { @hyperlink.highlightClick = false }
- assert_raise(ArgumentError) {@hyperlink.highlightClick = "bob"}
- assert_equal(@hyperlink.highlightClick, false )
+ assert_raise(ArgumentError) { @hyperlink.highlightClick = "bob" }
+ assert_equal(@hyperlink.highlightClick, false)
end
def test_history
assert_nothing_raised { @hyperlink.history = false }
- assert_raise(ArgumentError) {@hyperlink.history = "bob"}
- assert_equal(@hyperlink.history, false )
+ assert_raise(ArgumentError) { @hyperlink.history = "bob" }
+ assert_equal(@hyperlink.history, false)
end
def test_to_xml_string
diff --git a/test/drawing/tc_line_series.rb b/test/drawing/tc_line_series.rb
index 1327a48f..80643c4e 100644
--- a/test/drawing/tc_line_series.rb
+++ b/test/drawing/tc_line_series.rb
@@ -3,10 +3,10 @@ require 'tc_helper.rb'
class TestLineSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
+ @ws = p.workbook.add_worksheet :name => "hmmm"
chart = @ws.add_chart Axlsx::Line3DChart, :title => "fishery"
@series = chart.add_series(
- :data => [0,1,2],
+ :data => [0, 1, 2],
:labels => ["zero", "one", "two"],
:title => "bob",
:color => "#FF0000",
diff --git a/test/drawing/tc_marker.rb b/test/drawing/tc_marker.rb
index fdc6d5a1..ccfb76fe 100644
--- a/test/drawing/tc_marker.rb
+++ b/test/drawing/tc_marker.rb
@@ -16,23 +16,23 @@ class TestMarker < Test::Unit::TestCase
end
def test_col
- assert_raise(ArgumentError) { @marker.col = -1}
- assert_nothing_raised {@marker.col = 10}
+ assert_raise(ArgumentError) { @marker.col = -1 }
+ assert_nothing_raised { @marker.col = 10 }
end
def test_colOff
- assert_raise(ArgumentError) { @marker.colOff = "1"}
- assert_nothing_raised {@marker.colOff = -10}
+ assert_raise(ArgumentError) { @marker.colOff = "1" }
+ assert_nothing_raised { @marker.colOff = -10 }
end
def test_row
- assert_raise(ArgumentError) { @marker.row = -1}
- assert_nothing_raised {@marker.row = 10}
+ assert_raise(ArgumentError) { @marker.row = -1 }
+ assert_nothing_raised { @marker.row = 10 }
end
def test_rowOff
- assert_raise(ArgumentError) { @marker.rowOff = "1"}
- assert_nothing_raised {@marker.rowOff = -10}
+ assert_raise(ArgumentError) { @marker.rowOff = "1" }
+ assert_nothing_raised { @marker.rowOff = -10 }
end
def test_coord
diff --git a/test/drawing/tc_num_data.rb b/test/drawing/tc_num_data.rb
index fc5fabee..7e7e12e3 100644
--- a/test/drawing/tc_num_data.rb
+++ b/test/drawing/tc_num_data.rb
@@ -13,8 +13,8 @@ class TestNumData < Test::Unit::TestCase
end
def test_format_code
- assert_raise(ArgumentError) {@num_data.format_code = 7}
- assert_nothing_raised {@num_data.format_code = 'foo_bar'}
+ assert_raise(ArgumentError) { @num_data.format_code = 7 }
+ assert_nothing_raised { @num_data.format_code = 'foo_bar' }
end
def test_to_xml_string
diff --git a/test/drawing/tc_num_val.rb b/test/drawing/tc_num_val.rb
index 9722b434..2123ea92 100644
--- a/test/drawing/tc_num_val.rb
+++ b/test/drawing/tc_num_val.rb
@@ -11,8 +11,8 @@ class TestNumVal < Test::Unit::TestCase
end
def test_format_code
- assert_raise(ArgumentError) {@num_val.format_code = 7}
- assert_nothing_raised {@num_val.format_code = 'foo_bar'}
+ assert_raise(ArgumentError) { @num_val.format_code = 7 }
+ assert_nothing_raised { @num_val.format_code = 'foo_bar' }
end
def test_to_xml_string
diff --git a/test/drawing/tc_one_cell_anchor.rb b/test/drawing/tc_one_cell_anchor.rb
index f9a04492..1b18f12e 100644
--- a/test/drawing/tc_one_cell_anchor.rb
+++ b/test/drawing/tc_one_cell_anchor.rb
@@ -4,7 +4,7 @@ class TestOneCellAnchor < Test::Unit::TestCase
def setup
@p = Axlsx::Package.new
@ws = @p.workbook.add_worksheet
- @test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
+ @test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
@image = @ws.add_image :image_src => @test_img
@anchor = @image.anchor
end
@@ -50,8 +50,8 @@ class TestOneCellAnchor < Test::Unit::TestCase
end
def test_options
- assert_raise(ArgumentError, 'invalid start_at') { @ws.add_image :image_src=>@test_img, :start_at=>[1] }
- i = @ws.add_image :image_src=>@test_img, :start_at => [1,2], :width=>100, :height=>200, :name=>"someimage", :descr=>"a neat image"
+ assert_raise(ArgumentError, 'invalid start_at') { @ws.add_image :image_src => @test_img, :start_at => [1] }
+ i = @ws.add_image :image_src => @test_img, :start_at => [1, 2], :width => 100, :height => 200, :name => "someimage", :descr => "a neat image"
assert_equal("a neat image", i.descr)
assert_equal("someimage", i.name)
diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb
index bb81fc00..6760fa58 100644
--- a/test/drawing/tc_pic.rb
+++ b/test/drawing/tc_pic.rb
@@ -4,10 +4,10 @@ class TestPic < Test::Unit::TestCase
def setup
@p = Axlsx::Package.new
ws = @p.workbook.add_worksheet
- @test_img = @test_img_jpg = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
+ @test_img = @test_img_jpg = File.dirname(__FILE__) + "/../fixtures/image1.jpeg"
@test_img_png = File.dirname(__FILE__) + "/../fixtures/image1.png"
@test_img_gif = File.dirname(__FILE__) + "/../fixtures/image1.gif"
- @test_img_fake = File.dirname(__FILE__) + "/../fixtures/image1_fake.jpg"
+ @test_img_fake = File.dirname(__FILE__) + "/../fixtures/image1_fake.jpg"
@image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5
end
@@ -21,11 +21,11 @@ class TestPic < Test::Unit::TestCase
#swap from one cell to two cell when end_at is specified
assert(@image.anchor.is_a?(Axlsx::OneCellAnchor))
start_at = @image.anchor.from
- @image.end_at 10,5
+ @image.end_at 10, 5
assert(@image.anchor.is_a?(Axlsx::TwoCellAnchor))
assert_equal(start_at.col, @image.anchor.from.col)
assert_equal(start_at.row, @image.anchor.from.row)
- assert_equal(10,@image.anchor.to.col)
+ assert_equal(10, @image.anchor.to.col)
assert_equal(5, @image.anchor.to.row)
#swap from two cell to one cell when width or height are specified
diff --git a/test/drawing/tc_picture_locking.rb b/test/drawing/tc_picture_locking.rb
index 7347a571..6e5de47b 100644
--- a/test/drawing/tc_picture_locking.rb
+++ b/test/drawing/tc_picture_locking.rb
@@ -16,54 +16,54 @@ class TestPictureLocking < Test::Unit::TestCase
def test_noGrp
assert_raise(ArgumentError) { @item.noGrp = -1 }
assert_nothing_raised { @item.noGrp = false }
- assert_equal(@item.noGrp, false )
+ assert_equal(@item.noGrp, false)
end
def test_noRot
assert_raise(ArgumentError) { @item.noRot = -1 }
assert_nothing_raised { @item.noRot = false }
- assert_equal(@item.noRot, false )
+ assert_equal(@item.noRot, false)
end
def test_noChangeAspect
assert_raise(ArgumentError) { @item.noChangeAspect = -1 }
assert_nothing_raised { @item.noChangeAspect = false }
- assert_equal(@item.noChangeAspect, false )
+ assert_equal(@item.noChangeAspect, false)
end
def test_noMove
assert_raise(ArgumentError) { @item.noMove = -1 }
assert_nothing_raised { @item.noMove = false }
- assert_equal(@item.noMove, false )
+ assert_equal(@item.noMove, false)
end
def test_noResize
assert_raise(ArgumentError) { @item.noResize = -1 }
assert_nothing_raised { @item.noResize = false }
- assert_equal(@item.noResize, false )
+ assert_equal(@item.noResize, false)
end
def test_noEditPoints
assert_raise(ArgumentError) { @item.noEditPoints = -1 }
assert_nothing_raised { @item.noEditPoints = false }
- assert_equal(@item.noEditPoints, false )
+ assert_equal(@item.noEditPoints, false)
end
def test_noAdjustHandles
assert_raise(ArgumentError) { @item.noAdjustHandles = -1 }
assert_nothing_raised { @item.noAdjustHandles = false }
- assert_equal(@item.noAdjustHandles, false )
+ assert_equal(@item.noAdjustHandles, false)
end
def test_noChangeArrowheads
assert_raise(ArgumentError) { @item.noChangeArrowheads = -1 }
assert_nothing_raised { @item.noChangeArrowheads = false }
- assert_equal(@item.noChangeArrowheads, false )
+ assert_equal(@item.noChangeArrowheads, false)
end
def test_noChangeShapeType
assert_raise(ArgumentError) { @item.noChangeShapeType = -1 }
assert_nothing_raised { @item.noChangeShapeType = false }
- assert_equal(@item.noChangeShapeType, false )
+ assert_equal(@item.noChangeShapeType, false)
end
end
diff --git a/test/drawing/tc_pie_3D_chart.rb b/test/drawing/tc_pie_3D_chart.rb
index 6eb0dfe5..f536f086 100644
--- a/test/drawing/tc_pie_3D_chart.rb
+++ b/test/drawing/tc_pie_3D_chart.rb
@@ -20,7 +20,7 @@ class TestPie3DChart < Test::Unit::TestCase
def test_to_xml
schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD))
doc = Nokogiri::XML(@chart.to_xml_string)
- errors = schema.validate(doc).map {|error| puts error.message; error }
+ errors = schema.validate(doc).map { |error| puts error.message; error }
assert(errors.empty?, "error free validation")
end
end
diff --git a/test/drawing/tc_pie_series.rb b/test/drawing/tc_pie_series.rb
index 7ab81f46..ce516f83 100644
--- a/test/drawing/tc_pie_series.rb
+++ b/test/drawing/tc_pie_series.rb
@@ -3,9 +3,9 @@ require 'tc_helper.rb'
class TestPieSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
+ @ws = p.workbook.add_worksheet :name => "hmmm"
chart = @ws.add_chart Axlsx::Pie3DChart, :title => "fishery"
- @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob", :colors => ["FF0000", "00FF00", "0000FF"]
+ @series = chart.add_series :data => [0, 1, 2], :labels => ["zero", "one", "two"], :title => "bob", :colors => ["FF0000", "00FF00", "0000FF"]
end
def test_initialize
diff --git a/test/drawing/tc_scaling.rb b/test/drawing/tc_scaling.rb
index 909dded5..8f92a024 100644
--- a/test/drawing/tc_scaling.rb
+++ b/test/drawing/tc_scaling.rb
@@ -13,22 +13,22 @@ class TestScaling < Test::Unit::TestCase
end
def test_logBase
- assert_raise(ArgumentError) { @scaling.logBase = 1}
- assert_nothing_raised {@scaling.logBase = 10}
+ assert_raise(ArgumentError) { @scaling.logBase = 1 }
+ assert_nothing_raised { @scaling.logBase = 10 }
end
def test_orientation
- assert_raise(ArgumentError) { @scaling.orientation = "1"}
- assert_nothing_raised {@scaling.orientation = :maxMin}
+ assert_raise(ArgumentError) { @scaling.orientation = "1" }
+ assert_nothing_raised { @scaling.orientation = :maxMin }
end
def test_max
- assert_raise(ArgumentError) { @scaling.max = 1}
- assert_nothing_raised {@scaling.max = 10.5}
+ assert_raise(ArgumentError) { @scaling.max = 1 }
+ assert_nothing_raised { @scaling.max = 10.5 }
end
def test_min
- assert_raise(ArgumentError) { @scaling.min = 1}
- assert_nothing_raised {@scaling.min = 10.5}
+ assert_raise(ArgumentError) { @scaling.min = 1 }
+ assert_nothing_raised { @scaling.min = 10.5 }
end
end
diff --git a/test/drawing/tc_scatter_series.rb b/test/drawing/tc_scatter_series.rb
index fb30dd70..5ca126a2 100644
--- a/test/drawing/tc_scatter_series.rb
+++ b/test/drawing/tc_scatter_series.rb
@@ -3,9 +3,9 @@ require 'tc_helper.rb'
class TestScatterSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
+ @ws = p.workbook.add_worksheet :name => "hmmm"
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Scatter Chart"
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"exponents", :color => 'FF0000', :smooth => true
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "exponents", :color => 'FF0000', :smooth => true
end
def test_initialize
@@ -14,31 +14,31 @@ class TestScatterSeries < Test::Unit::TestCase
def test_smoothed_chart_default_smoothing
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Smooth Chart", :scatter_style => :smoothMarker
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"smoothed exponents"
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "smoothed exponents"
assert(@series.smooth, "series is smooth by default on smooth charts")
end
def test_unsmoothed_chart_default_smoothing
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Unsmooth Chart", :scatter_style => :line
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"unsmoothed exponents"
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "unsmoothed exponents"
assert([email protected], "series is not smooth by default on non-smooth charts")
end
def test_explicit_smoothing
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Unsmooth Chart, Smooth Series", :scatter_style => :line
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"smoothed exponents", :smooth => true
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "smoothed exponents", :smooth => true
assert(@series.smooth, "series is smooth when overriding chart default")
end
def test_explicit_unsmoothing
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Smooth Chart, Unsmooth Series", :scatter_style => :smoothMarker
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"unsmoothed exponents", :smooth => false
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "unsmoothed exponents", :smooth => false
assert([email protected], "series is not smooth when overriding chart default")
end
def test_ln_width
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "ln width", :scatter_style => :line
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"ln_width"
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "ln_width"
@series.ln_width = 12700
assert_equal(@series.ln_width, 12700, 'line width assigment is allowed')
end
@@ -48,25 +48,25 @@ class TestScatterSeries < Test::Unit::TestCase
@series.ln_width = 12700
doc = Nokogiri::XML(@chart.to_xml_string)
assert_equal(12700, @series.ln_width)
- assert_equal(doc.xpath("//a:srgbClr[@val='#{@series.color}']").size,4)
+ assert_equal(doc.xpath("//a:srgbClr[@val='#{@series.color}']").size, 4)
assert_equal(doc.xpath("//a:ln[@w='#{@series.ln_width}']").length, 1)
end
def test_false_show_marker
@chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Smooth Chart', :scatter_style => :smoothMarker
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9]
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9]
assert(@series.show_marker, 'markers are enabled for marker-related styles')
end
def test_true_show_marker
@chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Line chart', :scatter_style => :line
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9]
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9]
assert([email protected]_marker, 'markers are disabled for markerless scatter styles')
end
def test_marker_symbol
@chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Line chart', :scatter_style => :line
- @series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :marker_symbol => :diamond
+ @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :marker_symbol => :diamond
assert_equal(@series.marker_symbol, :diamond, 'series could have own custom marker symbol')
end
end
diff --git a/test/drawing/tc_series.rb b/test/drawing/tc_series.rb
index fc4d97e3..80f4b7cb 100644
--- a/test/drawing/tc_series.rb
+++ b/test/drawing/tc_series.rb
@@ -3,9 +3,9 @@ require 'tc_helper.rb'
class TestSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
+ @ws = p.workbook.add_worksheet :name => "hmmm"
chart = @ws.add_chart Axlsx::Chart, :title => "fishery"
- @series = chart.add_series :title=>"bob"
+ @series = chart.add_series :title => "bob"
end
def test_initialize
diff --git a/test/drawing/tc_two_cell_anchor.rb b/test/drawing/tc_two_cell_anchor.rb
index 2c0f32bd..f2067c23 100644
--- a/test/drawing/tc_two_cell_anchor.rb
+++ b/test/drawing/tc_two_cell_anchor.rb
@@ -21,8 +21,8 @@ class TestTwoCellAnchor < Test::Unit::TestCase
end
def test_options
- assert_raise(ArgumentError, 'invalid start_at') { @ws.add_chart Axlsx::Chart, :start_at=>"1" }
- assert_raise(ArgumentError, 'invalid end_at') { @ws.add_chart Axlsx::Chart, :start_at=>[1,2], :end_at => ["a", 4] }
+ assert_raise(ArgumentError, 'invalid start_at') { @ws.add_chart Axlsx::Chart, :start_at => "1" }
+ assert_raise(ArgumentError, 'invalid end_at') { @ws.add_chart Axlsx::Chart, :start_at => [1, 2], :end_at => ["a", 4] }
# this is actually raised in the graphic frame
assert_raise(ArgumentError, 'invalid Chart') { @ws.add_chart Axlsx::TwoCellAnchor }
a = @ws.add_chart Axlsx::Chart, :start_at => [15, 35], :end_at => [90, 45]
diff --git a/test/drawing/tc_view_3D.rb b/test/drawing/tc_view_3D.rb
index 6202d851..9aceb542 100644
--- a/test/drawing/tc_view_3D.rb
+++ b/test/drawing/tc_view_3D.rb
@@ -19,32 +19,32 @@ class TestView3D < Test::Unit::TestCase
end
def test_rot_x
- assert_raise(ArgumentError) {@view.rot_x = "bob"}
- assert_nothing_raised {@view.rot_x = -90}
+ assert_raise(ArgumentError) { @view.rot_x = "bob" }
+ assert_nothing_raised { @view.rot_x = -90 }
end
def test_rot_y
- assert_raise(ArgumentError) {@view.rot_y = "bob"}
- assert_nothing_raised {@view.rot_y = 90}
+ assert_raise(ArgumentError) { @view.rot_y = "bob" }
+ assert_nothing_raised { @view.rot_y = 90 }
end
def test_h_percent
- assert_raise(ArgumentError) {@view.h_percent = "bob"}
- assert_nothing_raised {@view.h_percent = "500%"}
+ assert_raise(ArgumentError) { @view.h_percent = "bob" }
+ assert_nothing_raised { @view.h_percent = "500%" }
end
def test_depth_percent
- assert_raise(ArgumentError) {@view.depth_percent = "bob"}
- assert_nothing_raised {@view.depth_percent = "20%"}
+ assert_raise(ArgumentError) { @view.depth_percent = "bob" }
+ assert_nothing_raised { @view.depth_percent = "20%" }
end
def test_rAngAx
- assert_raise(ArgumentError) {@view.rAngAx = "bob"}
- assert_nothing_raised {@view.rAngAx = true}
+ assert_raise(ArgumentError) { @view.rAngAx = "bob" }
+ assert_nothing_raised { @view.rAngAx = true }
end
def test_perspective
- assert_raise(ArgumentError) {@view.perspective = "bob"}
- assert_nothing_raised {@view.perspective = 30}
+ assert_raise(ArgumentError) { @view.perspective = "bob" }
+ assert_nothing_raised { @view.perspective = 30 }
end
end
diff --git a/test/drawing/tc_vml_drawing.rb b/test/drawing/tc_vml_drawing.rb
index 792384e9..debba561 100644
--- a/test/drawing/tc_vml_drawing.rb
+++ b/test/drawing/tc_vml_drawing.rb
@@ -18,6 +18,6 @@ class TestVmlDrawing < Test::Unit::TestCase
str = @vml_drawing.to_xml_string()
doc = Nokogiri::XML(str)
assert_equal(doc.xpath("//v:shape").size, 2)
- assert(doc.xpath("//o:idmap[@o:data='#{@ws.index+1}']"))
+ assert(doc.xpath("//o:idmap[@o:data='#{@ws.index + 1}']"))
end
end
diff --git a/test/profile.rb b/test/profile.rb
index de00b32b..4805dad8 100644
--- a/test/profile.rb
+++ b/test/profile.rb
@@ -8,7 +8,7 @@ require 'ruby-prof'
row = []
# Taking worst case scenario of all string data
input = (32..126).to_a.pack('U*').chars.to_a
-20.times { row << input.shuffle.join}
+20.times { row << input.shuffle.join }
profile = RubyProf.profile do
p = Axlsx::Package.new
diff --git a/test/rels/tc_relationship.rb b/test/rels/tc_relationship.rb
index afdf5d1f..1a9df27a 100644
--- a/test/rels/tc_relationship.rb
+++ b/test/rels/tc_relationship.rb
@@ -40,7 +40,7 @@ class TestRelationships < Test::Unit::TestCase
def test_target_mode
assert_raise(ArgumentError) { Axlsx::Relationship.new nil, 'type', 'target', :target_mode => "FISH" }
- assert_nothing_raised { Axlsx::Relationship.new( nil, Axlsx::WORKSHEET_R, 'target', :target_mode => :External) }
+ assert_nothing_raised { Axlsx::Relationship.new(nil, Axlsx::WORKSHEET_R, 'target', :target_mode => :External) }
end
def test_ampersand_escaping_in_target
diff --git a/test/stylesheet/tc_border.rb b/test/stylesheet/tc_border.rb
index c2fb0d98..9e29dda4 100644
--- a/test/stylesheet/tc_border.rb
+++ b/test/stylesheet/tc_border.rb
@@ -18,22 +18,22 @@ class TestBorder < Test::Unit::TestCase
def test_diagonalUp
assert_raise(ArgumentError) { @b.diagonalUp = :red }
assert_nothing_raised { @b.diagonalUp = true }
- assert_equal(@b.diagonalUp, true )
+ assert_equal(@b.diagonalUp, true)
end
def test_diagonalDown
assert_raise(ArgumentError) { @b.diagonalDown = :red }
assert_nothing_raised { @b.diagonalDown = true }
- assert_equal(@b.diagonalDown, true )
+ assert_equal(@b.diagonalDown, true)
end
def test_outline
assert_raise(ArgumentError) { @b.outline = :red }
assert_nothing_raised { @b.outline = true }
- assert_equal(@b.outline, true )
+ assert_equal(@b.outline, true)
end
def test_prs
- assert_nothing_raised { @b.prs << Axlsx::BorderPr.new(:name=>:top, :style=>:thin, :color => Axlsx::Color.new(:rgb=>"FF0000FF")) }
+ assert_nothing_raised { @b.prs << Axlsx::BorderPr.new(:name => :top, :style => :thin, :color => Axlsx::Color.new(:rgb => "FF0000FF")) }
end
end
diff --git a/test/stylesheet/tc_border_pr.rb b/test/stylesheet/tc_border_pr.rb
index 1e1c1dcc..3b25575b 100644
--- a/test/stylesheet/tc_border_pr.rb
+++ b/test/stylesheet/tc_border_pr.rb
@@ -16,7 +16,7 @@ class TestBorderPr < Test::Unit::TestCase
def test_color
assert_raise(ArgumentError) { @bpr.color = :red }
- assert_nothing_raised { @bpr.color = Axlsx::Color.new :rgb=>"FF000000" }
+ assert_nothing_raised { @bpr.color = Axlsx::Color.new :rgb => "FF000000" }
assert(@bpr.color.is_a?(Axlsx::Color))
end
diff --git a/test/stylesheet/tc_cell_alignment.rb b/test/stylesheet/tc_cell_alignment.rb
index a61d764f..fe2e9fe4 100644
--- a/test/stylesheet/tc_cell_alignment.rb
+++ b/test/stylesheet/tc_cell_alignment.rb
@@ -15,66 +15,66 @@ class TestCellAlignment < Test::Unit::TestCase
assert_equal(@item.justifyLastLine, nil)
assert_equal(@item.shrinkToFit, nil)
assert_equal(@item.readingOrder, nil)
- options = { :horizontal => :left, :vertical => :top, :textRotation => 3,
+ options = { :horizontal => :left, :vertical => :top, :textRotation => 3,
:wrapText => true, :indent => 2, :relativeIndent => 5,
:justifyLastLine => true, :shrinkToFit => true, :readingOrder => 2 }
ca = Axlsx::CellAlignment.new options
options.each do |key, value|
- assert_equal(ca.send(key.to_sym),value)
+ assert_equal(ca.send(key.to_sym), value)
end
end
def test_horizontal
assert_raise(ArgumentError) { @item.horizontal = :red }
assert_nothing_raised { @item.horizontal = :left }
- assert_equal(@item.horizontal, :left )
+ assert_equal(@item.horizontal, :left)
end
def test_vertical
assert_raise(ArgumentError) { @item.vertical = :red }
assert_nothing_raised { @item.vertical = :top }
- assert_equal(@item.vertical, :top )
+ assert_equal(@item.vertical, :top)
end
def test_textRotation
assert_raise(ArgumentError) { @item.textRotation = -1 }
assert_nothing_raised { @item.textRotation = 5 }
- assert_equal(@item.textRotation, 5 )
+ assert_equal(@item.textRotation, 5)
end
def test_wrapText
assert_raise(ArgumentError) { @item.wrapText = -1 }
assert_nothing_raised { @item.wrapText = false }
- assert_equal(@item.wrapText, false )
+ assert_equal(@item.wrapText, false)
end
def test_indent
assert_raise(ArgumentError) { @item.indent = -1 }
assert_nothing_raised { @item.indent = 5 }
- assert_equal(@item.indent, 5 )
+ assert_equal(@item.indent, 5)
end
def test_relativeIndent
assert_raise(ArgumentError) { @item.relativeIndent = :symbol }
assert_nothing_raised { @item.relativeIndent = 5 }
- assert_equal(@item.relativeIndent, 5 )
+ assert_equal(@item.relativeIndent, 5)
end
def test_justifyLastLine
assert_raise(ArgumentError) { @item.justifyLastLine = -1 }
assert_nothing_raised { @item.justifyLastLine = true }
- assert_equal(@item.justifyLastLine, true )
+ assert_equal(@item.justifyLastLine, true)
end
def test_shrinkToFit
assert_raise(ArgumentError) { @item.shrinkToFit = -1 }
assert_nothing_raised { @item.shrinkToFit = true }
- assert_equal(@item.shrinkToFit, true )
+ assert_equal(@item.shrinkToFit, true)
end
def test_readingOrder
assert_raise(ArgumentError) { @item.readingOrder = -1 }
assert_nothing_raised { @item.readingOrder = 2 }
- assert_equal(@item.readingOrder, 2 )
+ assert_equal(@item.readingOrder, 2)
end
end
diff --git a/test/stylesheet/tc_cell_protection.rb b/test/stylesheet/tc_cell_protection.rb
index a9648745..a1fc59b2 100644
--- a/test/stylesheet/tc_cell_protection.rb
+++ b/test/stylesheet/tc_cell_protection.rb
@@ -16,12 +16,12 @@ class TestCellProtection < Test::Unit::TestCase
def test_hidden
assert_raise(ArgumentError) { @item.hidden = -1 }
assert_nothing_raised { @item.hidden = false }
- assert_equal(@item.hidden, false )
+ assert_equal(@item.hidden, false)
end
def test_locked
assert_raise(ArgumentError) { @item.locked = -1 }
assert_nothing_raised { @item.locked = false }
- assert_equal(@item.locked, false )
+ assert_equal(@item.locked, false)
end
end
diff --git a/test/stylesheet/tc_cell_style.rb b/test/stylesheet/tc_cell_style.rb
index 5e71a698..18e7a1ab 100644
--- a/test/stylesheet/tc_cell_style.rb
+++ b/test/stylesheet/tc_cell_style.rb
@@ -20,36 +20,36 @@ class TestCellStyle < Test::Unit::TestCase
def test_name
assert_raise(ArgumentError) { @item.name = -1 }
assert_nothing_raised { @item.name = "stylin" }
- assert_equal(@item.name, "stylin" )
+ assert_equal(@item.name, "stylin")
end
def test_xfId
assert_raise(ArgumentError) { @item.xfId = -1 }
assert_nothing_raised { @item.xfId = 5 }
- assert_equal(@item.xfId, 5 )
+ assert_equal(@item.xfId, 5)
end
def test_builtinId
assert_raise(ArgumentError) { @item.builtinId = -1 }
assert_nothing_raised { @item.builtinId = 5 }
- assert_equal(@item.builtinId, 5 )
+ assert_equal(@item.builtinId, 5)
end
def test_iLevel
assert_raise(ArgumentError) { @item.iLevel = -1 }
assert_nothing_raised { @item.iLevel = 5 }
- assert_equal(@item.iLevel, 5 )
+ assert_equal(@item.iLevel, 5)
end
def test_hidden
assert_raise(ArgumentError) { @item.hidden = -1 }
assert_nothing_raised { @item.hidden = true }
- assert_equal(@item.hidden, true )
+ assert_equal(@item.hidden, true)
end
def test_customBuiltin
assert_raise(ArgumentError) { @item.customBuiltin = -1 }
assert_nothing_raised { @item.customBuiltin = true }
- assert_equal(@item.customBuiltin, true )
+ assert_equal(@item.customBuiltin, true)
end
end
diff --git a/test/stylesheet/tc_color.rb b/test/stylesheet/tc_color.rb
index 1fff4c3b..8f87111e 100644
--- a/test/stylesheet/tc_color.rb
+++ b/test/stylesheet/tc_color.rb
@@ -17,13 +17,13 @@ class TestColor < Test::Unit::TestCase
def test_auto
assert_raise(ArgumentError) { @item.auto = -1 }
assert_nothing_raised { @item.auto = true }
- assert_equal(@item.auto, true )
+ assert_equal(@item.auto, true)
end
def test_rgb
assert_raise(ArgumentError) { @item.rgb = -1 }
assert_nothing_raised { @item.rgb = "FF00FF00" }
- assert_equal(@item.rgb, "FF00FF00" )
+ assert_equal(@item.rgb, "FF00FF00")
end
def test_rgb_writer_doesnt_mutate_its_argument
@@ -35,6 +35,6 @@ class TestColor < Test::Unit::TestCase
def test_tint
assert_raise(ArgumentError) { @item.tint = -1 }
assert_nothing_raised { @item.tint = -1.0 }
- assert_equal(@item.tint, -1.0 )
+ assert_equal(@item.tint, -1.0)
end
end
diff --git a/test/stylesheet/tc_dxf.rb b/test/stylesheet/tc_dxf.rb
index ffc59dfb..9e87007d 100644
--- a/test/stylesheet/tc_dxf.rb
+++ b/test/stylesheet/tc_dxf.rb
@@ -37,8 +37,8 @@ class TestDxf < Test::Unit::TestCase
end
def test_fill
- assert_raise(ArgumentError) { @item.fill = 1 }
- assert_nothing_raised { @item.fill = Axlsx::Fill.new(Axlsx::PatternFill.new(:patternType =>:solid, :fgColor=> Axlsx::Color.new(:rgb => "FF000000"))) }
+ assert_raise(ArgumentError) { @item.fill = 1 }
+ assert_nothing_raised { @item.fill = Axlsx::Fill.new(Axlsx::PatternFill.new(:patternType => :solid, :fgColor => Axlsx::Color.new(:rgb => "FF000000"))) }
assert @item.fill.is_a? Axlsx::Fill
end
@@ -64,7 +64,7 @@ class TestDxf < Test::Unit::TestCase
def test_many_options_xml
@item.border = Axlsx::Border.new
@item.alignment = Axlsx::CellAlignment.new
- @item.fill = Axlsx::Fill.new(Axlsx::PatternFill.new(:patternType =>:solid, :fgColor=> Axlsx::Color.new(:rgb => "FF000000")))
+ @item.fill = Axlsx::Fill.new(Axlsx::PatternFill.new(:patternType => :solid, :fgColor => Axlsx::Color.new(:rgb => "FF000000")))
@item.font = Axlsx::Font.new
@item.protection = Axlsx::CellProtection.new
@item.numFmt = Axlsx::NumFmt.new
diff --git a/test/stylesheet/tc_font.rb b/test/stylesheet/tc_font.rb
index fb52f846..821e8820 100644
--- a/test/stylesheet/tc_font.rb
+++ b/test/stylesheet/tc_font.rb
@@ -116,7 +116,7 @@ class TestFont < Test::Unit::TestCase
# def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color=v end
def test_color
assert_raise(ArgumentError) { @item.color = -7 }
- assert_nothing_raised { @item.color = Axlsx::Color.new(:rgb=>"00000000") }
+ assert_nothing_raised { @item.color = Axlsx::Color.new(:rgb => "00000000") }
assert(@item.color.is_a?(Axlsx::Color))
end
diff --git a/test/stylesheet/tc_gradient_fill.rb b/test/stylesheet/tc_gradient_fill.rb
index 9ff043cc..3950fcf7 100644
--- a/test/stylesheet/tc_gradient_fill.rb
+++ b/test/stylesheet/tc_gradient_fill.rb
@@ -55,7 +55,7 @@ class TestGradientFill < Test::Unit::TestCase
end
def test_stop
- @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(:rgb=>"00000000"), 0.5)
+ @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(:rgb => "00000000"), 0.5)
assert(@item.stop.size == 1)
assert(@item.stop.last.is_a?(Axlsx::GradientStop))
end
diff --git a/test/stylesheet/tc_gradient_stop.rb b/test/stylesheet/tc_gradient_stop.rb
index 2865f12d..6dc140e0 100644
--- a/test/stylesheet/tc_gradient_stop.rb
+++ b/test/stylesheet/tc_gradient_stop.rb
@@ -2,7 +2,7 @@ require 'tc_helper.rb'
class TestGradientStop < Test::Unit::TestCase
def setup
- @item = Axlsx::GradientStop.new(Axlsx::Color.new(:rgb=>"FFFF0000"), 1.0)
+ @item = Axlsx::GradientStop.new(Axlsx::Color.new(:rgb => "FFFF0000"), 1.0)
end
def teardown
@@ -21,7 +21,7 @@ class TestGradientStop < Test::Unit::TestCase
def test_color
assert_raise(ArgumentError) { @item.color = nil }
- color = Axlsx::Color.new(:rgb=>"FF0000FF")
+ color = Axlsx::Color.new(:rgb => "FF0000FF")
@item.color = color
assert_equal(@item.color.rgb, "FF0000FF")
end
diff --git a/test/stylesheet/tc_pattern_fill.rb b/test/stylesheet/tc_pattern_fill.rb
index e22f4de6..1126e919 100644
--- a/test/stylesheet/tc_pattern_fill.rb
+++ b/test/stylesheet/tc_pattern_fill.rb
@@ -33,7 +33,7 @@ class TestPatternFill < Test::Unit::TestCase
end
def test_to_xml_string
- @item = Axlsx::PatternFill.new :bgColor => Axlsx::Color.new(:rgb => "FF0000"), :fgColor => Axlsx::Color.new(:rgb=>"00FF00")
+ @item = Axlsx::PatternFill.new :bgColor => Axlsx::Color.new(:rgb => "FF0000"), :fgColor => Axlsx::Color.new(:rgb => "00FF00")
doc = Nokogiri::XML(@item.to_xml_string)
assert(doc.xpath('//color[@rgb="FFFF0000"]'))
assert(doc.xpath('//color[@rgb="FF00FF00"]'))
diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb
index 8bb6ff32..78e82354 100644
--- a/test/stylesheet/tc_styles.rb
+++ b/test/stylesheet/tc_styles.rb
@@ -21,10 +21,10 @@ class TestStyles < Test::Unit::TestCase
def test_add_style_border_hash
border_count = @styles.borders.size
- @styles.add_style :border => {:style => :thin, :color => "FFFF0000"}
+ @styles.add_style :border => { :style => :thin, :color => "FFFF0000" }
assert_equal(@styles.borders.size, border_count + 1)
assert_equal(@styles.borders.last.prs.last.color.rgb, "FFFF0000")
- assert_raise(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"} }
+ assert_raise(ArgumentError) { @styles.add_style :border => { :color => "FFFF0000" } }
assert_equal @styles.borders.last.prs.size, 4
end
@@ -32,23 +32,23 @@ class TestStyles < Test::Unit::TestCase
prev_border_count = @styles.borders.size
borders_array = [
- {:style => :thin, :color => "DDDDDD"},
- {:edges => [:top], :style => :thin, :color => "000000"},
- {:edges => [:bottom], :style => :thick, :color => "FF0000"},
- {:edges => [:left], :style => :dotted, :color => "FFFF00"},
- {:edges => [:right], :style => :dashed, :color => "FFFFFF"},
- {:style => :thick, :color => "CCCCCC"}
+ { :style => :thin, :color => "DDDDDD" },
+ { :edges => [:top], :style => :thin, :color => "000000" },
+ { :edges => [:bottom], :style => :thick, :color => "FF0000" },
+ { :edges => [:left], :style => :dotted, :color => "FFFF00" },
+ { :edges => [:right], :style => :dashed, :color => "FFFFFF" },
+ { :style => :thick, :color => "CCCCCC" }
]
@styles.add_style(border: borders_array)
- assert_equal(@styles.borders.size, (prev_border_count+1))
+ assert_equal(@styles.borders.size, (prev_border_count + 1))
current_border = @styles.borders.last
borders_array.each do |b_opts|
if b_opts[:edges]
- border_pr = current_border.prs.detect{|x| x.name == b_opts[:edges].first }
+ border_pr = current_border.prs.detect { |x| x.name == b_opts[:edges].first }
assert_equal(border_pr.color.rgb, "FF#{b_opts[:color]}")
end
end
@@ -63,39 +63,39 @@ class TestStyles < Test::Unit::TestCase
def test_do_not_alter_options_in_add_style
#This should test all options, but for now - just the bits that we know caused some pain
- options = { :border => { :style => :thin, :color =>"FF000000" } }
+ options = { :border => { :style => :thin, :color => "FF000000" } }
@styles.add_style options
assert_equal options[:border][:style], :thin, 'thin style is stil in option'
assert_equal options[:border][:color], "FF000000", 'color is stil in option'
end
def test_parse_num_fmt
- f_code = {:format_code => "YYYY/MM"}
- num_fmt = {:num_fmt => 5}
+ f_code = { :format_code => "YYYY/MM" }
+ num_fmt = { :num_fmt => 5 }
assert_equal(@styles.parse_num_fmt_options, nil, 'noop if neither :format_code or :num_fmt exist')
- max = @styles.numFmts.map{ |nf| nf.numFmtId }.max
+ max = @styles.numFmts.map { |nf| nf.numFmtId }.max
@styles.parse_num_fmt_options(f_code)
assert_equal(@styles.numFmts.last.numFmtId, max + 1, "new numfmts gets next available id")
assert(@styles.parse_num_fmt_options(num_fmt).is_a?(Integer), "Should return the provided num_fmt if not dxf")
- assert(@styles.parse_num_fmt_options(num_fmt.merge({:type => :dxf})).is_a?(Axlsx::NumFmt), "Makes a new NumFmt if dxf")
+ assert(@styles.parse_num_fmt_options(num_fmt.merge({ :type => :dxf })).is_a?(Axlsx::NumFmt), "Makes a new NumFmt if dxf")
end
def test_parse_border_options_hash_required_keys
assert_raise(ArgumentError, "Require color key") { @styles.parse_border_options(:border => { :style => :thin }) }
assert_raise(ArgumentError, "Require style key") { @styles.parse_border_options(:border => { :color => "FF0d0d0d" }) }
- assert_nothing_raised { @styles.parse_border_options(:border => { :style => :thin, :color => "FF000000"} ) }
+ assert_nothing_raised { @styles.parse_border_options(:border => { :style => :thin, :color => "FF000000" }) }
end
def test_parse_border_basic_options
- b_opts = {:border => { :diagonalUp => 1, :edges => [:left, :right], :color => "FFDADADA", :style => :thick } }
+ b_opts = { :border => { :diagonalUp => 1, :edges => [:left, :right], :color => "FFDADADA", :style => :thick } }
b = @styles.parse_border_options b_opts
assert(b.is_a? Integer)
- assert_equal(@styles.parse_border_options(b_opts.merge({:type => :dxf})).class,Axlsx::Border)
+ assert_equal(@styles.parse_border_options(b_opts.merge({ :type => :dxf })).class, Axlsx::Border)
assert(@styles.borders.last.diagonalUp == 1, "border options are passed in to the initializer")
end
def test_parse_border_options_edges
- b_opts = {:border => { :diagonalUp => 1, :edges => [:left, :right], :color => "FFDADADA", :style => :thick } }
+ b_opts = { :border => { :diagonalUp => 1, :edges => [:left, :right], :color => "FFDADADA", :style => :thick } }
@styles.parse_border_options b_opts
b = @styles.borders.last
left = b.prs.select { |bpr| bpr.name == :left }[0]
@@ -106,10 +106,10 @@ class TestStyles < Test::Unit::TestCase
assert_equal(bottom, nil, "unspecified bottom edge should not be created")
assert(left.is_a?(Axlsx::BorderPr), "specified left edge is set")
assert(right.is_a?(Axlsx::BorderPr), "specified right edge is set")
- assert_equal(left.style,right.style, "edge parts have the same style")
+ assert_equal(left.style, right.style, "edge parts have the same style")
assert_equal(left.style, :thick, "the style is THICK")
- assert_equal(right.color.rgb,left.color.rgb, "edge parts are colors are the same")
- assert_equal(right.color.rgb,"FFDADADA", "edge color rgb is correct")
+ assert_equal(right.color.rgb, left.color.rgb, "edge parts are colors are the same")
+ assert_equal(right.color.rgb, "FFDADADA", "edge color rgb is correct")
end
def test_parse_border_options_noop
@@ -118,11 +118,11 @@ class TestStyles < Test::Unit::TestCase
def test_parse_border_options_integer_xf
assert_equal(@styles.parse_border_options(:border => 1), 1)
- assert_raise(ArgumentError, "unknown border index") {@styles.parse_border_options(:border => 100) }
+ assert_raise(ArgumentError, "unknown border index") { @styles.parse_border_options(:border => 100) }
end
def test_parse_border_options_integer_dxf
- b_opts = { :border => { :edges => [:left, :right], :color => "FFFFFFFF", :style=> :thick } }
+ b_opts = { :border => { :edges => [:left, :right], :color => "FFFFFFFF", :style => :thick } }
b = @styles.parse_border_options(b_opts)
b2 = @styles.parse_border_options(:border => b, :type => :dxf)
assert(b2.is_a?(Axlsx::Border), "Cloned existing border object")
@@ -140,7 +140,7 @@ class TestStyles < Test::Unit::TestCase
original_attributes = Axlsx.instance_values_for(original)
assert_equal(1, created.b)
assert_equal(99, created.sz)
- copied = original_attributes.reject{ |key, value| %w(b sz).include? key }
+ copied = original_attributes.reject { |key, value| %w(b sz).include? key }
instance_vals = Axlsx.instance_values_for(created)
copied.each do |key, value|
assert_equal(instance_vals[key], value)
@@ -162,8 +162,8 @@ class TestStyles < Test::Unit::TestCase
:font_name => "woot font"
}
assert_equal(@styles.parse_font_options {}, nil, "noop if no font keys are set")
- assert(@styles.parse_font_options(:b=>1).is_a?(Integer), "return index of font if not :dxf type")
- assert_equal(@styles.parse_font_options(:b=>1, :type => :dxf).class, Axlsx::Font, "return font object if :dxf type")
+ assert(@styles.parse_font_options(:b => 1).is_a?(Integer), "return index of font if not :dxf type")
+ assert_equal(@styles.parse_font_options(:b => 1, :type => :dxf).class, Axlsx::Font, "return font object if :dxf type")
f = @styles.parse_font_options(options.merge(:type => :dxf))
color = options.delete(:fg_color)
@@ -192,15 +192,15 @@ class TestStyles < Test::Unit::TestCase
font_count = @styles.fonts.size
xf_count = @styles.cellXfs.size
- @styles.add_style :bg_color=>"FF000000", :fg_color=>"FFFFFFFF", :sz=>13, :num_fmt=>Axlsx::NUM_FMT_PERCENT, :alignment=>{:horizontal=>:left}, :border=>Axlsx::STYLE_THIN_BORDER, :hidden=>true, :locked=>true
- assert_equal(@styles.fills.size, fill_count+1)
- assert_equal(@styles.fonts.size, font_count+1)
- assert_equal(@styles.cellXfs.size, xf_count+1)
+ @styles.add_style :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz => 13, :num_fmt => Axlsx::NUM_FMT_PERCENT, :alignment => { :horizontal => :left }, :border => Axlsx::STYLE_THIN_BORDER, :hidden => true, :locked => true
+ assert_equal(@styles.fills.size, fill_count + 1)
+ assert_equal(@styles.fonts.size, font_count + 1)
+ assert_equal(@styles.cellXfs.size, xf_count + 1)
xf = @styles.cellXfs.last
- assert_equal(xf.fillId, (@styles.fills.size-1), "points to the last created fill")
+ assert_equal(xf.fillId, (@styles.fills.size - 1), "points to the last created fill")
assert_equal(@styles.fills.last.fill_type.fgColor.rgb, "FF000000", "fill created with color")
- assert_equal(xf.fontId, (@styles.fonts.size-1), "points to the last created font")
+ assert_equal(xf.fontId, (@styles.fonts.size - 1), "points to the last created font")
assert_equal(@styles.fonts.last.sz, 13, "font sz applied")
assert_equal(@styles.fonts.last.color.rgb, "FFFFFFFF", "font color applied")
@@ -215,16 +215,16 @@ class TestStyles < Test::Unit::TestCase
assert_equal(xf.applyProtection, true, "protection applied")
assert_equal(xf.applyBorder, true, "border applied")
- assert_equal(xf.applyNumberFormat,true, "number format applied")
+ assert_equal(xf.applyNumberFormat, true, "number format applied")
assert_equal(xf.applyAlignment, true, "alignment applied")
end
def test_basic_add_style_dxf
border_count = @styles.borders.size
- @styles.add_style :border => {:style => :thin, :color => "FFFF0000"}, :type => :dxf
+ @styles.add_style :border => { :style => :thin, :color => "FFFF0000" }, :type => :dxf
assert_equal(@styles.borders.size, border_count, "styles borders not affected")
assert_equal(@styles.dxfs.last.border.prs.last.color.rgb, "FFFF0000")
- assert_raise(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"}, :type => :dxf }
+ assert_raise(ArgumentError) { @styles.add_style :border => { :color => "FFFF0000" }, :type => :dxf }
assert_equal @styles.borders.last.prs.size, 4
end
@@ -233,8 +233,8 @@ class TestStyles < Test::Unit::TestCase
font_count = @styles.fonts.size
dxf_count = @styles.dxfs.size
- style = @styles.add_style :bg_color=>"FF000000", :fg_color=>"FFFFFFFF", :sz=>13, :alignment=>{:horizontal=>:left}, :border=>{:style => :thin, :color => "FFFF0000"}, :hidden=>true, :locked=>true, :type => :dxf
- assert_equal(@styles.dxfs.size, dxf_count+1)
+ style = @styles.add_style :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz => 13, :alignment => { :horizontal => :left }, :border => { :style => :thin, :color => "FFFF0000" }, :hidden => true, :locked => true, :type => :dxf
+ assert_equal(@styles.dxfs.size, dxf_count + 1)
assert_equal(0, style, "returns the zero-based dxfId")
dxf = @styles.dxfs.last
@@ -255,9 +255,9 @@ class TestStyles < Test::Unit::TestCase
def test_multiple_dxf
# add a second style
- style = @styles.add_style :bg_color=>"00000000", :fg_color=>"FFFFFFFF", :sz=>13, :alignment=>{:horizontal=>:left}, :border=>{:style => :thin, :color => "FFFF0000"}, :hidden=>true, :locked=>true, :type => :dxf
+ style = @styles.add_style :bg_color => "00000000", :fg_color => "FFFFFFFF", :sz => 13, :alignment => { :horizontal => :left }, :border => { :style => :thin, :color => "FFFF0000" }, :hidden => true, :locked => true, :type => :dxf
assert_equal(0, style, "returns the first dxfId")
- style = @styles.add_style :bg_color=>"FF000000", :fg_color=>"FFFFFFFF", :sz=>13, :alignment=>{:horizontal=>:left}, :border=>{:style => :thin, :color => "FFFF0000"}, :hidden=>true, :locked=>true, :type => :dxf
+ style = @styles.add_style :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz => 13, :alignment => { :horizontal => :left }, :border => { :style => :thin, :color => "FFFF0000" }, :hidden => true, :locked => true, :type => :dxf
assert_equal(1, style, "returns the second dxfId")
end
@@ -302,7 +302,7 @@ class TestStyles < Test::Unit::TestCase
current_border = @styles.borders.last
- border_pr = current_border.prs.detect{|x| x.name == edge }
+ border_pr = current_border.prs.detect { |x| x.name == edge }
assert_equal(border_pr.color.rgb, "FF#{b_opts[:color]}")
end
end
diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb
index fc23cc5f..c214f8e2 100644
--- a/test/tc_axlsx.rb
+++ b/test/tc_axlsx.rb
@@ -64,7 +64,7 @@ class TestAxlsx < Test::Unit::TestCase
def test_name_to_indices
setup_wide
@wide_test_points.each do |key, value|
- assert_equal(Axlsx.name_to_indices(key), [value,2])
+ assert_equal(Axlsx.name_to_indices(key), [value, 2])
end
end
@@ -108,7 +108,7 @@ class TestAxlsx < Test::Unit::TestCase
end
class InstanceValuesSubject
- def initialize(args={})
+ def initialize(args = {})
args.each do |key, v|
instance_variable_set("@#{key}".to_sym, v)
end
@@ -120,23 +120,23 @@ class TestAxlsx < Test::Unit::TestCase
assert_equal({}, Axlsx.instance_values_for(empty), 'should generate with no ivars')
single = InstanceValuesSubject.new(a: 2)
- assert_equal({"a" => 2}, Axlsx.instance_values_for(single), 'should generate for a single ivar')
+ assert_equal({ "a" => 2 }, Axlsx.instance_values_for(single), 'should generate for a single ivar')
double = InstanceValuesSubject.new(a: 2, b: "c")
- assert_equal({"a" => 2, "b" => "c"}, Axlsx.instance_values_for(double), 'should generate for multiple ivars')
+ assert_equal({ "a" => 2, "b" => "c" }, Axlsx.instance_values_for(double), 'should generate for multiple ivars')
inner_obj = Object.new
complex = InstanceValuesSubject.new(obj: inner_obj)
- assert_equal({"obj" => inner_obj}, Axlsx.instance_values_for(complex), 'should pass value of ivar directly')
+ assert_equal({ "obj" => inner_obj }, Axlsx.instance_values_for(complex), 'should pass value of ivar directly')
nil_subject = InstanceValuesSubject.new(nil_obj: nil)
- assert_equal({"nil_obj" => nil}, Axlsx.instance_values_for(nil_subject), 'should return nil ivars')
+ assert_equal({ "nil_obj" => nil }, Axlsx.instance_values_for(nil_subject), 'should return nil ivars')
end
def test_hash_deep_merge
- h1 = {foo: {bar: true}}
- h2 = {foo: {baz: true}}
- assert_equal({foo: {baz: true}}, h1.merge(h2))
- assert_equal({foo: {bar: true, baz: true}}, Axlsx.hash_deep_merge(h1, h2))
+ h1 = { foo: { bar: true } }
+ h2 = { foo: { baz: true } }
+ assert_equal({ foo: { baz: true } }, h1.merge(h2))
+ assert_equal({ foo: { bar: true, baz: true } }, Axlsx.hash_deep_merge(h1, h2))
end
end
diff --git a/test/tc_package.rb b/test/tc_package.rb
index b3ca6810..c8f35211 100644
--- a/test/tc_package.rb
+++ b/test/tc_package.rb
@@ -39,8 +39,8 @@ class TestPackage < Test::Unit::TestCase
vs.add_selection(:bottom_right, { :active_cell => 'I57', :sqref => 'I57' })
end
- ws.add_chart(Axlsx::Pie3DChart, :title => "これは?", :start_at => [0,3]) do |chart|
- chart.add_series :data=>[1,2,3], :labels=>["a", "b", "c"]
+ ws.add_chart(Axlsx::Pie3DChart, :title => "これは?", :start_at => [0, 3]) do |chart|
+ chart.add_series :data => [1, 2, 3], :labels => ["a", "b", "c"]
chart.d_lbls.show_val = true
chart.d_lbls.d_lbl_pos = :outEnd
chart.d_lbls.show_percent = true
@@ -52,33 +52,33 @@ class TestPackage < Test::Unit::TestCase
end
ws.add_chart(Axlsx::Bar3DChart, :title => 'bar chart') do |chart|
- chart.add_series :data => [1,4,5], :labels => %w(A B C)
+ chart.add_series :data => [1, 4, 5], :labels => %w(A B C)
chart.d_lbls.show_percent = true
end
ws.add_chart(Axlsx::ScatterChart, :title => 'scat man') do |chart|
- chart.add_series :xData => [1,2,3,4], :yData => [4,3,2,1]
+ chart.add_series :xData => [1, 2, 3, 4], :yData => [4, 3, 2, 1]
chart.d_lbls.show_val = true
end
ws.add_chart(Axlsx::BubbleChart, :title => 'bubble chart') do |chart|
- chart.add_series :xData => [1,2,3,4], :yData => [1,3,2,4]
+ chart.add_series :xData => [1, 2, 3, 4], :yData => [1, 3, 2, 4]
chart.d_lbls.show_val = true
end
@fname = 'axlsx_test_serialization.xlsx'
img = File.expand_path('../fixtures/image1.jpeg', __FILE__)
- ws.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
- image.width=720
- image.height=666
+ ws.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink => "http://axlsx.blogspot.com") do |image|
+ image.width = 720
+ image.height = 666
image.hyperlink.tooltip = "Labeled Link"
image.start_at 5, 5
image.end_at 10, 10
end
ws.add_image :image_src => File.expand_path('../fixtures/image1.gif', __FILE__) do |image|
image.start_at 0, 20
- image.width=360
- image.height=333
+ image.width = 360
+ image.height = 333
end
ws.add_image :image_src => File.expand_path('../fixtures/image1.png', __FILE__) do |image|
image.start_at 9, 20
@@ -99,18 +99,18 @@ class TestPackage < Test::Unit::TestCase
def test_core_accessor
assert_equal(@package.core, Axlsx.instance_values_for(@package)["core"])
- assert_raise(NoMethodError) {@package.core = nil }
+ assert_raise(NoMethodError) { @package.core = nil }
end
def test_app_accessor
assert_equal(@package.app, Axlsx.instance_values_for(@package)["app"])
- assert_raise(NoMethodError) {@package.app = nil }
+ assert_raise(NoMethodError) { @package.app = nil }
end
def test_use_shared_strings
assert_equal(@package.use_shared_strings, nil)
- assert_raise(ArgumentError) {@package.use_shared_strings 9}
- assert_nothing_raised {@package.use_shared_strings = true}
+ assert_raise(ArgumentError) { @package.use_shared_strings 9 }
+ assert_nothing_raised { @package.use_shared_strings = true }
assert_equal(@package.use_shared_strings, @package.workbook.use_shared_strings)
end
@@ -177,7 +177,7 @@ class TestPackage < Test::Unit::TestCase
def assert_zip_file_matches_package(fname, package)
zf = Zip::File.open(fname)
- package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }
+ package.send(:parts).each { |part| zf.get_entry(part[:entry]) }
end
def assert_created_with_rubyzip(fname, package)
@@ -250,22 +250,22 @@ class TestPackage < Test::Unit::TestCase
def test_parts
p = @package.send(:parts)
#all parts have an entry
- assert_equal(p.select{ |part| part[:entry] =~ /_rels\/\.rels/ }.size, 1, "rels missing")
- assert_equal(p.select{ |part| part[:entry] =~ /docProps\/core\.xml/ }.size, 1, "core missing")
- assert_equal(p.select{ |part| part[:entry] =~ /docProps\/app\.xml/ }.size, 1, "app missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/_rels\/workbook\.xml\.rels/ }.size, 1, "workbook rels missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/workbook\.xml/ }.size, 1, "workbook missing")
- assert_equal(p.select{ |part| part[:entry] =~ /\[Content_Types\]\.xml/ }.size, 1, "content types missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/styles\.xml/ }.size, 1, "styles missin")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/drawings\/_rels\/drawing\d\.xml\.rels/ }.size, @package.workbook.drawings.size, "one or more drawing rels missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/drawings\/drawing\d\.xml/ }.size, @package.workbook.drawings.size, "one or more drawings missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/charts\/chart\d\.xml/ }.size, @package.workbook.charts.size, "one or more charts missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/worksheets\/sheet\d\.xml/ }.size, @package.workbook.worksheets.size, "one or more sheet missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/worksheets\/_rels\/sheet\d\.xml\.rels/ }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/comments\d\.xml/ }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/pivotTables\/pivotTable\d\.xml/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/pivotTables\/_rels\/pivotTable\d\.xml.rels/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables rels missing")
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/pivotCache\/pivotCacheDefinition\d\.xml/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables missing")
+ assert_equal(p.select { |part| part[:entry] =~ /_rels\/\.rels/ }.size, 1, "rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ /docProps\/core\.xml/ }.size, 1, "core missing")
+ assert_equal(p.select { |part| part[:entry] =~ /docProps\/app\.xml/ }.size, 1, "app missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/_rels\/workbook\.xml\.rels/ }.size, 1, "workbook rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/workbook\.xml/ }.size, 1, "workbook missing")
+ assert_equal(p.select { |part| part[:entry] =~ /\[Content_Types\]\.xml/ }.size, 1, "content types missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/styles\.xml/ }.size, 1, "styles missin")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/drawings\/_rels\/drawing\d\.xml\.rels/ }.size, @package.workbook.drawings.size, "one or more drawing rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/drawings\/drawing\d\.xml/ }.size, @package.workbook.drawings.size, "one or more drawings missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/charts\/chart\d\.xml/ }.size, @package.workbook.charts.size, "one or more charts missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/worksheets\/sheet\d\.xml/ }.size, @package.workbook.worksheets.size, "one or more sheet missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/worksheets\/_rels\/sheet\d\.xml\.rels/ }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/comments\d\.xml/ }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/pivotTables\/pivotTable\d\.xml/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/pivotTables\/_rels\/pivotTable\d\.xml.rels/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/pivotCache\/pivotCacheDefinition\d\.xml/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables missing")
#no mystery parts
assert_equal(25, p.size)
@@ -280,7 +280,7 @@ class TestPackage < Test::Unit::TestCase
@package.use_shared_strings = true
@package.to_stream #ensure all cell_serializer paths are hit
p = @package.send(:parts)
- assert_equal(p.select{ |part| part[:entry] =~/xl\/sharedStrings.xml/}.size, 1, "shared strings table missing")
+ assert_equal(p.select { |part| part[:entry] =~ /xl\/sharedStrings.xml/ }.size, 1, "shared strings table missing")
end
def test_workbook_is_a_workbook
@@ -305,8 +305,8 @@ class TestPackage < Test::Unit::TestCase
end
def test_name_to_indices
- assert(Axlsx::name_to_indices('A1') == [0,0])
- assert(Axlsx::name_to_indices('A100') == [0,99], 'needs to axcept rows that contain 0')
+ assert(Axlsx::name_to_indices('A1') == [0, 0])
+ assert(Axlsx::name_to_indices('A100') == [0, 99], 'needs to axcept rows that contain 0')
end
def test_to_stream
diff --git a/test/util/tc_simple_typed_list.rb b/test/util/tc_simple_typed_list.rb
index 88e75a1c..abcacf26 100644
--- a/test/util/tc_simple_typed_list.rb
+++ b/test/util/tc_simple_typed_list.rb
@@ -9,7 +9,7 @@ class TestSimpleTypedList < Test::Unit::TestCase
def test_type_is_a_class_or_array_of_class
assert_nothing_raised { Axlsx::SimpleTypedList.new Integer }
- assert_nothing_raised { Axlsx::SimpleTypedList.new [Integer,String] }
+ assert_nothing_raised { Axlsx::SimpleTypedList.new [Integer, String] }
assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new }
assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new "1" }
assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new [Integer, "Class"] }
@@ -29,20 +29,20 @@ class TestSimpleTypedList < Test::Unit::TestCase
end
def test_concat_should_return_index
- assert( @list.size == 0 )
- assert( @list << 1 == 0 )
- assert( @list << 2 == 1 )
+ assert(@list.size == 0)
+ assert(@list << 1 == 0)
+ assert(@list << 2 == 1)
@list.delete_at 0
- assert( @list << 3 == 1 )
- assert( @list.index(2) == 0 )
+ assert(@list << 3 == 1)
+ assert(@list.index(2) == 0)
end
def test_push_should_return_index
- assert( @list.push(1) == 0 )
- assert( @list.push(2) == 1 )
+ assert(@list.push(1) == 0)
+ assert(@list.push(2) == 1)
@list.delete_at 0
- assert( @list.push(3) == 1 )
- assert( @list.index(2) == 0 )
+ assert(@list.push(3) == 1)
+ assert(@list.index(2) == 0)
end
def test_locking
@@ -72,6 +72,6 @@ class TestSimpleTypedList < Test::Unit::TestCase
def test_equality
@list.push 1
@list.push 2
- assert_equal(@list.to_ary, [1,2])
+ assert_equal(@list.to_ary, [1, 2])
end
end
diff --git a/test/util/tc_validators.rb b/test/util/tc_validators.rb
index 26fb2a89..c0e2e356 100644
--- a/test/util/tc_validators.rb
+++ b/test/util/tc_validators.rb
@@ -10,17 +10,17 @@ class TestValidators < Test::Unit::TestCase
#unsigned_int
assert_nothing_raised { Axlsx.validate_unsigned_int 1 }
assert_nothing_raised { Axlsx.validate_unsigned_int(+1) }
- assert_raise(ArgumentError) { Axlsx.validate_unsigned_int(-1)}
+ assert_raise(ArgumentError) { Axlsx.validate_unsigned_int(-1) }
assert_raise(ArgumentError) { Axlsx.validate_unsigned_int('1') }
#int
assert_nothing_raised { Axlsx.validate_int(1) }
assert_nothing_raised { Axlsx.validate_int(-1) }
- assert_raise(ArgumentError) { Axlsx.validate_int('a')}
+ assert_raise(ArgumentError) { Axlsx.validate_int('a') }
assert_raise(ArgumentError) { Axlsx.validate_int(Array) }
#boolean (as 0 or 1, :true, :false, true, false, or "true," "false")
- [0,1,:true, :false, true, false, "true", "false"].each do |v|
+ [0, 1, :true, :false, true, false, "true", "false"].each do |v|
assert_nothing_raised { Axlsx.validate_boolean 0 }
end
assert_raise(ArgumentError) { Axlsx.validate_boolean 2 }
diff --git a/test/workbook/tc_shared_strings_table.rb b/test/workbook/tc_shared_strings_table.rb
index 7e8fb38e..cb7557c6 100644
--- a/test/workbook/tc_shared_strings_table.rb
+++ b/test/workbook/tc_shared_strings_table.rb
@@ -2,7 +2,7 @@ require 'tc_helper.rb'
class TestSharedStringsTable < Test::Unit::TestCase
def setup
- @p = Axlsx::Package.new :use_shared_strings=>true
+ @p = Axlsx::Package.new :use_shared_strings => true
ws = @p.workbook.add_worksheet
ws.add_row ['a', 1, 'b']
@@ -39,11 +39,11 @@ class TestSharedStringsTable < Test::Unit::TestCase
puts error.message
errors << error
end
- assert_equal(errors.size, 0, "sharedStirngs.xml Invalid" + errors.map{ |e| e.message }.to_s)
+ assert_equal(errors.size, 0, "sharedStirngs.xml Invalid" + errors.map { |e| e.message }.to_s)
end
def test_remove_control_characters_in_xml_serialization
- nasties = "hello\x10\x00\x1C\x1Eworld"
+ nasties = "hello\x10\x00\x1C\x1Eworld"
@p.workbook.worksheets[0].add_row [nasties]
# test that the nasty string was added to the shared strings
diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb
index b678a183..c5a72e48 100644
--- a/test/workbook/tc_workbook.rb
+++ b/test/workbook/tc_workbook.rb
@@ -28,26 +28,26 @@ class TestWorkbook < Test::Unit::TestCase
def test_no_autowidth
assert_equal(@wb.use_autowidth, true)
- assert_raise(ArgumentError) {@wb.use_autowidth = 0.1}
- assert_nothing_raised {@wb.use_autowidth = false}
+ assert_raise(ArgumentError) { @wb.use_autowidth = 0.1 }
+ assert_nothing_raised { @wb.use_autowidth = false }
assert_equal(@wb.use_autowidth, false)
end
def test_is_reversed
assert_equal(@wb.is_reversed, nil)
- assert_raise(ArgumentError) {@wb.is_reversed = 0.1}
- assert_nothing_raised {@wb.is_reversed = true }
+ assert_raise(ArgumentError) { @wb.is_reversed = 0.1 }
+ assert_nothing_raised { @wb.is_reversed = true }
assert_equal(@wb.use_autowidth, true)
end
def test_sheet_by_name_retrieval
- @wb.add_worksheet(:name=>'foo')
- @wb.add_worksheet(:name=>'bar')
+ @wb.add_worksheet(:name => 'foo')
+ @wb.add_worksheet(:name => 'bar')
assert_equal('foo', @wb.sheet_by_name('foo').name)
end
def test_worksheet_empty_name
- assert_raise(ArgumentError) {@wb.add_worksheet(:name=>'')}
+ assert_raise(ArgumentError) { @wb.add_worksheet(:name => '') }
end
def test_date1904
@@ -70,13 +70,13 @@ class TestWorkbook < Test::Unit::TestCase
def test_shared_strings
assert_equal(@wb.use_shared_strings, nil)
- assert_raise(ArgumentError) {@wb.use_shared_strings = 'bpb'}
- assert_nothing_raised {@wb.use_shared_strings = :true}
+ assert_raise(ArgumentError) { @wb.use_shared_strings = 'bpb' }
+ assert_nothing_raised { @wb.use_shared_strings = :true }
end
def test_add_worksheet
assert(@wb.worksheets.empty?, "worbook has no worksheets by default")
- ws = @wb.add_worksheet(:name=>"bob")
+ ws = @wb.add_worksheet(:name => "bob")
assert_equal(@wb.worksheets.size, 1, "add_worksheet adds a worksheet!")
assert_equal(@wb.worksheets.first, ws, "the worksheet returned is the worksheet added")
assert_equal(ws.name, "bob", "name option gets passed to worksheet")
@@ -118,10 +118,10 @@ class TestWorkbook < Test::Unit::TestCase
end
def test_range_requires_valid_sheet
- ws = @wb.add_worksheet :name=>'fish'
- ws.add_row [1,2,3]
- ws.add_row [4,5,6]
- assert_raise(ArgumentError, "no sheet name part") { @wb["A1:C2"]}
+ ws = @wb.add_worksheet :name => 'fish'
+ ws.add_row [1, 2, 3]
+ ws.add_row [4, 5, 6]
+ assert_raise(ArgumentError, "no sheet name part") { @wb["A1:C2"] }
assert_equal @wb['fish!A1:C2'].size, 6
end
diff --git a/test/workbook/tc_workbook_view.rb b/test/workbook/tc_workbook_view.rb
index 8280d8d5..6fb300a8 100644
--- a/test/workbook/tc_workbook_view.rb
+++ b/test/workbook/tc_workbook_view.rb
@@ -17,14 +17,14 @@ class TestWorkbookView < Test::Unit::TestCase
def test_boolean_attribute_validation
%w(minimized show_horizontal_scroll show_vertical_scroll show_sheet_tabs auto_filter_date_grouping).each do |attr|
assert_raise(ArgumentError, 'only booleanish allowed in boolean attributes') { @book_view.send("#{attr}=", "banana") }
- assert_nothing_raised { @book_view.send("#{attr}=", false )}
+ assert_nothing_raised { @book_view.send("#{attr}=", false) }
end
end
def test_integer_attribute_validation
%w(tab_ratio first_sheet active_tab x_window y_window window_width window_height).each do |attr|
assert_raise(ArgumentError, 'only integer allowed in integer attributes') { @book_view.send("#{attr}=", "b") }
- assert_nothing_raised { @book_view.send("#{attr}=", 7 )}
+ assert_nothing_raised { @book_view.send("#{attr}=", 7) }
end
end
diff --git a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
index 60089d22..eb561554 100644
--- a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
+++ b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
class TestAutoFilter < Test::Unit::TestCase
def setup
ws = Axlsx::Package.new.workbook.add_worksheet
- 3.times { |index| ws.add_row [1*index,2*index,3*index] }
+ 3.times { |index| ws.add_row [1 * index, 2 * index, 3 * index] }
@auto_filter = ws.auto_filter
@auto_filter.range = 'A1:C3'
@auto_filter.add_column 0, :filters, :filter_items => [1]
diff --git a/test/workbook/worksheet/auto_filter/tc_filters.rb b/test/workbook/worksheet/auto_filter/tc_filters.rb
index d1c30446..8e853772 100644
--- a/test/workbook/worksheet/auto_filter/tc_filters.rb
+++ b/test/workbook/worksheet/auto_filter/tc_filters.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
class TestFilters < Test::Unit::TestCase
def setup
@filters = Axlsx::Filters.new(:filter_items => [1, 'a'],
- :date_group_items =>[{ :date_time_grouping => :year, :year => 2011, :month => 11, :day => 11, :hour => 0, :minute => 0, :second => 0 }],
+ :date_group_items => [{ :date_time_grouping => :year, :year => 2011, :month => 11, :day => 11, :hour => 0, :minute => 0, :second => 0 }],
:blank => true)
end
diff --git a/test/workbook/worksheet/tc_border_creator.rb b/test/workbook/worksheet/tc_border_creator.rb
index eb27fe98..c9f3df8f 100644
--- a/test/workbook/worksheet/tc_border_creator.rb
+++ b/test/workbook/worksheet/tc_border_creator.rb
@@ -8,7 +8,7 @@ class TestBorderCreator < Test::Unit::TestCase
end
def test_initialize
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
bc = Axlsx::BorderCreator.new(worksheet: @ws, cells: @ws["A1:B1"])
assert_equal bc.instance_variable_get(:@edges), Axlsx::Border::EDGES
@@ -22,7 +22,7 @@ class TestBorderCreator < Test::Unit::TestCase
end
def test_initialize_edges
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
bc = Axlsx::BorderCreator.new(worksheet: @ws, cells: @ws["A1:B1"], edges: nil)
assert_equal bc.instance_variable_get(:@edges), Axlsx::Border::EDGES
@@ -48,7 +48,7 @@ class TestBorderCreator < Test::Unit::TestCase
def test_draw
5.times do
- @ws.add_row [1,2,3,4,5]
+ @ws.add_row [1, 2, 3, 4, 5]
end
bc = Axlsx::BorderCreator.new(worksheet: @ws, cells: @ws["A1:C3"], edges: ["top", :left], style: :thick, color: "ffffff")
diff --git a/test/workbook/worksheet/tc_break.rb b/test/workbook/worksheet/tc_break.rb
index 884d9e01..2c67fed7 100644
--- a/test/workbook/worksheet/tc_break.rb
+++ b/test/workbook/worksheet/tc_break.rb
@@ -8,7 +8,7 @@ class TestBreak < Test::Unit::TestCase
def test_id
assert_equal(1, @break.id)
assert_raises ArgumentError do
- Axlsx::Break.new(:hoge, {:id => -1})
+ Axlsx::Break.new(:hoge, { :id => -1 })
end
end
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb
index af3699ad..a4aab11c 100644
--- a/test/workbook/worksheet/tc_cell.rb
+++ b/test/workbook/worksheet/tc_cell.rb
@@ -4,10 +4,10 @@ class TestCell < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
p.use_shared_strings = true
- @ws = p.workbook.add_worksheet :name=>"hmmm"
- p.workbook.styles.add_style :sz=>20
+ @ws = p.workbook.add_worksheet :name => "hmmm"
+ p.workbook.styles.add_style :sz => 20
@row = @ws.add_row
- @c = @row.add_cell 1, :type=>:float, :style=>1, :escape_formulas=>true
+ @c = @row.add_cell 1, :type => :float, :style => 1, :escape_formulas => true
data = (0..26).map { |index| index }
@ws.add_row data
@cAA = @ws["AA2"]
@@ -47,8 +47,8 @@ class TestCell < Test::Unit::TestCase
end
def test_r_abs
- assert_equal(@c.r_abs,"$A$1", "calculate absolute cell reference")
- assert_equal(@cAA.r_abs,"$AA$2", "needs to accept multi-digit columns")
+ assert_equal(@c.r_abs, "$A$1", "calculate absolute cell reference")
+ assert_equal(@cAA.r_abs, "$AA$2", "needs to accept multi-digit columns")
end
def test_name
@@ -58,7 +58,7 @@ class TestCell < Test::Unit::TestCase
end
def test_autowidth
- style = @c.row.worksheet.workbook.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}} )
+ style = @c.row.worksheet.workbook.styles.add_style({ :alignment => { :horizontal => :center, :vertical => :center, :wrap_text => true } })
@c.style = style
assert_in_delta(6.6, @c.autowidth, 0.01)
end
@@ -90,8 +90,8 @@ class TestCell < Test::Unit::TestCase
end
def test_style
- assert_raise(ArgumentError, "must reject invalid style indexes") { @[email protected] }
- assert_nothing_raised("must allow valid style index changes") {@c.style=1}
+ assert_raise(ArgumentError, "must reject invalid style indexes") { @c.style = @c.row.worksheet.workbook.styles.cellXfs.size }
+ assert_nothing_raised("must allow valid style index changes") { @c.style = 1 }
assert_equal(@c.style, 1)
end
@@ -99,7 +99,7 @@ class TestCell < Test::Unit::TestCase
assert_raise(ArgumentError, "type must be :string, :integer, :float, :date, :time, :boolean") { @c.type = :array }
assert_nothing_raised("type can be changed") { @c.type = :string }
assert_equal(@c.value, "1.0", "changing type casts the value")
- assert_equal(:float, @row.add_cell(1.0/10**7).type, 'properly identify exponential floats as float type')
+ assert_equal(:float, @row.add_cell(1.0 / 10**7).type, 'properly identify exponential floats as float type')
assert_equal(@row.add_cell(Time.now).type, :time, 'time should be time')
assert_equal(@row.add_cell(Date.today).type, :date, 'date should be date')
assert_equal(@row.add_cell(true).type, :boolean, 'boolean should be boolean')
@@ -133,7 +133,7 @@ class TestCell < Test::Unit::TestCase
assert_equal(@c.send(:cell_type_from_value, -1), :integer)
assert_equal(@c.send(:cell_type_from_value, true), :boolean)
assert_equal(@c.send(:cell_type_from_value, false), :boolean)
- assert_equal(@c.send(:cell_type_from_value, 1.0/10**6), :float)
+ assert_equal(@c.send(:cell_type_from_value, 1.0 / 10**6), :float)
assert_equal(@c.send(:cell_type_from_value, Axlsx::RichText.new), :richtext)
assert_equal(:iso_8601, @c.send(:cell_type_from_value, '2008-08-30T01:45:36.123+09:00'))
end
@@ -255,7 +255,7 @@ class TestCell < Test::Unit::TestCase
assert_raise(ArgumentError) { @c.u = -1.1 }
assert_nothing_raised { @c.u = :single }
assert_equal(@c.u, :single)
- doc = Nokogiri::XML(@c.to_xml_string(1,1))
+ doc = Nokogiri::XML(@c.to_xml_string(1, 1))
assert(doc.xpath('//u[@val="single"]'))
end
@@ -339,13 +339,13 @@ class TestCell < Test::Unit::TestCase
end
def test_to_xml_string
- c_xml = Nokogiri::XML(@c.to_xml_string(1,1))
+ c_xml = Nokogiri::XML(@c.to_xml_string(1, 1))
assert_equal(c_xml.xpath("/c[@s=1]").size, 1)
end
def test_to_xml_string_nil
@c.value = nil
- c_xml = Nokogiri::XML(@c.to_xml_string(1,1))
+ c_xml = Nokogiri::XML(@c.to_xml_string(1, 1))
assert_equal(c_xml.xpath("/c[@s=1]").size, 1)
end
@@ -357,7 +357,7 @@ class TestCell < Test::Unit::TestCase
@c.value = "a"
@c.font_name = 'arial'
@c.color = 'FF0000'
- c_xml = Nokogiri::XML(@c.to_xml_string(1,1))
+ c_xml = Nokogiri::XML(@c.to_xml_string(1, 1))
assert(c_xml.xpath("//b").any?)
end
diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb
index 2f31d7a2..80b228d0 100644
--- a/test/workbook/worksheet/tc_col.rb
+++ b/test/workbook/worksheet/tc_col.rb
@@ -6,10 +6,10 @@ class TestCol < Test::Unit::TestCase
end
def test_initialize
- options = { :width => 12, :collapsed => true, :hidden => true, :outline_level => 1, :phonetic => true, :style => 1}
+ options = { :width => 12, :collapsed => true, :hidden => true, :outline_level => 1, :phonetic => true, :style => 1 }
col = Axlsx::Col.new 0, 0, options
- options.each{ |key, value| assert_equal(col.send(key.to_sym), value) }
+ options.each { |key, value| assert_equal(col.send(key.to_sym), value) }
end
def test_min_max_required
diff --git a/test/workbook/worksheet/tc_color_scale.rb b/test/workbook/worksheet/tc_color_scale.rb
index 7f9e5def..073cd71f 100644
--- a/test/workbook/worksheet/tc_color_scale.rb
+++ b/test/workbook/worksheet/tc_color_scale.rb
@@ -21,7 +21,7 @@ class TestColorScale < Test::Unit::TestCase
first = Axlsx::ColorScale.default_cfvos.first
second = Axlsx::ColorScale.default_cfvos.last
assert_equal 'FFFF7128', first[:color]
- assert_equal :min,first[:type]
+ assert_equal :min, first[:type]
assert_equal 0, first[:val]
assert_equal 'FFFFEF9C', second[:color]
@@ -30,7 +30,7 @@ class TestColorScale < Test::Unit::TestCase
end
def test_partial_default_cfvo_override
- first_def = {:type => :percent, :val => "10.0", :color => 'FF00FF00'}
+ first_def = { :type => :percent, :val => "10.0", :color => 'FF00FF00' }
color_scale = Axlsx::ColorScale.new(first_def)
assert_equal color_scale.value_objects.first.val, first_def[:val]
assert_equal color_scale.value_objects.first.type, first_def[:type]
@@ -39,15 +39,15 @@ class TestColorScale < Test::Unit::TestCase
def test_add
@color_scale.add :type => :max, :val => 5, :color => "FFDEDEDE"
- assert_equal(@color_scale.value_objects.size,3)
- assert_equal(@color_scale.colors.size,3)
+ assert_equal(@color_scale.value_objects.size, 3)
+ assert_equal(@color_scale.colors.size, 3)
end
def test_delete_at
@color_scale.add :type => :max, :val => 5, :color => "FFDEDEDE"
- assert_nothing_raised {@color_scale.delete_at 2}
- assert_equal(@color_scale.value_objects.size,2)
- assert_equal(@color_scale.colors.size,2)
+ assert_nothing_raised { @color_scale.delete_at 2 }
+ assert_equal(@color_scale.value_objects.size, 2)
+ assert_equal(@color_scale.colors.size, 2)
end
def test_to_xml_string
diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb
index 44a637e6..cbd93f01 100644
--- a/test/workbook/worksheet/tc_comment.rb
+++ b/test/workbook/worksheet/tc_comment.rb
@@ -47,7 +47,7 @@ class TestComment < Test::Unit::TestCase
assert_equal(pos[0], @c1.vml_shape.left_column)
assert(@c1.vml_shape.top_row == pos[1])
assert_equal(pos[0] + 2, @c1.vml_shape.right_column)
- assert(@c1.vml_shape.bottom_row == pos[1]+4)
+ assert(@c1.vml_shape.bottom_row == pos[1] + 4)
end
def test_to_xml_string
diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb
index 6b07b465..276dd3b0 100644
--- a/test/workbook/worksheet/tc_comments.rb
+++ b/test/workbook/worksheet/tc_comments.rb
@@ -19,7 +19,7 @@ class TestComments < Test::Unit::TestCase
assert_raise(ArgumentError) { @ws.comments.add_comment() }
assert_raise(ArgumentError) { @ws.comments.add_comment(:text => 'Yes We Can', :ref => 'A1') }
assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :ref => 'A1') }
- assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can')}
+ assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can') }
assert_nothing_raised { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can', :ref => 'A1') }
assert_equal(@ws.comments.size, 3)
end
@@ -33,7 +33,7 @@ class TestComments < Test::Unit::TestCase
end
def test_pn
- assert_equal(@ws.comments.pn, Axlsx::COMMENT_PN % (@ws.index+1).to_s)
+ assert_equal(@ws.comments.pn, Axlsx::COMMENT_PN % (@ws.index + 1).to_s)
end
def test_index
diff --git a/test/workbook/worksheet/tc_conditional_formatting.rb b/test/workbook/worksheet/tc_conditional_formatting.rb
index cc885255..dcbb3ca6 100644
--- a/test/workbook/worksheet/tc_conditional_formatting.rb
+++ b/test/workbook/worksheet/tc_conditional_formatting.rb
@@ -3,14 +3,14 @@ require 'tc_helper.rb'
class TestConditionalFormatting < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
- @cfs = @ws.add_conditional_formatting( "A1:A1", [{ :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :greaterThan, :formula => "0.5" }])
+ @ws = p.workbook.add_worksheet :name => "hmmm"
+ @cfs = @ws.add_conditional_formatting("A1:A1", [{ :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :greaterThan, :formula => "0.5" }])
@cf = @cfs.first
@cfr = @cf.rules.first
end
def test_initialize_with_options
- optioned = Axlsx::ConditionalFormatting.new( :sqref => "AA1:AB100", :rules => [1, 2] )
+ optioned = Axlsx::ConditionalFormatting.new(:sqref => "AA1:AB100", :rules => [1, 2])
assert_equal("AA1:AB100", optioned.sqref)
assert_equal([1, 2], optioned.rules)
end
@@ -25,17 +25,17 @@ class TestConditionalFormatting < Test::Unit::TestCase
data_bar = Axlsx::DataBar.new :color => "FFFF0000"
icon_set = Axlsx::IconSet.new :iconSet => "5Rating"
- cfr = Axlsx::ConditionalFormattingRule.new( { :type => :containsText, :text => "TRUE",
+ cfr = Axlsx::ConditionalFormattingRule.new({ :type => :containsText, :text => "TRUE",
:dxfId => 0, :priority => 1,
:formula => 'NOT(ISERROR(SEARCH("FALSE",AB1)))',
:color_scale => color_scale,
:data_bar => data_bar,
- :icon_set => icon_set})
+ :icon_set => icon_set })
assert(cfr.data_bar.is_a?(Axlsx::DataBar))
assert(cfr.icon_set.is_a?(Axlsx::IconSet))
assert(cfr.color_scale.is_a?(Axlsx::ColorScale))
- cfs = @ws.add_conditional_formatting( "B2:B2", [cfr])
+ cfs = @ws.add_conditional_formatting("B2:B2", [cfr])
doc = Nokogiri::XML.parse(cfs.last.to_xml_string)
assert_equal(1, doc.xpath(".//conditionalFormatting[@sqref='B2:B2']//cfRule[@type='containsText'][@dxfId=0][@priority=1]").size)
assert doc.xpath(".//conditionalFormatting//cfRule[@type='containsText'][@dxfId=0][@priority=1]//formula='NOT(ISERROR(SEARCH(\"FALSE\",AB1)))'")
@@ -68,12 +68,12 @@ class TestConditionalFormatting < Test::Unit::TestCase
data_bar = Axlsx::DataBar.new :color => "FFFF0000"
icon_set = Axlsx::IconSet.new :iconSet => "5Rating"
- cfs = @ws.add_conditional_formatting( "B2:B2", [{ :type => :containsText, :text => "TRUE",
+ cfs = @ws.add_conditional_formatting("B2:B2", [{ :type => :containsText, :text => "TRUE",
:dxfId => 0, :priority => 1,
:formula => 'NOT(ISERROR(SEARCH("FALSE",AB1)))',
:color_scale => color_scale,
:data_bar => data_bar,
- :icon_set => icon_set}])
+ :icon_set => icon_set }])
doc = Nokogiri::XML.parse(cfs.last.to_xml_string)
assert_equal(1, doc.xpath(".//conditionalFormatting[@sqref='B2:B2']//cfRule[@type='containsText'][@dxfId=0][@priority=1]").size)
assert doc.xpath(".//conditionalFormatting//cfRule[@type='containsText'][@dxfId=0][@priority=1]//formula='NOT(ISERROR(SEARCH(\"FALSE\",AB1)))'")
@@ -102,11 +102,11 @@ class TestConditionalFormatting < Test::Unit::TestCase
end
def test_many_options
- cf = Axlsx::ConditionalFormatting.new( :sqref => "B3:B4" )
- cf.add_rule({:type => :cellIs, :aboveAverage => false, :bottom => false, :dxfId => 0,
+ cf = Axlsx::ConditionalFormatting.new(:sqref => "B3:B4")
+ cf.add_rule({ :type => :cellIs, :aboveAverage => false, :bottom => false, :dxfId => 0,
:equalAverage => false, :priority => 2, :operator => :lessThan, :text => "",
:percent => false, :rank => 0, :stdDev => 1, :stopIfTrue => true, :timePeriod => :today,
- :formula => "0.0"})
+ :formula => "0.0" })
doc = Nokogiri::XML.parse(cf.to_xml_string)
assert_equal(1, doc.xpath(".//conditionalFormatting//cfRule[@type='cellIs'][@aboveAverage=0][@bottom=0][@dxfId=0][@equalAverage=0][@priority=2][@operator='lessThan'][@text=''][@percent=0][@rank=0][@stdDev=1][@stopIfTrue=1][@timePeriod='today']").size)
assert doc.xpath(".//conditionalFormatting//cfRule[@type='cellIs'][@aboveAverage=0][@bottom=0][@dxfId=0][@equalAverage=0][@priority=2][@operator='lessThan'][@text=''][@percent=0][@rank=0][@stdDev=1][@stopIfTrue=1][@timePeriod='today']//formula=0.0")
@@ -126,7 +126,7 @@ class TestConditionalFormatting < Test::Unit::TestCase
end
def test_multiple_formulas
- @ws.add_conditional_formatting "B3:B3", { :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :between, :formula => ["1 <> 2","5"] }
+ @ws.add_conditional_formatting "B3:B3", { :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :between, :formula => ["1 <> 2", "5"] }
doc = Nokogiri::XML.parse(@ws.to_xml_string)
assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='between']//xmlns:formula='1 <> 2'")
assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='between']//xmlns:formula='5'")
diff --git a/test/workbook/worksheet/tc_data_bar.rb b/test/workbook/worksheet/tc_data_bar.rb
index 65995dd2..aa39c48b 100644
--- a/test/workbook/worksheet/tc_data_bar.rb
+++ b/test/workbook/worksheet/tc_data_bar.rb
@@ -12,26 +12,26 @@ class TestDataBar < Test::Unit::TestCase
end
def test_override_default_cfvos
- data_bar = Axlsx::DataBar.new({:color => 'FF00FF00'}, {:type => :min, :val => "20"})
+ data_bar = Axlsx::DataBar.new({ :color => 'FF00FF00' }, { :type => :min, :val => "20" })
assert_equal("20", data_bar.value_objects.first.val)
assert_equal("0", data_bar.value_objects.last.val)
end
def test_minLength
assert_raise(ArgumentError) { @data_bar.minLength = :invalid_type }
- assert_nothing_raised { @data_bar.minLength = 0}
+ assert_nothing_raised { @data_bar.minLength = 0 }
assert_equal(@data_bar.minLength, 0)
end
def test_maxLength
assert_raise(ArgumentError) { @data_bar.maxLength = :invalid_type }
- assert_nothing_raised { @data_bar.maxLength = 0}
+ assert_nothing_raised { @data_bar.maxLength = 0 }
assert_equal(@data_bar.maxLength, 0)
end
def test_showValue
assert_raise(ArgumentError) { @data_bar.showValue = :invalid_type }
- assert_nothing_raised { @data_bar.showValue = false}
+ assert_nothing_raised { @data_bar.showValue = false }
assert_equal(@data_bar.showValue, false)
end
diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb
index 0d9a2eb0..59fd34f6 100644
--- a/test/workbook/worksheet/tc_data_validation.rb
+++ b/test/workbook/worksheet/tc_data_validation.rb
@@ -12,7 +12,7 @@ class TestDataValidation < Test::Unit::TestCase
@error_style_option = { :errorStyle => :warning }
@string_options = { :formula1 => 'foo', :formula2 => 'foo', :error => 'foo', :errorTitle => 'foo', :prompt => 'foo', :promptTitle => 'foo', :sqref => 'foo' }
- @symbol_options = { :errorStyle => :warning, :operator => :lessThan, :type => :whole}
+ @symbol_options = { :errorStyle => :warning, :operator => :lessThan, :type => :whole }
@options = @boolean_options.merge(@nil_options).merge(@type_option).merge(@error_style_option)
@@ -163,11 +163,11 @@ class TestDataValidation < Test::Unit::TestCase
def test_whole_decimal_data_time_textLength_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"data_validation"
+ @ws = p.workbook.add_worksheet :name => "data_validation"
@ws.add_data_validation("A1", { :type => :whole, :operator => :between, :formula1 => '5', :formula2 => '10',
:showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values between 5 and 10',
:errorStyle => :information, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values between 5 and 10'})
+ :prompt => 'Only values between 5 and 10' })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -192,11 +192,11 @@ class TestDataValidation < Test::Unit::TestCase
def test_list_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"data_validation"
+ @ws = p.workbook.add_worksheet :name => "data_validation"
@ws.add_data_validation("A1", { :type => :list, :formula1 => 'A1:A5',
:showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values from list',
:errorStyle => :stop, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values from list', :hideDropDown => true})
+ :prompt => 'Only values from list', :hideDropDown => true })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -216,11 +216,11 @@ class TestDataValidation < Test::Unit::TestCase
def test_custom_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"data_validation"
+ @ws = p.workbook.add_worksheet :name => "data_validation"
@ws.add_data_validation("A1", { :type => :custom, :formula1 => '=5/2',
:showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values corresponding formula',
:errorStyle => :stop, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values corresponding formula'})
+ :prompt => 'Only values corresponding formula' })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
@@ -239,15 +239,15 @@ class TestDataValidation < Test::Unit::TestCase
def test_multiple_datavalidations_to_xml
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"data_validation"
+ @ws = p.workbook.add_worksheet :name => "data_validation"
@ws.add_data_validation("A1", { :type => :whole, :operator => :between, :formula1 => '5', :formula2 => '10',
:showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values between 5 and 10',
:errorStyle => :information, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values between 5 and 10'})
+ :prompt => 'Only values between 5 and 10' })
@ws.add_data_validation("B1", { :type => :list, :formula1 => 'A1:A5',
:showErrorMessage => true, :errorTitle => 'Wrong input', :error => 'Only values from list',
:errorStyle => :stop, :showInputMessage => true, :promptTitle => 'Be carful!',
- :prompt => 'Only values from list', :hideDropDown => true})
+ :prompt => 'Only values from list', :hideDropDown => true })
doc = Nokogiri::XML.parse(@ws.to_xml_string)
diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb
index 393a9d1a..cb139d45 100644
--- a/test/workbook/worksheet/tc_date_time_converter.rb
+++ b/test/workbook/worksheet/tc_date_time_converter.rb
@@ -114,8 +114,8 @@ class TestDateTimeConverter < Test::Unit::TestCase
local = Time.parse "2012-01-01 09:00:00 +0900"
assert_equal local, utc
- assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f/86400, Axlsx::DateTimeConverter::time_to_serial(utc)
+ assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f / 86400, Axlsx::DateTimeConverter::time_to_serial(utc)
Axlsx::Workbook.date1904 = true
- assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f/86400, Axlsx::DateTimeConverter::time_to_serial(utc)
+ assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f / 86400, Axlsx::DateTimeConverter::time_to_serial(utc)
end
end
diff --git a/test/workbook/worksheet/tc_icon_set.rb b/test/workbook/worksheet/tc_icon_set.rb
index 483de228..3a4079bf 100644
--- a/test/workbook/worksheet/tc_icon_set.rb
+++ b/test/workbook/worksheet/tc_icon_set.rb
@@ -14,25 +14,25 @@ class TestIconSet < Test::Unit::TestCase
def test_icon_set
assert_raise(ArgumentError) { @icon_set.iconSet = "invalid_value" }
- assert_nothing_raised { @icon_set.iconSet = "5Rating"}
+ assert_nothing_raised { @icon_set.iconSet = "5Rating" }
assert_equal(@icon_set.iconSet, "5Rating")
end
def test_percent
assert_raise(ArgumentError) { @icon_set.percent = :invalid_type }
- assert_nothing_raised { @icon_set.percent = false}
+ assert_nothing_raised { @icon_set.percent = false }
assert_equal(@icon_set.percent, false)
end
def test_showValue
assert_raise(ArgumentError) { @icon_set.showValue = :invalid_type }
- assert_nothing_raised { @icon_set.showValue = false}
+ assert_nothing_raised { @icon_set.showValue = false }
assert_equal(@icon_set.showValue, false)
end
def test_reverse
assert_raise(ArgumentError) { @icon_set.reverse = :invalid_type }
- assert_nothing_raised { @icon_set.reverse = false}
+ assert_nothing_raised { @icon_set.reverse = false }
assert_equal(@icon_set.reverse, false)
end
diff --git a/test/workbook/worksheet/tc_page_margins.rb b/test/workbook/worksheet/tc_page_margins.rb
index c1f2a626..ba532e7f 100644
--- a/test/workbook/worksheet/tc_page_margins.rb
+++ b/test/workbook/worksheet/tc_page_margins.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
class TestPageMargins < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- ws = p.workbook.add_worksheet :name=>"hmmm"
+ ws = p.workbook.add_worksheet :name => "hmmm"
@pm = ws.page_margins
end
diff --git a/test/workbook/worksheet/tc_page_setup.rb b/test/workbook/worksheet/tc_page_setup.rb
index c7cec18b..b7a36600 100644
--- a/test/workbook/worksheet/tc_page_setup.rb
+++ b/test/workbook/worksheet/tc_page_setup.rb
@@ -132,9 +132,9 @@ class TestPageSetup < Test::Unit::TestCase
fits = @ps.fit_to(:width => 1)
assert_equal([1, 999], fits)
fits = @ps.fit_to :height => 1
- assert_equal(fits, [999,1])
+ assert_equal(fits, [999, 1])
fits = @ps.fit_to :height => 7, :width => 2
assert_equal(fits, [2, 7])
- assert_raise(ArgumentError) { puts @ps.fit_to(:width => true)}
+ assert_raise(ArgumentError) { puts @ps.fit_to(:width => true) }
end
end
diff --git a/test/workbook/worksheet/tc_pivot_table.rb b/test/workbook/worksheet/tc_pivot_table.rb
index 85aa14cd..83f8fce6 100644
--- a/test/workbook/worksheet/tc_pivot_table.rb
+++ b/test/workbook/worksheet/tc_pivot_table.rb
@@ -16,7 +16,7 @@ class TestPivotTable < Test::Unit::TestCase
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet
- @ws << ["Year","Month","Region", "Type", "Sales"]
+ @ws << ["Year", "Month", "Region", "Type", "Sales"]
@ws << [2012, "Nov", "East", "Soda", "12345"]
end
@@ -54,21 +54,21 @@ class TestPivotTable < Test::Unit::TestCase
end
assert_equal(['Year', 'Month'], pivot_table.rows)
assert_equal(['Type'], pivot_table.columns)
- assert_equal([{:ref=>"Sales"}], pivot_table.data)
+ assert_equal([{ :ref => "Sales" }], pivot_table.data)
assert_equal(['Region'], pivot_table.pages)
shared_test_pivot_table_xml_validity(pivot_table)
end
def test_add_pivot_table_with_options_on_data_field
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:D5') do |pt|
- pt.data = [{:ref=>"Sales", :subtotal => 'average'}]
+ pt.data = [{ :ref => "Sales", :subtotal => 'average' }]
end
- assert_equal([{:ref=>"Sales", :subtotal => 'average'}], pivot_table.data)
+ assert_equal([{ :ref => "Sales", :subtotal => 'average' }], pivot_table.data)
end
def test_add_pivot_table_with_style_info
- style_info_data = { :name=>"PivotStyleMedium9", :showRowHeaders=>"1", :showLastColumn=>"0"}
- pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', {:style_info=>style_info_data}) do |pt|
+ style_info_data = { :name => "PivotStyleMedium9", :showRowHeaders => "1", :showLastColumn => "0" }
+ pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { :style_info => style_info_data }) do |pt|
pt.rows = ['Year', 'Month']
pt.columns = ['Type']
pt.data = ['Sales']
@@ -79,33 +79,33 @@ class TestPivotTable < Test::Unit::TestCase
end
def test_add_pivot_table_with_row_without_subtotals
- pivot_table = @ws.add_pivot_table('G5:G6', 'A1:D5', {:no_subtotals_on_headers=>['Year']}) do |pt|
+ pivot_table = @ws.add_pivot_table('G5:G6', 'A1:D5', { :no_subtotals_on_headers => ['Year'] }) do |pt|
pt.data = ['Sales']
- pt.rows = ['Year','Month']
+ pt.rows = ['Year', 'Month']
end
assert_equal(['Year'], pivot_table.no_subtotals_on_headers)
end
def test_add_pivot_table_with_months_sorted
- pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', {:sort_on_headers=>['Month']}) do |pt|
+ pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { :sort_on_headers => ['Month'] }) do |pt|
pt.data = ['Sales']
- pt.rows = ['Year','Month']
+ pt.rows = ['Year', 'Month']
end
- assert_equal({'Month' => :ascending}, pivot_table.sort_on_headers)
+ assert_equal({ 'Month' => :ascending }, pivot_table.sort_on_headers)
- pivot_table.sort_on_headers = {'Month' => :descending}
- assert_equal({'Month' => :descending}, pivot_table.sort_on_headers)
+ pivot_table.sort_on_headers = { 'Month' => :descending }
+ assert_equal({ 'Month' => :descending }, pivot_table.sort_on_headers)
shared_test_pivot_table_xml_validity(pivot_table)
end
def test_header_indices
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5')
- assert_equal(0, pivot_table.header_index_of('Year' ))
- assert_equal(1, pivot_table.header_index_of('Month' ))
- assert_equal(2, pivot_table.header_index_of('Region' ))
- assert_equal(3, pivot_table.header_index_of('Type' ))
- assert_equal(4, pivot_table.header_index_of('Sales' ))
+ assert_equal(0, pivot_table.header_index_of('Year'))
+ assert_equal(1, pivot_table.header_index_of('Month'))
+ assert_equal(2, pivot_table.header_index_of('Region'))
+ assert_equal(3, pivot_table.header_index_of('Type'))
+ assert_equal(4, pivot_table.header_index_of('Sales'))
assert_equal(nil, pivot_table.header_index_of('Missing'))
assert_equal(%w(A1 B1 C1 D1 E1), pivot_table.header_cell_refs)
end
@@ -129,7 +129,7 @@ class TestPivotTable < Test::Unit::TestCase
end
def test_to_xml_string
- pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', {:no_subtotals_on_headers=>['Year']}) do |pt|
+ pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5', { :no_subtotals_on_headers => ['Year'] }) do |pt|
pt.rows = ['Year', 'Month']
pt.columns = ['Type']
pt.data = ['Sales']
@@ -140,14 +140,14 @@ class TestPivotTable < Test::Unit::TestCase
def test_to_xml_string_with_options_on_data_field
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5') do |pt|
- pt.data = [{:ref=>"Sales", :subtotal => 'average'}]
+ pt.data = [{ :ref => "Sales", :subtotal => 'average' }]
end
shared_test_pivot_table_xml_validity(pivot_table)
end
def test_add_pivot_table_with_format_options_on_data_field
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5') do |pt|
- pt.data = [{:ref=>"Sales", :subtotal => 'sum', num_fmt: 4}]
+ pt.data = [{ :ref => "Sales", :subtotal => 'sum', num_fmt: 4 }]
end
doc = Nokogiri::XML(pivot_table.to_xml_string)
assert_equal('4', doc.at_css('dataFields dataField')['numFmtId'], 'adding format options to pivot_table')
@@ -159,9 +159,9 @@ class TestPivotTable < Test::Unit::TestCase
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5') do |pt|
pt.rows = ["Date", "Name"]
pt.data = [
- {ref: "Gross amount", num_fmt: 2},
- {ref: "Net amount", num_fmt: 2},
- {ref: "Margin", num_fmt: 2}
+ { ref: "Gross amount", num_fmt: 2 },
+ { ref: "Net amount", num_fmt: 2 },
+ { ref: "Margin", num_fmt: 2 }
]
end
@@ -177,8 +177,8 @@ class TestPivotTable < Test::Unit::TestCase
assert_equal('-2', doc.at_css('colFields field')['x'])
assert_equal('3', doc.at_css('colItems')['count'])
- assert_equal( 3, doc.at_css('colItems').children.size)
- assert_nil( doc.at_css('colItems i')['x'])
+ assert_equal(3, doc.at_css('colItems').children.size)
+ assert_nil(doc.at_css('colItems i')['x'])
assert_equal('1', doc.at_css('colItems i[i=1] x')['v'])
assert_equal('2', doc.at_css('colItems i[i=2] x')['v'])
end
@@ -189,7 +189,7 @@ class TestPivotTable < Test::Unit::TestCase
pivot_table = @ws.add_pivot_table('G5:G6', 'A1:E5') do |pt|
pt.rows = ["Date", "Name"]
pt.data = [
- {ref: "Gross amount", num_fmt: 2}
+ { ref: "Gross amount", num_fmt: 2 }
]
end
diff --git a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb
index 37d7e485..2127c4b3 100644
--- a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb
+++ b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb
@@ -5,7 +5,7 @@ class TestPivotTableCacheDefinition < Test::Unit::TestCase
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet
5.times do
- @ws << ["aa","aa","aa","aa"]
+ @ws << ["aa", "aa", "aa", "aa"]
end
@pivot_table = @ws.add_pivot_table('G5:G6', 'A1:D5')
@cache_definition = @pivot_table.cache_definition
diff --git a/test/workbook/worksheet/tc_protected_range.rb b/test/workbook/worksheet/tc_protected_range.rb
index 52d07d77..6d609097 100644
--- a/test/workbook/worksheet/tc_protected_range.rb
+++ b/test/workbook/worksheet/tc_protected_range.rb
@@ -2,11 +2,11 @@ require 'tc_helper.rb'
class TestProtectedRange < Test::Unit::TestCase
def setup
@p = Axlsx::Package.new
- @ws = @p.workbook.add_worksheet { |sheet| sheet.add_row [1,2,3,4,5,6,7,8,9] }
+ @ws = @p.workbook.add_worksheet { |sheet| sheet.add_row [1, 2, 3, 4, 5, 6, 7, 8, 9] }
end
def test_initialize_options
- assert_nothing_raised {Axlsx::ProtectedRange.new(:sqref => 'A1:B1', :name => "only bob")}
+ assert_nothing_raised { Axlsx::ProtectedRange.new(:sqref => 'A1:B1', :name => "only bob") }
end
def test_range
diff --git a/test/workbook/worksheet/tc_rich_text.rb b/test/workbook/worksheet/tc_rich_text.rb
index 1bd3ec76..34117b1b 100644
--- a/test/workbook/worksheet/tc_rich_text.rb
+++ b/test/workbook/worksheet/tc_rich_text.rb
@@ -8,7 +8,7 @@ class RichText < Test::Unit::TestCase
@rt = Axlsx::RichText.new
b = true
(0..26).each do |r|
- @rt.add_run "run #{r}, ", :b => (b=!b), :i => !b
+ @rt.add_run "run #{r}, ", :b => (b = !b), :i => !b
end
@row = @ws.add_row [@rt]
@c = @row.first
@@ -22,7 +22,7 @@ class RichText < Test::Unit::TestCase
assert_equal(rt_direct.runs.length, 1)
assert_equal(rt_indirect.runs.length, 1)
row = @ws.add_row [rt_direct, rt_indirect]
- assert_equal(row[0].to_xml_string(0,0), row[1].to_xml_string(0,0))
+ assert_equal(row[0].to_xml_string(0, 0), row[1].to_xml_string(0, 0))
end
def test_textruns
@@ -39,6 +39,6 @@ class RichText < Test::Unit::TestCase
row_rt = @ws.add_row [rt]
row_imp = @ws.add_row ['a']
row_imp[0].b = true
- assert_equal(row_rt[0].to_xml_string(0,0), row_imp[0].to_xml_string(0,0))
+ assert_equal(row_rt[0].to_xml_string(0, 0), row_imp[0].to_xml_string(0, 0))
end
end
diff --git a/test/workbook/worksheet/tc_rich_text_run.rb b/test/workbook/worksheet/tc_rich_text_run.rb
index 39919a31..d21329a9 100644
--- a/test/workbook/worksheet/tc_rich_text_run.rb
+++ b/test/workbook/worksheet/tc_rich_text_run.rb
@@ -106,7 +106,7 @@ class RichTextRun < Test::Unit::TestCase
assert_raise(ArgumentError) { @c.u = -1.1 }
assert_nothing_raised { @c.u = :single }
assert_equal(@c.u, :single)
- doc = Nokogiri::XML(@c.to_xml_string(1,1))
+ doc = Nokogiri::XML(@c.to_xml_string(1, 1))
assert(doc.xpath('//u[@val="single"]'))
end
@@ -141,7 +141,7 @@ class RichTextRun < Test::Unit::TestCase
end
def test_multiline_autowidth
- wrap = @p.workbook.styles.add_style({:alignment => {:wrap_text => true}})
+ wrap = @p.workbook.styles.add_style({ :alignment => { :wrap_text => true } })
awtr = Axlsx::RichTextRun.new('I\'m bold' + "\n", :b => true)
rt = Axlsx::RichText.new
rt.runs << awtr
diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb
index 900e751e..29c4415b 100644
--- a/test/workbook/worksheet/tc_row.rb
+++ b/test/workbook/worksheet/tc_row.rb
@@ -3,7 +3,7 @@ require 'tc_helper.rb'
class TestRow < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
- @ws = p.workbook.add_worksheet :name=>"hmmm"
+ @ws = p.workbook.add_worksheet :name => "hmmm"
@row = @ws.add_row
end
@@ -15,19 +15,19 @@ class TestRow < Test::Unit::TestCase
end
def test_initialize_with_fixed_height
- row = @ws.add_row([1,2,3,4,5], :height=>40)
+ row = @ws.add_row([1, 2, 3, 4, 5], :height => 40)
assert_equal(40, row.height)
assert(row.custom_height)
end
def test_style
- r = @ws.add_row([1,2,3,4,5])
- r.style=1
- r.cells.each { |c| assert_equal(c.style,1) }
+ r = @ws.add_row([1, 2, 3, 4, 5])
+ r.style = 1
+ r.cells.each { |c| assert_equal(c.style, 1) }
end
def test_color
- r = @ws.add_row([1,2,3,4,5])
+ r = @ws.add_row([1, 2, 3, 4, 5])
r.color = "FF00FF00"
r.cells.each { |c| assert_equal(c.color.rgb, "FF00FF00") }
end
@@ -48,12 +48,12 @@ class TestRow < Test::Unit::TestCase
end
def test_array_to_cells
- r = @ws.add_row [1,2,3], :style=>1, :types=>[:integer, :string, :float]
+ r = @ws.add_row [1, 2, 3], :style => 1, :types => [:integer, :string, :float]
assert_equal(r.cells.size, 3)
r.cells.each do |c|
assert_equal(c.style, 1)
end
- r = @ws.add_row [1,2,3], :style=>[1]
+ r = @ws.add_row [1, 2, 3], :style => [1]
assert_equal(r.cells.first.style, 1, "only apply style to cells with at the same index of of the style array")
assert_equal(r.cells.last.style, 0, "only apply style to cells with at the same index of of the style array")
end
@@ -135,7 +135,7 @@ class TestRow < Test::Unit::TestCase
def test_offsets
offset = 3
- values = [1,2,3,4,5]
+ values = [1, 2, 3, 4, 5]
r = @ws.add_row(values, offset: offset, style: 1)
r.cells.each_with_index do |c, index|
assert_equal(c.style, index < offset ? 0 : 1)
@@ -145,11 +145,11 @@ class TestRow < Test::Unit::TestCase
def test_offsets_with_styles
offset = 3
- values = [1,2,3,4,5]
- styles = (1..5).map{ @ws.workbook.styles.add_style }
+ values = [1, 2, 3, 4, 5]
+ styles = (1..5).map { @ws.workbook.styles.add_style }
r = @ws.add_row(values, offset: offset, style: styles)
r.cells.each_with_index do |c, index|
- assert_equal(c.style, index < offset ? 0 : styles[index-offset])
+ assert_equal(c.style, index < offset ? 0 : styles[index - offset])
assert_equal(c.value, index < offset ? nil : values[index - offset])
end
end
diff --git a/test/workbook/worksheet/tc_sheet_format_pr.rb b/test/workbook/worksheet/tc_sheet_format_pr.rb
index ef4eb0d8..48643bc6 100644
--- a/test/workbook/worksheet/tc_sheet_format_pr.rb
+++ b/test/workbook/worksheet/tc_sheet_format_pr.rb
@@ -45,31 +45,31 @@ class TestSheetFormatPr < Test::Unit::TestCase
def test_default_row_height
assert_raise(ArgumentError) { @sheet_format_pr.default_row_height = :foo }
- assert_nothing_raised { @sheet_format_pr.default_row_height= 1.0 }
+ assert_nothing_raised { @sheet_format_pr.default_row_height = 1.0 }
end
def test_default_col_width
- assert_raise(ArgumentError) { @sheet_format_pr.default_col_width= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.default_col_width = :foo }
assert_nothing_raised { @sheet_format_pr.default_col_width = 1.0 }
end
def test_custom_height
- assert_raise(ArgumentError) { @sheet_format_pr.custom_height= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.custom_height = :foo }
assert_nothing_raised { @sheet_format_pr.custom_height = true }
end
def test_zero_height
- assert_raise(ArgumentError) { @sheet_format_pr.zero_height= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.zero_height = :foo }
assert_nothing_raised { @sheet_format_pr.zero_height = true }
end
def test_thick_top
- assert_raise(ArgumentError) { @sheet_format_pr.thick_top= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.thick_top = :foo }
assert_nothing_raised { @sheet_format_pr.thick_top = true }
end
def test_thick_bottom
- assert_raise(ArgumentError) { @sheet_format_pr.thick_bottom= :foo }
+ assert_raise(ArgumentError) { @sheet_format_pr.thick_bottom = :foo }
assert_nothing_raised { @sheet_format_pr.thick_bottom = true }
end
diff --git a/test/workbook/worksheet/tc_sheet_pr.rb b/test/workbook/worksheet/tc_sheet_pr.rb
index f6ffcfdb..70ce0428 100644
--- a/test/workbook/worksheet/tc_sheet_pr.rb
+++ b/test/workbook/worksheet/tc_sheet_pr.rb
@@ -20,7 +20,7 @@ class TestSheetPr < Test::Unit::TestCase
def test_initialization
@options.each do |key, value|
- if key==:tab_color
+ if key == :tab_color
stored_value = @sheet_pr.send(key)
assert_equal Axlsx::Color, stored_value.class
assert_equal value, stored_value.rgb
diff --git a/test/workbook/worksheet/tc_sheet_protection.rb b/test/workbook/worksheet/tc_sheet_protection.rb
index 26297bc4..8d5452cc 100644
--- a/test/workbook/worksheet/tc_sheet_protection.rb
+++ b/test/workbook/worksheet/tc_sheet_protection.rb
@@ -55,7 +55,7 @@ class TestSheetProtection < Test::Unit::TestCase
@sp.password = 'fish' # -> CA3F
doc = Nokogiri::XML(@sp.to_xml_string)
@options.each do |key, value|
- assert(doc.xpath("//sheetProtection[@#{key.to_s.gsub(/_(.)/){ $1.upcase }}='#{value}']"))
+ assert(doc.xpath("//sheetProtection[@#{key.to_s.gsub(/_(.)/) { $1.upcase }}='#{value}']"))
end
end
end
diff --git a/test/workbook/worksheet/tc_table.rb b/test/workbook/worksheet/tc_table.rb
index 1a90f0bc..7a2e5987 100644
--- a/test/workbook/worksheet/tc_table.rb
+++ b/test/workbook/worksheet/tc_table.rb
@@ -5,7 +5,7 @@ class TestTable < Test::Unit::TestCase
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet
40.times do
- @ws << ["aa","aa","aa","aa","aa","aa"]
+ @ws << ["aa", "aa", "aa", "aa", "aa", "aa"]
end
end
diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb
index 19beaaba..2067959c 100644
--- a/test/workbook/worksheet/tc_table_style_info.rb
+++ b/test/workbook/worksheet/tc_table_style_info.rb
@@ -7,7 +7,7 @@ class TestTableStyleInfo < Test::Unit::TestCase
40.times do
@ws.add_row %w(aa bb cc dd ee ff gg hh ii jj kk)
end
- @table = @ws.add_table(Axlsx::cell_range([@ws.rows.first.cells.first,@ws.rows.last.cells.last], false), :name => 'foo')
+ @table = @ws.add_table(Axlsx::cell_range([@ws.rows.first.cells.first, @ws.rows.last.cells.last], false), :name => 'foo')
@options = { :show_first_column => 1,
:show_last_column => 1,
:show_row_stripes => 1,
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index 8475f5aa..bae9f904 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -29,7 +29,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_name_unique
- assert_raise(ArgumentError, "worksheet name must be unique") { n = @ws.name; @ws.workbook.add_worksheet(:name=> n) }
+ assert_raise(ArgumentError, "worksheet name must be unique") { n = @ws.name; @ws.workbook.add_worksheet(:name => n) }
end
def test_name_unique_only_checks_other_worksheet_names
@@ -107,15 +107,15 @@ class TestWorksheet < Test::Unit::TestCase
def test_no_autowidth
@ws.workbook.use_autowidth = false
- @ws.add_row [1,2,3,4]
+ @ws.add_row [1, 2, 3, 4]
assert_equal(@ws.column_info[0].width, nil)
end
def test_initialization_options
- page_margins = {:left => 2, :right => 2, :bottom => 2, :top => 2, :header => 2, :footer => 2}
- page_setup = {:fit_to_height => 1, :fit_to_width => 1, :orientation => :landscape, :paper_width => "210mm", :paper_height => "297mm", :scale => 80}
- print_options = {:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true}
- header_footer = {:different_first => false, :different_odd_even => false, :odd_header => 'Header'}
+ page_margins = { :left => 2, :right => 2, :bottom => 2, :top => 2, :header => 2, :footer => 2 }
+ page_setup = { :fit_to_height => 1, :fit_to_width => 1, :orientation => :landscape, :paper_width => "210mm", :paper_height => "297mm", :scale => 80 }
+ print_options = { :grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true }
+ header_footer = { :different_first => false, :different_odd_even => false, :odd_header => 'Header' }
optioned = @ws.workbook.add_worksheet(:name => 'bob', :page_margins => page_margins, :page_setup => page_setup, :print_options => print_options, :header_footer => header_footer)
page_margins.keys.each do |key|
assert_equal(page_margins[key], optioned.page_margins.send(key))
@@ -175,8 +175,8 @@ class TestWorksheet < Test::Unit::TestCase
range = @ws["A1:C2"]
first_row = @ws[0]
last_row = @ws[1]
- assert_equal(@ws.rows[0],first_row)
- assert_equal(@ws.rows[1],last_row)
+ assert_equal(@ws.rows[0], first_row)
+ assert_equal(@ws.rows[1], last_row)
assert_equal(range.size, 6)
assert_equal(range.first, @ws.rows.first.cells.first)
assert_equal(range.last, @ws.rows.last.cells.last)
@@ -184,7 +184,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_add_row
assert(@ws.rows.empty?, "sheet has no rows by default")
- r = @ws.add_row([1,2,3])
+ r = @ws.add_row([1, 2, 3])
assert_equal(@ws.rows.size, 1, "add_row adds a row")
assert_equal(@ws.rows.first, r, "the row returned is the row added")
end
@@ -227,11 +227,11 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_col_style
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3,4]
- @ws.col_style( (1..2), 1, :row_offset=>1)
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.col_style((1..2), 1, :row_offset => 1)
@ws.rows[(1..-1)].each do |r|
assert_equal(r.cells[1].style, 1)
assert_equal(r.cells[2].style, 1)
@@ -241,41 +241,41 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_col_style_with_empty_column
- @ws.add_row [1,2,3,4]
+ @ws.add_row [1, 2, 3, 4]
@ws.add_row [1]
- @ws.add_row [1,2,3,4]
- assert_nothing_raised {@ws.col_style(1, 1)}
+ @ws.add_row [1, 2, 3, 4]
+ assert_nothing_raised { @ws.col_style(1, 1) }
end
def test_cols
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3]
- @ws.add_row [1,2,3,4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3]
+ @ws.add_row [1, 2, 3, 4]
c = @ws.cols[1]
assert_equal(c.size, 4)
assert_equal(c[0].value, 2)
end
def test_cols_with_block
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
@ws.add_row [1]
- cols = @ws.cols {|row, column| :foo }
+ cols = @ws.cols { |row, column| :foo }
assert_equal(:foo, cols[1][1])
end
def test_row_style
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3,4]
- @ws.add_row [1,2,3,4]
- @ws.row_style 1, 1, :col_offset=>1
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.add_row [1, 2, 3, 4]
+ @ws.row_style 1, 1, :col_offset => 1
@ws.rows[1].cells[(1..-1)].each do |c|
assert_equal(c.style, 1)
end
assert_equal(@ws.rows[1].cells[0].style, 0)
assert_equal(@ws.rows[2].cells[1].style, 0)
- @ws.row_style( 1..2, 1, :col_offset => 2)
+ @ws.row_style(1..2, 1, :col_offset => 2)
@ws.rows[(1..2)].each do |r|
r.cells[(2..-1)].each do |c|
assert_equal(c.style, 1)
@@ -290,7 +290,7 @@ class TestWorksheet < Test::Unit::TestCase
# end
def test_to_xml_string_dimensions
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:dimension[@ref="A1:C1"]').size, 1)
end
@@ -414,7 +414,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_to_xml_string
schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
doc = Nokogiri::XML(@ws.to_xml_string)
- assert(schema.validate(doc).map{ |e| puts e.message; e }.empty?, "error free validation")
+ assert(schema.validate(doc).map { |e| puts e.message; e }.empty?, "error free validation")
end
def test_styles
@@ -424,7 +424,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_to_xml_string_with_illegal_chars
old = Axlsx::trust_input
Axlsx::trust_input = false
- nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
+ nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
@ws.add_row [nasties]
assert_equal(0, @ws.rows.last.cells.last.value.index("\v"))
assert_equal(nil, @ws.to_xml_string.index("\v"))
@@ -455,7 +455,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_relationships
- @ws.add_row [1,2,3]
+ @ws.add_row [1, 2, 3]
assert(@ws.relationships.empty?, "No Drawing relationship until you add a chart")
@ws.add_chart Axlsx::Pie3DChart
assert_equal(@ws.relationships.size, 1, "adding a chart creates the relationship")
@@ -529,14 +529,14 @@ class TestWorksheet < Test::Unit::TestCase
def test_protect_range_with_cells
@ws.add_row [1, 2, 3]
- assert_nothing_raised {@ws.protect_range(@ws.rows.first.cells) }
+ assert_nothing_raised { @ws.protect_range(@ws.rows.first.cells) }
assert_equal('A1:C1', @ws.send(:protected_ranges).last.sqref)
end
def test_merge_cells
- @ws.add_row [1,2,3]
- @ws.add_row [4,5,6]
- @ws.add_row [7,8,9]
+ @ws.add_row [1, 2, 3]
+ @ws.add_row [4, 5, 6]
+ @ws.add_row [7, 8, 9]
@ws.merge_cells "A1:A2"
@ws.merge_cells "B2:C3"
@ws.merge_cells @ws.rows.last.cells[(0..1)]
@@ -554,12 +554,12 @@ class TestWorksheet < Test::Unit::TestCase
def test_auto_filter
assert(@ws.auto_filter.range.nil?)
- assert(@wb.defined_names.none?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
+ assert(@wb.defined_names.none? { |defined_name| defined_name.name == '_xlnm._FilterDatabase' })
assert_raise(ArgumentError) { @ws.auto_filter = 123 }
@ws.auto_filter.range = "A1:D9"
assert_equal(@ws.auto_filter.range, "A1:D9")
@ws.to_xml_string
- assert(@wb.defined_names.any?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
+ assert(@wb.defined_names.any? { |defined_name| defined_name.name == '_xlnm._FilterDatabase' })
end
def test_auto_filter_assign
@@ -567,7 +567,7 @@ class TestWorksheet < Test::Unit::TestCase
assert(@ws.auto_filter.range.nil?)
assert(other_ws.auto_filter.range.nil?)
- assert(@wb.defined_names.none?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'})
+ assert(@wb.defined_names.none? { |defined_name| defined_name.name == '_xlnm._FilterDatabase' })
assert_raise(ArgumentError) { @ws.auto_filter = 123 }
@ws.auto_filter = "A1:D9"
@@ -579,7 +579,7 @@ class TestWorksheet < Test::Unit::TestCase
@ws.to_xml_string
other_ws.to_xml_string
- filter_database = @wb.defined_names.select{|defined_name| defined_name.name=='_xlnm._FilterDatabase'}
+ filter_database = @wb.defined_names.select { |defined_name| defined_name.name == '_xlnm._FilterDatabase' }
assert_equal(2, filter_database.size)
assert_equal(@ws.index, filter_database[0].local_sheet_id)
assert_equal(other_ws.index, filter_database[1].local_sheet_id)
@@ -593,7 +593,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_outline_level_rows
- 3.times { @ws.add_row [1,2,3] }
+ 3.times { @ws.add_row [1, 2, 3] }
@ws.outline_level_rows 0, 2
assert_equal(1, @ws.rows[0].outline_level)
assert_equal(true, @ws.rows[2].hidden)
@@ -601,7 +601,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_outline_level_columns
- 3.times { @ws.add_row [1,2,3] }
+ 3.times { @ws.add_row [1, 2, 3] }
@ws.outline_level_columns 0, 2
assert_equal(1, @ws.column_info[0].outline_level)
assert_equal(true, @ws.column_info[2].hidden)
@@ -717,16 +717,16 @@ class TestWorksheet < Test::Unit::TestCase
wb.add_worksheet do |sheet|
20.times.each do
- sheet.add_row [1,2,3,4,5]
+ sheet.add_row [1, 2, 3, 4, 5]
end
sheet.add_border "B2:D5"
- sheet.add_border ["C3:C4", "D3:D4", "A2"], {color: "FF00000"}
+ sheet.add_border ["C3:C4", "D3:D4", "A2"], { color: "FF00000" }
sheet.add_border "B10:E10", [:top, :bottom, :left, :right]
sheet.add_border "B12:E12", :all
sheet.add_border "B14:E14", Axlsx::Border::EDGES
- sheet.add_border "B16:E16", {edges: :all, style: :thick}
- sheet.add_border "B18:E18", {edges: [:top], style: :thick, color: "FFFFF00"}
+ sheet.add_border "B16:E16", { edges: :all, style: :thick }
+ sheet.add_border "B18:E18", { edges: [:top], style: :thick, color: "FFFFF00" }
end
wb.apply_styles
@@ -786,7 +786,7 @@ class TestWorksheet < Test::Unit::TestCase
sz: 11,
family: 1
}
- assert_equal b2_cell_style, wb.styles.style_index.values.find{|x| x == b2_cell_style}
+ assert_equal b2_cell_style, wb.styles.style_index.values.find { |x| x == b2_cell_style }
d3_cell_style = {
border: {
@@ -799,7 +799,7 @@ class TestWorksheet < Test::Unit::TestCase
sz: 11,
family: 1
}
- assert_equal d3_cell_style, wb.styles.style_index.values.find{|x| x == d3_cell_style}
+ assert_equal d3_cell_style, wb.styles.style_index.values.find { |x| x == d3_cell_style }
end
def test_mixed_borders_1
@@ -872,7 +872,7 @@ class TestWorksheet < Test::Unit::TestCase
wb.styles.fonts[0].sz = 12
wb.add_worksheet do |sheet|
- sheet.add_row [1,2,3]
+ sheet.add_row [1, 2, 3]
sheet.add_style "A1:C1", { color: "FFFFFF" }
end