Skip to content

Commit

Permalink
Merge pull request #93 from pedroaxl/master
Browse files Browse the repository at this point in the history
Exporting link url when converting spreadsheet to csv
  • Loading branch information
Empact committed Jan 25, 2014
2 parents 435c70c + 584334c commit 636541d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/roo/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ def cell_to_csv(row, col, sheet)
onecell.to_s
when :time
Roo::Base.integer_to_timestring(onecell)
when :link
%{"#{onecell.url.gsub(/"/,'""')}"}
else
raise "unhandled celltype #{celltype(row,col,sheet)}"
end || ""
Expand Down
1 change: 1 addition & 0 deletions test/files/link.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"http://www.google.com"
14 changes: 13 additions & 1 deletion test/test_roo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,19 @@ def test_boolean_to_csv
end
end
end

def test_link_to_csv
with_each_spreadsheet(:name=>'link',:format=>:excel) do |oo|
Dir.mktmpdir do |tempdir|
csv_output = File.join(tempdir,'link.csv')
assert oo.to_csv(csv_output)
assert File.exists?(csv_output)
puts `diff --strip-trailing-cr #{TESTDIR}/link.csv #{csv_output}`
assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/link.csv #{csv_output}`
# --strip-trailing-cr is needed because the test-file use 0A and
# the test on an windows box generates 0D 0A as line endings
end
end
end
def test_date_time_yaml
with_each_spreadsheet(:name=>'time-test') do |oo|
expected =
Expand Down

0 comments on commit 636541d

Please sign in to comment.