summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-02-13 09:47:10 +0900
committerRandy Morgan <[email protected]>2012-02-13 09:47:10 +0900
commit472b388df84eb278ee4df3e6c34371430fe9a8b4 (patch)
treed454ac437e0b1699ad40c71c888449329a99cd9c /lib
parent5eccc5e560fd3f92508a6f131fe99ab054d1bb60 (diff)
downloadcaxlsx-472b388df84eb278ee4df3e6c34371430fe9a8b4.tar.gz
caxlsx-472b388df84eb278ee4df3e6c34371430fe9a8b4.zip
Remove entirely the dependancies on i18n and active support.
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx.rb11
-rw-r--r--lib/axlsx/stylesheet/styles.rb10
-rw-r--r--lib/axlsx/util/simple_typed_list.rb2
3 files changed, 12 insertions, 11 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb
index 06488091..0859f93b 100644
--- a/lib/axlsx.rb
+++ b/lib/axlsx.rb
@@ -1,7 +1,4 @@
# encoding: UTF-8
-Encoding::default_internal = 'UTF-8' unless RUBY_VERSION < '1.9'
-Encoding::default_external = 'UTF-8' unless RUBY_VERSION < '1.9'
-
require 'axlsx/version.rb'
require 'axlsx/util/simple_typed_list.rb'
@@ -28,8 +25,6 @@ require 'axlsx/package.rb'
#required gems
require 'nokogiri'
-require 'active_support/core_ext/object/instance_variables'
-require 'active_support/inflector'
require 'RMagick'
require 'zip/zip'
@@ -37,6 +32,12 @@ require 'zip/zip'
require 'bigdecimal'
require 'time'
+#if object does not have this already, I am borrowing it from active_support.
+
+ Object.send :define_method, :instance_values do
+ Hash[instance_variables.map { |name| [name.to_s[1..-1], instance_variable_get(name)] }]
+ end unless Object.respond_to?(:instance_values)
+
# xlsx generation with charts, images, automated column width, customizable styles and full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification. Check out the README for some examples of how easy it is. Best of all, you can validate your xlsx file before serialization so you know for sure that anything generated is going to load on your client's machine.
module Axlsx
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb
index 7c2913e5..421215c1 100644
--- a/lib/axlsx/stylesheet/styles.rb
+++ b/lib/axlsx/stylesheet/styles.rb
@@ -253,22 +253,22 @@ module Axlsx
# Creates the default set of styles the exel requires to be valid as well as setting up the
# Axlsx::STYLE_THIN_BORDER
def load_default_styles
- @numFmts = SimpleTypedList.new NumFmt
+ @numFmts = SimpleTypedList.new NumFmt, 'numFmts'
@numFmts << NumFmt.new(:numFmtId => NUM_FMT_YYYYMMDD, :formatCode=> "yyyy/mm/dd")
@numFmts << NumFmt.new(:numFmtId => NUM_FMT_YYYYMMDDHHMMSS, :formatCode=> "yyyy/mm/dd hh:mm:ss")
@numFmts.lock
- @fonts = SimpleTypedList.new Font
+ @fonts = SimpleTypedList.new Font, 'fonts'
@fonts << Font.new(:name => "Arial", :sz => 11, :family=>1)
@fonts.lock
- @fills = SimpleTypedList.new Fill
+ @fills = SimpleTypedList.new Fill, 'fills'
@fills << Fill.new(Axlsx::PatternFill.new(:patternType=>:none))
@fills << Fill.new(Axlsx::PatternFill.new(:patternType=>:gray125))
@fills.lock
- @borders = SimpleTypedList.new Border
+ @borders = SimpleTypedList.new Border, 'borders'
@borders << Border.new
black_border = Border.new
[:left, :right, :top, :bottom].each do |item|
@@ -281,7 +281,7 @@ module Axlsx
@cellStyleXfs << Xf.new(:borderId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0)
@cellStyleXfs.lock
- @cellStyles = SimpleTypedList.new CellStyle
+ @cellStyles = SimpleTypedList.new CellStyle, 'cellStyles'
@cellStyles << CellStyle.new(:name =>"Normal", :builtinId =>0, :xfId=>0)
@cellStyles.lock
diff --git a/lib/axlsx/util/simple_typed_list.rb b/lib/axlsx/util/simple_typed_list.rb
index 5a5addfa..ce34a9bb 100644
--- a/lib/axlsx/util/simple_typed_list.rb
+++ b/lib/axlsx/util/simple_typed_list.rb
@@ -154,7 +154,7 @@ module Axlsx
# @return [String]
def to_xml(xml)
classname = @allowed_types[0].name.split('::').last
- el_name = serialize_as || (classname[0,1].downcase + classname[1..-1]).pluralize
+ el_name = serialize_as || (classname[0,1].downcase + classname[1..-1])
xml.send(el_name, :count=>@list.size) {
@list.each { |item| item.to_xml(xml) }
}