diff options
| -rw-r--r-- | lib/axlsx/util/constants.rb | 27 | ||||
| -rw-r--r-- | test/tc_package.rb | 21 |
2 files changed, 26 insertions, 22 deletions
diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb index e9a0a02a..bdda9216 100644 --- a/lib/axlsx/util/constants.rb +++ b/lib/axlsx/util/constants.rb @@ -21,7 +21,7 @@ module Axlsx # dc elements (core) namespace CORE_NS_DC = "http://purl.org/dc/elements/1.1/" - + # dcmit (core) namespcace CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/" @@ -30,10 +30,10 @@ module Axlsx # xml schema namespace CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance" - + # spreadsheet drawing namespace XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" - + # drawing namespace XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main" @@ -43,13 +43,12 @@ module Axlsx # relationships namespace XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships" - # relationships name space RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships" # table rels namespace TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table" - + # workbook rels namespace WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" @@ -80,7 +79,7 @@ module Axlsx # image rels namespace HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" - # table content type + # table content type TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml" # workbook content type @@ -90,14 +89,14 @@ module Axlsx APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml" # rels content type - RELS_CT = "application/vnd.openxmlformats-package.relationships+xml" + RELS_CT = "application/vnd.openxmlformats-package.relationships+xml" # styles content type STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" # xml content type XML_CT = "application/xml" - + # worksheet content type WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" @@ -127,7 +126,7 @@ module Axlsx # jpeg extension JPEG_EX = "jpeg" - + # gif extension GIF_EX = "gif" @@ -145,10 +144,10 @@ module Axlsx # shared_strings part SHARED_STRINGS_PN = "sharedStrings.xml" - + # app part APP_PN = "docProps/app.xml" - + # core part CORE_PN = "docProps/core.xml" @@ -196,12 +195,12 @@ module Axlsx # spreadsheetML validation schema SML_XSD = SCHEMA_BASE + "sml.xsd" - + # drawing validation schema DRAWING_XSD = SCHEMA_BASE + "dml-spreadsheetDrawing.xsd" # number format id for pecentage formatting using the default formatting id. - NUM_FMT_PERCENT = 9 + NUM_FMT_PERCENT = 9 # number format id for date format like 2011/11/13 NUM_FMT_YYYYMMDD = 100 @@ -216,7 +215,7 @@ module Axlsx STYLE_DATE = 2 # error messages RestrictionValidor - ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s." + ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s." # error message DataTypeValidator ERR_TYPE = "Invalid Data %s for %s. must be %s." diff --git a/test/tc_package.rb b/test/tc_package.rb index 7057badd..26556143 100644 --- a/test/tc_package.rb +++ b/test/tc_package.rb @@ -2,7 +2,7 @@ require 'test/unit' require 'axlsx.rb' class TestPackage < Test::Unit::TestCase - def setup + def setup @package = Axlsx::Package.new ws = @package.workbook.add_worksheet chart = ws.add_chart Axlsx::Pie3DChart @@ -39,16 +39,16 @@ class TestPackage < Test::Unit::TestCase fname = 'axlsx_test_serialization.xlsx' assert_nothing_raised do begin - z= @package.serialize(@fname) + z= @package.serialize(@fname) zf = Zip::ZipFile.open(@fname) @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) } - File.delete(@fname) + File.delete(@fname) rescue Errno::EACCES puts "WARNING:: test_serialization requires write access." end - end + end end - + def test_validation assert_equal(@package.validate.size, 0, @package.validate) #how to test for failure? the internal validations on the models are so strict I cant break anthing..... @@ -58,7 +58,7 @@ class TestPackage < Test::Unit::TestCase p = @package.send(:parts) p.each do |part| #all parts must have :doc, :entry, :schema - assert(part.keys.size == 3 && part.keys.reject{ |k| [:doc, :entry, :schema].include? k}.empty?) + assert(part.keys.size == 3 && part.keys.reject{ |k| [:doc, :entry, :schema].include? k}.empty?) end #all parts have an entry assert_equal(p.select{ |part| part[:entry] =~ /_rels\/\.rels/ }.size, 1, "rels missing") @@ -76,7 +76,7 @@ class TestPackage < Test::Unit::TestCase #no mystery parts assert_equal(p.size, 12) - + end def test_shared_strings_requires_part @@ -84,7 +84,7 @@ class TestPackage < Test::Unit::TestCase p = @package.send(:parts) assert_equal(p.select{ |part| part[:entry] =~/xl\/sharedStrings.xml/}.size, 1, "shared strings table missing") end - + def test_workbook_is_a_workbook assert @package.workbook.is_a? Axlsx::Workbook end @@ -106,4 +106,9 @@ class TestPackage < Test::Unit::TestCase assert(ct.select { |ct| ct.ContentType == Axlsx::SHARED_STRINGS_CT }.size == 1) end + def test_name_to_indices + assert(Axlsx::name_to_indices('A1') == [0,0]) + assert(Axlsx::name_to_indices('A100') == [0,99], 'needs to axcept rows that contain 0') + + end end |
