xmlss 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +12 -11
- data/README.rdoc +141 -107
- data/Rakefile +24 -1
- data/bench/profiler.rb +6 -0
- data/bench/profiler_runner.rb +43 -0
- data/examples/example_workbook.rb +8 -12
- data/examples/layout.rb +34 -60
- data/examples/layout.xml +66 -0
- data/examples/simple.rb +16 -21
- data/examples/simple.xml +32 -0
- data/examples/styles.rb +52 -56
- data/examples/styles.xml +50 -0
- data/examples/text.rb +18 -28
- data/examples/text.xml +20 -0
- data/lib/xmlss/{cell.rb → element/cell.rb} +4 -14
- data/lib/xmlss/{column.rb → element/column.rb} +2 -7
- data/lib/xmlss/{data.rb → element/data.rb} +7 -12
- data/lib/xmlss/{row.rb → element/row.rb} +2 -13
- data/lib/xmlss/{worksheet.rb → element/worksheet.rb} +7 -18
- data/lib/xmlss/style/alignment.rb +3 -10
- data/lib/xmlss/style/base.rb +6 -45
- data/lib/xmlss/style/border.rb +5 -5
- data/lib/xmlss/style/font.rb +2 -9
- data/lib/xmlss/style/interior.rb +2 -5
- data/lib/xmlss/style/number_format.rb +4 -7
- data/lib/xmlss/style/protection.rb +4 -7
- data/lib/xmlss/undies_writer.rb +172 -0
- data/lib/xmlss/version.rb +1 -1
- data/lib/xmlss/workbook.rb +97 -31
- data/lib/xmlss.rb +1 -28
- data/test/{cell_test.rb → element/cell_test.rb} +11 -35
- data/test/{column_test.rb → element/column_test.rb} +6 -12
- data/test/{data_test.rb → element/data_test.rb} +15 -10
- data/test/{row_test.rb → element/row_test.rb} +5 -35
- data/test/{worksheet_test.rb → element/worksheet_test.rb} +4 -30
- data/test/helper.rb +13 -30
- data/test/style/alignment_test.rb +13 -45
- data/test/style/base_test.rb +1 -106
- data/test/style/border_test.rb +12 -32
- data/test/style/font_test.rb +11 -43
- data/test/style/interior_test.rb +7 -27
- data/test/style/number_format_test.rb +5 -21
- data/test/style/protection_test.rb +2 -12
- data/test/undies_writer_test.rb +333 -0
- data/test/workbook_test.rb +89 -44
- data/xmlss.gemspec +2 -2
- metadata +37 -39
- data/lib/xmlss/item_set.rb +0 -17
- data/lib/xmlss/table.rb +0 -22
- data/lib/xmlss/xml.rb +0 -60
- data/test/item_set_test.rb +0 -27
- data/test/table_test.rb +0 -56
- data/test/xml_test.rb +0 -81
- data/test/xmlss_test.rb +0 -31
@@ -0,0 +1,333 @@
|
|
1
|
+
require 'assert'
|
2
|
+
|
3
|
+
require 'xmlss/undies_writer'
|
4
|
+
require 'xmlss/workbook'
|
5
|
+
|
6
|
+
class Xmlss::UndiesWriter
|
7
|
+
|
8
|
+
class BasicTests < Assert::Context
|
9
|
+
desc "UndiesWriter"
|
10
|
+
setup do
|
11
|
+
@w = Xmlss::UndiesWriter.new
|
12
|
+
end
|
13
|
+
subject { @w }
|
14
|
+
|
15
|
+
should have_class_methods :attributes, :classify, :coerce
|
16
|
+
should have_readers :style_markup, :element_markup
|
17
|
+
should have_instance_method :flush, :workbook
|
18
|
+
should have_instance_methods :style, :alignment, :borders, :border
|
19
|
+
should have_instance_methods :font, :interior, :number_format, :protection
|
20
|
+
should have_instance_methods :worksheet, :column, :row, :data
|
21
|
+
|
22
|
+
should "return itself when flushed" do
|
23
|
+
assert_equal subject, subject.flush
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
class HelpersTests < BasicTests
|
29
|
+
|
30
|
+
should "coerce certain values for xml output" do
|
31
|
+
assert_equal 1, Xmlss::UndiesWriter.coerce(true)
|
32
|
+
assert_nil Xmlss::UndiesWriter.coerce(false)
|
33
|
+
assert_nil Xmlss::UndiesWriter.coerce("")
|
34
|
+
assert_equal "hi", Xmlss::UndiesWriter.coerce("hi")
|
35
|
+
assert_equal 1, Xmlss::UndiesWriter.coerce(1)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "classify underscored string" do
|
39
|
+
assert_equal "Hi", Xmlss::UndiesWriter.classify("Hi")
|
40
|
+
assert_equal "Hi", Xmlss::UndiesWriter.classify("hi")
|
41
|
+
assert_equal "Hithere", Xmlss::UndiesWriter.classify("HiThere")
|
42
|
+
assert_equal "Hithere", Xmlss::UndiesWriter.classify("hithere")
|
43
|
+
assert_equal "HiThere", Xmlss::UndiesWriter.classify("Hi_There")
|
44
|
+
assert_equal "HiThere", Xmlss::UndiesWriter.classify("Hi_there")
|
45
|
+
assert_equal "HiThere", Xmlss::UndiesWriter.classify("hi_there")
|
46
|
+
end
|
47
|
+
|
48
|
+
should "convert a list of attributes for xml output" do
|
49
|
+
class Thing
|
50
|
+
def keys; [:thing, :other, 'some', 'hi', :hi_there]; end
|
51
|
+
|
52
|
+
def thing; true; end
|
53
|
+
def other; false; end
|
54
|
+
def some; ""; end
|
55
|
+
def hi; :there; end
|
56
|
+
def hi_there; "you"; end
|
57
|
+
end
|
58
|
+
thing = Thing.new
|
59
|
+
exp = {
|
60
|
+
"ss:Hi" => "there",
|
61
|
+
"ss:HiThere" => "you",
|
62
|
+
"ss:Thing" => "1"
|
63
|
+
}
|
64
|
+
|
65
|
+
assert_equal exp, Xmlss::UndiesWriter.attributes(thing, thing.keys)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
class StyleWritingTests < BasicTests
|
71
|
+
desc "writing style markup"
|
72
|
+
|
73
|
+
should "write alignment markup" do
|
74
|
+
subject.alignment(Xmlss::Style::Alignment.new({
|
75
|
+
:wrap_text => true,
|
76
|
+
:horizontal => :center,
|
77
|
+
:vertical => :bottom,
|
78
|
+
:rotate => 90
|
79
|
+
}))
|
80
|
+
subject.flush
|
81
|
+
|
82
|
+
assert_equal(
|
83
|
+
"<Alignment ss:Horizontal=\"Center\" ss:Rotate=\"90\" ss:Vertical=\"Bottom\" ss:WrapText=\"1\" />",
|
84
|
+
subject.style_markup
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
should "write border markup" do
|
89
|
+
subject.border(Xmlss::Style::Border.new({
|
90
|
+
:color => '#FF0000',
|
91
|
+
:position => :top,
|
92
|
+
:weight => :thick,
|
93
|
+
:line_style => :dot
|
94
|
+
}))
|
95
|
+
subject.flush
|
96
|
+
|
97
|
+
assert_equal(
|
98
|
+
"<Border ss:Color=\"#FF0000\" ss:LineStyle=\"Dot\" ss:Position=\"Top\" ss:Weight=\"3\" />",
|
99
|
+
subject.style_markup
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
should "write border collection markup" do
|
104
|
+
subject.borders {
|
105
|
+
subject.border(Xmlss::Style::Border.new({
|
106
|
+
:color => '#FF0000',
|
107
|
+
:position => :top
|
108
|
+
}))
|
109
|
+
subject.border(Xmlss::Style::Border.new({
|
110
|
+
:position => :left
|
111
|
+
}))
|
112
|
+
}
|
113
|
+
subject.flush
|
114
|
+
|
115
|
+
assert_equal(
|
116
|
+
"<Borders><Border ss:Color=\"#FF0000\" ss:LineStyle=\"Continuous\" ss:Position=\"Top\" ss:Weight=\"1\" /><Border ss:LineStyle=\"Continuous\" ss:Position=\"Left\" ss:Weight=\"1\" /></Borders>",
|
117
|
+
subject.style_markup
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
121
|
+
should "write font markup" do
|
122
|
+
subject.font(Xmlss::Style::Font.new({
|
123
|
+
:bold => true,
|
124
|
+
:color => '#FF0000',
|
125
|
+
:italic => true,
|
126
|
+
:size => 10,
|
127
|
+
:strike_through => true,
|
128
|
+
:underline => :single,
|
129
|
+
:alignment => :superscript,
|
130
|
+
:name => 'Verdana'
|
131
|
+
}))
|
132
|
+
subject.flush
|
133
|
+
|
134
|
+
assert_equal(
|
135
|
+
"<Font ss:Bold=\"1\" ss:Color=\"#FF0000\" ss:FontName=\"Verdana\" ss:Italic=\"1\" ss:Size=\"10\" ss:StrikeThrough=\"1\" ss:Underline=\"Single\" ss:VerticalAlign=\"Superscript\" />",
|
136
|
+
subject.style_markup
|
137
|
+
)
|
138
|
+
end
|
139
|
+
|
140
|
+
should "write interior markup" do
|
141
|
+
subject.interior(Xmlss::Style::Interior.new({
|
142
|
+
:color => "#000000",
|
143
|
+
:pattern => :solid,
|
144
|
+
:pattern_color => "#FF0000"
|
145
|
+
}))
|
146
|
+
subject.flush
|
147
|
+
|
148
|
+
assert_equal(
|
149
|
+
"<Interior ss:Color=\"#000000\" ss:Pattern=\"Solid\" ss:PatternColor=\"#FF0000\" />",
|
150
|
+
subject.style_markup
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
should "write number format markup" do
|
155
|
+
subject.number_format(Xmlss::Style::NumberFormat.new("General"))
|
156
|
+
subject.flush
|
157
|
+
|
158
|
+
assert_equal(
|
159
|
+
"<NumberFormat ss:Format=\"General\" />",
|
160
|
+
subject.style_markup
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
164
|
+
should "write protection markup" do
|
165
|
+
subject.protection(Xmlss::Style::Protection.new(true))
|
166
|
+
subject.flush
|
167
|
+
|
168
|
+
assert_equal(
|
169
|
+
"<Protection ss:Protect=\"1\" />",
|
170
|
+
subject.style_markup
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
should "write full style markup" do
|
175
|
+
subject.style(Xmlss::Style::Base.new(:write_markup_test)) {
|
176
|
+
subject.alignment(Xmlss::Style::Alignment.new({
|
177
|
+
:horizontal => :left,
|
178
|
+
:vertical => :center,
|
179
|
+
:wrap_text => true
|
180
|
+
}))
|
181
|
+
subject.borders {
|
182
|
+
subject.border(Xmlss::Style::Border.new({:position => :left}))
|
183
|
+
subject.border(Xmlss::Style::Border.new({:position => :right}))
|
184
|
+
}
|
185
|
+
subject.font(Xmlss::Style::Font.new({:bold => true}))
|
186
|
+
subject.interior(Xmlss::Style::Interior.new({:color => "#000000"}))
|
187
|
+
subject.number_format(Xmlss::Style::NumberFormat.new("General"))
|
188
|
+
subject.protection(Xmlss::Style::Protection.new(true))
|
189
|
+
}
|
190
|
+
subject.flush
|
191
|
+
|
192
|
+
assert_equal(
|
193
|
+
"<Style ss:ID=\"write_markup_test\"><Alignment ss:Horizontal=\"Left\" ss:Vertical=\"Center\" ss:WrapText=\"1\" /><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Left\" ss:Weight=\"1\" /><Border ss:LineStyle=\"Continuous\" ss:Position=\"Right\" ss:Weight=\"1\" /></Borders><Font ss:Bold=\"1\" /><Interior ss:Color=\"#000000\" /><NumberFormat ss:Format=\"General\" /><Protection ss:Protect=\"1\" /></Style>",
|
194
|
+
subject.style_markup
|
195
|
+
)
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
class WorksheetWritingTests < BasicTests
|
202
|
+
desc "writing worksheet markup"
|
203
|
+
|
204
|
+
should "write data markup" do
|
205
|
+
subject.data(Xmlss::Element::Data.new("some data"))
|
206
|
+
subject.flush
|
207
|
+
|
208
|
+
assert_equal(
|
209
|
+
"<Data ss:Type=\"String\">some data</Data>",
|
210
|
+
subject.element_markup
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
should "write data markup w/ line breaks" do
|
215
|
+
subject.data(Xmlss::Element::Data.new(%s{
|
216
|
+
Hello World
|
217
|
+
}, :type => :string))
|
218
|
+
subject.flush
|
219
|
+
|
220
|
+
assert_equal(
|
221
|
+
"<Data ss:Type=\"String\"> Hello World </Data>",
|
222
|
+
subject.element_markup
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
226
|
+
should "write cell markup" do
|
227
|
+
subject.cell(Xmlss::Element::Cell.new({:index => 2})) {
|
228
|
+
subject.data(Xmlss::Element::Data.new("some data"))
|
229
|
+
}
|
230
|
+
subject.flush
|
231
|
+
|
232
|
+
assert_equal(
|
233
|
+
"<Cell ss:Index=\"2\"><Data ss:Type=\"String\">some data</Data></Cell>",
|
234
|
+
subject.element_markup
|
235
|
+
)
|
236
|
+
end
|
237
|
+
|
238
|
+
should "write row markup" do
|
239
|
+
subject.row(Xmlss::Element::Row.new({:hidden => true})) {
|
240
|
+
subject.cell(Xmlss::Element::Cell.new({:index => 2})) {
|
241
|
+
subject.data(Xmlss::Element::Data.new("some data"))
|
242
|
+
}
|
243
|
+
}
|
244
|
+
subject.flush
|
245
|
+
|
246
|
+
assert_equal(
|
247
|
+
"<Row ss:Hidden=\"1\"><Cell ss:Index=\"2\"><Data ss:Type=\"String\">some data</Data></Cell></Row>",
|
248
|
+
subject.element_markup
|
249
|
+
)
|
250
|
+
end
|
251
|
+
|
252
|
+
should "write column markup" do
|
253
|
+
subject.column(Xmlss::Element::Column.new({:hidden => true}))
|
254
|
+
subject.flush
|
255
|
+
|
256
|
+
assert_equal(
|
257
|
+
"<Column ss:Hidden=\"1\" />",
|
258
|
+
subject.element_markup
|
259
|
+
)
|
260
|
+
end
|
261
|
+
|
262
|
+
should "write worksheet markup" do
|
263
|
+
subject.worksheet(Xmlss::Element::Worksheet.new('test')) {
|
264
|
+
subject.row(Xmlss::Element::Row.new({:hidden => true})) {
|
265
|
+
subject.cell(Xmlss::Element::Cell.new({:index => 2})) {
|
266
|
+
subject.data(Xmlss::Element::Data.new("some data"))
|
267
|
+
}
|
268
|
+
}
|
269
|
+
}
|
270
|
+
subject.flush
|
271
|
+
|
272
|
+
assert_equal(
|
273
|
+
"<Worksheet ss:Name=\"test\"><Table><Row ss:Hidden=\"1\"><Cell ss:Index=\"2\"><Data ss:Type=\"String\">some data</Data></Cell></Row></Table></Worksheet>",
|
274
|
+
subject.element_markup
|
275
|
+
)
|
276
|
+
end
|
277
|
+
|
278
|
+
should "return workbook markup" do
|
279
|
+
subject.style(Xmlss::Style::Base.new(:some_font)) {
|
280
|
+
subject.font(Xmlss::Style::Font.new({:bold => true}))
|
281
|
+
}
|
282
|
+
|
283
|
+
subject.style(Xmlss::Style::Base.new(:some_numformat)) {
|
284
|
+
subject.number_format(Xmlss::Style::NumberFormat.new("General"))
|
285
|
+
}
|
286
|
+
|
287
|
+
subject.worksheet(Xmlss::Element::Worksheet.new('test')) {
|
288
|
+
subject.row(Xmlss::Element::Row.new({:hidden => true})) {
|
289
|
+
subject.cell(Xmlss::Element::Cell.new({:index => 2})) {
|
290
|
+
subject.data(Xmlss::Element::Data.new("some data"))
|
291
|
+
}
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
subject.flush
|
296
|
+
|
297
|
+
assert_equal(
|
298
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"><Styles><Style ss:ID=\"some_font\"><Font ss:Bold=\"1\" /></Style><Style ss:ID=\"some_numformat\"><NumberFormat ss:Format=\"General\" /></Style></Styles><Worksheet ss:Name=\"test\"><Table><Row ss:Hidden=\"1\"><Cell ss:Index=\"2\"><Data ss:Type=\"String\">some data</Data></Cell></Row></Table></Worksheet></Workbook>",
|
299
|
+
subject.workbook
|
300
|
+
)
|
301
|
+
end
|
302
|
+
|
303
|
+
should "return pretty workbook markup" do
|
304
|
+
writer = Xmlss::UndiesWriter.new(:pp => 2)
|
305
|
+
writer.style(Xmlss::Style::Base.new(:some_font)) {
|
306
|
+
writer.font(Xmlss::Style::Font.new({:bold => true}))
|
307
|
+
}
|
308
|
+
|
309
|
+
writer.style(Xmlss::Style::Base.new(:some_numformat)) {
|
310
|
+
writer.number_format(Xmlss::Style::NumberFormat.new("General"))
|
311
|
+
}
|
312
|
+
|
313
|
+
writer.worksheet(Xmlss::Element::Worksheet.new('test')) {
|
314
|
+
writer.row(Xmlss::Element::Row.new({:hidden => true})) {
|
315
|
+
writer.cell(Xmlss::Element::Cell.new({:index => 2})) {
|
316
|
+
writer.data(Xmlss::Element::Data.new("some data"))
|
317
|
+
}
|
318
|
+
}
|
319
|
+
}
|
320
|
+
|
321
|
+
writer.flush
|
322
|
+
|
323
|
+
assert_equal(
|
324
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\">\n <Styles>\n <Style ss:ID=\"some_font\">\n <Font ss:Bold=\"1\" />\n </Style>\n <Style ss:ID=\"some_numformat\">\n <NumberFormat ss:Format=\"General\" />\n </Style>\n </Styles>\n <Worksheet ss:Name=\"test\">\n <Table>\n <Row ss:Hidden=\"1\">\n <Cell ss:Index=\"2\">\n <Data ss:Type=\"String\">some data</Data>\n </Cell>\n </Row>\n </Table>\n </Worksheet>\n</Workbook>",
|
325
|
+
writer.workbook
|
326
|
+
)
|
327
|
+
end
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|
data/test/workbook_test.rb
CHANGED
@@ -1,66 +1,111 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'xmlss/workbook'
|
3
3
|
|
4
|
-
module Xmlss
|
5
|
-
|
4
|
+
module Xmlss::Worbook
|
5
|
+
|
6
|
+
class BasicTests < Assert::Context
|
6
7
|
desc "Xmlss::Workbook"
|
7
|
-
before { @wkbk = Workbook.new }
|
8
|
+
before { @wkbk = Xmlss::Workbook.new }
|
8
9
|
subject { @wkbk }
|
9
10
|
|
10
|
-
should
|
11
|
-
should
|
11
|
+
should have_instance_methods :to_s, :to_file
|
12
|
+
should have_instance_methods :worksheet, :column, :row, :cell, :data
|
13
|
+
should have_instance_methods :style, :alignment, :borders, :border
|
14
|
+
should have_instance_methods :font, :interior, :number_format, :protection
|
12
15
|
|
13
|
-
should "
|
14
|
-
|
15
|
-
|
16
|
+
should "return element objs when calling its element methods" do
|
17
|
+
assert_kind_of Xmlss::Element::Worksheet, subject.worksheet('test')
|
18
|
+
assert_kind_of Xmlss::Element::Column, subject.column
|
19
|
+
assert_kind_of Xmlss::Element::Row, subject.row
|
20
|
+
assert_kind_of Xmlss::Element::Cell, subject.cell
|
21
|
+
assert_kind_of Xmlss::Element::Data, subject.data('test')
|
16
22
|
end
|
17
23
|
|
18
|
-
|
24
|
+
should "return style objs when calling its style methods" do
|
25
|
+
assert_kind_of Xmlss::Style::Base, subject.style('test')
|
26
|
+
assert_kind_of Xmlss::Style::Alignment, subject.alignment
|
27
|
+
assert_kind_of Xmlss::Style::Border, subject.border
|
28
|
+
assert_kind_of Xmlss::Style::Font, subject.font
|
29
|
+
assert_kind_of Xmlss::Style::Interior, subject.interior
|
30
|
+
assert_kind_of Xmlss::Style::NumberFormat, subject.number_format
|
31
|
+
assert_kind_of Xmlss::Style::Protection, subject.protection
|
32
|
+
end
|
19
33
|
|
20
|
-
|
21
|
-
|
22
|
-
subject { @wkbk }
|
23
|
-
before do
|
24
|
-
# specifying attrs at init time
|
25
|
-
@wkbk = Workbook.new({
|
26
|
-
:worksheets => [Worksheet.new('sheet1')]
|
27
|
-
})
|
28
|
-
|
29
|
-
# writing attrs at run time
|
30
|
-
@wkbk.styles = [
|
31
|
-
Xmlss::Style::Base.new('title') do
|
32
|
-
alignment({:horizontal => :left})
|
33
|
-
font({:size => 14, :bold => true})
|
34
|
-
end,
|
35
|
-
|
36
|
-
Xmlss::Style::Base.new('header') do
|
37
|
-
alignment({:horizontal => :left})
|
38
|
-
font({:bold => true})
|
39
|
-
[:top, :right, :bottom, :left].each do |p|
|
40
|
-
border({:position => :p})
|
41
|
-
end
|
42
|
-
end
|
43
|
-
]
|
34
|
+
should "return workbook markup string" do
|
35
|
+
assert_match /<Workbook /, subject.to_s
|
44
36
|
end
|
45
37
|
|
46
|
-
should "
|
47
|
-
|
48
|
-
|
38
|
+
should "write workbook markup to a file path" do
|
39
|
+
path = nil
|
40
|
+
assert_nothing_raised do
|
41
|
+
path = subject.to_file("./tmp/workbook_test.xls")
|
49
42
|
end
|
50
|
-
assert_kind_of
|
51
|
-
assert_equal
|
43
|
+
assert_kind_of ::String, path
|
44
|
+
assert_equal './tmp/workbook_test.xls', path
|
45
|
+
assert File.exists?(path)
|
46
|
+
end
|
52
47
|
|
53
|
-
|
54
|
-
|
48
|
+
should "maintain the workbook's scope throughout content blocks" do
|
49
|
+
wkbk = Xmlss::Workbook.new do
|
50
|
+
style('test') {
|
51
|
+
alignment
|
52
|
+
borders {
|
53
|
+
border
|
54
|
+
}
|
55
|
+
font
|
56
|
+
interior
|
57
|
+
number_format
|
58
|
+
protection
|
59
|
+
}
|
60
|
+
worksheet('test') {
|
61
|
+
column
|
62
|
+
|
63
|
+
row {
|
64
|
+
cell { data self.object_id }
|
65
|
+
}
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
assert_equal(
|
70
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"><Styles><Style ss:ID=\"test\"><Alignment /><Borders><Border ss:LineStyle=\"Continuous\" ss:Weight=\"1\" /></Borders><Font /><Interior /><NumberFormat /><Protection /></Style></Styles><Worksheet ss:Name=\"test\"><Table><Column /><Row><Cell><Data ss:Type=\"Number\">#{wkbk.object_id}</Data></Cell></Row></Table></Worksheet></Workbook>",
|
71
|
+
wkbk.to_s
|
72
|
+
)
|
55
73
|
end
|
56
74
|
|
57
75
|
end
|
58
76
|
|
59
|
-
class
|
60
|
-
|
77
|
+
class DataTests < BasicTests
|
78
|
+
|
79
|
+
should "bork if non hash-like data is provided" do
|
80
|
+
assert_raises NoMethodError do
|
81
|
+
Xmlss::Workbook.new(:data => "some data")
|
82
|
+
end
|
83
|
+
assert_respond_to(
|
84
|
+
:some,
|
85
|
+
Xmlss::Workbook.new(:data => {:some => 'data'})
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
89
|
+
should "complain if trying to set data that conflict with public methods" do
|
90
|
+
assert_raises ArgumentError do
|
91
|
+
Xmlss::Workbook.new(:data => {:worksheet => "yay!"})
|
92
|
+
end
|
93
|
+
end
|
61
94
|
|
62
|
-
should
|
63
|
-
|
95
|
+
should "respond to each data key with its value" do
|
96
|
+
wkbk = Xmlss::Workbook.new(:data => {:some => 'data'})
|
97
|
+
assert_equal "data", wkbk.some
|
98
|
+
end
|
99
|
+
|
100
|
+
should "be able to access its data in the workbook definition" do
|
101
|
+
wkbk = Xmlss::Workbook.new(:data => {:name => "awesome"}) do
|
102
|
+
worksheet name
|
103
|
+
end
|
104
|
+
assert_equal(
|
105
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"><Styles></Styles><Worksheet ss:Name=\"awesome\"><Table /></Worksheet></Workbook>",
|
106
|
+
wkbk.to_s
|
107
|
+
)
|
108
|
+
end
|
64
109
|
|
65
110
|
end
|
66
111
|
|
data/xmlss.gemspec
CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_development_dependency("bundler", ["~> 1.0"])
|
21
21
|
s.add_development_dependency("assert", ["~> 0.6"])
|
22
|
-
s.add_dependency("
|
23
|
-
s.add_dependency("enumeration", ["~> 1.
|
22
|
+
s.add_dependency("undies", ["~> 2.1"])
|
23
|
+
s.add_dependency("enumeration", ["~> 1.3"])
|
24
24
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmlss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kelly Redding
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :development
|
@@ -55,13 +55,13 @@ dependencies:
|
|
55
55
|
requirements:
|
56
56
|
- - ~>
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
58
|
+
hash: 1
|
59
59
|
segments:
|
60
|
+
- 2
|
60
61
|
- 1
|
61
|
-
|
62
|
-
version: "1.4"
|
62
|
+
version: "2.1"
|
63
63
|
version_requirements: *id003
|
64
|
-
name:
|
64
|
+
name: undies
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
@@ -70,11 +70,11 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ~>
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
73
|
+
hash: 9
|
74
74
|
segments:
|
75
75
|
- 1
|
76
|
-
-
|
77
|
-
version: "1.
|
76
|
+
- 3
|
77
|
+
version: "1.3"
|
78
78
|
version_requirements: *id004
|
79
79
|
name: enumeration
|
80
80
|
description: This gem provides an api for constructing spreadsheet data and then uses that data to generate xml that can be interpreted by MS Excel. The xml conforms to the XML Spreadsheet spec (http://msdn.microsoft.com/en-us/library/aa140066(office.10).aspx).
|
@@ -92,17 +92,23 @@ files:
|
|
92
92
|
- Gemfile.lock
|
93
93
|
- README.rdoc
|
94
94
|
- Rakefile
|
95
|
+
- bench/profiler.rb
|
96
|
+
- bench/profiler_runner.rb
|
95
97
|
- examples/example_workbook.rb
|
96
98
|
- examples/layout.rb
|
99
|
+
- examples/layout.xml
|
97
100
|
- examples/simple.rb
|
101
|
+
- examples/simple.xml
|
98
102
|
- examples/styles.rb
|
103
|
+
- examples/styles.xml
|
99
104
|
- examples/text.rb
|
105
|
+
- examples/text.xml
|
100
106
|
- lib/xmlss.rb
|
101
|
-
- lib/xmlss/cell.rb
|
102
|
-
- lib/xmlss/column.rb
|
103
|
-
- lib/xmlss/data.rb
|
104
|
-
- lib/xmlss/
|
105
|
-
- lib/xmlss/
|
107
|
+
- lib/xmlss/element/cell.rb
|
108
|
+
- lib/xmlss/element/column.rb
|
109
|
+
- lib/xmlss/element/data.rb
|
110
|
+
- lib/xmlss/element/row.rb
|
111
|
+
- lib/xmlss/element/worksheet.rb
|
106
112
|
- lib/xmlss/style/alignment.rb
|
107
113
|
- lib/xmlss/style/base.rb
|
108
114
|
- lib/xmlss/style/border.rb
|
@@ -110,18 +116,16 @@ files:
|
|
110
116
|
- lib/xmlss/style/interior.rb
|
111
117
|
- lib/xmlss/style/number_format.rb
|
112
118
|
- lib/xmlss/style/protection.rb
|
113
|
-
- lib/xmlss/
|
119
|
+
- lib/xmlss/undies_writer.rb
|
114
120
|
- lib/xmlss/version.rb
|
115
121
|
- lib/xmlss/workbook.rb
|
116
|
-
-
|
117
|
-
-
|
118
|
-
- test/
|
119
|
-
- test/
|
120
|
-
- test/
|
122
|
+
- test/element/cell_test.rb
|
123
|
+
- test/element/column_test.rb
|
124
|
+
- test/element/data_test.rb
|
125
|
+
- test/element/row_test.rb
|
126
|
+
- test/element/worksheet_test.rb
|
121
127
|
- test/helper.rb
|
122
128
|
- test/irb.rb
|
123
|
-
- test/item_set_test.rb
|
124
|
-
- test/row_test.rb
|
125
129
|
- test/style/alignment_test.rb
|
126
130
|
- test/style/base_test.rb
|
127
131
|
- test/style/border_test.rb
|
@@ -129,12 +133,9 @@ files:
|
|
129
133
|
- test/style/interior_test.rb
|
130
134
|
- test/style/number_format_test.rb
|
131
135
|
- test/style/protection_test.rb
|
132
|
-
- test/table_test.rb
|
133
136
|
- test/thing.rb
|
137
|
+
- test/undies_writer_test.rb
|
134
138
|
- test/workbook_test.rb
|
135
|
-
- test/worksheet_test.rb
|
136
|
-
- test/xml_test.rb
|
137
|
-
- test/xmlss_test.rb
|
138
139
|
- xmlss.gemspec
|
139
140
|
homepage: http://github.com/kelredd/xmlss
|
140
141
|
licenses: []
|
@@ -165,18 +166,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
166
|
requirements: []
|
166
167
|
|
167
168
|
rubyforge_project:
|
168
|
-
rubygems_version: 1.8.
|
169
|
+
rubygems_version: 1.8.11
|
169
170
|
signing_key:
|
170
171
|
specification_version: 3
|
171
172
|
summary: Generate spreadsheet docs for MS Excel using XML Spreedsheet
|
172
173
|
test_files:
|
173
|
-
- test/cell_test.rb
|
174
|
-
- test/column_test.rb
|
175
|
-
- test/data_test.rb
|
174
|
+
- test/element/cell_test.rb
|
175
|
+
- test/element/column_test.rb
|
176
|
+
- test/element/data_test.rb
|
177
|
+
- test/element/row_test.rb
|
178
|
+
- test/element/worksheet_test.rb
|
176
179
|
- test/helper.rb
|
177
180
|
- test/irb.rb
|
178
|
-
- test/item_set_test.rb
|
179
|
-
- test/row_test.rb
|
180
181
|
- test/style/alignment_test.rb
|
181
182
|
- test/style/base_test.rb
|
182
183
|
- test/style/border_test.rb
|
@@ -184,9 +185,6 @@ test_files:
|
|
184
185
|
- test/style/interior_test.rb
|
185
186
|
- test/style/number_format_test.rb
|
186
187
|
- test/style/protection_test.rb
|
187
|
-
- test/table_test.rb
|
188
188
|
- test/thing.rb
|
189
|
+
- test/undies_writer_test.rb
|
189
190
|
- test/workbook_test.rb
|
190
|
-
- test/worksheet_test.rb
|
191
|
-
- test/xml_test.rb
|
192
|
-
- test/xmlss_test.rb
|
data/lib/xmlss/item_set.rb
DELETED