From 33f36899cb0ce80e4ce55f229fc132aab5f6f6a4 Mon Sep 17 00:00:00 2001 From: gorn Date: Tue, 4 Jun 2019 12:05:32 +0200 Subject: [PATCH] . --- lib/rspreadsheet/empty_file_template.fods | 9 + spec/fods_spec.rb | 45 + spec/testfile1.fods | 1039 +++++++++++++++++++++ 3 files changed, 1093 insertions(+) create mode 100644 lib/rspreadsheet/empty_file_template.fods create mode 100644 spec/fods_spec.rb create mode 100644 spec/testfile1.fods diff --git a/lib/rspreadsheet/empty_file_template.fods b/lib/rspreadsheet/empty_file_template.fods new file mode 100644 index 0000000..d965eff --- /dev/null +++ b/lib/rspreadsheet/empty_file_template.fods @@ -0,0 +1,9 @@ + + + +Rspreadshhet gem by Gorn + + + + + diff --git a/spec/fods_spec.rb b/spec/fods_spec.rb new file mode 100644 index 0000000..4f6c542 --- /dev/null +++ b/spec/fods_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' +using ClassExtensions if RUBY_VERSION > '2.1' + +describe 'Rspreadsheet flat ODS format' do + before do + @tmp_filename = '/tmp/testfile.ods' # delete temp file before tests + delete_tmpfile(@tmp_filename) + end + after do + delete_tmpfile(@tmp_filename) # delete temp file after tests + end + + it 'can open flat ods testfile and reads its content correctly' do + book = Rspreadsheet.open($test_filename_fods, format: :fods ) + s = book.worksheets(1) + (1..10).each do |i| + s[i,1].should === i + end + s[1,2].should === 'text' + s[2,2].should === Date.new(2014,1,1) + end + + it 'can open and save flast ods file, and saved file is exactly same as original' do + book = Rspreadsheet.new($test_filename_fods) # open test file + book.save(@tmp_filename) # and save it as temp file + + # now compare them + @content_xml1 = Zip::File.open($test_filename) do |zip| + LibXML::XML::Document.io zip.get_input_stream('content.xml') + end + @content_xml2 = Zip::File.open(@tmp_filename) do |zip| + LibXML::XML::Document.io zip.get_input_stream('content.xml') + end + + @content_xml2.root.first_diff(@content_xml1.root).should be_nil + @content_xml1.root.first_diff(@content_xml2.root).should be_nil + @content_xml1.root.to_s.should == @content_xml2.root.to_s + end + + private + def delete_tmpfile(afile) + File.delete(afile) if File.exist?(afile) + end + +end diff --git a/spec/testfile1.fods b/spec/testfile1.fods new file mode 100644 index 0000000..6c6a810 --- /dev/null +++ b/spec/testfile1.fods @@ -0,0 +1,1039 @@ + + + + 2014-05-17T14:48:24.2075349322017-03-25T18:11:28.237662270PT12H45M9S40LibreOffice/6.1.5.2$Linux_X86_64 LibreOffice_project/10$Build-2Jakub Tesinsky + + + 0 + 0 + 18090 + 10385 + + + view1 + + + 1 + 8 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 100 + 60 + true + false + + + List1 + 778 + 0 + 100 + 60 + false + true + true + true + 12632256 + true + true + true + true + false + false + false + 1000 + 1000 + 1 + 1 + true + false + + + + + 7 + true + false + false + 0 + true + rQH+/0xleG1hcmstSW50ZXJuYXRpb25hbC1MZXhtYXJrLUNYMzE3ZG4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ1VQUzpMZXhtYXJrLUludGVybmF0aW9uYWwtTGV4bQAWAAMAzgAAAAAAAAAIAFZUAAAkbQAASm9iRGF0YSAxCnByaW50ZXI9TGV4bWFyay1JbnRlcm5hdGlvbmFsLUxleG1hcmstQ1gzMTdkbgpvcmllbnRhdGlvbj1Qb3J0cmFpdApjb3BpZXM9MQpjb2xsYXRlPWZhbHNlCm1hcmdpbmRhanVzdG1lbnQ9MCwwLDAsMApjb2xvcmRlcHRoPTI0CnBzbGV2ZWw9MApwZGZkZXZpY2U9MQpjb2xvcmRldmljZT0wClBQRENvbnRleERhdGEKUGFnZVNpemU6TGV0dGVyAAASAENPTVBBVF9EVVBMRVhfTU9ERQ8ARHVwbGV4TW9kZTo6T2Zm + Lexmark-International-Lexmark-CX317dn + + + cs + CZ + + + + + + true + 3 + true + false + true + true + 12632256 + true + true + false + true + false + true + false + true + 1 + false + 1000 + 1000 + false + 1 + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + - + + + + + ( + + ) + + + + . + + . + + + + + + + + - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + % + + + + : + + + + + : + + : + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + $ + + + + + - + $ + + + + + $ + + + + + - + $ + + + + + $ + + + + + - + $ + + + + + $ + + + . + + + + $ + ( + + .) + + + + + + + + + + - + + + + + + + + . + + . + + + + + + : + + : + + + + + + + % + + + + + + + - + + + + + + + + + + + - + + + + + + + + + + - + + + + + + + + + + + - + + + + + + + . + + . + + + + + . + + . + + + + + . + + + + + . + + + + + : + + + + + + + : + + : + + + + + + + : + + + + + : + + : + + + + + . + + . + + + + : + + + + + + + + - + + + + + + + + + + + - + + + + + + + + + + - + + + + + + + + + + + - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + - Kč + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + : + + + + + : + + : + + + + + : + + + + + + + $ + + + + + + $ + ( + + ) + + + $ + - + + + + + $ + + + + + $ + ( + + ) + + + $ + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + . + + + + + : + + + + + : + + + + + + + - + + - + + + + : + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ??? + + + + Stránka 1 + + + + + + + ???(???) + + + 00.00.0000, 00:00:00 + + + + + Stránka 1/ 99 + + + + + + + + + + + + + + + + + 1 + + + text + + + + + + 2 + + + 01.01.2014 + + + + + + 3 + + + 45,00% + + + + + + 4 + + + nic + + + + 7 + + + + + 5 + + + + + + 6 + + + + bold + + + italic + + + red font + + + blue backgound + + + font size 7 + + + + + 7 + + + + + + 8 + + + + border + + + + + + + + + 9 + + + + + + + 10 + + + + + + + + [http://example.org/] + + + + + + + afterrepeated + + + + + + + + + + F19 + + + + + + + + + + Currency types + + + note + + + Time types + + + note + + + Date types + + + note + + + + + + $ (147984,84.) + + + + 02:22 + + + simplest example – time only + + + 2006-06-06 03:44:21 + + + date and time + + + + + + 344,-- Kč + + + + 03:33 dop. + + + time with „hidden date“ (date converted to time) + + + + + + + + \ No newline at end of file