xmlss 1.0.0.rc.3 → 1.0.0.rc.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -3
- data/README.rdoc +14 -11
- data/lib/xmlss/element/column.rb +6 -0
- data/lib/xmlss/element/row.rb +6 -0
- data/lib/xmlss/version.rb +1 -1
- data/lib/xmlss/workbook.rb +33 -31
- data/test/element/column_test.rb +2 -1
- data/test/element/row_test.rb +3 -1
- data/test/workbook_test.rb +5 -5
- data/xmlss.gemspec +1 -1
- metadata +7 -7
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
xmlss (1.0.0.rc.
|
4
|
+
xmlss (1.0.0.rc.4)
|
5
5
|
enumeration (~> 1.3)
|
6
|
-
undies (~> 3.0.0.rc.
|
6
|
+
undies (~> 3.0.0.rc.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
enumeration (1.3.1)
|
17
17
|
rake (0.9.2)
|
18
18
|
ruby-prof (0.10.8)
|
19
|
-
undies (3.0.0.rc.
|
19
|
+
undies (3.0.0.rc.3)
|
20
20
|
whysoslow (0.0.2)
|
21
21
|
ansi (~> 1.4)
|
22
22
|
|
data/README.rdoc
CHANGED
@@ -106,25 +106,26 @@ protection(value):
|
|
106
106
|
|
107
107
|
== Usage
|
108
108
|
|
109
|
-
To generate a spreadsheet, create an Xmlss::Workbook instance and build the workbook using the above DSL. Workbook takes
|
110
|
-
*
|
111
|
-
*
|
109
|
+
To generate a spreadsheet, create an Xmlss::Workbook instance and build the workbook using the above DSL. Workbook takes three parameters:
|
110
|
+
* Xmlss::Writer instance
|
111
|
+
* data hash: (optional) key value data to bind to the workbook scope
|
112
|
+
* build block: (optional) block containing DSL directives
|
112
113
|
|
113
|
-
===
|
114
|
+
=== Writer (Undies)
|
114
115
|
|
115
|
-
Xmlss
|
116
|
+
The Xmlss::Writer uses Undies (https://github.com/kellyredding/undies) to write the XML output. The writer takes Undies::IO options. See the Undies README for usage details.
|
116
117
|
|
117
|
-
Xmlss::Workbook.new(Xmlss::Writer.new
|
118
|
-
worksheet(
|
118
|
+
Xmlss::Workbook.new(Xmlss::Writer.new(:pp => 2)) do
|
119
|
+
worksheet('A cool sheet') {
|
119
120
|
...
|
120
121
|
}
|
121
122
|
end
|
122
123
|
|
123
|
-
===
|
124
|
+
=== Data hash
|
124
125
|
|
125
|
-
Xmlss
|
126
|
+
Xmlss evals the build proc in the scope of the workbook instance. This means that the build has access to only the data it is given or the DSL itself. Data is given in the form of a Hash. The string form of the hash keys are exposed as local workbook methods that return their corresponding values.
|
126
127
|
|
127
|
-
Xmlss::Workbook.new(Xmlss::Writer.new
|
128
|
+
Xmlss::Workbook.new(Xmlss::Writer.new, :sheet_name => 'A cool sheet') do
|
128
129
|
worksheet(sheet_name) {
|
129
130
|
...
|
130
131
|
}
|
@@ -155,7 +156,9 @@ Now just interact with the Workbook API directly.
|
|
155
156
|
|
156
157
|
== Disclaimer
|
157
158
|
|
158
|
-
Be aware this library only provides the basic, raw API for constructing spreadsheets using this spec and utilities to convert those objects to string xml data representing them. It does not provide any macro logic to aid in constructing the sheets. If you want a more convenient API for your use case, I suggest
|
159
|
+
Be aware this library only provides the basic, raw API for constructing spreadsheets using this spec and utilities to convert those objects to string xml data representing them. It does not provide any macro logic to aid in constructing the sheets. If you want a more convenient API for your use case, I suggest extending the objects and tailoring them to your needs.
|
160
|
+
|
161
|
+
You may also be interested in osheet-xmlss (https://github.com/kellyredding/osheet-xmlss). I wrote this to use the more convenient Osheet workbook syntax to generate Xmlss workbooks.
|
159
162
|
|
160
163
|
The XML Spreadsheet spec and format are legacy and may have limited support depending on your version of MS Excel. For a more modern spreadsheet generation method, I suggest looking into Office Open XML Workbook format (http://en.wikipedia.org/wiki/Office_Open_XML).
|
161
164
|
|
data/lib/xmlss/element/column.rb
CHANGED
@@ -20,5 +20,11 @@ module Xmlss::Element
|
|
20
20
|
@width = value && value < 0 ? nil : value
|
21
21
|
end
|
22
22
|
|
23
|
+
def autofit; self.auto_fit_width; end
|
24
|
+
def autofit=(value); self.auto_fit_width = value; end
|
25
|
+
|
26
|
+
def autofit?; !!self.autofit; end
|
27
|
+
def hidden?; !!self.hidden; end
|
28
|
+
|
23
29
|
end
|
24
30
|
end
|
data/lib/xmlss/element/row.rb
CHANGED
@@ -20,5 +20,11 @@ module Xmlss::Element
|
|
20
20
|
@height = value && value < 0 ? nil : value
|
21
21
|
end
|
22
22
|
|
23
|
+
def autofit; self.auto_fit_height; end
|
24
|
+
def autofit=(value); self.auto_fit_height = value; end
|
25
|
+
|
26
|
+
def autofit?; !!self.autofit; end
|
27
|
+
def hidden?; !!self.hidden; end
|
28
|
+
|
23
29
|
end
|
24
30
|
end
|
data/lib/xmlss/version.rb
CHANGED
data/lib/xmlss/workbook.rb
CHANGED
@@ -101,63 +101,65 @@ module Xmlss
|
|
101
101
|
|
102
102
|
# Workbook element attributes API
|
103
103
|
|
104
|
-
def
|
105
|
-
|
106
|
-
if (c = self.class.worksheets_stack(self).current)
|
107
|
-
c.style_id = value
|
108
|
-
end
|
104
|
+
def merge_across(value) # cell
|
105
|
+
self.class.worksheets_stack(self).current.merge_across = value
|
109
106
|
end
|
110
107
|
|
111
|
-
def
|
112
|
-
self.class.worksheets_stack(self).current.
|
108
|
+
def merge_down(value) # cell
|
109
|
+
self.class.worksheets_stack(self).current.merge_down = value
|
113
110
|
end
|
114
111
|
|
115
|
-
def
|
116
|
-
self.class.worksheets_stack(self).current.
|
112
|
+
def name(value) # worksheet
|
113
|
+
self.class.worksheets_stack(self).current.name = value
|
117
114
|
end
|
118
115
|
|
119
|
-
def
|
120
|
-
|
116
|
+
def style_id(value) # cell, row, column
|
117
|
+
# check to make sure there is a current on this one
|
118
|
+
if (c = self.class.worksheets_stack(self).current)
|
119
|
+
c.style_id = value
|
120
|
+
end
|
121
121
|
end
|
122
122
|
|
123
|
-
def
|
124
|
-
self.class.worksheets_stack(self).current.
|
123
|
+
def width(value) # column
|
124
|
+
self.class.worksheets_stack(self).current.width = value
|
125
125
|
end
|
126
126
|
|
127
|
-
def
|
128
|
-
self.class.worksheets_stack(self).current.
|
127
|
+
def height(value) # row
|
128
|
+
self.class.worksheets_stack(self).current.height = value
|
129
129
|
end
|
130
130
|
|
131
|
-
def
|
132
|
-
self.class.worksheets_stack(self).current.
|
131
|
+
def autofit(value) # column, row
|
132
|
+
self.class.worksheets_stack(self).current.autofit = value
|
133
133
|
end
|
134
|
+
alias_method :auto_fit_width, :autofit
|
135
|
+
alias_method :auto_fit_height, :autofit
|
134
136
|
|
135
|
-
def
|
136
|
-
self.class.worksheets_stack(self).current.
|
137
|
+
def autofit?
|
138
|
+
self.class.worksheets_stack(self).current.autofit?
|
137
139
|
end
|
138
140
|
|
139
|
-
def
|
140
|
-
self.class.worksheets_stack(self).current.
|
141
|
+
def hidden(value) # row, column
|
142
|
+
self.class.worksheets_stack(self).current.hidden = value
|
141
143
|
end
|
142
144
|
|
143
|
-
def
|
144
|
-
self.class.worksheets_stack(self).current.
|
145
|
+
def hidden?
|
146
|
+
self.class.worksheets_stack(self).current.hidden?
|
145
147
|
end
|
146
148
|
|
147
|
-
def
|
148
|
-
self.class.worksheets_stack(self).current.
|
149
|
+
def data(value) # cell
|
150
|
+
self.class.worksheets_stack(self).current.data = value
|
149
151
|
end
|
150
152
|
|
151
|
-
def
|
152
|
-
self.class.worksheets_stack(self).current.
|
153
|
+
def href(value) # cell
|
154
|
+
self.class.worksheets_stack(self).current.href = value
|
153
155
|
end
|
154
156
|
|
155
|
-
def
|
156
|
-
self.class.worksheets_stack(self).current.
|
157
|
+
def formula(value) # cell
|
158
|
+
self.class.worksheets_stack(self).current.formula = value
|
157
159
|
end
|
158
160
|
|
159
|
-
def
|
160
|
-
self.class.worksheets_stack(self).current.
|
161
|
+
def index(value) # cell
|
162
|
+
self.class.worksheets_stack(self).current.index = value
|
161
163
|
end
|
162
164
|
|
163
165
|
# overriding to make less noisy
|
data/test/element/column_test.rb
CHANGED
@@ -10,7 +10,8 @@ module Xmlss::Element
|
|
10
10
|
|
11
11
|
should be_styled
|
12
12
|
should have_class_method :writer
|
13
|
-
should
|
13
|
+
should have_accessors :width, :auto_fit_width, :autofit, :hidden
|
14
|
+
should have_readers :autofit?, :hidden?
|
14
15
|
|
15
16
|
should "know its writer hook" do
|
16
17
|
assert_equal :column, subject.class.writer
|
data/test/element/row_test.rb
CHANGED
@@ -10,7 +10,9 @@ module Xmlss::Element
|
|
10
10
|
|
11
11
|
should be_styled
|
12
12
|
should have_class_method :writer
|
13
|
-
should have_accessors :height, :auto_fit_height, :hidden
|
13
|
+
should have_accessors :height, :auto_fit_height, :autofit, :hidden
|
14
|
+
should have_readers :autofit?, :hidden?
|
15
|
+
|
14
16
|
|
15
17
|
should "know its writer hook" do
|
16
18
|
assert_equal :row, subject.class.writer
|
data/test/workbook_test.rb
CHANGED
@@ -16,11 +16,11 @@ module Xmlss::Worbook
|
|
16
16
|
|
17
17
|
should have_instance_methods :worksheet, :column, :row, :cell
|
18
18
|
|
19
|
-
should have_instance_methods :data, :
|
20
|
-
should have_instance_methods :
|
21
|
-
should have_instance_methods :
|
22
|
-
should have_instance_methods :
|
23
|
-
should have_instance_methods :
|
19
|
+
should have_instance_methods :data, :index, :style_id, :formula, :href, :name
|
20
|
+
should have_instance_methods :merge_across, :merge_down, :height, :width
|
21
|
+
should have_instance_methods :hidden, :hidden?
|
22
|
+
should have_instance_methods :autofit, :autofit?
|
23
|
+
should have_instance_methods :auto_fit_height, :auto_fit_width
|
24
24
|
|
25
25
|
should "return element objs when calling its element methods" do
|
26
26
|
assert_kind_of Xmlss::Element::Worksheet, subject.worksheet('test')
|
data/xmlss.gemspec
CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_development_dependency("assert", ["~> 0.7.3"])
|
21
21
|
s.add_development_dependency("assert-view", ["~> 0.6"])
|
22
|
-
s.add_dependency("undies", ["~> 3.0.0.rc.
|
22
|
+
s.add_dependency("undies", ["~> 3.0.0.rc.3"])
|
23
23
|
s.add_dependency("enumeration", ["~> 1.3"])
|
24
24
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmlss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424061
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 1.0.0.rc.
|
11
|
+
- 4
|
12
|
+
version: 1.0.0.rc.4
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Kelly Redding
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-
|
20
|
+
date: 2012-05-07 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
type: :development
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - ~>
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
60
|
+
hash: 15424115
|
61
61
|
segments:
|
62
62
|
- 3
|
63
63
|
- 0
|
64
64
|
- 0
|
65
65
|
- rc
|
66
|
-
-
|
67
|
-
version: 3.0.0.rc.
|
66
|
+
- 3
|
67
|
+
version: 3.0.0.rc.3
|
68
68
|
name: undies
|
69
69
|
version_requirements: *id003
|
70
70
|
prerelease: false
|