Skip to content

Commit

Permalink
convert all hashes to ruby 1.9+ syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Dec 3, 2016
1 parent bf5cd08 commit d702e4c
Show file tree
Hide file tree
Showing 21 changed files with 128 additions and 128 deletions.
2 changes: 1 addition & 1 deletion lib/rodf/cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions lib/rodf/property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [[
Expand Down
2 changes: 1 addition & 1 deletion lib/rodf/spreadsheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/rodf/style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rodf/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 22 additions & 22 deletions spec/cell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -39,36 +39,36 @@
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'
elem['table:formula'].should == 'oooc:=SUM([.A1:.A4])'
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'
elem['table:number-matrix-rows-spanned'].should == '1'
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
Expand All @@ -82,51 +82,51 @@
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'
cell['office:value'].should be_nil
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

Expand All @@ -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'
Expand All @@ -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')
Expand All @@ -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
Expand All @@ -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')
Expand Down
12 changes: 6 additions & 6 deletions spec/data_style_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/hyperlink_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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).
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion spec/master_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/page_layout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
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

it "should accept parameterless blocks" do
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
Expand Down
8 changes: 4 additions & 4 deletions spec/paragraph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit d702e4c

Please sign in to comment.