From d702e4cd7bc71912c5c5a9c846398814f0db99d4 Mon Sep 17 00:00:00 2001 From: Weston Ganger Date: Fri, 2 Dec 2016 16:51:33 -0800 Subject: [PATCH] convert all hashes to ruby 1.9+ syntax --- lib/rodf/cell.rb | 2 +- lib/rodf/property.rb | 16 ++++++------ lib/rodf/spreadsheet.rb | 2 +- lib/rodf/style.rb | 2 +- lib/rodf/text.rb | 2 +- spec/cell_spec.rb | 44 ++++++++++++++++---------------- spec/data_style_spec.rb | 12 ++++----- spec/hyperlink_spec.rb | 6 ++--- spec/master_page_spec.rb | 2 +- spec/page_layout_spec.rb | 4 +-- spec/paragraph_spec.rb | 8 +++--- spec/property_spec.rb | 52 +++++++++++++++++++------------------- spec/row_spec.rb | 6 ++--- spec/skeleton_spec.rb | 8 +++--- spec/span_spec.rb | 4 +-- spec/spreadsheet_spec.rb | 20 +++++++-------- spec/style_section_spec.rb | 4 +-- spec/style_spec.rb | 34 ++++++++++++------------- spec/tab_spec.rb | 2 +- spec/table_spec.rb | 10 ++++---- spec/text_spec.rb | 16 ++++++------ 21 files changed, 128 insertions(+), 128 deletions(-) diff --git a/lib/rodf/cell.rb b/lib/rodf/cell.rb index e715e41..26e134b 100644 --- a/lib/rodf/cell.rb +++ b/lib/rodf/cell.rb @@ -109,7 +109,7 @@ def make_value_paragraph cell, value, url = self, @value, @url paragraph do if cell.contains_url? - link value, :href => url + link value, href: url else self << value end diff --git a/lib/rodf/property.rb b/lib/rodf/property.rb index 102adb6..479fb0b 100644 --- a/lib/rodf/property.rb +++ b/lib/rodf/property.rb @@ -19,14 +19,14 @@ module RODF class Property - PROPERTY_NAMES = {:cell => 'table-cell-properties', - :text => 'text-properties', - :column => 'table-column-properties', - :row => 'table-row-properties', - :page_layout => 'page-layout-properties', - :header_footer => 'header-footer-properties', - :list_level => 'list-level-properties', - :conditional => 'map'} + PROPERTY_NAMES = {cell: 'table-cell-properties', + text: 'text-properties', + column: 'table-column-properties', + row: 'table-row-properties', + page_layout: 'page-layout-properties', + header_footer: 'header-footer-properties', + list_level: 'list-level-properties', + conditional: 'map'} TRANSLATED_SPECS = [:border_color, :border_style, :border_width] ATTRIBUTES_TO_NAMESPACES = [[ diff --git a/lib/rodf/spreadsheet.rb b/lib/rodf/spreadsheet.rb index 863ddbf..2c88591 100644 --- a/lib/rodf/spreadsheet.rb +++ b/lib/rodf/spreadsheet.rb @@ -28,7 +28,7 @@ class Spreadsheet < Document def xml b = Builder::XmlMarkup.new - b.instruct! :xml, :version => '1.0', :encoding => 'UTF-8' + b.instruct! :xml, version: '1.0', encoding: 'UTF-8' b.tag! 'office:document-content', 'xmlns:office' => "urn:oasis:names:tc:opendocument:xmlns:office:1.0", 'xmlns:table' => "urn:oasis:names:tc:opendocument:xmlns:table:1.0", diff --git a/lib/rodf/style.rb b/lib/rodf/style.rb index 4be8405..42e5bb8 100644 --- a/lib/rodf/style.rb +++ b/lib/rodf/style.rb @@ -24,7 +24,7 @@ module RODF class Style < Container contains :properties - FAMILIES = {:cell => 'table-cell', :column => 'table-column', :row => 'table-row'} + FAMILIES = {cell: 'table-cell', column: 'table-column', row: 'table-row'} def initialize(name='', opts={}, node_tag='style:style') @name, @node_tag = name, node_tag diff --git a/lib/rodf/text.rb b/lib/rodf/text.rb index 79b8c2a..f2064bb 100644 --- a/lib/rodf/text.rb +++ b/lib/rodf/text.rb @@ -33,7 +33,7 @@ class Text < Document def xml b = Builder::XmlMarkup.new - b.instruct! :xml, :version => '1.0', :encoding => 'UTF-8' + b.instruct! :xml, version: '1.0', encoding: 'UTF-8' b.tag! 'office:document-content', 'xmlns:office' => "urn:oasis:names:tc:opendocument:xmlns:office:1.0", 'xmlns:table' => "urn:oasis:names:tc:opendocument:xmlns:table:1.0", 'xmlns:text' => "urn:oasis:names:tc:opendocument:xmlns:text:1.0", diff --git a/spec/cell_spec.rb b/spec/cell_spec.rb index 6b10c1e..187a135 100644 --- a/spec/cell_spec.rb +++ b/spec/cell_spec.rb @@ -30,7 +30,7 @@ end it "should allow value types to be specified" do - output = RODF::Cell.new(34.2, :type => :float).xml + output = RODF::Cell.new(34.2, type: :float).xml Hpricot(output).at('table:table-cell')['office:value-type'].should=='float' end @@ -39,18 +39,18 @@ output.should have_tag('//text:p') Hpricot(output).at('text:p').innerHTML.should == 'Test' - output = RODF::Cell.new(47, :type => :float).xml + output = RODF::Cell.new(47, type: :float).xml output.should_not have_tag('//table:table-cell/*') Hpricot(output).at('table:table-cell')['office:value'].should == '47' - output = RODF::Cell.new(34.2, :type => :string).xml + output = RODF::Cell.new(34.2, type: :string).xml output.should have_tag('//text:p') Hpricot(output).at('text:p').innerHTML.should == '34.2' end it "should accept formulas" do - output = RODF::Cell.new(:type => :float, - :formula => "oooc:=SUM([.A1:.A4])").xml + output = RODF::Cell.new(type: :float, + formula: "oooc:=SUM([.A1:.A4])").xml elem = Hpricot(output).at('table:table-cell') elem['office:value-type'].should == 'float' @@ -58,8 +58,8 @@ end it "should accept matrix formulas" do - output = RODF::Cell.new(:type => :float, :matrix_formula => true, - :formula => "oooc:=SUM([.A1:.A4])").xml + output = RODF::Cell.new(type: :float, matrix_formula: true, + formula: "oooc:=SUM([.A1:.A4])").xml elem = Hpricot(output).at('table:table-cell') elem['table:number-matrix-columns-spanned'].should == '1' @@ -67,8 +67,8 @@ end it "should not make a matrix formula when asked not too" do - output = RODF::Cell.new(:type => :float, :matrix_formula => false, - :formula => "oooc:=SUM([.A1:.A4])").xml + output = RODF::Cell.new(type: :float, matrix_formula: false, + formula: "oooc:=SUM([.A1:.A4])").xml elem = Hpricot(output).at('table:table-cell') elem['table:number-matrix-columns-spanned'].should be_nil @@ -82,43 +82,43 @@ end it "should allow an style to be specified in the constructor" do - cell = RODF::Cell.new 45.8, :type => :float, :style => 'left-column-cell' + cell = RODF::Cell.new 45.8, type: :float, style: 'left-column-cell' Hpricot(cell.xml).at('table:table-cell')['table:style-name']. should == 'left-column-cell' end it "should allow and style to be specified through a method call" do - cell = RODF::Cell.new 45.8, :type => :float + cell = RODF::Cell.new 45.8, type: :float cell.style = 'left-column-cell' Hpricot(cell.xml).at('table:table-cell')['table:style-name']. should == 'left-column-cell' end it "should span multiple cells when asked to" do - cell = RODF::Cell.new 'Spreadsheet title', :span => 4 + cell = RODF::Cell.new 'Spreadsheet title', span: 4 doc = Hpricot(cell.xml) doc.at('table:table-cell')['table:number-columns-spanned'].should == '4' doc.search('table:table-cell').size.should == 4 end it "should have the URL set correctly when requested on a string" do - cell = RODF::Cell.new 'Example Link', :url => 'http://www.example.org' + cell = RODF::Cell.new 'Example Link', url: 'http://www.example.org' doc = Hpricot(cell.xml) doc.at('text:a')['xlink:href'].should == 'http://www.example.org' end it "should ignore the URL requested on anything other than a string" do - cell = RODF::Cell.new(47.1, :type => :float, :url => 'http://www.example.org') + cell = RODF::Cell.new(47.1, type: :float, url: 'http://www.example.org') cell.xml.should_not have_tag('text:p') cell.xml.should_not have_tag('text:a') - cell = RODF::Cell.new(Date.parse('15 Apr 2010'), :type => :date, :url => 'http://www.example.org') + cell = RODF::Cell.new(Date.parse('15 Apr 2010'), type: :date, url: 'http://www.example.org') cell.xml.should_not have_tag('text:p') cell.xml.should_not have_tag('text:a') end it "should have the date set correctly" do - cell = Hpricot(RODF::Cell.new(Date.parse('15 Apr 2010'), :type => :date).xml). + cell = Hpricot(RODF::Cell.new(Date.parse('15 Apr 2010'), type: :date).xml). at('table:table-cell') cell['office:value-type'].should == 'date' cell['office:date-value'].should == '2010-04-15' @@ -126,7 +126,7 @@ end it "should also accept strings as date values" do - Hpricot(RODF::Cell.new(Date.parse('16 Apr 2010'), :type => :date).xml). + Hpricot(RODF::Cell.new(Date.parse('16 Apr 2010'), type: :date).xml). at('table:table-cell')['office:date-value'] = '2010-04-16' end @@ -135,7 +135,7 @@ c.paragraph "testing" output = c.xml - output.should have_tag("//table:table-cell/*", :count => 1) + output.should have_tag("//table:table-cell/*", count: 1) output.should have_tag("//text:p") Hpricot(output).at('text:p').innerHTML.should == 'testing' @@ -147,7 +147,7 @@ c.paragraph "second" end - output.should have_tag("//table:table-cell/*", :count => 2) + output.should have_tag("//table:table-cell/*", count: 2) output.should have_tag("//text:p") ps = Hpricot(output).search('text:p') @@ -156,11 +156,11 @@ end it "should not render value type for non-string nil values" do - Hpricot(RODF::Cell.new(nil, :type => :string).xml). + Hpricot(RODF::Cell.new(nil, type: :string).xml). at('table:table-cell').innerHTML.should == '' [:float, :date].each do |t| - cell = Hpricot(RODF::Cell.new(nil, :type => t).xml).at('table:table-cell') + cell = Hpricot(RODF::Cell.new(nil, type: t).xml).at('table:table-cell') cell.innerHTML.should == '' cell['office:value'].should be_nil cell['office:date-value'].should be_nil @@ -174,7 +174,7 @@ paragraph "second" end - output.should have_tag("//table:table-cell/*", :count => 2) + output.should have_tag("//table:table-cell/*", count: 2) output.should have_tag("//text:p") ps = Hpricot(output).search('text:p') diff --git a/spec/data_style_spec.rb b/spec/data_style_spec.rb index 85b6a1a..decb33f 100644 --- a/spec/data_style_spec.rb +++ b/spec/data_style_spec.rb @@ -22,8 +22,8 @@ describe RODF::DataStyle do it "should have sections" do output = RODF::DataStyle.create 'year-to-day', :date do |s| - s.section :year, :style => 'long' - s.section :month, :style => 'long' + s.section :year, style: 'long' + s.section :month, style: 'long' s.section :day end @@ -37,8 +37,8 @@ it "should allow short section names" do output = RODF::DataStyle.create 'year-to-day', :date do |number| - number.year :style => 'long' - number.month :style => 'long' + number.year style: 'long' + number.month style: 'long' number.day end @@ -49,8 +49,8 @@ it "should accept parameterless blocks" do output = RODF::DataStyle.create 'year-to-day', :date do - section :year, :style => 'long' - section :month, :style => 'long' + section :year, style: 'long' + section :month, style: 'long' section :day end diff --git a/spec/hyperlink_spec.rb b/spec/hyperlink_spec.rb index 9e0497f..89f9bd8 100644 --- a/spec/hyperlink_spec.rb +++ b/spec/hyperlink_spec.rb @@ -21,7 +21,7 @@ describe RODF::Hyperlink do it "should receive content text in first argument" do - output = RODF::Hyperlink.new('link somewhere', :href => 'http://www.example.org/').xml + output = RODF::Hyperlink.new('link somewhere', href: 'http://www.example.org/').xml output.should have_tag('//text:a') link = Hpricot(output).at('text:a') @@ -30,7 +30,7 @@ end it "should accept ref both in second argument as in argument hash" do - Hpricot(RODF::Hyperlink.new('link somewhere', :href => 'http://www.example.org/').xml). + Hpricot(RODF::Hyperlink.new('link somewhere', href: 'http://www.example.org/').xml). at('text:a')['xlink:href'].should == 'http://www.example.org/' Hpricot(RODF::Hyperlink.new('link somewhere', 'http://www.example.org/').xml). @@ -42,7 +42,7 @@ link.strong 'important link' end - output.should have_tag('//text:a/*', :count => 1) + output.should have_tag('//text:a/*', count: 1) tree = Hpricot(output) tree.at('//text:a')['xlink:href'].should == 'http://www.example.com/' span = tree.at('//text:span') diff --git a/spec/master_page_spec.rb b/spec/master_page_spec.rb index ec7c953..ddd1d94 100644 --- a/spec/master_page_spec.rb +++ b/spec/master_page_spec.rb @@ -28,7 +28,7 @@ end it "should accept a layout reference" do - Hpricot(RODF::MasterPage.new('my-master-page', :layout => 'A4').xml). + Hpricot(RODF::MasterPage.new('my-master-page', layout: 'A4').xml). at('style:master-page')['style:page-layout-name'].should == 'A4' end end diff --git a/spec/page_layout_spec.rb b/spec/page_layout_spec.rb index 148356f..2f715a2 100644 --- a/spec/page_layout_spec.rb +++ b/spec/page_layout_spec.rb @@ -30,7 +30,7 @@ output = RODF::PageLayout.create 'main-layout' do |l| l.property 'page-layout' end - output.should have_tag('//style:page-layout/*', :count => 1) + output.should have_tag('//style:page-layout/*', count: 1) output.should have_tag('style:page-layout-properties') end @@ -38,7 +38,7 @@ output = RODF::PageLayout.create 'main-layout' do property 'page-layout' end - output.should have_tag('//style:page-layout/*', :count => 1) + output.should have_tag('//style:page-layout/*', count: 1) output.should have_tag('style:page-layout-properties') end end diff --git a/spec/paragraph_spec.rb b/spec/paragraph_spec.rb index 5d8cbeb..38d67f2 100644 --- a/spec/paragraph_spec.rb +++ b/spec/paragraph_spec.rb @@ -52,22 +52,22 @@ it "should be able to hold hyperlinks" do output = RODF::Paragraph.create {|p| p << "please visit " - p.a "example.org", :href => "http://www.example.org/" + p.a "example.org", href: "http://www.example.org/" p << " for more details" } - output.should have_tag("//text:p/*", :count => 3) + output.should have_tag("//text:p/*", count: 3) output.should have_tag("//text:a") Hpricot(output).at('text:a').innerHTML.should == 'example.org' end it "should support style attribute" do - Hpricot(RODF::Paragraph.create('styled paragraph', :style => 'highlight')). + Hpricot(RODF::Paragraph.create('styled paragraph', style: 'highlight')). at('text:p')['text:style-name'].should == 'highlight' end it "should accept attributes in the first parameter too" do - para = Hpricot(RODF::Paragraph.create(:style => 'testing')).at('text:p') + para = Hpricot(RODF::Paragraph.create(style: 'testing')).at('text:p') para.innerHTML.should be_empty para['text:style-name'].should == 'testing' end diff --git a/spec/property_spec.rb b/spec/property_spec.rb index 34a0c8f..a9c9891 100644 --- a/spec/property_spec.rb +++ b/spec/property_spec.rb @@ -21,7 +21,7 @@ describe RODF::Property do it "should accept either strings or symbols as keys" do - property = RODF::Property.new :text, :color=>'#4c4c4c', 'font-weight'=>'bold' + property = RODF::Property.new :text, color:'#4c4c4c', 'font-weight'=>'bold' elem = Hpricot(property.xml).at('style:text-properties') elem['fo:color'].should == '#4c4c4c' elem['fo:font-weight'].should == 'bold' @@ -62,25 +62,25 @@ end it "should accept full perimeter border specs" do - property = RODF::Property.new :cell, :border => "0.025in solid #000000" + property = RODF::Property.new :cell, border: "0.025in solid #000000" Hpricot(property.xml).at('//style:table-cell-properties')['fo:border']. should == "0.025in solid #000000" end it "should accept splited full perimeter border specs" do - property = RODF::Property.new :cell, :border_width => '0.025in', - :border_color => '#000000', - :border_style => 'solid' + property = RODF::Property.new :cell, border_width: '0.025in', + border_color: '#000000', + border_style: 'solid' Hpricot(property.xml).at('//style:table-cell-properties')['fo:border']. should == "0.025in solid #000000" end it "should use the first value for vertical and second for horizontal border side specs" do - property = RODF::Property.new :cell, :border_width => '0.025in 0.3in', - :border_color => '#ff0000 #0000ff', - :border_style => 'solid' + property = RODF::Property.new :cell, border_width: '0.025in 0.3in', + border_color: '#ff0000 #0000ff', + border_style: 'solid' elem= Hpricot(property.xml).at('//style:table-cell-properties') elem['fo:border-top'].should == "0.025in solid #ff0000" @@ -90,46 +90,46 @@ end it "should use the third value for bottom border specs when present" do - property = RODF::Property.new :cell, :border_width => '0.025in 0.3in 0.4in', - :border_color => '#ff0000 #0000ff', - :border_style => 'dotted solid solid' + property = RODF::Property.new :cell, border_width: '0.025in 0.3in 0.4in', + border_color: '#ff0000 #0000ff', + border_style: 'dotted solid solid' elem = Hpricot(property.xml).at('//style:table-cell-properties') elem['fo:border-bottom'].should == "0.4in solid #ff0000" - property = RODF::Property.new :cell, :border_width => '0.025in', - :border_color => '#ff0000 #0000ff #00ff00', - :border_style => 'dotted solid' + property = RODF::Property.new :cell, border_width: '0.025in', + border_color: '#ff0000 #0000ff #00ff00', + border_style: 'dotted solid' elem = Hpricot(property.xml).at('//style:table-cell-properties') elem['fo:border-bottom'].should == "0.025in dotted #00ff00" end it "should cascade left border specs from fourth to second to first" do - property = RODF::Property.new :cell, :border_width => '0.1in 0.2in 0.3in 0.4in', - :border_color => '#ff0000 #0000ff #00ff00', - :border_style => 'dotted solid' + property = RODF::Property.new :cell, border_width: '0.1in 0.2in 0.3in 0.4in', + border_color: '#ff0000 #0000ff #00ff00', + border_style: 'dotted solid' elem = Hpricot(property.xml).at('//style:table-cell-properties') elem['fo:border-left'].should == "0.4in solid #0000ff" - property = RODF::Property.new :cell, :border_width => '0.1in 0.2in 0.3in', - :border_color => '#ff0000 #0000ff', - :border_style => 'dotted' + property = RODF::Property.new :cell, border_width: '0.1in 0.2in 0.3in', + border_color: '#ff0000 #0000ff', + border_style: 'dotted' elem = Hpricot(property.xml).at('//style:table-cell-properties') elem['fo:border-left'].should == "0.2in dotted #0000ff" - property = RODF::Property.new :cell, :border_width => '0.1in 0.2in', - :border_color => '#ff0000', - :border_style => 'dotted solid dashed double' + property = RODF::Property.new :cell, border_width: '0.1in 0.2in', + border_color: '#ff0000', + border_style: 'dotted solid dashed double' elem = Hpricot(property.xml).at('//style:table-cell-properties') elem['fo:border-left'].should == "0.2in double #ff0000" - property = RODF::Property.new :cell, :border_width => '0.1in', - :border_color => '#ff0000 #0000ff #00ff00 #ffff00', - :border_style => 'dotted solid dashed' + property = RODF::Property.new :cell, border_width: '0.1in', + border_color: '#ff0000 #0000ff #00ff00 #ffff00', + border_style: 'dotted solid dashed' elem = Hpricot(property.xml).at('//style:table-cell-properties') elem['fo:border-left'].should == "0.1in solid #ffff00" diff --git a/spec/row_spec.rb b/spec/row_spec.rb index e9b4b2f..089dd43 100644 --- a/spec/row_spec.rb +++ b/spec/row_spec.rb @@ -29,7 +29,7 @@ r.cell r.cell } - output.should have_tag('//table:table-row/*', :count => 2) + output.should have_tag('//table:table-row/*', count: 2) output.should have_tag('//table:table-cell') end @@ -38,12 +38,12 @@ cell cell end - output.should have_tag('//table:table-row/*', :count => 2) + output.should have_tag('//table:table-row/*', count: 2) output.should have_tag('//table:table-cell') end it "should be stylable in the initialization" do - output = RODF::Row.create 0, :style => 'dark' do + output = RODF::Row.create 0, style: 'dark' do cell end Hpricot(output).at('table:table-row')['table:style-name']. diff --git a/spec/skeleton_spec.rb b/spec/skeleton_spec.rb index ac00b0e..bc87e8a 100644 --- a/spec/skeleton_spec.rb +++ b/spec/skeleton_spec.rb @@ -24,10 +24,10 @@ output = RODF::Skeleton.new.styles output.should have_tag('//office:document-styles/*') output.should have_tag('//office:font-face-decls') - output.should have_tag('//office:styles', :count => 1) - output.should have_tag('//style:style', :count => 1) - output.should have_tag('//number:number-style', :count => 2) - output.should have_tag('//number:date-style', :count => 1) + output.should have_tag('//office:styles', count: 1) + output.should have_tag('//style:style', count: 1) + output.should have_tag('//number:number-style', count: 2) + output.should have_tag('//number:date-style', count: 1) end end diff --git a/spec/span_spec.rb b/spec/span_spec.rb index 9921d60..dca0934 100644 --- a/spec/span_spec.rb +++ b/spec/span_spec.rb @@ -37,7 +37,7 @@ s.italics 'highlighted text' end - output.should have_tag('//text:span/*', :count => 2) + output.should have_tag('//text:span/*', count: 2) Hpricot(output).search('//text:span')[1]. innerHTML.should == 'highlighted text' end @@ -49,7 +49,7 @@ s.a 'back again', 'http://www.example.com/' end - output.should have_tag('//text:a', :count => 2) + output.should have_tag('//text:a', count: 2) elem = Hpricot(output) links = elem.search('//text:a') diff --git a/spec/spreadsheet_spec.rb b/spec/spreadsheet_spec.rb index d17ef87..5594765 100644 --- a/spec/spreadsheet_spec.rb +++ b/spec/spreadsheet_spec.rb @@ -36,15 +36,15 @@ output = RODF::SpreadSheet.create { |s| s.table 'Example' } - output.should have_tag('//office:spreadsheet/*', :count => 1) - output.should have_tag('//table:table', :count => 1) + output.should have_tag('//office:spreadsheet/*', count: 1) + output.should have_tag('//table:table', count: 1) Hpricot(output).at('//table:table')['table:name'].should == 'Example' output = RODF::SpreadSheet.create { |s| s.table 'First table' s.table 'Second table' } - output.should have_tag('//office:spreadsheet/*', :count => 2) + output.should have_tag('//office:spreadsheet/*', count: 2) end it "should allow rows to be added inside tables" do @@ -61,10 +61,10 @@ it "should allow styles to be added" do RODF::SpreadSheet.create.should_not have_tag('//office:automatic-styles') output = RODF::SpreadSheet.create do |s| - s.style 'even-row-cell', :family => :cell + s.style 'even-row-cell', family: :cell end - output.should have_tag('//office:automatic-styles/*', :count => 1) + output.should have_tag('//office:automatic-styles/*', count: 1) output.should have_tag('//style:style') Hpricot(output).at('//style:style')['style:name'].should == 'even-row-cell' Hpricot(output).at('//style:style')['style:family'].should == 'table-cell' @@ -74,13 +74,13 @@ output = RODF::SpreadSheet.create do |ss| ss.data_style 'year-to-day-long', :date end - output.should have_tag('//office:automatic-styles/*', :count => 1) + output.should have_tag('//office:automatic-styles/*', count: 1) output.should have_tag('//number:date-style') end it "should allow conditional styles to be added" do output = RODF::SpreadSheet.create do |s| - s.style 'cond-cell', :family => :cell do + s.style 'cond-cell', family: :cell do property :conditional, 'condition' => 'cell-content()!=0', 'apply-style-name' => 'red-cell' @@ -93,7 +93,7 @@ it "should allow office styles to be added" do spread = RODF::SpreadSheet.new - spread.office_style 'red-cell', :family => :cell + spread.office_style 'red-cell', family: :cell output = spread.office_styles_xml @@ -104,8 +104,8 @@ it "should support mixed office and conditional styles to be added" do spread = RODF::SpreadSheet.new - spread.office_style 'red-cell', :family => :cell - spread.style 'cond-cell', :family => :cell do + spread.office_style 'red-cell', family: :cell + spread.style 'cond-cell', family: :cell do property :conditional, 'condition' => 'cell-content()!=0', 'apply-style-name' => 'red-cell' diff --git a/spec/style_section_spec.rb b/spec/style_section_spec.rb index 9bc923b..cafa64f 100644 --- a/spec/style_section_spec.rb +++ b/spec/style_section_spec.rb @@ -21,13 +21,13 @@ describe RODF::StyleSection do it "should allow style attribute" do - output = RODF::StyleSection.new(:year, :style => 'long').xml + output = RODF::StyleSection.new(:year, style: 'long').xml output.should have_tag('number:year') Hpricot(output).at('number:year')['number:style'].should == 'long' end it "should allow textual flag" do - output = RODF::StyleSection.new(:month, :textual => true).xml + output = RODF::StyleSection.new(:month, textual: true).xml Hpricot(output).at('number:month')['number:textual'].should == 'true' end diff --git a/spec/style_spec.rb b/spec/style_spec.rb index f42e5ad..f780cd4 100644 --- a/spec/style_spec.rb +++ b/spec/style_spec.rb @@ -23,13 +23,13 @@ it "should output properties when they're added" do RODF::Style.create.should_not have_tag('//style:style/*') - output = RODF::Style.create 'odd-row-cell', :family => :cell do |s| + output = RODF::Style.create 'odd-row-cell', family: :cell do |s| s.property :cell, 'background-color' => '#b3b3b3', 'border' => '0.002cm solid #000000' s.property :text, 'color' => '#4c4c4c', 'font-weight' => 'bold' end - output.should have_tag('//style:style/*', :count => 2) + output.should have_tag('//style:style/*', count: 2) output.should have_tag('//style:table-cell-properties') output.should have_tag('//style:text-properties') @@ -43,23 +43,23 @@ end it "should allow data styles" do - xml = RODF::Style.create 'my-style', :family => :cell, - :data_style => 'currency-grouped' + xml = RODF::Style.create 'my-style', family: :cell, + data_style: 'currency-grouped' style = Hpricot(xml).at('//style:style') style['style:data-style-name'].should == 'currency-grouped' end it "should allow parent styles" do - xml = RODF::Style.create 'child-style', :family => :cell, - :parent => 'cell-default' + xml = RODF::Style.create 'child-style', family: :cell, + parent: 'cell-default' style = Hpricot(xml).at('//style:style') style['style:parent-style-name'].should == 'cell-default' - cell_style = RODF::Style.new('cell-default', :family => :cell) - xml = RODF::Style.create 'child-style', :family => :cell, - :parent => cell_style + cell_style = RODF::Style.new('cell-default', family: :cell) + xml = RODF::Style.create 'child-style', family: :cell, + parent: cell_style style = Hpricot(xml).at('//style:style') style['style:parent-style-name'].should == 'cell-default' @@ -67,39 +67,39 @@ it "should allow master pages" do xml = RODF::Style.create 'standard', - :family => :paragraph, - :master_page => 'letter' + family: :paragraph, + master_page: 'letter' Hpricot(xml).at('//style:style')['style:master-page-name'].should == 'letter' end it "should be able to describe column styles" do - xml = RODF::Style.create 'column-style', :family => :column do |style| + xml = RODF::Style.create 'column-style', family: :column do |style| style.property :column, 'column-width' => '2cm' end Hpricot(xml).at('//style:style')['style:family'].should == 'table-column' - xml.should have_tag('//style:style/*', :count => 1) + xml.should have_tag('//style:style/*', count: 1) xml.should have_tag('//style:table-column-properties') end it "should be able to describe row styles" do - xml = RODF::Style.create 'column-style', :family => :row do |style| + xml = RODF::Style.create 'column-style', family: :row do |style| end Hpricot(xml).at('//style:style')['style:family'].should == 'table-row' end it "should accept other families" do - Hpricot(RODF::Style.create('text-style', :family => :text)). + Hpricot(RODF::Style.create('text-style', family: :text)). at('//style:style')['style:family'].should == 'text' - Hpricot(RODF::Style.create('text-style', :family => :paragraph)). + Hpricot(RODF::Style.create('text-style', family: :paragraph)). at('//style:style')['style:family'].should == 'paragraph' end it "should accept parameterless blocks" do - output = RODF::Style.create 'odd-row-cell', :family => :cell do + output = RODF::Style.create 'odd-row-cell', family: :cell do property :text, 'color' => '#4c4c4c', 'font-weight' => 'bold' end diff --git a/spec/tab_spec.rb b/spec/tab_spec.rb index 374a80d..b9dab98 100644 --- a/spec/tab_spec.rb +++ b/spec/tab_spec.rb @@ -27,7 +27,7 @@ p.tab p << "test" } - output.should have_tag("//text:p/*", :count => 3) + output.should have_tag("//text:p/*", count: 3) output.should have_tag("//text:tab") end end diff --git a/spec/table_spec.rb b/spec/table_spec.rb index c7e9153..7e0a15f 100644 --- a/spec/table_spec.rb +++ b/spec/table_spec.rb @@ -26,14 +26,14 @@ output.should_not have_tag('//table:table/*') output = RODF::Table.create('MyTable') {|t| t.row } - output.should have_tag('//table:table/*', :count => 1) + output.should have_tag('//table:table/*', count: 1) output.should have_tag('//table:table-row') output = RODF::Table.create('MyTable') {|t| t.row t.row } - output.should have_tag('//table:table/*', :count => 2) + output.should have_tag('//table:table/*', count: 2) output.should have_tag('//table:table-row') end @@ -48,7 +48,7 @@ it "should allow column style specifications" do xml = RODF::Table.create('Styles columns table') do |t| - t.column :style => 'wide' + t.column style: 'wide' end xml.should have_tag('table:table-column') @@ -61,7 +61,7 @@ row row } - output.should have_tag('//table:table/*', :count => 2) + output.should have_tag('//table:table/*', count: 2) output.should have_tag('//table:table-row') end @@ -70,7 +70,7 @@ row {cell} row } - output.should have_tag('//table:table/*', :count => 2) + output.should have_tag('//table:table/*', count: 2) output.should have_tag('//table:table-row') output.should have_tag('//table:table-cell') end diff --git a/spec/text_spec.rb b/spec/text_spec.rb index 78bbd9e..19a6bf9 100644 --- a/spec/text_spec.rb +++ b/spec/text_spec.rb @@ -43,12 +43,12 @@ it "should allow styles" do RODF::Text.create.should_not have_tag('//office:automatic-styles') output = RODF::Text.create { |doc| - doc.style('bold', :family => 'text') {|s| + doc.style('bold', family: 'text') {|s| s.property(:text, 'font-weight' => 'bold') } - doc.style('italic', :family => 'text') {|s| + doc.style('italic', family: 'text') {|s| s.property(:text, 'font-weight' => 'italic') } } - output.should have_tag('//office:automatic-styles/*', :count => 2) + output.should have_tag('//office:automatic-styles/*', count: 2) output.should have_tag('//style:style') end @@ -56,23 +56,23 @@ output = RODF::Text.create { |doc| doc.page_layout 'main-layout' } - output.should have_tag('//office:automatic-styles/*', :count => 1) + output.should have_tag('//office:automatic-styles/*', count: 1) output.should have_tag('//style:page-layout') end it "should support master pages" do output = RODF::Text.create do |doc| - doc.master_page 'standard', :layout => 'letter' + doc.master_page 'standard', layout: 'letter' end - output.should have_tag('//office:master-styles/*', :count => 1) + output.should have_tag('//office:master-styles/*', count: 1) output.should have_tag('//style:master-page') end it "should support default styles" do output = RODF::Text.create do |doc| - doc.default_style :family => 'paragraph' + doc.default_style family: 'paragraph' end - output.should have_tag('//office:styles/*', :count => 1) + output.should have_tag('//office:styles/*', count: 1) output.should have_tag('//style:default-style') end end