diff options
| author | Randy Morgan <[email protected]> | 2012-02-01 13:01:12 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-02-01 13:01:12 +0900 |
| commit | 38a3046b2a02b309ac5835c02c7a252ee4831d41 (patch) | |
| tree | 36bbce36b7197d0ef9894c839998995f1566ccd8 | |
| parent | 24520038e7e25110ef87fee0396fe3a1e2ca67b6 (diff) | |
| download | caxlsx-38a3046b2a02b309ac5835c02c7a252ee4831d41.tar.gz caxlsx-38a3046b2a02b309ac5835c02c7a252ee4831d41.zip | |
Updating schema loading for validation to correctly load the schema file relative to the package as reported by Phong in #21.
https://github.com/randym/axlsx/issues/21
| -rw-r--r-- | lib/axlsx/package.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/util/constants.rb | 12 | ||||
| -rw-r--r-- | lib/axlsx/workbook/workbook.rb | 7 |
3 files changed, 13 insertions, 8 deletions
diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb index b725c0c7..a096bbc6 100644 --- a/lib/axlsx/package.rb +++ b/lib/axlsx/package.rb @@ -157,7 +157,7 @@ module Axlsx # @return [Array] An array of all validation errors encountered. # @private def validate_single_doc(schema, doc) - schema = Nokogiri::XML::Schema(File.open(schema)) + schema = Nokogiri::XML::Schema(File.open(File.dirname(__FILE__)+schema)) doc = Nokogiri::XML(doc) errors = [] diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb index b0a81eac..d7bb8524 100644 --- a/lib/axlsx/util/constants.rb +++ b/lib/axlsx/util/constants.rb @@ -170,22 +170,22 @@ module Axlsx IMAGE_PN = "media/image%d.%s" # App validation schema - APP_XSD = "lib/schema/shared-documentPropertiesExtended.xsd" + APP_XSD = "/../schema/shared-documentPropertiesExtended.xsd" # core validation schema - CORE_XSD = "lib/schema/opc-coreProperties.xsd" + CORE_XSD = "/../schema/opc-coreProperties.xsd" # content types validation schema - CONTENT_TYPES_XSD = "lib/schema/opc-contentTypes.xsd" + CONTENT_TYPES_XSD = "/../schema/opc-contentTypes.xsd" # rels validation schema - RELS_XSD = "lib/schema/opc-relationships.xsd" + RELS_XSD = "/../schema/opc-relationships.xsd" # spreadsheetML validation schema - SML_XSD = "lib/schema/sml.xsd" + SML_XSD = "/../schema/sml.xsd" # drawing validation schema - DRAWING_XSD = "lib/schema/dml-spreadsheetDrawing.xsd" + DRAWING_XSD = "/../schema/dml-spreadsheetDrawing.xsd" # number format id for pecentage formatting using the default formatting id. NUM_FMT_PERCENT = 9 diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index ea733a4f..c74e74a8 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -82,7 +82,9 @@ require 'axlsx/workbook/worksheet/worksheet.rb' #end # Creates a new Workbook - # @option options [Boolean] date1904 + # + # @option options [Boolean] date1904. If this is not specified, we try to determine if the platform is bsd/darwin and set date1904 to true automatically. + # def initialize(options={}) @styles = Styles.new @worksheets = SimpleTypedList.new Worksheet @@ -93,6 +95,9 @@ require 'axlsx/workbook/worksheet/worksheet.rb' yield self if block_given? end + # Uses RUBY_PLATFORM constant to determine if the OS is freebsd or darwin + # based on this value we attempt to set date1904. + # @return [Boolean] def is_bsd? platform = RUBY_PLATFORM.downcase platform.include?('freebsd') || platform.include?('darwin') |
