diff options
| author | Geremia Taglialatela <[email protected]> | 2023-05-22 20:13:13 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-05-22 20:13:13 +0200 |
| commit | 083c4c6d62011cd88966d608b0c6bb736f300a0c (patch) | |
| tree | b5ceb9b3a32c4130d84c3075966b4033bf32a118 | |
| parent | 6752225bbb8a9eec905ec02a98f1a25a309c404a (diff) | |
| download | caxlsx-083c4c6d62011cd88966d608b0c6bb736f300a0c.tar.gz caxlsx-083c4c6d62011cd88966d608b0c6bb736f300a0c.zip | |
Use Ruby 1.9 hash syntax (non-production code)
92 files changed, 512 insertions, 519 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 4ab6b157..7d315f1b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -37,6 +37,11 @@ Performance: Style: Enabled: true +# FIXME: remove this rule +Style/HashSyntax: + Exclude: + - 'lib/**/*' + Style/Semicolon: AllowAsExpressionSeparator: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1de00edb..3e09044c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -77,11 +77,6 @@ Lint/UnusedMethodArgument: - 'lib/axlsx/package.rb' - 'lib/axlsx/util/validators.rb' -Lint/UselessAssignment: - Exclude: - - 'lib/axlsx/workbook/worksheet/header_footer.rb' - - 'lib/axlsx/workbook/worksheet/sheet_protection.rb' - # Configuration parameters: MinSize. Performance/CollectionLiteralInLoop: Exclude: @@ -216,13 +211,6 @@ Style/HashEachMethods: - 'lib/axlsx/workbook/worksheet/rich_text_run.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: - Enabled: false - -# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowIfModifier. Style/IfInsideElse: Exclude: @@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/lib/axlsx/version.rb') -task :build => :gendoc do +task build: :gendoc do system "gem build axlsx.gemspec" end @@ -23,8 +23,8 @@ Rake::TestTask.new do |t| t.warning = true end -task :release => :build do +task release: :build do system "gem push caxlsx-#{Axlsx::VERSION}.gem" end -task :default => :test +task default: :test diff --git a/test/content_type/tc_default.rb b/test/content_type/tc_default.rb index 89125bf1..d9ae1dd3 100644 --- a/test/content_type/tc_default.rb +++ b/test/content_type/tc_default.rb @@ -4,11 +4,11 @@ require 'tc_helper' 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(1, doc.xpath("Default[@ContentType='#{Axlsx::XML_CT}']").size) diff --git a/test/content_type/tc_override.rb b/test/content_type/tc_override.rb index 73a13410..c9cf3c4c 100644 --- a/test/content_type/tc_override.rb +++ b/test/content_type/tc_override.rb @@ -4,11 +4,11 @@ require 'tc_helper' 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(1, doc.xpath("Override[@ContentType='#{Axlsx::CHART_CT}']").size) diff --git a/test/doc_props/tc_app.rb b/test/doc_props/tc_app.rb index d96723db..82e33f12 100644 --- a/test/doc_props/tc_app.rb +++ b/test/doc_props/tc_app.rb @@ -5,29 +5,29 @@ require 'tc_helper' class TestApp < Test::Unit::TestCase def setup options = { - :Template => 'Foo.xlt', - :Manager => 'Penny', - :Company => "Bob's Repair", - :Pages => 1, - :Words => 2, - :Characters => 7, - :PresentationFormat => 'any', - :Lines => 1, - :Paragraphs => 1, - :Slides => 4, - :Notes => 1, - :TotalTime => 2, - :HidddenSlides => 3, - :MMClips => 10, - :ScaleCrop => true, - :LinksUpToDate => true, - :CharactersWithSpaces => 9, - :SharedDoc => false, - :HyperlinkBase => 'foo', - :HyperlInksChanged => false, - :Application => 'axlsx', - :AppVersion => '1.1.5', - :DocSecurity => 0 + Template: 'Foo.xlt', + Manager: 'Penny', + Company: "Bob's Repair", + Pages: 1, + Words: 2, + Characters: 7, + PresentationFormat: 'any', + Lines: 1, + Paragraphs: 1, + Slides: 4, + Notes: 1, + TotalTime: 2, + HidddenSlides: 3, + MMClips: 10, + ScaleCrop: true, + LinksUpToDate: true, + CharactersWithSpaces: 9, + SharedDoc: false, + HyperlinkBase: 'foo', + HyperlInksChanged: false, + Application: 'axlsx', + AppVersion: '1.1.5', + DocSecurity: 0 } @app = Axlsx::App.new options diff --git a/test/doc_props/tc_core.rb b/test/doc_props/tc_core.rb index 9714a6eb..bfacab45 100644 --- a/test/doc_props/tc_core.rb +++ b/test/doc_props/tc_core.rb @@ -27,7 +27,7 @@ class TestCore < Test::Unit::TestCase def test_created_as_option time = Time.utc(2013, 1, 1, 12, 0) - c = Axlsx::Core.new :created => time + c = Axlsx::Core.new created: time doc = Nokogiri::XML(c.to_xml_string) assert_equal(doc.xpath('//dcterms:created').text, time.xmlschema, "dcterms:created incorrect") @@ -38,7 +38,7 @@ class TestCore < Test::Unit::TestCase end def test_creator_as_option - c = Axlsx::Core.new :creator => "some guy" + c = Axlsx::Core.new creator: "some guy" doc = Nokogiri::XML(c.to_xml_string) assert_equal("some guy", doc.xpath('//dc:creator').text) diff --git a/test/drawing/tc_area_chart.rb b/test/drawing/tc_area_chart.rb index 5829149a..3aa7d20c 100644 --- a/test/drawing/tc_area_chart.rb +++ b/test/drawing/tc_area_chart.rb @@ -7,7 +7,7 @@ class TestAreaChart < Test::Unit::TestCase @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @row = ws.add_row ["one", 1, Time.now] - @chart = ws.add_chart Axlsx::AreaChart, :title => "fishery" + @chart = ws.add_chart Axlsx::AreaChart, title: "fishery" end def teardown; end diff --git a/test/drawing/tc_area_series.rb b/test/drawing/tc_area_series.rb index c9b9a949..334a3ba4 100644 --- a/test/drawing/tc_area_series.rb +++ b/test/drawing/tc_area_series.rb @@ -5,15 +5,15 @@ require 'tc_helper' class TestAreaSeries < Test::Unit::TestCase def setup p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "hmmm" - chart = @ws.add_chart Axlsx::AreaChart, :title => "fishery" + @ws = p.workbook.add_worksheet name: "hmmm" + chart = @ws.add_chart Axlsx::AreaChart, title: "fishery" @series = chart.add_series( - :data => [0, 1, 2], - :labels => ["zero", "one", "two"], - :title => "bob", - :color => "#FF0000", - :show_marker => true, - :smooth => true + data: [0, 1, 2], + labels: ["zero", "one", "two"], + title: "bob", + color: "#FF0000", + show_marker: true, + smooth: true ) end diff --git a/test/drawing/tc_axes.rb b/test/drawing/tc_axes.rb index 2e9aab90..7ec5613c 100644 --- a/test/drawing/tc_axes.rb +++ b/test/drawing/tc_axes.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestAxes < Test::Unit::TestCase def test_constructor_requires_cat_axis_first - assert_raise(ArgumentError) { Axlsx::Axes.new(:val_axis => Axlsx::ValAxis, :cat_axis => Axlsx::CatAxis) } - assert_nothing_raised { Axlsx::Axes.new(:cat_axis => Axlsx::CatAxis, :val_axis => Axlsx::ValAxis) } + assert_raise(ArgumentError) { Axlsx::Axes.new(val_axis: Axlsx::ValAxis, cat_axis: Axlsx::CatAxis) } + assert_nothing_raised { Axlsx::Axes.new(cat_axis: Axlsx::CatAxis, val_axis: Axlsx::ValAxis) } end end diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb index 59f48d1d..cbe7187e 100644 --- a/test/drawing/tc_axis.rb +++ b/test/drawing/tc_axis.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestAxis < Test::Unit::TestCase def setup - @axis = Axlsx::Axis.new :gridlines => false, :title => 'Foo' + @axis = Axlsx::Axis.new gridlines: false, title: 'Foo' end def test_initialization @@ -28,12 +28,12 @@ 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] sheet.add_chart(Axlsx::Line3DChart) do |chart| - chart.add_series :data => sheet['B2:D2'], :labels => sheet['B1'] + chart.add_series data: sheet['B2:D2'], labels: sheet['B1'] chart.val_axis.title = sheet['A1'] assert_equal('battle victories', chart.val_axis.title.text) @@ -66,10 +66,10 @@ class TestAxis < Test::Unit::TestCase def create_chart_with_formatting(format_string = nil) p = Axlsx::Package.new - p.workbook.add_worksheet(:name => "Formatting Test") do |sheet| + 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| - chart.add_series :data => sheet["B1:B1"], :labels => sheet["A1:A1"] + 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) yield doc diff --git a/test/drawing/tc_bar_3D_chart.rb b/test/drawing/tc_bar_3D_chart.rb index d825ce94..b01dcd38 100644 --- a/test/drawing/tc_bar_3D_chart.rb +++ b/test/drawing/tc_bar_3D_chart.rb @@ -7,7 +7,7 @@ class TestBar3DChart < Test::Unit::TestCase @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @row = ws.add_row ["one", 1, Time.now] - @chart = ws.add_chart Axlsx::Bar3DChart, :title => "fishery" + @chart = ws.add_chart Axlsx::Bar3DChart, title: "fishery" end def teardown; end diff --git a/test/drawing/tc_bar_chart.rb b/test/drawing/tc_bar_chart.rb index 0d4fd341..d81d3b8d 100644 --- a/test/drawing/tc_bar_chart.rb +++ b/test/drawing/tc_bar_chart.rb @@ -7,7 +7,7 @@ class TestBarChart < Test::Unit::TestCase @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @row = ws.add_row ["one", 1, Time.now] - @chart = ws.add_chart Axlsx::BarChart, :title => "fishery" + @chart = ws.add_chart Axlsx::BarChart, title: "fishery" end def teardown; end diff --git a/test/drawing/tc_bar_series.rb b/test/drawing/tc_bar_series.rb index 450b67e5..f3dd34fe 100644 --- a/test/drawing/tc_bar_series.rb +++ b/test/drawing/tc_bar_series.rb @@ -5,8 +5,8 @@ require 'tc_helper' class TestBarSeries < Test::Unit::TestCase def setup p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "hmmm" - @chart = @ws.add_chart Axlsx::Bar3DChart, :title => "fishery" + @ws = p.workbook.add_worksheet name: "hmmm" + @chart = @ws.add_chart Axlsx::Bar3DChart, title: "fishery" @series = @chart.add_series( data: [0, 1, 2], labels: ['zero', 'one', 'two'], diff --git a/test/drawing/tc_bubble_chart.rb b/test/drawing/tc_bubble_chart.rb index b38e636b..5081e4b6 100644 --- a/test/drawing/tc_bubble_chart.rb +++ b/test/drawing/tc_bubble_chart.rb @@ -13,11 +13,11 @@ class TestBubbleChart < Test::Unit::TestCase sheet.add_row ["Second", 5, 2, 14, 9] sheet.add_row ["", 5, 10, 15, 20] sheet.add_row ["", 5, 28, 92, 13] - sheet.add_chart(Axlsx::BubbleChart, :title => "example: Bubble Chart") do |chart| + sheet.add_chart(Axlsx::BubbleChart, title: "example: Bubble Chart") do |chart| chart.start_at 0, 4 chart.end_at 10, 19 - chart.add_series :xData => sheet["B1:E1"], :yData => sheet["B2:E2"], :bubbleSize => sheet["B3:E3"], :title => sheet["A1"] - chart.add_series :xData => sheet["B4:E4"], :yData => sheet["B5:E5"], :bubbleSize => sheet["B6:E6"], :title => sheet["A3"] + chart.add_series xData: sheet["B1:E1"], yData: sheet["B2:E2"], bubbleSize: sheet["B3:E3"], title: sheet["A1"] + chart.add_series xData: sheet["B4:E4"], yData: sheet["B5:E5"], bubbleSize: sheet["B6:E6"], title: sheet["A3"] @chart = chart end end diff --git a/test/drawing/tc_bubble_series.rb b/test/drawing/tc_bubble_series.rb index 78ac1b23..3e799b98 100644 --- a/test/drawing/tc_bubble_series.rb +++ b/test/drawing/tc_bubble_series.rb @@ -5,9 +5,9 @@ require 'tc_helper' class TestBubbleSeries < Test::Unit::TestCase def setup p = Axlsx::Package.new - @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' + @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' end def test_initialize diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb index c7527e15..596a8bfa 100644 --- a/test/drawing/tc_chart.rb +++ b/test/drawing/tc_chart.rb @@ -7,7 +7,7 @@ class TestChart < Test::Unit::TestCase @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @row = ws.add_row ["one", 1, Time.now] - @chart = ws.add_chart Axlsx::Bar3DChart, :title => "fishery", :bg_color => "000000" + @chart = ws.add_chart Axlsx::Bar3DChart, title: "fishery", bg_color: "000000" end def teardown; end @@ -101,7 +101,7 @@ class TestChart < Test::Unit::TestCase 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("bob", s.title.text, "series title has been applied") diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb index b7d664b4..9bb2d4ba 100644 --- a/test/drawing/tc_d_lbls.rb +++ b/test/drawing/tc_d_lbls.rb @@ -24,7 +24,7 @@ class TestDLbls < Test::Unit::TestCase def test_initialization_with_optoins options_hash = @boolean_attributes.to_h { |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(d_lbls.send(attr), "boolean attributes set by options") diff --git a/test/drawing/tc_data_source.rb b/test/drawing/tc_data_source.rb index fd500819..c950accd 100644 --- a/test/drawing/tc_data_source.rb +++ b/test/drawing/tc_data_source.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestNumDataSource < Test::Unit::TestCase def setup - @data_source = Axlsx::NumDataSource.new :data => ["1", "2", "3"] + @data_source = Axlsx::NumDataSource.new data: ["1", "2", "3"] end def test_tag_name diff --git a/test/drawing/tc_drawing.rb b/test/drawing/tc_drawing.rb index 1e72b462..d7e3e8df 100644 --- a/test/drawing/tc_drawing.rb +++ b/test/drawing/tc_drawing.rb @@ -13,7 +13,7 @@ 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") @@ -27,7 +27,7 @@ class TestDrawing < Test::Unit::TestCase 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)) @@ -37,17 +37,17 @@ 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 @@ -71,10 +71,10 @@ 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(1, @ws.drawing.relationships.size, "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(2, @ws.drawing.relationships.size, "adding a chart adds a relationship") end diff --git a/test/drawing/tc_hyperlink.rb b/test/drawing/tc_hyperlink.rb index cad418f8..c3cffb1c 100644 --- a/test/drawing/tc_hyperlink.rb +++ b/test/drawing/tc_hyperlink.rb @@ -7,7 +7,7 @@ class TestHyperlink < Test::Unit::TestCase @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg" - @image = ws.add_image :image_src => @test_img, :hyperlink => "http://axlsx.blogspot.com" + @image = ws.add_image image_src: @test_img, hyperlink: "http://axlsx.blogspot.com" @hyperlink = @image.hyperlink end diff --git a/test/drawing/tc_line_3d_chart.rb b/test/drawing/tc_line_3d_chart.rb index 2107f1a0..471e9498 100644 --- a/test/drawing/tc_line_3d_chart.rb +++ b/test/drawing/tc_line_3d_chart.rb @@ -7,7 +7,7 @@ class TestLine3DChart < Test::Unit::TestCase @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @row = ws.add_row ["one", 1, Time.now] - @chart = ws.add_chart Axlsx::Line3DChart, :title => "fishery" + @chart = ws.add_chart Axlsx::Line3DChart, title: "fishery" end def teardown; end diff --git a/test/drawing/tc_line_chart.rb b/test/drawing/tc_line_chart.rb index 460b2055..b1bc0a75 100644 --- a/test/drawing/tc_line_chart.rb +++ b/test/drawing/tc_line_chart.rb @@ -7,7 +7,7 @@ class TestLineChart < Test::Unit::TestCase @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @row = ws.add_row ["one", 1, Time.now] - @chart = ws.add_chart Axlsx::LineChart, :title => "fishery" + @chart = ws.add_chart Axlsx::LineChart, title: "fishery" end def teardown; end diff --git a/test/drawing/tc_line_series.rb b/test/drawing/tc_line_series.rb index 7223fca3..0add56ee 100644 --- a/test/drawing/tc_line_series.rb +++ b/test/drawing/tc_line_series.rb @@ -5,15 +5,15 @@ require 'tc_helper' class TestLineSeries < Test::Unit::TestCase def setup p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "hmmm" - chart = @ws.add_chart Axlsx::Line3DChart, :title => "fishery" + @ws = p.workbook.add_worksheet name: "hmmm" + chart = @ws.add_chart Axlsx::Line3DChart, title: "fishery" @series = chart.add_series( - :data => [0, 1, 2], - :labels => ["zero", "one", "two"], - :title => "bob", - :color => "#FF0000", - :show_marker => true, - :smooth => true + data: [0, 1, 2], + labels: ["zero", "one", "two"], + title: "bob", + color: "#FF0000", + show_marker: true, + smooth: true ) end diff --git a/test/drawing/tc_num_data.rb b/test/drawing/tc_num_data.rb index c794faf8..72f564c0 100644 --- a/test/drawing/tc_num_data.rb +++ b/test/drawing/tc_num_data.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestNumData < Test::Unit::TestCase def setup - @num_data = Axlsx::NumData.new :data => [1, 2, 3] + @num_data = Axlsx::NumData.new data: [1, 2, 3] end def test_initialize diff --git a/test/drawing/tc_num_val.rb b/test/drawing/tc_num_val.rb index 7ad6ace4..27553b6a 100644 --- a/test/drawing/tc_num_val.rb +++ b/test/drawing/tc_num_val.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestNumVal < Test::Unit::TestCase def setup - @num_val = Axlsx::NumVal.new :v => 1 + @num_val = Axlsx::NumVal.new v: 1 end def test_initialize diff --git a/test/drawing/tc_one_cell_anchor.rb b/test/drawing/tc_one_cell_anchor.rb index 7f0a7c4a..e3eb8d90 100644 --- a/test/drawing/tc_one_cell_anchor.rb +++ b/test/drawing/tc_one_cell_anchor.rb @@ -7,7 +7,7 @@ class TestOneCellAnchor < Test::Unit::TestCase @p = Axlsx::Package.new @ws = @p.workbook.add_worksheet @test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg" - @image = @ws.add_image :image_src => @test_img + @image = @ws.add_image image_src: @test_img @anchor = @image.anchor end @@ -52,8 +52,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 daa8b4a3..dc0f32da 100644 --- a/test/drawing/tc_pic.rb +++ b/test/drawing/tc_pic.rb @@ -15,8 +15,8 @@ class TestPic < Test::Unit::TestCase @test_img_fake = File.dirname(__FILE__) + "/../fixtures/image1_fake.jpg" @test_img_remote_png = "https://example.com/sample-image.png" @test_img_remote_fake = "invalid_URI" - @image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5 - @image_remote = ws.add_image :image_src => @test_img_remote_png, remote: true, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5 + @image = ws.add_image image_src: @test_img, hyperlink: 'https://github.com/randym', tooltip: "What's up doc?", opacity: 5 + @image_remote = ws.add_image image_src: @test_img_remote_png, remote: true, hyperlink: 'https://github.com/randym', tooltip: "What's up doc?", opacity: 5 end def test_initialization diff --git a/test/drawing/tc_pie_3D_chart.rb b/test/drawing/tc_pie_3D_chart.rb index 889e383f..3fbdeacb 100644 --- a/test/drawing/tc_pie_3D_chart.rb +++ b/test/drawing/tc_pie_3D_chart.rb @@ -7,7 +7,7 @@ class TestPie3DChart < Test::Unit::TestCase p = Axlsx::Package.new ws = p.workbook.add_worksheet @row = ws.add_row ["one", 1, Time.now] - @chart = ws.add_chart Axlsx::Pie3DChart, :title => "fishery" + @chart = ws.add_chart Axlsx::Pie3DChart, title: "fishery" end def teardown; end diff --git a/test/drawing/tc_pie_series.rb b/test/drawing/tc_pie_series.rb index a0d63cfc..88930213 100644 --- a/test/drawing/tc_pie_series.rb +++ b/test/drawing/tc_pie_series.rb @@ -5,9 +5,9 @@ require 'tc_helper' class TestPieSeries < Test::Unit::TestCase def setup p = Axlsx::Package.new - @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"] + @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"] end def test_initialize diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb index 92bc8486..9a7a3073 100644 --- a/test/drawing/tc_scatter_chart.rb +++ b/test/drawing/tc_scatter_chart.rb @@ -11,11 +11,11 @@ class TestScatterChart < Test::Unit::TestCase sheet.add_row ["", 1, 25, 49, 81] sheet.add_row ["Second", 5, 2, 14, 9] sheet.add_row ["", 5, 10, 15, 20] - sheet.add_chart(Axlsx::ScatterChart, :title => "example 7: Scatter Chart") do |chart| + sheet.add_chart(Axlsx::ScatterChart, title: "example 7: Scatter Chart") do |chart| chart.start_at 0, 4 chart.end_at 10, 19 - chart.add_series :xData => sheet["B1:E1"], :yData => sheet["B2:E2"], :title => sheet["A1"] - chart.add_series :xData => sheet["B3:E3"], :yData => sheet["B4:E4"], :title => sheet["A3"] + chart.add_series xData: sheet["B1:E1"], yData: sheet["B2:E2"], title: sheet["A1"] + chart.add_series xData: sheet["B3:E3"], yData: sheet["B4:E4"], title: sheet["A3"] @chart = chart end end diff --git a/test/drawing/tc_scatter_series.rb b/test/drawing/tc_scatter_series.rb index a550271b..26ed01ea 100644 --- a/test/drawing/tc_scatter_series.rb +++ b/test/drawing/tc_scatter_series.rb @@ -5,9 +5,9 @@ require 'tc_helper' class TestScatterSeries < Test::Unit::TestCase def setup p = Axlsx::Package.new - @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 + @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 end def test_initialize @@ -15,36 +15,36 @@ class TestScatterSeries < Test::Unit::TestCase end 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" + @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" 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" + @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" refute(@series.smooth, "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 + @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 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 + @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 refute(@series.smooth, "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" + @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.ln_width = 12_700 assert_equal(12_700, @series.ln_width, 'line width assigment is allowed') @@ -61,22 +61,22 @@ class TestScatterSeries < Test::Unit::TestCase 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] + @chart = @ws.add_chart Axlsx::ScatterChart, title: 'Smooth Chart', scatter_style: :smoothMarker + @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] + @chart = @ws.add_chart Axlsx::ScatterChart, title: 'Line chart', scatter_style: :line + @series = @chart.add_series xData: [1, 2, 4], yData: [1, 3, 9] refute(@series.show_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 + @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 assert_equal(:diamond, @series.marker_symbol, 'series could have own custom marker symbol') end diff --git a/test/drawing/tc_ser_axis.rb b/test/drawing/tc_ser_axis.rb index 6d26b182..fa67024c 100644 --- a/test/drawing/tc_ser_axis.rb +++ b/test/drawing/tc_ser_axis.rb @@ -10,7 +10,7 @@ class TestSerAxis < Test::Unit::TestCase def teardown; end def test_options - a = Axlsx::SerAxis.new(:tick_lbl_skip => 9, :tick_mark_skip => 7) + a = Axlsx::SerAxis.new(tick_lbl_skip: 9, tick_mark_skip: 7) assert_equal(9, a.tick_lbl_skip) assert_equal(7, a.tick_mark_skip) diff --git a/test/drawing/tc_series.rb b/test/drawing/tc_series.rb index 2215d398..756beaee 100644 --- a/test/drawing/tc_series.rb +++ b/test/drawing/tc_series.rb @@ -5,9 +5,9 @@ require 'tc_helper' class TestSeries < Test::Unit::TestCase def setup p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "hmmm" - chart = @ws.add_chart Axlsx::Chart, :title => "fishery" - @series = chart.add_series :title => "bob" + @ws = p.workbook.add_worksheet name: "hmmm" + chart = @ws.add_chart Axlsx::Chart, title: "fishery" + @series = chart.add_series title: "bob" end def test_initialize diff --git a/test/drawing/tc_str_data.rb b/test/drawing/tc_str_data.rb index f80bf24b..cc15d0fd 100644 --- a/test/drawing/tc_str_data.rb +++ b/test/drawing/tc_str_data.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestStrData < Test::Unit::TestCase def setup - @str_data = Axlsx::StrData.new :data => ["1", "2", "3"] + @str_data = Axlsx::StrData.new data: ["1", "2", "3"] end def test_to_xml_string_strLit diff --git a/test/drawing/tc_str_val.rb b/test/drawing/tc_str_val.rb index c094c450..783d4122 100644 --- a/test/drawing/tc_str_val.rb +++ b/test/drawing/tc_str_val.rb @@ -4,8 +4,8 @@ require 'tc_helper' class TestStrVal < Test::Unit::TestCase def setup - @str_val = Axlsx::StrVal.new :v => "1" - @str_val_with_special_characters = Axlsx::StrVal.new :v => "a & b <c>" + @str_val = Axlsx::StrVal.new v: "1" + @str_val_with_special_characters = Axlsx::StrVal.new v: "a & b <c>" end def test_initialize diff --git a/test/drawing/tc_two_cell_anchor.rb b/test/drawing/tc_two_cell_anchor.rb index bfdaf4de..f20aebfb 100644 --- a/test/drawing/tc_two_cell_anchor.rb +++ b/test/drawing/tc_two_cell_anchor.rb @@ -23,11 +23,11 @@ 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] + a = @ws.add_chart Axlsx::Chart, start_at: [15, 35], end_at: [90, 45] assert_equal(15, a.graphic_frame.anchor.from.col) assert_equal(35, a.graphic_frame.anchor.from.row) diff --git a/test/drawing/tc_val_axis.rb b/test/drawing/tc_val_axis.rb index bb464048..e9c1dbaf 100644 --- a/test/drawing/tc_val_axis.rb +++ b/test/drawing/tc_val_axis.rb @@ -14,7 +14,7 @@ class TestValAxis < Test::Unit::TestCase end def test_options - a = Axlsx::ValAxis.new(:cross_between => :midCat) + a = Axlsx::ValAxis.new(cross_between: :midCat) assert_equal(:midCat, a.cross_between) end diff --git a/test/drawing/tc_view_3D.rb b/test/drawing/tc_view_3D.rb index e09edc13..f411127a 100644 --- a/test/drawing/tc_view_3D.rb +++ b/test/drawing/tc_view_3D.rb @@ -10,7 +10,7 @@ class TestView3D < Test::Unit::TestCase def teardown; end def test_options - v = Axlsx::View3D.new :rot_x => 10, :rot_y => 5, :h_percent => "30%", :depth_percent => "45%", :r_ang_ax => false, :perspective => 10 + v = Axlsx::View3D.new rot_x: 10, rot_y: 5, h_percent: "30%", depth_percent: "45%", r_ang_ax: false, perspective: 10 assert_equal(10, v.rot_x) assert_equal(5, v.rot_y) diff --git a/test/drawing/tc_vml_drawing.rb b/test/drawing/tc_vml_drawing.rb index 815cc556..fa939f56 100644 --- a/test/drawing/tc_vml_drawing.rb +++ b/test/drawing/tc_vml_drawing.rb @@ -7,8 +7,8 @@ class TestVmlDrawing < Test::Unit::TestCase p = Axlsx::Package.new wb = p.workbook @ws = wb.add_worksheet - @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank' - @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO' + @ws.add_comment ref: 'A1', text: 'penut machine', author: 'crank' + @ws.add_comment ref: 'C3', text: 'rust bucket', author: 'PO' @vml_drawing = @ws.comments.vml_drawing end diff --git a/test/drawing/tc_vml_shape.rb b/test/drawing/tc_vml_shape.rb index 8e415cc1..cf8fe541 100644 --- a/test/drawing/tc_vml_shape.rb +++ b/test/drawing/tc_vml_shape.rb @@ -7,8 +7,8 @@ class TestVmlShape < Test::Unit::TestCase p = Axlsx::Package.new wb = p.workbook @ws = wb.add_worksheet - @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank', :visible => true - @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO', :visible => false + @ws.add_comment ref: 'A1', text: 'penut machine', author: 'crank', visible: true + @ws.add_comment ref: 'C3', text: 'rust bucket', author: 'PO', visible: false @comments = @ws.comments end diff --git a/test/rels/tc_relationship.rb b/test/rels/tc_relationship.rb index 04dab810..9efe3909 100644 --- a/test/rels/tc_relationship.rb +++ b/test/rels/tc_relationship.rb @@ -33,8 +33,8 @@ class TestRelationships < Test::Unit::TestCase assert_equal rel_1.Id, rel_2.Id - rel_3 = Axlsx::Relationship.new(source_obj, Axlsx::HYPERLINK_R, 'target', :target_mode => :External) - rel_4 = Axlsx::Relationship.new(source_obj, Axlsx::HYPERLINK_R, '../target', :target_mode => :External) + rel_3 = Axlsx::Relationship.new(source_obj, Axlsx::HYPERLINK_R, 'target', target_mode: :External) + rel_4 = Axlsx::Relationship.new(source_obj, Axlsx::HYPERLINK_R, '../target', target_mode: :External) assert_not_equal rel_3.Id, rel_4.Id end @@ -46,12 +46,12 @@ class TestRelationships < Test::Unit::TestCase end 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_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) } end def test_ampersand_escaping_in_target - r = Axlsx::Relationship.new(nil, Axlsx::HYPERLINK_R, "http://example.com?foo=1&bar=2", :target_mod => :External) + r = Axlsx::Relationship.new(nil, Axlsx::HYPERLINK_R, "http://example.com?foo=1&bar=2", target_mod: :External) doc = Nokogiri::XML(r.to_xml_string) assert_equal(1, doc.xpath("//Relationship[@Target='http://example.com?foo=1&bar=2']").size) diff --git a/test/stylesheet/tc_border.rb b/test/stylesheet/tc_border.rb index 96bef927..84dbf0c9 100644 --- a/test/stylesheet/tc_border.rb +++ b/test/stylesheet/tc_border.rb @@ -35,6 +35,6 @@ class TestBorder < Test::Unit::TestCase 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 a1069f5d..7216d2d6 100644 --- a/test/stylesheet/tc_border_pr.rb +++ b/test/stylesheet/tc_border_pr.rb @@ -17,7 +17,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 2e95db54..d12ff74b 100644 --- a/test/stylesheet/tc_cell_alignment.rb +++ b/test/stylesheet/tc_cell_alignment.rb @@ -17,9 +17,9 @@ class TestCellAlignment < Test::Unit::TestCase assert_nil(@item.justifyLastLine) assert_nil(@item.shrinkToFit) assert_nil(@item.readingOrder) - options = { :horizontal => :left, :vertical => :top, :textRotation => 3, - :wrapText => true, :indent => 2, :relativeIndent => 5, - :justifyLastLine => true, :shrinkToFit => true, :readingOrder => 2 } + 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| diff --git a/test/stylesheet/tc_dxf.rb b/test/stylesheet/tc_dxf.rb index 5e25a133..170cf52f 100644 --- a/test/stylesheet/tc_dxf.rb +++ b/test/stylesheet/tc_dxf.rb @@ -39,7 +39,7 @@ class TestDxf < Test::Unit::TestCase 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_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 @@ -66,7 +66,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 3cee3e63..c9776be8 100644 --- a/test/stylesheet/tc_font.rb +++ b/test/stylesheet/tc_font.rb @@ -118,7 +118,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 a150a01b..ab4dc11a 100644 --- a/test/stylesheet/tc_gradient_fill.rb +++ b/test/stylesheet/tc_gradient_fill.rb @@ -56,15 +56,15 @@ 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_equal(1, @item.stop.size) assert(@item.stop.last.is_a?(Axlsx::GradientStop)) end def test_to_xml_string - @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(:rgb => "000000"), 0.5) - @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(:rgb => "FFFFFF"), 0.5) + @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(rgb: "000000"), 0.5) + @item.stop << Axlsx::GradientStop.new(Axlsx::Color.new(rgb: "FFFFFF"), 0.5) @item.type = :path doc = Nokogiri::XML(@item.to_xml_string) diff --git a/test/stylesheet/tc_gradient_stop.rb b/test/stylesheet/tc_gradient_stop.rb index 23a1d58e..6b37779f 100644 --- a/test/stylesheet/tc_gradient_stop.rb +++ b/test/stylesheet/tc_gradient_stop.rb @@ -4,7 +4,7 @@ require 'tc_helper' 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; end @@ -22,7 +22,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("FF0000FF", @item.color.rgb) diff --git a/test/stylesheet/tc_pattern_fill.rb b/test/stylesheet/tc_pattern_fill.rb index 120f5f33..8698d54d 100644 --- a/test/stylesheet/tc_pattern_fill.rb +++ b/test/stylesheet/tc_pattern_fill.rb @@ -34,7 +34,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"]')) diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb index 3b77616f..29d37a3a 100644 --- a/test/stylesheet/tc_styles.rb +++ b/test/stylesheet/tc_styles.rb @@ -23,11 +23,11 @@ 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("FFFF0000", @styles.borders.last.prs.last.color.rgb) - assert_raise(ArgumentError) { @styles.add_style :border => { :color => "FFFF0000" } } + assert_raise(ArgumentError) { @styles.add_style border: { color: "FFFF0000" } } assert_equal(4, @styles.borders.last.prs.size) end @@ -35,12 +35,12 @@ 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) @@ -59,7 +59,7 @@ class TestStyles < Test::Unit::TestCase end def test_add_style_border_edges - @styles.add_style :border => { :style => :thin, :color => "0000FFFF", :edges => [:top, :bottom] } + @styles.add_style border: { style: :thin, color: "0000FFFF", edges: [:top, :bottom] } parts = @styles.borders.last.prs parts.each { |pr| assert_equal("0000FFFF", pr.color.rgb, "Style is applied to #{pr.name} properly") } @@ -68,7 +68,7 @@ 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(:thin, options[:border][:style], 'thin style is stil in option') @@ -76,8 +76,8 @@ class TestStyles < Test::Unit::TestCase 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_nil(@styles.parse_num_fmt_options, 'noop if neither :format_code or :num_fmt exist') max = @styles.numFmts.map(&:numFmtId).max @@ -85,26 +85,26 @@ class TestStyles < Test::Unit::TestCase 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_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" }) } 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_equal(1, @styles.borders.last.diagonalUp, "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.find { |bpr| bpr.name == :left } @@ -127,26 +127,26 @@ class TestStyles < Test::Unit::TestCase end def test_parse_border_options_integer_xf - assert_equal(1, @styles.parse_border_options(:border => 1)) - assert_raise(ArgumentError, "unknown border index") { @styles.parse_border_options(:border => 100) } + assert_equal(1, @styles.parse_border_options(border: 1)) + 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) + b2 = @styles.parse_border_options(border: b, type: :dxf) assert(b2.is_a?(Axlsx::Border), "Cloned existing border object") end def test_parse_alignment_options assert_nil(@styles.parse_alignment_options, "noop if :alignment is not set") - assert(@styles.parse_alignment_options(:alignment => {}).is_a?(Axlsx::CellAlignment)) + assert(@styles.parse_alignment_options(alignment: {}).is_a?(Axlsx::CellAlignment)) end def test_parse_font_using_defaults original = @styles.fonts.first - @styles.add_style :b => 1, :sz => 99 + @styles.add_style b: 1, sz: 99 created = @styles.fonts.last original_attributes = Axlsx.instance_values_for(original) @@ -163,24 +163,24 @@ class TestStyles < Test::Unit::TestCase def test_parse_font_options options = { - :fg_color => "FF050505", - :sz => 20, - :b => 1, - :i => 1, - :u => :single, - :strike => 1, - :outline => 1, - :shadow => 1, - :charset => 9, - :family => 1, - :font_name => "woot font" + fg_color: "FF050505", + sz: 20, + b: 1, + i: 1, + u: :single, + strike: 1, + outline: 1, + shadow: 1, + charset: 9, + family: 1, + font_name: "woot font" } assert_nil(@styles.parse_font_options, "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)) + f = @styles.parse_font_options(options.merge(type: :dxf)) color = options.delete(:fg_color) options[:name] = options.delete(:font_name) @@ -192,16 +192,16 @@ class TestStyles < Test::Unit::TestCase def test_parse_fill_options assert_nil(@styles.parse_fill_options, "noop if no fill keys are set") - assert(@styles.parse_fill_options(:bg_color => "DE").is_a?(Integer), "return index of fill if not :dxf type") - assert_equal(@styles.parse_fill_options(:bg_color => "DE", :type => :dxf).class, Axlsx::Fill, "return fill object if :dxf type") - f = @styles.parse_fill_options(:bg_color => "DE", :type => :dxf) + assert(@styles.parse_fill_options(bg_color: "DE").is_a?(Integer), "return index of fill if not :dxf type") + assert_equal(@styles.parse_fill_options(bg_color: "DE", type: :dxf).class, Axlsx::Fill, "return fill object if :dxf type") + f = @styles.parse_fill_options(bg_color: "DE", type: :dxf) assert_equal("FFDEDEDE", f.fill_type.bgColor.rgb) end def test_parse_protection_options assert_nil(@styles.parse_protection_options, "noop if no protection keys are set") - assert_equal(@styles.parse_protection_options(:hidden => 1).class, Axlsx::CellProtection, "creates a new cell protection object") + assert_equal(@styles.parse_protection_options(hidden: 1).class, Axlsx::CellProtection, "creates a new cell protection object") end def test_add_style @@ -209,7 +209,7 @@ 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 + @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) @@ -230,7 +230,7 @@ class TestStyles < Test::Unit::TestCase assert_equal(:left, xf.alignment.horizontal, "horizontal alignment applied") assert(xf.protection.hidden, "hidden protection set") assert(xf.protection.locked, "cell locking set") - assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 } + assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style border: 2 } assert(xf.applyProtection, "protection applied") assert(xf.applyBorder, "border applied") @@ -240,11 +240,11 @@ class TestStyles < Test::Unit::TestCase 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("FFFF0000", @styles.dxfs.last.border.prs.last.color.rgb) - assert_raise(ArgumentError) { @styles.add_style :border => { :color => "FFFF0000" }, :type => :dxf } + assert_raise(ArgumentError) { @styles.add_style border: { color: "FFFF0000" }, type: :dxf } assert_equal(4, @styles.borders.last.prs.size) end @@ -253,7 +253,7 @@ 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 + 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") @@ -272,32 +272,32 @@ class TestStyles < Test::Unit::TestCase assert_equal(:left, dxf.alignment.horizontal, "horizontal alignment applied") assert(dxf.protection.hidden, "hidden protection set") assert(dxf.protection.locked, "cell locking set") - assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 3 } + assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style border: 3 } end 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 def test_valid_document_with_font_options font_options = { - :fg_color => "FF050505", - :sz => 20, - :b => 1, - :i => 1, - :u => :single, - :strike => 1, - :outline => 1, - :shadow => 1, - :charset => 9, - :family => 1, - :font_name => "woot font" + fg_color: "FF050505", + sz: 20, + b: 1, + i: 1, + u: :single, + strike: 1, + outline: 1, + shadow: 1, + charset: 9, + family: 1, + font_name: "woot font" } @styles.add_style font_options diff --git a/test/stylesheet/tc_table_style.rb b/test/stylesheet/tc_table_style.rb index ea3334b7..defa0531 100644 --- a/test/stylesheet/tc_table_style.rb +++ b/test/stylesheet/tc_table_style.rb @@ -13,7 +13,7 @@ class TestTableStyle < Test::Unit::TestCase assert_equal("fisher", @item.name) assert_nil(@item.pivot) assert_nil(@item.table) - ts = Axlsx::TableStyle.new 'price', :pivot => true, :table => true + ts = Axlsx::TableStyle.new 'price', pivot: true, table: true assert_equal('price', ts.name) assert(ts.pivot) diff --git a/test/stylesheet/tc_table_style_element.rb b/test/stylesheet/tc_table_style_element.rb index 93ad9453..7f56e9ed 100644 --- a/test/stylesheet/tc_table_style_element.rb +++ b/test/stylesheet/tc_table_style_element.rb @@ -13,7 +13,7 @@ class TestTableStyleElement < Test::Unit::TestCase assert_nil(@item.type) assert_nil(@item.size) assert_nil(@item.dxfId) - options = { :type => :headerRow, :size => 10, :dxfId => 1 } + options = { type: :headerRow, size: 10, dxfId: 1 } tse = Axlsx::TableStyleElement.new options diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb index 3c4b5f93..f4f6a01d 100644 --- a/test/tc_axlsx.rb +++ b/test/tc_axlsx.rb @@ -50,7 +50,7 @@ class TestAxlsx < Test::Unit::TestCase def test_cell_range_absolute p = Axlsx::Package.new - ws = p.workbook.add_worksheet :name => "Sheet <'>\" 1" + ws = p.workbook.add_worksheet name: "Sheet <'>\" 1" row = ws.add_row c1 = row.add_cell c2 = row.add_cell diff --git a/test/tc_package.rb b/test/tc_package.rb index f4087c4d..75fe2cdf 100644 --- a/test/tc_package.rb +++ b/test/tc_package.rb @@ -12,20 +12,20 @@ class TestPackage < Test::Unit::TestCase ws.add_row ['Can', 'we', 'build it?'] ws.add_row ['Yes!', 'We', 'can!'] @rt = Axlsx::RichText.new - @rt.add_run "run 1", :b => true, :i => false + @rt.add_run "run 1", b: true, i: false ws.add_row [@rt] - ws.rows.last.add_cell('b', :type => :text) + ws.rows.last.add_cell('b', type: :text) ws.outline_level_rows 0, 1 ws.outline_level_columns 0, 1 - ws.add_hyperlink :ref => ws.rows.first.cells.last, :location => 'https://github.com/randym' - ws.workbook.add_defined_name("#{ws.name}!A1:C2", :name => '_xlnm.Print_Titles', :hidden => true) + ws.add_hyperlink ref: ws.rows.first.cells.last, location: 'https://github.com/randym' + ws.workbook.add_defined_name("#{ws.name}!A1:C2", name: '_xlnm.Print_Titles', hidden: true) ws.workbook.add_view active_tab: 1, first_sheet: 0 ws.protect_range('A1:C1') ws.protect_range(ws.rows.last.cells) - ws.add_comment :author => 'alice', :text => 'Hi Bob', :ref => 'A12' - ws.add_comment :author => 'bob', :text => 'Hi Alice', :ref => 'F19' + ws.add_comment author: 'alice', text: 'Hi Bob', ref: 'A12' + ws.add_comment author: 'bob', text: 'Hi Alice', ref: 'F19' ws.sheet_view do |vs| vs.pane do |p| p.active_pane = :top_right @@ -35,54 +35,54 @@ class TestPackage < Test::Unit::TestCase p.top_left_cell = 'C44' end - vs.add_selection(:top_left, { :active_cell => 'A2', :sqref => 'A2' }) - vs.add_selection(:top_right, { :active_cell => 'I10', :sqref => 'I10' }) - vs.add_selection(:bottom_left, { :active_cell => 'E55', :sqref => 'E55' }) - vs.add_selection(:bottom_right, { :active_cell => 'I57', :sqref => 'I57' }) + vs.add_selection(:top_left, { active_cell: 'A2', sqref: 'A2' }) + vs.add_selection(:top_right, { active_cell: 'I10', sqref: 'I10' }) + vs.add_selection(:bottom_left, { active_cell: 'E55', sqref: 'E55' }) + 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 end - ws.add_chart(Axlsx::Line3DChart, :title => "axis labels") do |chart| + ws.add_chart(Axlsx::Line3DChart, title: "axis labels") do |chart| chart.valAxis.title = 'bob' chart.d_lbls.show_val = true end - ws.add_chart(Axlsx::Bar3DChart, :title => 'bar chart') do |chart| - chart.add_series :data => [1, 4, 5], :labels => %w(A B C) + ws.add_chart(Axlsx::Bar3DChart, title: 'bar chart') do |chart| + 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] + ws.add_chart(Axlsx::ScatterChart, title: 'scat man') do |chart| + 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] + ws.add_chart(Axlsx::BubbleChart, title: 'bubble chart') do |chart| + 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', __dir__) - ws.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink => "http://axlsx.blogspot.com") do |image| + 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', __dir__) do |image| + ws.add_image image_src: File.expand_path('fixtures/image1.gif', __dir__) do |image| image.start_at 0, 20 image.width = 360 image.height = 333 end - ws.add_image :image_src => File.expand_path('fixtures/image1.png', __dir__) do |image| + ws.add_image image_src: File.expand_path('fixtures/image1.png', __dir__) do |image| image.start_at 9, 20 image.width = 180 image.height = 167 @@ -126,7 +126,7 @@ class TestPackage < Test::Unit::TestCase def test_created_at_is_propagated_to_core time = Time.utc(2013, 1, 1, 12, 0) - p = Axlsx::Package.new :created_at => time + p = Axlsx::Package.new created_at: time assert_equal(time, p.core.created) end @@ -237,8 +237,8 @@ class TestPackage < Test::Unit::TestCase def test_serialization_creates_identical_files_for_identical_packages package_1, package_2 = Array.new(2) do - Axlsx::Package.new(:created_at => Time.utc(2013, 1, 1)).tap do |p| - p.workbook.add_worksheet(:name => "Basic Worksheet") do |sheet| + Axlsx::Package.new(created_at: Time.utc(2013, 1, 1)).tap do |p| + p.workbook.add_worksheet(name: "Basic Worksheet") do |sheet| sheet.add_row [1, 2, 3] end end diff --git a/test/workbook/tc_shared_strings_table.rb b/test/workbook/tc_shared_strings_table.rb index 4aa308f1..2edf5f4a 100644 --- a/test/workbook/tc_shared_strings_table.rb +++ b/test/workbook/tc_shared_strings_table.rb @@ -4,13 +4,13 @@ require 'tc_helper' 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'] ws.add_row ['b', 1, 'c'] ws.add_row ['c', 1, 'd'] - ws.rows.last.add_cell('b', :type => :text) + ws.rows.last.add_cell('b', type: :text) end def test_workbook_has_shared_strings diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb index b1cfdc71..51fe3976 100644 --- a/test/workbook/tc_workbook.rb +++ b/test/workbook/tc_workbook.rb @@ -11,7 +11,7 @@ class TestWorkbook < Test::Unit::TestCase def teardown; end def test_worksheet_users_xml_space - sheet = @wb.add_worksheet(:name => 'foo') + sheet = @wb.add_worksheet(name: 'foo') ws_xml = Nokogiri::XML(sheet.to_xml_string) assert(ws_xml.xpath("//xmlns:worksheet/@xml:space='preserve'")) @@ -45,16 +45,16 @@ class TestWorkbook < Test::Unit::TestCase end def test_sheet_by_name_retrieval - @wb.add_worksheet(:name => 'foo') - @wb.add_worksheet(:name => 'bar') - @wb.add_worksheet(:name => "testin'") + @wb.add_worksheet(name: 'foo') + @wb.add_worksheet(name: 'bar') + @wb.add_worksheet(name: "testin'") assert_equal('foo', @wb.sheet_by_name('foo').name) assert_equal("testin'", @wb.sheet_by_name("testin'").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 @@ -68,7 +68,7 @@ class TestWorkbook < Test::Unit::TestCase end def test_add_defined_name - @wb.add_defined_name 'Sheet1!1:1', :name => '_xlnm.Print_Titles', :hidden => true + @wb.add_defined_name 'Sheet1!1:1', name: '_xlnm.Print_Titles', hidden: true assert_equal(1, @wb.defined_names.size) end @@ -87,7 +87,7 @@ class TestWorkbook < Test::Unit::TestCase def test_add_worksheet assert_empty(@wb.worksheets, "worbook has no worksheets by default") - ws = @wb.add_worksheet(:name => "bob") + ws = @wb.add_worksheet(name: "bob") assert_equal(1, @wb.worksheets.size, "add_worksheet adds a worksheet!") assert_equal(@wb.worksheets.first, ws, "the worksheet returned is the worksheet added") @@ -95,9 +95,9 @@ class TestWorkbook < Test::Unit::TestCase end def test_insert_worksheet - @wb.add_worksheet(:name => 'A') - @wb.add_worksheet(:name => 'B') - ws3 = @wb.insert_worksheet(0, :name => 'C') + @wb.add_worksheet(name: 'A') + @wb.add_worksheet(name: 'B') + ws3 = @wb.insert_worksheet(0, name: 'C') assert_equal(ws3.name, @wb.worksheets.first.name) end @@ -127,15 +127,15 @@ class TestWorkbook < Test::Unit::TestCase def test_to_xml_reversed @wb.is_reversed = true - @wb.add_worksheet(:name => 'first') - second = @wb.add_worksheet(:name => 'second') + @wb.add_worksheet(name: 'first') + second = @wb.add_worksheet(name: 'second') doc = Nokogiri::XML(@wb.to_xml_string) assert_equal second.name, doc.xpath('//xmlns:workbook/xmlns:sheets/*[1]/@name').to_s end def test_range_requires_valid_sheet - ws = @wb.add_worksheet :name => 'fish' + 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"] } @@ -178,7 +178,7 @@ class TestWorkbook < Test::Unit::TestCase end def test_worksheet_name_is_intact_after_serialized_into_xml - sheet = @wb.add_worksheet(:name => '_Example') + sheet = @wb.add_worksheet(name: '_Example') wb_xml = Nokogiri::XML(@wb.to_xml_string) assert_equal sheet.name, wb_xml.xpath('//xmlns:workbook/xmlns:sheets/*[1]/@name').to_s diff --git a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb index 85ba32b7..cb8b34fa 100644 --- a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +++ b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb @@ -8,7 +8,7 @@ class TestAutoFilter < Test::Unit::TestCase 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] + @auto_filter.add_column 0, :filters, filter_items: [1] end def test_defined_name diff --git a/test/workbook/worksheet/auto_filter/tc_filter_column.rb b/test/workbook/worksheet/auto_filter/tc_filter_column.rb index d89446c6..b98314cb 100644 --- a/test/workbook/worksheet/auto_filter/tc_filter_column.rb +++ b/test/workbook/worksheet/auto_filter/tc_filter_column.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestFilterColumn < Test::Unit::TestCase def setup - @filter_column = Axlsx::FilterColumn.new(0, :filters, :filter_items => [200]) + @filter_column = Axlsx::FilterColumn.new(0, :filters, filter_items: [200]) end def test_initialize_col_id diff --git a/test/workbook/worksheet/auto_filter/tc_filters.rb b/test/workbook/worksheet/auto_filter/tc_filters.rb index 4cd8ca00..fc1b5c21 100644 --- a/test/workbook/worksheet/auto_filter/tc_filters.rb +++ b/test/workbook/worksheet/auto_filter/tc_filters.rb @@ -4,9 +4,9 @@ require 'tc_helper' 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 }], - :blank => true) + @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 }], + blank: true) end def test_blank diff --git a/test/workbook/worksheet/tc_break.rb b/test/workbook/worksheet/tc_break.rb index a441abe0..32cc2864 100644 --- a/test/workbook/worksheet/tc_break.rb +++ b/test/workbook/worksheet/tc_break.rb @@ -4,41 +4,41 @@ require 'tc_helper' class TestBreak < Test::Unit::TestCase def setup - @break = Axlsx::Break.new(:id => 1, :min => 1, :max => 10, :man => true, :pt => false) + @break = Axlsx::Break.new(id: 1, min: 1, max: 10, man: true, pt: false) end 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 def test_min assert_equal(1, @break.min) assert_raises ArgumentError do - Axlsx::Break.new(:hoge, :min => -1) + Axlsx::Break.new(:hoge, min: -1) end end def test_max assert_equal(10, @break.max) assert_raises ArgumentError do - Axlsx::Break.new(:hoge, :max => -1) + Axlsx::Break.new(:hoge, max: -1) end end def test_man assert(@break.man) assert_raises ArgumentError do - Axlsx::Break.new(:man => -1) + Axlsx::Break.new(man: -1) end end def test_pt refute(@break.pt) assert_raises ArgumentError do - Axlsx::Break.new(:pt => -1) + Axlsx::Break.new(pt: -1) end end diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index fef23ede..a8ab6ca1 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -6,10 +6,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"] @@ -62,7 +62,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) @@ -539,20 +539,20 @@ class TestCell < Test::Unit::TestCase end def test_font_size_with_custom_style_and_no_sz - @c.style = @c.row.worksheet.workbook.styles.add_style :bg_color => 'FF00FF' + @c.style = @c.row.worksheet.workbook.styles.add_style bg_color: 'FF00FF' sz = @c.send(:font_size) assert_equal(sz, @c.row.worksheet.workbook.styles.fonts.first.sz) end def test_font_size_with_bolding - @c.style = @c.row.worksheet.workbook.styles.add_style :b => true + @c.style = @c.row.worksheet.workbook.styles.add_style b: true assert_equal(@c.row.worksheet.workbook.styles.fonts.first.sz * 1.5, @c.send(:font_size)) end def test_font_size_with_custom_sz - @c.style = @c.row.worksheet.workbook.styles.add_style :sz => 52 + @c.style = @c.row.worksheet.workbook.styles.add_style sz: 52 sz = @c.send(:font_size) assert_equal(52, sz) diff --git a/test/workbook/worksheet/tc_cfvo.rb b/test/workbook/worksheet/tc_cfvo.rb index 0e2e5332..dac48b23 100644 --- a/test/workbook/worksheet/tc_cfvo.rb +++ b/test/workbook/worksheet/tc_cfvo.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestCfvo < Test::Unit::TestCase def setup - @cfvo = Axlsx::Cfvo.new(:val => "0", :type => :min) + @cfvo = Axlsx::Cfvo.new(val: "0", type: :min) end def test_val diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb index e795c301..c20d32be 100644 --- a/test/workbook/worksheet/tc_col.rb +++ b/test/workbook/worksheet/tc_col.rb @@ -8,7 +8,7 @@ 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 diff --git a/test/workbook/worksheet/tc_color_scale.rb b/test/workbook/worksheet/tc_color_scale.rb index 335e8057..b4720e3e 100644 --- a/test/workbook/worksheet/tc_color_scale.rb +++ b/test/workbook/worksheet/tc_color_scale.rb @@ -35,7 +35,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] @@ -44,14 +44,14 @@ class TestColorScale < Test::Unit::TestCase end def test_add - @color_scale.add :type => :max, :val => 5, :color => "FFDEDEDE" + @color_scale.add type: :max, val: 5, color: "FFDEDEDE" assert_equal(3, @color_scale.value_objects.size) assert_equal(3, @color_scale.colors.size) end def test_delete_at - @color_scale.add :type => :max, :val => 5, :color => "FFDEDEDE" + @color_scale.add type: :max, val: 5, color: "FFDEDEDE" assert_nothing_raised { @color_scale.delete_at 2 } assert_equal(2, @color_scale.value_objects.size) assert_equal(2, @color_scale.colors.size) diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb index 65b2ca1d..aa33dba4 100644 --- a/test/workbook/worksheet/tc_comment.rb +++ b/test/workbook/worksheet/tc_comment.rb @@ -7,8 +7,8 @@ class TestComment < Test::Unit::TestCase p = Axlsx::Package.new wb = p.workbook @ws = wb.add_worksheet - @c1 = @ws.add_comment :ref => 'A1', :text => 'text with special char <', :author => 'author with special char <', :visible => false - @c2 = @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO' + @c1 = @ws.add_comment ref: 'A1', text: 'text with special char <', author: 'author with special char <', visible: false + @c2 = @ws.add_comment ref: 'C3', text: 'rust bucket', author: 'PO' end def test_initailize @@ -63,14 +63,14 @@ class TestComment < Test::Unit::TestCase end def test_comment_text_contain_author_and_text - comment = @ws.add_comment :ref => 'C4', :text => 'some text', :author => 'Bob' + comment = @ws.add_comment ref: 'C4', text: 'some text', author: 'Bob' doc = Nokogiri::XML(comment.to_xml_string) assert_equal("Bob:\nsome text", doc.xpath("//comment/text").text) end def test_comment_text_does_not_contain_stray_colon_if_author_blank - comment = @ws.add_comment :ref => 'C5', :text => 'some text', :author => '' + comment = @ws.add_comment ref: 'C5', text: 'some text', author: '' doc = Nokogiri::XML(comment.to_xml_string) assert_equal("some text", doc.xpath("//comment/text").text) diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb index 445f2342..d9be807e 100644 --- a/test/workbook/worksheet/tc_comments.rb +++ b/test/workbook/worksheet/tc_comments.rb @@ -7,8 +7,8 @@ class TestComments < Test::Unit::TestCase p = Axlsx::Package.new wb = p.workbook @ws = wb.add_worksheet - @c1 = @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank' - @c2 = @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO' + @c1 = @ws.add_comment ref: 'A1', text: 'penut machine', author: 'crank' + @c2 = @ws.add_comment ref: 'C3', text: 'rust bucket', author: 'PO' end def test_initialize @@ -19,19 +19,19 @@ class TestComments < Test::Unit::TestCase def test_add_comment assert_equal(2, @ws.comments.size) 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_nothing_raised { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can', :ref => 'A1') } + 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_nothing_raised { @ws.comments.add_comment(author: 'bob', text: 'Yes We Can', ref: 'A1') } assert_equal(3, @ws.comments.size) end def test_authors assert_equal(@ws.comments.authors.size, @ws.comments.size) - @ws.add_comment(:text => 'Yes We Can!', :author => 'bob', :ref => 'F1') + @ws.add_comment(text: 'Yes We Can!', author: 'bob', ref: 'F1') assert_equal(3, @ws.comments.authors.size) - @ws.add_comment(:text => 'Yes We Can!', :author => 'bob', :ref => 'F1') + @ws.add_comment(text: 'Yes We Can!', author: 'bob', ref: 'F1') assert_equal(3, @ws.comments.authors.size, 'only unique authors are returned') end diff --git a/test/workbook/worksheet/tc_conditional_formatting.rb b/test/workbook/worksheet/tc_conditional_formatting.rb index f706dae3..104ce456 100644 --- a/test/workbook/worksheet/tc_conditional_formatting.rb +++ b/test/workbook/worksheet/tc_conditional_formatting.rb @@ -5,14 +5,14 @@ require 'tc_helper' 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) @@ -26,14 +26,14 @@ class TestConditionalFormatting < Test::Unit::TestCase cs.value_objects.first.val = 5 end - data_bar = Axlsx::DataBar.new :color => "FFFF0000" - icon_set = Axlsx::IconSet.new :iconSet => "5Rating" - 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 }) + data_bar = Axlsx::DataBar.new color: "FFFF0000" + icon_set = Axlsx::IconSet.new iconSet: "5Rating" + 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 }) assert(cfr.data_bar.is_a?(Axlsx::DataBar)) assert(cfr.icon_set.is_a?(Axlsx::IconSet)) @@ -72,15 +72,15 @@ class TestConditionalFormatting < Test::Unit::TestCase cs.value_objects.first.val = 5 end - data_bar = Axlsx::DataBar.new :color => "FFFF0000" - icon_set = Axlsx::IconSet.new :iconSet => "5Rating" + 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", - :dxfId => 0, :priority => 1, - :formula => 'NOT(ISERROR(SEARCH("FALSE",AB1)))', - :color_scale => color_scale, - :data_bar => data_bar, - :icon_set => icon_set }]) + 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 }]) 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) @@ -114,11 +114,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, - :equalAverage => false, :priority => 2, :operator => :lessThan, :text => "", - :percent => false, :rank => 0, :stdDev => 1, :stopIfTrue => true, :timePeriod => :today, - :formula => "0.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" }) 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) @@ -133,7 +133,7 @@ class TestConditionalFormatting < Test::Unit::TestCase end def test_multiple_formats - @ws.add_conditional_formatting "B3:B3", { :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :greaterThan, :formula => "1" } + @ws.add_conditional_formatting "B3:B3", { type: :cellIs, dxfId: 0, priority: 1, operator: :greaterThan, formula: "1" } doc = Nokogiri::XML.parse(@ws.to_xml_string) assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='greaterThan']//xmlns:formula='1'") @@ -141,7 +141,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'") diff --git a/test/workbook/worksheet/tc_data_bar.rb b/test/workbook/worksheet/tc_data_bar.rb index 62c6fc34..03af393b 100644 --- a/test/workbook/worksheet/tc_data_bar.rb +++ b/test/workbook/worksheet/tc_data_bar.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestDataBar < Test::Unit::TestCase def setup - @data_bar = Axlsx::DataBar.new :color => "FF638EC6" + @data_bar = Axlsx::DataBar.new color: "FF638EC6" end def test_defaults @@ -14,7 +14,7 @@ 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) diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb index 4be68673..fa09b0ab 100644 --- a/test/workbook/worksheet/tc_data_validation.rb +++ b/test/workbook/worksheet/tc_data_validation.rb @@ -8,13 +8,13 @@ class TestDataValidation < Test::Unit::TestCase def setup # inverse defaults - @boolean_options = { :allowBlank => false, :hideDropDown => true, :showErrorMessage => false, :showInputMessage => true } - @nil_options = { :formula1 => 'foo', :formula2 => 'foo', :errorTitle => 'foo', :operator => :lessThan, :prompt => 'foo', :promptTitle => 'foo', :sqref => 'foo' } - @type_option = { :type => :whole } - @error_style_option = { :errorStyle => :warning } + @boolean_options = { allowBlank: false, hideDropDown: true, showErrorMessage: false, showInputMessage: true } + @nil_options = { formula1: 'foo', formula2: 'foo', errorTitle: 'foo', operator: :lessThan, prompt: 'foo', promptTitle: 'foo', sqref: 'foo' } + @type_option = { type: :whole } + @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 } + @string_options = { formula1: 'foo', formula2: 'foo', error: 'foo', errorTitle: 'foo', prompt: 'foo', promptTitle: 'foo', sqref: 'foo' } + @symbol_options = { errorStyle: :warning, operator: :lessThan, type: :whole } @options = @boolean_options.merge(@nil_options).merge(@type_option).merge(@error_style_option) @@ -165,11 +165,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.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' }) + @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' }) doc = Nokogiri::XML.parse(@ws.to_xml_string) @@ -194,11 +194,11 @@ class TestDataValidation < Test::Unit::TestCase def test_list_to_xml p = Axlsx::Package.new - @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 }) + @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 }) doc = Nokogiri::XML.parse(@ws.to_xml_string) @@ -218,11 +218,11 @@ class TestDataValidation < Test::Unit::TestCase def test_custom_to_xml p = Axlsx::Package.new - @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' }) + @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' }) doc = Nokogiri::XML.parse(@ws.to_xml_string) @@ -241,15 +241,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.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' }) - @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 }) + @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' }) + @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 }) doc = Nokogiri::XML.parse(@ws.to_xml_string) diff --git a/test/workbook/worksheet/tc_header_footer.rb b/test/workbook/worksheet/tc_header_footer.rb index 8a62b281..d5c7651c 100644 --- a/test/workbook/worksheet/tc_header_footer.rb +++ b/test/workbook/worksheet/tc_header_footer.rb @@ -5,7 +5,7 @@ require 'tc_helper' class TestHeaderFooter < Test::Unit::TestCase def setup @p = Axlsx::Package.new - ws = @p.workbook.add_worksheet :name => 'test' + ws = @p.workbook.add_worksheet name: 'test' @hf = ws.header_footer end @@ -25,19 +25,19 @@ class TestHeaderFooter < Test::Unit::TestCase def test_initialize_with_options header_footer = { - :odd_header => 'oh', - :odd_footer => 'of', + odd_header: 'oh', + odd_footer: 'of', - :even_header => 'eh', - :even_footer => 'ef', + even_header: 'eh', + even_footer: 'ef', - :first_header => 'fh', - :first_footer => 'ff', + first_header: 'fh', + first_footer: 'ff', - :different_first => true, - :different_odd_even => true + different_first: true, + different_odd_even: true } - optioned = @p.workbook.add_worksheet(:name => 'optioned', :header_footer => header_footer).header_footer + optioned = @p.workbook.add_worksheet(name: 'optioned', header_footer: header_footer).header_footer assert_equal('oh', optioned.odd_header) assert_equal('of', optioned.odd_footer) @@ -68,17 +68,17 @@ class TestHeaderFooter < Test::Unit::TestCase def test_set_all_values @hf.set( - :odd_header => 'oh', - :odd_footer => 'of', + odd_header: 'oh', + odd_footer: 'of', - :even_header => 'eh', - :even_footer => 'ef', + even_header: 'eh', + even_footer: 'ef', - :first_header => 'fh', - :first_footer => 'ff', + first_header: 'fh', + first_footer: 'ff', - :different_first => true, - :different_odd_even => true + different_first: true, + different_odd_even: true ) assert_equal('oh', @hf.odd_header) @@ -96,17 +96,17 @@ class TestHeaderFooter < Test::Unit::TestCase def test_to_xml_all_values @hf.set( - :odd_header => 'oh', - :odd_footer => 'of', + odd_header: 'oh', + odd_footer: 'of', - :even_header => 'eh', - :even_footer => 'ef', + even_header: 'eh', + even_footer: 'ef', - :first_header => 'fh', - :first_footer => 'ff', + first_header: 'fh', + first_footer: 'ff', - :different_first => true, - :different_odd_even => true + different_first: true, + different_odd_even: true ) doc = Nokogiri::XML.parse(@hf.to_xml_string) @@ -131,8 +131,8 @@ class TestHeaderFooter < Test::Unit::TestCase def test_to_xml_some_values @hf.set( - :odd_header => 'oh', - :different_odd_even => false + odd_header: 'oh', + different_odd_even: false ) doc = Nokogiri::XML.parse(@hf.to_xml_string) diff --git a/test/workbook/worksheet/tc_outline_pr.rb b/test/workbook/worksheet/tc_outline_pr.rb index 95b52530..7c3769c9 100644 --- a/test/workbook/worksheet/tc_outline_pr.rb +++ b/test/workbook/worksheet/tc_outline_pr.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestOutlinePr < Test::Unit::TestCase def setup - @outline_pr = Axlsx::OutlinePr.new(:summary_below => false, :summary_right => true, :apply_styles => false) + @outline_pr = Axlsx::OutlinePr.new(summary_below: false, summary_right: true, apply_styles: false) end def test_summary_below diff --git a/test/workbook/worksheet/tc_page_margins.rb b/test/workbook/worksheet/tc_page_margins.rb index 8c580204..39f51fec 100644 --- a/test/workbook/worksheet/tc_page_margins.rb +++ b/test/workbook/worksheet/tc_page_margins.rb @@ -5,7 +5,7 @@ require 'tc_helper' 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 @@ -19,7 +19,7 @@ class TestPageMargins < Test::Unit::TestCase end def test_initialize_with_options - optioned = Axlsx::PageMargins.new(:left => 2, :right => 3, :top => 2, :bottom => 1, :header => 0.1, :footer => 0.1) + optioned = Axlsx::PageMargins.new(left: 2, right: 3, top: 2, bottom: 1, header: 0.1, footer: 0.1) assert_equal(2, optioned.left) assert_equal(3, optioned.right) @@ -30,7 +30,7 @@ class TestPageMargins < Test::Unit::TestCase end def test_set_all_values - @pm.set(:left => 1.1, :right => 1.2, :top => 1.3, :bottom => 1.4, :header => 0.8, :footer => 0.9) + @pm.set(left: 1.1, right: 1.2, top: 1.3, bottom: 1.4, header: 0.8, footer: 0.9) assert_in_delta(1.1, @pm.left) assert_in_delta(1.2, @pm.right) @@ -41,7 +41,7 @@ class TestPageMargins < Test::Unit::TestCase end def test_set_some_values - @pm.set(:left => 1.1, :right => 1.2) + @pm.set(left: 1.1, right: 1.2) assert_in_delta(1.1, @pm.left) assert_in_delta(1.2, @pm.right) diff --git a/test/workbook/worksheet/tc_page_set_up_pr.rb b/test/workbook/worksheet/tc_page_set_up_pr.rb index 36a2a6f4..8a9ee695 100644 --- a/test/workbook/worksheet/tc_page_set_up_pr.rb +++ b/test/workbook/worksheet/tc_page_set_up_pr.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestPageSetUpPr < Test::Unit::TestCase def setup - @page_setup_pr = Axlsx::PageSetUpPr.new(:fit_to_page => true, :auto_page_breaks => true) + @page_setup_pr = Axlsx::PageSetUpPr.new(fit_to_page: true, auto_page_breaks: true) end def test_fit_to_page diff --git a/test/workbook/worksheet/tc_page_setup.rb b/test/workbook/worksheet/tc_page_setup.rb index 95703c1c..db52e4fb 100644 --- a/test/workbook/worksheet/tc_page_setup.rb +++ b/test/workbook/worksheet/tc_page_setup.rb @@ -5,7 +5,7 @@ require 'tc_helper' class TestPageSetup < Test::Unit::TestCase def setup @p = Axlsx::Package.new - ws = @p.workbook.add_worksheet :name => "hmmm" + ws = @p.workbook.add_worksheet name: "hmmm" @ps = ws.page_setup end @@ -19,14 +19,14 @@ class TestPageSetup < Test::Unit::TestCase end def test_initialize_with_options - page_setup = { :fit_to_height => 1, - :fit_to_width => 2, - :orientation => :landscape, - :paper_height => "297mm", - :paper_width => "210mm", - :scale => 50 } + page_setup = { fit_to_height: 1, + fit_to_width: 2, + orientation: :landscape, + paper_height: "297mm", + paper_width: "210mm", + scale: 50 } - optioned = @p.workbook.add_worksheet(:name => 'optioned', :page_setup => page_setup).page_setup + optioned = @p.workbook.add_worksheet(name: 'optioned', page_setup: page_setup).page_setup assert_equal(1, optioned.fit_to_height) assert_equal(2, optioned.fit_to_width) @@ -37,7 +37,7 @@ class TestPageSetup < Test::Unit::TestCase end def test_set_all_values - @ps.set(:fit_to_height => 1, :fit_to_width => 2, :orientation => :landscape, :paper_height => "297mm", :paper_width => "210mm", :scale => 50) + @ps.set(fit_to_height: 1, fit_to_width: 2, orientation: :landscape, paper_height: "297mm", paper_width: "210mm", scale: 50) assert_equal(1, @ps.fit_to_height) assert_equal(2, @ps.fit_to_width) @@ -53,7 +53,7 @@ class TestPageSetup < Test::Unit::TestCase end def test_set_some_values - @ps.set(:fit_to_width => 2, :orientation => :portrait) + @ps.set(fit_to_width: 2, orientation: :portrait) assert_equal(2, @ps.fit_to_width) assert_equal(:portrait, @ps.orientation) @@ -70,27 +70,27 @@ class TestPageSetup < Test::Unit::TestCase def test_with_height_fit_to_page? assert(@ps.fit_to_width.nil? && @ps.fit_to_height.nil?) - @ps.set(:fit_to_height => 1) + @ps.set(fit_to_height: 1) assert_predicate(@ps, :fit_to_page?) end def test_with_width_fit_to_page? assert(@ps.fit_to_width.nil? && @ps.fit_to_height.nil?) - @ps.set(:fit_to_width => 1) + @ps.set(fit_to_width: 1) assert_predicate(@ps, :fit_to_page?) end def test_to_xml_all_values - @ps.set(:fit_to_height => 1, :fit_to_width => 2, :orientation => :landscape, :paper_height => "297mm", :paper_width => "210mm", :scale => 50) + @ps.set(fit_to_height: 1, fit_to_width: 2, orientation: :landscape, paper_height: "297mm", paper_width: "210mm", scale: 50) doc = Nokogiri::XML.parse(@ps.to_xml_string) assert_equal(1, doc.xpath(".//pageSetup[@fitToHeight='1'][@fitToWidth='2'][@orientation='landscape'][@paperHeight='297mm'][@paperWidth='210mm'][@scale='50']").size) end def test_to_xml_some_values - @ps.set(:orientation => :portrait) + @ps.set(orientation: :portrait) doc = Nokogiri::XML.parse(@ps.to_xml_string) assert_equal(1, doc.xpath(".//pageSetup[@orientation='portrait']").size) @@ -138,15 +138,15 @@ class TestPageSetup < Test::Unit::TestCase end def test_fit_to - fits = @ps.fit_to(:width => 1) + fits = @ps.fit_to(width: 1) assert_equal([1, 999], fits) - fits = @ps.fit_to :height => 1 + fits = @ps.fit_to height: 1 assert_equal([999, 1], fits) - fits = @ps.fit_to :height => 7, :width => 2 + fits = @ps.fit_to height: 7, width: 2 assert_equal([2, 7], fits) - 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_pane.rb b/test/workbook/worksheet/tc_pane.rb index 59d411a0..cf94fac7 100644 --- a/test/workbook/worksheet/tc_pane.rb +++ b/test/workbook/worksheet/tc_pane.rb @@ -5,8 +5,8 @@ require 'tc_helper' class TestPane < Test::Unit::TestCase def setup # inverse defaults for booleans - @nil_options = { :active_pane => :bottom_left, :state => :frozen, :top_left_cell => 'A2' } - @int_0_options = { :x_split => 2, :y_split => 2 } + @nil_options = { active_pane: :bottom_left, state: :frozen, top_left_cell: 'A2' } + @int_0_options = { x_split: 2, y_split: 2 } @options = @nil_options.merge(@int_0_options) @pane = Axlsx::Pane.new(@options) end @@ -48,7 +48,7 @@ class TestPane < Test::Unit::TestCase end def test_to_xml_frozen - pane = Axlsx::Pane.new :state => :frozen, :y_split => 2 + pane = Axlsx::Pane.new state: :frozen, y_split: 2 doc = Nokogiri::XML(pane.to_xml_string) assert_equal(1, doc.xpath("//pane[@topLeftCell='A3']").size) diff --git a/test/workbook/worksheet/tc_pivot_table.rb b/test/workbook/worksheet/tc_pivot_table.rb index f5b23a96..606982db 100644 --- a/test/workbook/worksheet/tc_pivot_table.rb +++ b/test/workbook/worksheet/tc_pivot_table.rb @@ -60,22 +60,22 @@ class TestPivotTable < Test::Unit::TestCase 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'] @@ -87,7 +87,7 @@ 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'] end @@ -96,7 +96,7 @@ class TestPivotTable < Test::Unit::TestCase 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'] end @@ -145,7 +145,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'] @@ -156,14 +156,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) diff --git a/test/workbook/worksheet/tc_print_options.rb b/test/workbook/worksheet/tc_print_options.rb index 10639bcf..2d2dfaf8 100644 --- a/test/workbook/worksheet/tc_print_options.rb +++ b/test/workbook/worksheet/tc_print_options.rb @@ -5,7 +5,7 @@ require 'tc_helper' class TestPrintOptions < Test::Unit::TestCase def setup p = Axlsx::Package.new - ws = p.workbook.add_worksheet :name => "hmmm" + ws = p.workbook.add_worksheet name: "hmmm" @po = ws.print_options end @@ -17,7 +17,7 @@ class TestPrintOptions < Test::Unit::TestCase end def test_initialize_with_options - optioned = Axlsx::PrintOptions.new(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true) + optioned = Axlsx::PrintOptions.new(grid_lines: true, headings: true, horizontal_centered: true, vertical_centered: true) assert(optioned.grid_lines) assert(optioned.headings) @@ -26,7 +26,7 @@ class TestPrintOptions < Test::Unit::TestCase end def test_set_all_values - @po.set(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true) + @po.set(grid_lines: true, headings: true, horizontal_centered: true, vertical_centered: true) assert(@po.grid_lines) assert(@po.headings) @@ -35,7 +35,7 @@ class TestPrintOptions < Test::Unit::TestCase end def test_set_some_values - @po.set(:grid_lines => true, :headings => true) + @po.set(grid_lines: true, headings: true) assert(@po.grid_lines) assert(@po.headings) @@ -44,7 +44,7 @@ class TestPrintOptions < Test::Unit::TestCase end def test_to_xml - @po.set(:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true) + @po.set(grid_lines: true, headings: true, horizontal_centered: true, vertical_centered: true) doc = Nokogiri::XML.parse(@po.to_xml_string) assert_equal(1, doc.xpath(".//printOptions[@gridLines=1][@headings=1][@horizontalCentered=1][@verticalCentered=1]").size) diff --git a/test/workbook/worksheet/tc_protected_range.rb b/test/workbook/worksheet/tc_protected_range.rb index 44fe8333..db28126a 100644 --- a/test/workbook/worksheet/tc_protected_range.rb +++ b/test/workbook/worksheet/tc_protected_range.rb @@ -9,7 +9,7 @@ class TestProtectedRange < Test::Unit::TestCase 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 ed3ec9ca..e28ea0af 100644 --- a/test/workbook/worksheet/tc_rich_text.rb +++ b/test/workbook/worksheet/tc_rich_text.rb @@ -5,12 +5,12 @@ require 'tc_helper' class RichText < Test::Unit::TestCase def setup p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "hmmmz" - p.workbook.styles.add_style :sz => 20 + @ws = p.workbook.add_worksheet name: "hmmmz" + p.workbook.styles.add_style sz: 20 @rt = Axlsx::RichText.new b = true 27.times 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 @@ -18,9 +18,9 @@ class RichText < Test::Unit::TestCase def test_initialize assert_equal(@c.value, @rt) - rt_direct = Axlsx::RichText.new('hi', :i => true) + rt_direct = Axlsx::RichText.new('hi', i: true) rt_indirect = Axlsx::RichText.new - rt_indirect.add_run('hi', :i => true) + rt_indirect.add_run('hi', i: true) assert_equal(1, rt_direct.runs.length) assert_equal(1, rt_indirect.runs.length) @@ -40,7 +40,7 @@ class RichText < Test::Unit::TestCase end def test_implicit_richtext - rt = Axlsx::RichText.new('a', :b => true) + rt = Axlsx::RichText.new('a', b: true) row_rt = @ws.add_row [rt] row_imp = @ws.add_row ['a'] row_imp[0].b = true diff --git a/test/workbook/worksheet/tc_rich_text_run.rb b/test/workbook/worksheet/tc_rich_text_run.rb index e9011832..6274dda8 100644 --- a/test/workbook/worksheet/tc_rich_text_run.rb +++ b/test/workbook/worksheet/tc_rich_text_run.rb @@ -5,8 +5,8 @@ require 'tc_helper' class RichTextRun < Test::Unit::TestCase def setup @p = Axlsx::Package.new - @ws = @p.workbook.add_worksheet :name => "hmmmz" - @p.workbook.styles.add_style :sz => 20 + @ws = @p.workbook.add_worksheet name: "hmmmz" + @p.workbook.styles.add_style sz: 20 @rtr = Axlsx::RichTextRun.new('hihihi', b: true, i: false) @rtr2 = Axlsx::RichTextRun.new('hihi2hi2', b: false, i: true) @rt = Axlsx::RichText.new @@ -23,7 +23,7 @@ class RichTextRun < Test::Unit::TestCase end def test_font_size_with_custom_style_and_no_sz - @c.style = @c.row.worksheet.workbook.styles.add_style :bg_color => 'FF00FF' + @c.style = @c.row.worksheet.workbook.styles.add_style bg_color: 'FF00FF' sz = @rtr.send(:font_size) assert_equal(sz, @c.row.worksheet.workbook.styles.fonts.first.sz * 1.5) @@ -33,14 +33,14 @@ class RichTextRun < Test::Unit::TestCase end def test_font_size_with_bolding - @c.style = @c.row.worksheet.workbook.styles.add_style :b => true + @c.style = @c.row.worksheet.workbook.styles.add_style b: true assert_equal(@c.row.worksheet.workbook.styles.fonts.first.sz * 1.5, @rtr.send(:font_size)) assert_equal(@c.row.worksheet.workbook.styles.fonts.first.sz * 1.5, @rtr2.send(:font_size)) # is this the correct behaviour? end def test_font_size_with_custom_sz - @c.style = @c.row.worksheet.workbook.styles.add_style :sz => 52 + @c.style = @c.row.worksheet.workbook.styles.add_style sz: 52 sz = @rtr.send(:font_size) assert_equal(52 * 1.5, sz) @@ -150,11 +150,11 @@ class RichTextRun < Test::Unit::TestCase end def test_multiline_autowidth - wrap = @p.workbook.styles.add_style({ :alignment => { :wrap_text => true } }) - awtr = Axlsx::RichTextRun.new('I\'m bold' + "\n", :b => 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 - @ws.add_row [rt], :style => wrap + @ws.add_row [rt], style: wrap ar = [0] awtr.autowidth(ar) diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb index 273487ac..52ed036c 100644 --- a/test/workbook/worksheet/tc_row.rb +++ b/test/workbook/worksheet/tc_row.rb @@ -5,7 +5,7 @@ require 'tc_helper' 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 @@ -17,7 +17,7 @@ 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) @@ -55,13 +55,13 @@ 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(3, r.cells.size) r.cells.each do |c| assert_equal(1, c.style) end - r = @ws.add_row [1, 2, 3], :style => [1] + r = @ws.add_row [1, 2, 3], style: [1] assert_equal(1, r.cells.first.style, "only apply style to cells with at the same index of of the style array") assert_equal(0, r.cells.last.style, "only apply style to cells with at the same index of of the style array") diff --git a/test/workbook/worksheet/tc_selection.rb b/test/workbook/worksheet/tc_selection.rb index d68500a5..d4f34e3d 100644 --- a/test/workbook/worksheet/tc_selection.rb +++ b/test/workbook/worksheet/tc_selection.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestSelection < Test::Unit::TestCase def setup - @options = { :active_cell => 'A2', :active_cell_id => 1, :pane => :top_left, :sqref => 'A2' } + @options = { active_cell: 'A2', active_cell_id: 1, pane: :top_left, sqref: 'A2' } @selection = Axlsx::Selection.new(@options) end @@ -34,12 +34,12 @@ class TestSelection < Test::Unit::TestCase def test_to_xml p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "sheetview" + @ws = p.workbook.add_worksheet name: "sheetview" @ws.sheet_view do |vs| - vs.add_selection(:top_left, { :active_cell => 'B2', :sqref => 'B2' }) - vs.add_selection(:top_right, { :active_cell => 'I10', :sqref => 'I10' }) - vs.add_selection(:bottom_left, { :active_cell => 'E55', :sqref => 'E55' }) - vs.add_selection(:bottom_right, { :active_cell => 'I57', :sqref => 'I57' }) + vs.add_selection(:top_left, { active_cell: 'B2', sqref: 'B2' }) + vs.add_selection(:top_right, { active_cell: 'I10', sqref: 'I10' }) + vs.add_selection(:bottom_left, { active_cell: 'E55', sqref: 'E55' }) + vs.add_selection(:bottom_right, { active_cell: 'I57', sqref: 'I57' }) end doc = Nokogiri::XML.parse(@ws.to_xml_string) diff --git a/test/workbook/worksheet/tc_sheet_calc_pr.rb b/test/workbook/worksheet/tc_sheet_calc_pr.rb index cd1f6506..9598b0c0 100644 --- a/test/workbook/worksheet/tc_sheet_calc_pr.rb +++ b/test/workbook/worksheet/tc_sheet_calc_pr.rb @@ -4,7 +4,7 @@ require 'tc_helper' class TestSheetCalcPr < Test::Unit::TestCase def setup - @sheet_calc_pr = Axlsx::SheetCalcPr.new(:full_calc_on_load => false) + @sheet_calc_pr = Axlsx::SheetCalcPr.new(full_calc_on_load: false) end def test_full_calc_on_load diff --git a/test/workbook/worksheet/tc_sheet_format_pr.rb b/test/workbook/worksheet/tc_sheet_format_pr.rb index 18d62249..ac7048cd 100644 --- a/test/workbook/worksheet/tc_sheet_format_pr.rb +++ b/test/workbook/worksheet/tc_sheet_format_pr.rb @@ -5,15 +5,15 @@ require 'tc_helper' class TestSheetFormatPr < Test::Unit::TestCase def setup @options = { - :base_col_width => 5, - :default_col_width => 7.2, - :default_row_height => 5.2, - :custom_height => true, - :zero_height => false, - :thick_top => true, - :thick_bottom => true, - :outline_level_row => 0, - :outline_level_col => 0 + base_col_width: 5, + default_col_width: 7.2, + default_row_height: 5.2, + custom_height: true, + zero_height: false, + thick_top: true, + thick_bottom: true, + outline_level_row: 0, + outline_level_col: 0 } @sheet_format_pr = Axlsx::SheetFormatPr.new(@options) end diff --git a/test/workbook/worksheet/tc_sheet_pr.rb b/test/workbook/worksheet/tc_sheet_pr.rb index be87ebf7..58c61bb5 100644 --- a/test/workbook/worksheet/tc_sheet_pr.rb +++ b/test/workbook/worksheet/tc_sheet_pr.rb @@ -6,16 +6,16 @@ class TestSheetPr < Test::Unit::TestCase def setup worksheet = Axlsx::Package.new.workbook.add_worksheet @options = { - :sync_horizontal => false, - :sync_vertical => false, - :transition_evaluation => true, - :transition_entry => true, - :published => false, - :filter_mode => true, - :enable_format_conditions_calculation => false, - :code_name => '007', - :sync_ref => 'foo', - :tab_color => 'FFFF6666' + sync_horizontal: false, + sync_vertical: false, + transition_evaluation: true, + transition_entry: true, + published: false, + filter_mode: true, + enable_format_conditions_calculation: false, + code_name: '007', + sync_ref: 'foo', + tab_color: 'FFFF6666' } @sheet_pr = Axlsx::SheetPr.new(worksheet, @options) end diff --git a/test/workbook/worksheet/tc_sheet_protection.rb b/test/workbook/worksheet/tc_sheet_protection.rb index 4a5e22e8..ebfff4b6 100644 --- a/test/workbook/worksheet/tc_sheet_protection.rb +++ b/test/workbook/worksheet/tc_sheet_protection.rb @@ -25,12 +25,12 @@ require 'tc_helper' class TestSheetProtection < Test::Unit::TestCase def setup # inverse defaults - @boolean_options = { :sheet => false, :objects => true, :scenarios => true, :format_cells => false, - :format_columns => false, :format_rows => false, :insert_columns => false, :insert_rows => false, - :insert_hyperlinks => false, :delete_columns => false, :delete_rows => false, :select_locked_cells => true, - :sort => false, :auto_filter => false, :pivot_tables => false, :select_unlocked_cells => true } + @boolean_options = { sheet: false, objects: true, scenarios: true, format_cells: false, + format_columns: false, format_rows: false, insert_columns: false, insert_rows: false, + insert_hyperlinks: false, delete_columns: false, delete_rows: false, select_locked_cells: true, + sort: false, auto_filter: false, pivot_tables: false, select_unlocked_cells: true } - @string_options = { :password => nil } + @string_options = { password: nil } @options = @boolean_options.merge(@string_options) diff --git a/test/workbook/worksheet/tc_sheet_view.rb b/test/workbook/worksheet/tc_sheet_view.rb index b52b6954..498c2056 100644 --- a/test/workbook/worksheet/tc_sheet_view.rb +++ b/test/workbook/worksheet/tc_sheet_view.rb @@ -5,16 +5,16 @@ require 'tc_helper' class TestSheetView < Test::Unit::TestCase def setup # inverse defaults for booleans - @boolean_options = { :right_to_left => true, :show_formulas => true, :show_outline_symbols => true, - :show_white_space => true, :tab_selected => true, :default_grid_color => false, :show_grid_lines => false, - :show_row_col_headers => false, :show_ruler => false, :show_zeros => false, :window_protection => true } - @symbol_options = { :view => :page_break_preview } - @nil_options = { :color_id => 2, :top_left_cell => 'A2' } - @int_0 = { :zoom_scale_normal => 100, :zoom_scale_page_layout_view => 100, :zoom_scale_sheet_layout_view => 100, :workbook_view_id => 2 } - @int_100 = { :zoom_scale => 10 } + @boolean_options = { right_to_left: true, show_formulas: true, show_outline_symbols: true, + show_white_space: true, tab_selected: true, default_grid_color: false, show_grid_lines: false, + show_row_col_headers: false, show_ruler: false, show_zeros: false, window_protection: true } + @symbol_options = { view: :page_break_preview } + @nil_options = { color_id: 2, top_left_cell: 'A2' } + @int_0 = { zoom_scale_normal: 100, zoom_scale_page_layout_view: 100, zoom_scale_sheet_layout_view: 100, workbook_view_id: 2 } + @int_100 = { zoom_scale: 10 } - @integer_options = { :color_id => 2, :workbook_view_id => 2 }.merge(@int_0).merge(@int_100) - @string_options = { :top_left_cell => 'A2' } + @integer_options = { color_id: 2, workbook_view_id: 2 }.merge(@int_0).merge(@int_100) + @string_options = { top_left_cell: 'A2' } @options = @boolean_options.merge(@boolean_options).merge(@symbol_options).merge(@nil_options).merge(@int_0).merge(@int_100) @@ -189,7 +189,7 @@ class TestSheetView < Test::Unit::TestCase def test_to_xml p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "sheetview" + @ws = p.workbook.add_worksheet name: "sheetview" @ws.sheet_view do |vs| vs.view = :page_break_preview end @@ -206,7 +206,7 @@ class TestSheetView < Test::Unit::TestCase end def test_add_selection - @sv.add_selection(:top_left, :active_cell => "A1") + @sv.add_selection(:top_left, active_cell: "A1") assert_equal('A1', @sv.selections[:top_left].active_cell) end diff --git a/test/workbook/worksheet/tc_table.rb b/test/workbook/worksheet/tc_table.rb index 38f909b9..3769ac02 100644 --- a/test/workbook/worksheet/tc_table.rb +++ b/test/workbook/worksheet/tc_table.rb @@ -17,7 +17,7 @@ class TestTable < Test::Unit::TestCase end def test_table_style_info - table = @ws.add_table('A1:D5', :name => 'foo', :style_info => { :show_row_stripes => true, :name => "TableStyleMedium25" }) + table = @ws.add_table('A1:D5', name: 'foo', style_info: { show_row_stripes: true, name: "TableStyleMedium25" }) assert_equal('TableStyleMedium25', table.table_style_info.name) assert(table.table_style_info.show_row_stripes) @@ -25,7 +25,7 @@ class TestTable < Test::Unit::TestCase def test_add_table name = "test" - table = @ws.add_table("A1:D5", :name => name) + table = @ws.add_table("A1:D5", name: name) assert(table.is_a?(Axlsx::Table), "must create a table") assert_equal(@ws.workbook.tables.last, table, "must be added to workbook table collection") diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb index 60a4c113..6cb12b94 100644 --- a/test/workbook/worksheet/tc_table_style_info.rb +++ b/test/workbook/worksheet/tc_table_style_info.rb @@ -9,12 +9,12 @@ 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') - @options = { :show_first_column => 1, - :show_last_column => 1, - :show_row_stripes => 1, - :show_column_stripes => 1, - :name => "TableStyleDark4" } + @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, + show_column_stripes: 1, + name: "TableStyleDark4" } end def test_initialize diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index 3c54e3fc..4ec74efb 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -33,12 +33,12 @@ 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 assert_nothing_raised { @ws.name = @ws.name } - assert_nothing_raised { Axlsx::Package.new.workbook.add_worksheet :name => 'Sheet1' } + assert_nothing_raised { Axlsx::Package.new.workbook.add_worksheet name: 'Sheet1' } end def test_exception_if_name_too_long @@ -117,11 +117,11 @@ class TestWorksheet < Test::Unit::TestCase 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' } - 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 = { 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.each_key do |key| assert_equal(page_margins[key], optioned.page_margins.send(key)) @@ -247,7 +247,7 @@ class TestWorksheet < Test::Unit::TestCase @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.col_style((1..2), 1, row_offset: 1) @ws.rows[(1..-1)].each do |r| assert_equal(1, r.cells[1].style) assert_equal(1, r.cells[2].style) @@ -287,14 +287,14 @@ class TestWorksheet < Test::Unit::TestCase @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.row_style 1, 1, col_offset: 1 @ws.rows[1].cells[(1..-1)].each do |c| assert_equal(1, c.style) end assert_equal(0, @ws.rows[1].cells[0].style) assert_equal(0, @ws.rows[2].cells[1].style) - @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(1, c.style) @@ -477,9 +477,9 @@ class TestWorksheet < Test::Unit::TestCase # Make sure the XML for all optional elements (like pageMargins, autoFilter, ...) # is generated in correct order. def test_valid_with_optional_elements - @ws.page_margins.set :left => 9 - @ws.page_setup.set :fit_to_width => 1 - @ws.print_options.set :headings => true + @ws.page_margins.set left: 9 + @ws.page_setup.set fit_to_width: 1 + @ws.print_options.set headings: true @ws.auto_filter.range = "A1:C3" @ws.merge_cells "A4:A5" @ws.add_chart Axlsx::Pie3DChart @@ -501,10 +501,10 @@ class TestWorksheet < Test::Unit::TestCase @ws.add_chart Axlsx::Pie3DChart assert_equal(1, @ws.relationships.size, "multiple charts still only result in one relationship") - @ws.add_comment :text => 'builder', :author => 'bob', :ref => @ws.rows.last.cells.last + @ws.add_comment text: 'builder', author: 'bob', ref: @ws.rows.last.cells.last assert_equal(3, @ws.relationships.size, "adding a comment adds 2 relationships") - @ws.add_comment :text => 'not that is a comment!', :author => 'travis', :ref => "A1" + @ws.add_comment text: 'not that is a comment!', author: 'travis', ref: "A1" assert_equal(3, @ws.relationships.size, "adding multiple comments in the same worksheet should not add any additional comment relationships") @ws.add_pivot_table 'G5:G6', 'A1:D10' @@ -513,7 +513,7 @@ class TestWorksheet < Test::Unit::TestCase end def test_set_fixed_width_column - @ws.add_row ["mule", "donkey", "horse"], :widths => [20, :ignore, nil] + @ws.add_row ["mule", "donkey", "horse"], widths: [20, :ignore, nil] assert_equal(3, @ws.column_info.size, "a data item for each column") assert_equal(20, @ws.column_info[0].width, "adding a row with fixed width updates :fixed attribute") @@ -521,7 +521,7 @@ class TestWorksheet < Test::Unit::TestCase end def test_fixed_height - @ws.add_row [1, 2, 3], :height => 40 + @ws.add_row [1, 2, 3], height: 40 assert_equal(40, @ws.rows[-1].height) end @@ -641,7 +641,7 @@ class TestWorksheet < Test::Unit::TestCase def test_sheet_pr_for_auto_filter @ws.auto_filter.range = 'A1:D9' - @ws.auto_filter.add_column 0, :filters, :filter_items => [1] + @ws.auto_filter.add_column 0, :filters, filter_items: [1] doc = Nokogiri::XML(@ws.to_xml_string) assert(doc.xpath('//sheetPr[@filterMode=1]')) @@ -667,7 +667,7 @@ class TestWorksheet < Test::Unit::TestCase def test_worksheet_does_not_get_added_to_workbook_on_initialize_failure assert_equal(1, @wb.worksheets.size) - assert_raise(ArgumentError) { @wb.add_worksheet(:name => 'Sheet1') } + assert_raise(ArgumentError) { @wb.add_worksheet(name: 'Sheet1') } assert_equal(1, @wb.worksheets.size) end diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb index 19bacc0e..e4e82e88 100644 --- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb +++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb @@ -7,7 +7,7 @@ class TestWorksheetHyperlink < Test::Unit::TestCase p = Axlsx::Package.new wb = p.workbook @ws = wb.add_worksheet - @options = { :location => 'https://github.com/randym/axlsx?foo=1&bar=2', :tooltip => 'axlsx', :ref => 'A1', :display => 'AXSLX', :target => :internal } + @options = { location: 'https://github.com/randym/axlsx?foo=1&bar=2', tooltip: 'axlsx', ref: 'A1', display: 'AXSLX', target: :internal } @a = @ws.add_hyperlink @options end |
