osheet 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
- require "test/helper"
1
+ require "assert"
2
+
2
3
  require 'osheet/xmlss_writer'
3
4
 
4
5
  module Osheet
@@ -6,15 +7,16 @@ module Osheet
6
7
  class XmlssWriter::StylesTest < Assert::Context
7
8
  before do
8
9
  @writer = XmlssWriter::Base.new
10
+ @xworkbook = ::Xmlss::Workbook.new
9
11
  end
10
12
  subject { @writer }
11
13
 
12
14
  end
13
15
 
14
- class XmlssWriter::Style < XmlssWriter::StylesTest
16
+ class XmlssWriter::StyleTests < XmlssWriter::StylesTest
15
17
  desc "Xmlss style writer"
16
18
  before do
17
- subject.workbook = Workbook.new {
19
+ subject.oworkbook = Workbook.new {
18
20
  style('.font.size') { font 14 }
19
21
  style('.font.weight') { font :bold }
20
22
  style('.font.style') { font :italic }
@@ -31,39 +33,41 @@ module Osheet
31
33
  end
32
34
 
33
35
  should "not build a style obj when writing styles with no class str or format" do
34
- assert_equal nil, subject.send(:style, '')
36
+ assert_equal nil, subject.send(:style, @xworkbook, '')
35
37
  end
36
38
 
37
39
  should "build a style obj and add it to the writers styles" do
38
- xmlss_style = subject.send(:style, 'awesome')
40
+ xmlss_style = subject.send(:style, @xworkbook, 'awesome')
39
41
  assert_kind_of ::Xmlss::Style::Base, xmlss_style
40
42
  assert_equal '.awesome', xmlss_style.id
41
- assert_equal 1, subject.styles.size
42
- assert_equal xmlss_style, subject.styles.first
43
+ assert_equal 1, subject.used_xstyles.size
44
+ assert_equal xmlss_style, subject.used_xstyles.first
43
45
  end
44
46
 
45
- should "build a style obj from many matching osheet styles" do
46
- xmlss_style = subject.send(:style, 'font size weight style align center')
47
- assert_equal 14, xmlss_style.font.size
48
- assert_equal true, xmlss_style.font.bold?
49
- assert_equal true, xmlss_style.font.italic?
47
+ should "write style markup from many matching osheet styles" do
48
+ xmlss_style = subject.send(:style, @xworkbook, 'font size weight style align center')
49
+ assert_equal '.font.size.weight.style.align.center', xmlss_style.id
50
+
51
+ assert_equal(
52
+ "<Style ss:ID=\".font.size.weight.style.align.center\"><Alignment ss:Horizontal=\"Center\" /><Font ss:Bold=\"1\" ss:Italic=\"1\" ss:Size=\"14\" /><NumberFormat /></Style>",
53
+ xstyle_markup(@xworkbook)
54
+ )
50
55
  end
51
56
 
52
57
  should "provide style ids" do
53
- assert_equal '', subject.send(:style_id, '')
54
- assert_equal '.awesome', subject.send(:style_id, 'awesome')
55
- assert_equal '..number_none_0_nocomma_black', subject.send(:style_id, '', Osheet::Format.new(:number))
56
- assert_equal 2, subject.styles.size
58
+ assert_equal '', subject.send(:style_id, @xworkbook, '')
59
+ assert_equal '.awesome', subject.send(:style_id, @xworkbook, 'awesome')
60
+ assert_equal '..number_none_0_nocomma_black', subject.send(:style_id, @xworkbook, '', Osheet::Format.new(:number))
61
+ assert_equal 2, subject.used_xstyles.size
57
62
  end
58
63
 
59
64
  end
60
65
 
61
- class XmlssWriter::Alignment < XmlssWriter::StylesTest
66
+ class XmlssWriter::AlignmentTests < XmlssWriter::StylesTest
62
67
  desc "Alignment style writer"
63
68
  before do
64
- subject.workbook = Workbook.new {
65
- [
66
- :left, :center, :right,
69
+ subject.oworkbook = Workbook.new {
70
+ [ :left, :center, :right,
67
71
  :top, :middle, :bottom,
68
72
  :wrap
69
73
  ].each do |s|
@@ -73,36 +77,56 @@ module Osheet
73
77
  }
74
78
  end
75
79
 
76
- should "build a style obj with empty alignment settings by default" do
77
- assert_equal nil, subject.send(:style, 'align').alignment
80
+ should "write style markup with no alignment settings if no alignment style match" do
81
+ subject.send(:style, @xworkbook, 'align')
82
+ assert_equal(
83
+ "<Style ss:ID=\".align\"><NumberFormat /></Style>",
84
+ xstyle_markup(@xworkbook)
85
+ )
78
86
  end
79
87
 
80
- should "build style objs for horizontal alignment settings" do
81
- assert_equal ::Xmlss::Style::Alignment.horizontal(:left), subject.send(:style, 'align left').alignment.horizontal
82
- assert_equal ::Xmlss::Style::Alignment.horizontal(:center), subject.send(:style, 'align center').alignment.horizontal
83
- assert_equal ::Xmlss::Style::Alignment.horizontal(:right), subject.send(:style, 'align right').alignment.horizontal
88
+ should "write style markup for horizontal alignment settings" do
89
+ subject.send(:style, @xworkbook, 'align left')
90
+ subject.send(:style, @xworkbook, 'align center')
91
+ subject.send(:style, @xworkbook, 'align right')
92
+ assert_equal(
93
+ "<Style ss:ID=\".align.left\"><Alignment ss:Horizontal=\"Left\" /><NumberFormat /></Style><Style ss:ID=\".align.center\"><Alignment ss:Horizontal=\"Center\" /><NumberFormat /></Style><Style ss:ID=\".align.right\"><Alignment ss:Horizontal=\"Right\" /><NumberFormat /></Style>",
94
+ xstyle_markup(@xworkbook)
95
+ )
84
96
  end
85
97
 
86
- should "build style objs for vertical alignment settings" do
87
- assert_equal ::Xmlss::Style::Alignment.vertical(:top), subject.send(:style, 'align top').alignment.vertical
88
- assert_equal ::Xmlss::Style::Alignment.vertical(:center), subject.send(:style, 'align middle').alignment.vertical
89
- assert_equal ::Xmlss::Style::Alignment.vertical(:bottom), subject.send(:style, 'align bottom').alignment.vertical
98
+ should "write style markup for vertical alignment settings" do
99
+ subject.send(:style, @xworkbook, 'align top')
100
+ subject.send(:style, @xworkbook, 'align middle')
101
+ subject.send(:style, @xworkbook, 'align bottom')
102
+ assert_equal(
103
+ "<Style ss:ID=\".align.top\"><Alignment ss:Vertical=\"Top\" /><NumberFormat /></Style><Style ss:ID=\".align.middle\"><Alignment ss:Vertical=\"Center\" /><NumberFormat /></Style><Style ss:ID=\".align.bottom\"><Alignment ss:Vertical=\"Bottom\" /><NumberFormat /></Style>",
104
+ xstyle_markup(@xworkbook)
105
+ )
90
106
  end
91
107
 
92
- should "build style objs for text wrap settings" do
93
- assert_equal true, subject.send(:style, 'align wrap').alignment.wrap_text?
108
+ should "write style markup for text wrap settings" do
109
+ subject.send(:style, @xworkbook, 'align wrap')
110
+ assert_equal(
111
+ "<Style ss:ID=\".align.wrap\"><Alignment ss:WrapText=\"1\" /><NumberFormat /></Style>",
112
+ xstyle_markup(@xworkbook)
113
+ )
94
114
  end
95
115
 
96
- should "build style objs for text rotation settings" do
97
- assert_equal 90, subject.send(:style, 'align rotate').alignment.rotate
116
+ should "write style markup for text rotation settings" do
117
+ subject.send(:style, @xworkbook, 'align rotate')
118
+ assert_equal(
119
+ "<Style ss:ID=\".align.rotate\"><Alignment ss:Rotate=\"90\" /><NumberFormat /></Style>",
120
+ xstyle_markup(@xworkbook)
121
+ )
98
122
  end
99
123
 
100
124
  end
101
125
 
102
- class XmlssWriter::Font < XmlssWriter::StylesTest
126
+ class XmlssWriter::FontTests < XmlssWriter::StylesTest
103
127
  desc "Font style writer"
104
128
  before do
105
- subject.workbook = Workbook.new {
129
+ subject.oworkbook = Workbook.new {
106
130
  [ :underline, :double_underline, :accounting_underline, :double_accounting_underline,
107
131
  :subscript, :superscript, :shadow, :strikethrough, :wrap,
108
132
  :bold, :italic
@@ -115,47 +139,76 @@ module Osheet
115
139
  }
116
140
  end
117
141
 
118
- should "build a style obj with empty font settings by default" do
119
- assert_equal nil, subject.send(:style, 'font').font
142
+ should "write style markup with empty font settings if no match" do
143
+ subject.send(:style, @xworkbook, 'font')
144
+ assert_equal(
145
+ "<Style ss:ID=\".font\"><NumberFormat /></Style>",
146
+ xstyle_markup(@xworkbook)
147
+ )
120
148
  end
121
149
 
122
- should "build style objs for font underline settings" do
123
- assert_equal ::Xmlss::Style::Font.underline(:single), subject.send(:style, 'font underline').font.underline
124
- assert_equal ::Xmlss::Style::Font.underline(:double), subject.send(:style, 'font double_underline').font.underline
125
- assert_equal ::Xmlss::Style::Font.underline(:single_accounting), subject.send(:style, 'font accounting_underline').font.underline
126
- assert_equal ::Xmlss::Style::Font.underline(:double_accounting), subject.send(:style, 'font double_accounting_underline').font.underline
150
+ should "write style markup for font underline settings" do
151
+ subject.send(:style, @xworkbook, 'font underline')
152
+ subject.send(:style, @xworkbook, 'font double_underline')
153
+ subject.send(:style, @xworkbook, 'font accounting_underline')
154
+ subject.send(:style, @xworkbook, 'font double_accounting_underline')
155
+ assert_equal(
156
+ "<Style ss:ID=\".font.underline\"><Font ss:Underline=\"Single\" /><NumberFormat /></Style><Style ss:ID=\".font.double_underline\"><Font ss:Underline=\"Double\" /><NumberFormat /></Style><Style ss:ID=\".font.accounting_underline\"><Font ss:Underline=\"SingleAccounting\" /><NumberFormat /></Style><Style ss:ID=\".font.double_accounting_underline\"><Font ss:Underline=\"DoubleAccounting\" /><NumberFormat /></Style>",
157
+ xstyle_markup(@xworkbook)
158
+ )
159
+
127
160
  end
128
161
 
129
- should "build style objs for font alignment settings" do
130
- assert_equal ::Xmlss::Style::Font.alignment(:subscript), subject.send(:style, 'font subscript').font.alignment
131
- assert_equal ::Xmlss::Style::Font.alignment(:superscript), subject.send(:style, 'font superscript').font.alignment
162
+ should "write style markup for font alignment settings" do
163
+ subject.send(:style, @xworkbook, 'font subscript')
164
+ subject.send(:style, @xworkbook, 'font superscript')
165
+ assert_equal(
166
+ "<Style ss:ID=\".font.subscript\"><Font ss:VerticalAlign=\"Subscript\" /><NumberFormat /></Style><Style ss:ID=\".font.superscript\"><Font ss:VerticalAlign=\"Superscript\" /><NumberFormat /></Style>",
167
+ xstyle_markup(@xworkbook)
168
+ )
132
169
  end
133
170
 
134
- should "build style objs for font style settings" do
135
- assert_equal true, subject.send(:style, 'font bold').font.bold?
136
- assert_equal true, subject.send(:style, 'font italic').font.italic?
137
- assert_equal true, subject.send(:style, 'font strikethrough').font.strike_through?
138
- assert_equal true, subject.send(:style, 'font shadow').font.shadow?
171
+ should "write style markup for font style settings" do
172
+ subject.send(:style, @xworkbook, 'font bold')
173
+ subject.send(:style, @xworkbook, 'font italic')
174
+ subject.send(:style, @xworkbook, 'font strikethrough')
175
+ subject.send(:style, @xworkbook, 'font shadow')
176
+ assert_equal(
177
+ "<Style ss:ID=\".font.bold\"><Font ss:Bold=\"1\" /><NumberFormat /></Style><Style ss:ID=\".font.italic\"><Font ss:Italic=\"1\" /><NumberFormat /></Style><Style ss:ID=\".font.strikethrough\"><Font ss:StrikeThrough=\"1\" /><NumberFormat /></Style><Style ss:ID=\".font.shadow\"><Font ss:Shadow=\"1\" /><NumberFormat /></Style>",
178
+ xstyle_markup(@xworkbook)
179
+ )
139
180
  end
140
181
 
141
- should "build style objs for font size" do
142
- assert_equal 14, subject.send(:style, 'font size').font.size
182
+ should "write style markup for font size" do
183
+ subject.send(:style, @xworkbook, 'font size')
184
+ assert_equal(
185
+ "<Style ss:ID=\".font.size\"><Font ss:Size=\"14\" /><NumberFormat /></Style>",
186
+ xstyle_markup(@xworkbook)
187
+ )
143
188
  end
144
189
 
145
- should "build style objs for font color" do
146
- assert_equal '#FF0000', subject.send(:style, 'font color').font.color
190
+ should "write style markup for font color" do
191
+ subject.send(:style, @xworkbook, 'font color')
192
+ assert_equal(
193
+ "<Style ss:ID=\".font.color\"><Font ss:Color=\"#FF0000\" /><NumberFormat /></Style>",
194
+ xstyle_markup(@xworkbook)
195
+ )
147
196
  end
148
197
 
149
- should "build style objs for font name" do
150
- assert_equal 'Verdana', subject.send(:style, 'font name').font.name
198
+ should "write style markup for font name" do
199
+ subject.send(:style, @xworkbook, 'font name')
200
+ assert_equal(
201
+ "<Style ss:ID=\".font.name\"><Font ss:FontName=\"Verdana\" /><NumberFormat /></Style>",
202
+ xstyle_markup(@xworkbook)
203
+ )
151
204
  end
152
205
 
153
206
  end
154
207
 
155
- class XmlssWriter::Bg < XmlssWriter::StylesTest
208
+ class XmlssWriter::BgTests < XmlssWriter::StylesTest
156
209
  desc "Bg writer"
157
210
  before do
158
- subject.workbook = Workbook.new {
211
+ subject.oworkbook = Workbook.new {
159
212
  style('.bg.color') { bg '#FF0000' }
160
213
  style('.bg.pattern-only') { bg :solid }
161
214
  style('.bg.pattern-color') { bg :horz_stripe => '#0000FF' }
@@ -164,39 +217,65 @@ module Osheet
164
217
  }
165
218
  end
166
219
 
167
- should "build a style obj with empty bg settings by default" do
168
- assert_equal nil, subject.send(:style, 'bg').interior
220
+ should "write style markup with empty bg settings when no match" do
221
+ subject.send(:style, @xworkbook, 'bg')
222
+ # assert_equal nil, .interior
223
+ assert_equal(
224
+ "<Style ss:ID=\".bg\"><NumberFormat /></Style>",
225
+ xstyle_markup(@xworkbook)
226
+ )
169
227
  end
170
228
 
171
- should "build style objs for bg color and auto set the pattern to solid" do
172
- assert_equal '#FF0000', subject.send(:style, 'bg color').interior.color
229
+ should "write style markup for bg color and auto set the pattern to solid" do
230
+ subject.send(:style, @xworkbook, 'bg color')
231
+ # assert_equal '#FF0000', .interior.color
232
+ assert_equal(
233
+ "<Style ss:ID=\".bg.color\"><Interior ss:Color=\"#FF0000\" ss:Pattern=\"Solid\" /><NumberFormat /></Style>",
234
+ xstyle_markup(@xworkbook)
235
+ )
173
236
  end
174
237
 
175
- should "build style objs for bg pattern settings" do
176
- assert_equal ::Xmlss::Style::Interior.pattern(:solid), subject.send(:style, 'bg pattern-only').interior.pattern
177
- assert_equal nil, subject.send(:style, 'bg pattern-only').interior.pattern_color
178
- assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg pattern-color').interior.pattern
179
- assert_equal '#0000FF', subject.send(:style, 'bg pattern-color').interior.pattern_color
238
+ should "write style markup for bg pattern settings" do
239
+ subject.send(:style, @xworkbook, 'bg pattern-only')
240
+ subject.send(:style, @xworkbook, 'bg pattern-only')
241
+ subject.send(:style, @xworkbook, 'bg pattern-color')
242
+ subject.send(:style, @xworkbook, 'bg pattern-color')
243
+ assert_equal(
244
+ "<Style ss:ID=\".bg.pattern-only\"><Interior ss:Pattern=\"Solid\" /><NumberFormat /></Style><Style ss:ID=\".bg.pattern-color\"><Interior ss:Color=\"#FF0000\" ss:Pattern=\"HorzStripe\" ss:PatternColor=\"#0000FF\" /><NumberFormat /></Style>",
245
+ xstyle_markup(@xworkbook)
246
+ )
180
247
  end
181
248
 
182
- should "set pattern to solid when setting bg color" do
183
- assert_equal ::Xmlss::Style::Interior.pattern(:solid), subject.send(:style, 'bg color').interior.pattern
249
+ should "write style markup setting pattern to solid when setting bg color" do
250
+ subject.send(:style, @xworkbook, 'bg color')
251
+ assert_equal(
252
+ "<Style ss:ID=\".bg.color\"><Interior ss:Color=\"#FF0000\" ss:Pattern=\"Solid\" /><NumberFormat /></Style>",
253
+ xstyle_markup(@xworkbook)
254
+ )
184
255
  end
185
256
 
186
- should "set pattern to pattern setting when first setting bg color then pattern" do
187
- assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg color-first').interior.pattern
257
+ should "write style markup setting pattern to pattern setting when first setting bg color then pattern" do
258
+ subject.send(:style, @xworkbook, 'bg color-first')
259
+ assert_equal(
260
+ "<Style ss:ID=\".bg.color-first\"><Interior ss:Color=\"#00FF00\" ss:Pattern=\"HorzStripe\" ss:PatternColor=\"#0000FF\" /><NumberFormat /></Style>",
261
+ xstyle_markup(@xworkbook)
262
+ )
188
263
  end
189
264
 
190
- should "set pattern to pattern setting when first setting bg pattern then color" do
191
- assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg pattern-first').interior.pattern
265
+ should "write style markup setting pattern to pattern setting when first setting bg pattern then color" do
266
+ subject.send(:style, @xworkbook, 'bg pattern-first')
267
+ assert_equal(
268
+ "<Style ss:ID=\".bg.pattern-first\"><Interior ss:Color=\"#00FF00\" ss:Pattern=\"HorzStripe\" ss:PatternColor=\"#0000FF\" /><NumberFormat /></Style>",
269
+ xstyle_markup(@xworkbook)
270
+ )
192
271
  end
193
272
 
194
273
  end
195
274
 
196
- class XmlssWriter::Border < XmlssWriter::StylesTest
275
+ class XmlssWriter::BorderTests < XmlssWriter::StylesTest
197
276
  desc "Font border writer"
198
277
  before do
199
- subject.workbook = Workbook.new {
278
+ subject.oworkbook = Workbook.new {
200
279
  ::Osheet::Style::BORDER_POSITIONS.each do |p|
201
280
  style(".border.#{p}") { send("border_#{p}", :thin) }
202
281
  end
@@ -211,50 +290,75 @@ module Osheet
211
290
  }
212
291
  end
213
292
 
214
- should "build a style obj with empty border settings by default" do
215
- style = subject.send(:style, 'border')
216
- assert_kind_of ::Xmlss::ItemSet, style.borders
217
- assert_equal [], style.borders
293
+ should "write style markup with empty border settings when no match" do
294
+ subject.send(:style, @xworkbook, 'border')
295
+ assert_equal(
296
+ "<Style ss:ID=\".border\"><NumberFormat /></Style>",
297
+ xstyle_markup(@xworkbook)
298
+ )
218
299
  end
219
300
 
220
- should "build style objs with identical settings for all positions when using 'border'" do
221
- style = subject.send(:style, 'border all')
222
- assert_equal 4, style.borders.size
223
- assert_equal 1, style.borders.collect{|p| p.weight}.uniq.size
224
- assert_equal 1, style.borders.collect{|p| p.line_style}.uniq.size
225
- assert_equal 1, style.borders.collect{|p| p.color}.uniq.size
301
+ should "write style markup with identical settings for all positions when using 'border'" do
302
+ subject.send(:style, @xworkbook, 'border all')
303
+ assert_equal(
304
+ "<Style ss:ID=\".border.all\"><Borders><Border ss:Color=\"#FF0000\" ss:LineStyle=\"Dash\" ss:Position=\"Top\" ss:Weight=\"3\" /><Border ss:Color=\"#FF0000\" ss:LineStyle=\"Dash\" ss:Position=\"Right\" ss:Weight=\"3\" /><Border ss:Color=\"#FF0000\" ss:LineStyle=\"Dash\" ss:Position=\"Bottom\" ss:Weight=\"3\" /><Border ss:Color=\"#FF0000\" ss:LineStyle=\"Dash\" ss:Position=\"Left\" ss:Weight=\"3\" /></Borders><NumberFormat /></Style>",
305
+ xstyle_markup(@xworkbook)
306
+ )
226
307
  end
227
308
 
228
- should "build style objs for border specific positions" do
309
+ should "write style markup for border specific positions" do
229
310
  ::Osheet::Style::BORDER_POSITIONS.each do |p|
230
- assert_equal ::Xmlss::Style::Border.position(p), subject.send(:style, "border #{p}").borders.first.position
311
+ subject.send(:style, @xworkbook, "border #{p}")
231
312
  end
313
+ assert_equal(
314
+ "<Style ss:ID=\".border.top\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.right\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Right\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.bottom\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Bottom\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.left\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Left\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style>",
315
+ xstyle_markup(@xworkbook)
316
+ )
232
317
  end
233
318
 
234
- should "build style objs for border weight settings" do
319
+ should "write style markup for border weight settings" do
235
320
  [:hairline, :thin, :medium, :thick].each do |w|
236
- assert_equal ::Xmlss::Style::Border.weight(w), subject.send(:style, "border #{w}").borders.first.weight
321
+ subject.send(:style, @xworkbook, "border #{w}")
237
322
  end
323
+ assert_equal(
324
+ "<Style ss:ID=\".border.hairline\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Top\" ss:Weight=\"0\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.thin\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.medium\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Top\" ss:Weight=\"2\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.thick\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Top\" ss:Weight=\"3\" /></Borders><NumberFormat /></Style>",
325
+ xstyle_markup(@xworkbook)
326
+ )
238
327
  end
239
328
 
240
- should "build style objs for border style settings" do
329
+ should "write style markup for border style settings" do
241
330
  [:none, :continuous, :dash, :dot, :dash_dot, :dash_dot_dot].each do |s|
242
- assert_equal ::Xmlss::Style::Border.line_style(s), subject.send(:style, "border #{s}").borders.first.line_style
331
+ subject.send(:style, @xworkbook, "border #{s}")
243
332
  end
333
+ assert_equal(
334
+ "<Style ss:ID=\".border.none\"><Borders><Border ss:LineStyle=\"None\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.continuous\"><Borders><Border ss:LineStyle=\"Continuous\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.dash\"><Borders><Border ss:LineStyle=\"Dash\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.dot\"><Borders><Border ss:LineStyle=\"Dot\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.dash_dot\"><Borders><Border ss:LineStyle=\"DashDot\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style><Style ss:ID=\".border.dash_dot_dot\"><Borders><Border ss:LineStyle=\"DashDotDot\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style>",
335
+ xstyle_markup(@xworkbook)
336
+ )
244
337
  end
245
338
 
246
- should "build style objs for border color" do
247
- assert_equal '#FF0000', subject.send(:style, 'border color').borders.first.color
339
+ should "write style markup for border color" do
340
+ subject.send(:style, @xworkbook, 'border color')
341
+ assert_equal(
342
+ "<Style ss:ID=\".border.color\"><Borders><Border ss:Color=\"#FF0000\" ss:LineStyle=\"Continuous\" ss:Position=\"Top\" ss:Weight=\"1\" /></Borders><NumberFormat /></Style>",
343
+ xstyle_markup(@xworkbook)
344
+ )
248
345
  end
249
346
 
250
347
  end
251
348
 
252
- class XmlssWriter::NumberFormat < XmlssWriter::StylesTest
349
+ class XmlssWriter::NumberFormatTests < XmlssWriter::StylesTest
253
350
  desc "Xmlss style number format writer"
351
+ before do
352
+ subject.oworkbook = Workbook.new {}
353
+ end
254
354
 
255
- should "build a style obj with formatting" do
256
- assert_equal '@', subject.send(:style, '', Osheet::Format.new(:text)).number_format.format
257
- assert_equal 'mm/dd/yy', subject.send(:style, '', Osheet::Format.new(:datetime, 'mm/dd/yy')).number_format.format
355
+ should "write style markup with formatting" do
356
+ subject.send(:style, @xworkbook, '', Osheet::Format.new(:text))
357
+ subject.send(:style, @xworkbook, '', Osheet::Format.new(:datetime, 'mm/dd/yy'))
358
+ assert_equal(
359
+ "<Style ss:ID=\"..text\"><NumberFormat ss:Format=\"@\" /></Style><Style ss:ID=\"..datetime_mm/dd/yy\"><NumberFormat ss:Format=\"mm/dd/yy\" /></Style>",
360
+ xstyle_markup(@xworkbook)
361
+ )
258
362
  end
259
363
 
260
364
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osheet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 9
9
- - 2
10
- version: 0.9.2
8
+ - 10
9
+ - 0
10
+ version: 0.10.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: 2011-11-21 00:00:00 Z
18
+ date: 2012-01-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :development
@@ -55,11 +55,11 @@ dependencies:
55
55
  requirements:
56
56
  - - ~>
57
57
  - !ruby/object:Gem::Version
58
- hash: 11
58
+ hash: 9
59
59
  segments:
60
60
  - 1
61
- - 2
62
- version: "1.2"
61
+ - 3
62
+ version: "1.3"
63
63
  version_requirements: *id003
64
64
  name: enumeration
65
65
  - !ruby/object:Gem::Dependency
@@ -70,16 +70,16 @@ dependencies:
70
70
  requirements:
71
71
  - - ~>
72
72
  - !ruby/object:Gem::Version
73
- hash: 15
73
+ hash: 3
74
74
  segments:
75
75
  - 0
76
- - 2
77
- version: "0.2"
76
+ - 4
77
+ version: "0.4"
78
78
  version_requirements: *id004
79
79
  name: xmlss
80
80
  description: A DSL for specifying and generating spreadsheets using Ruby
81
81
  email:
82
- - kelly@kelredd.com
82
+ - kelly@kellyredding.com
83
83
  executables: []
84
84
 
85
85
  extensions: []
@@ -92,12 +92,21 @@ files:
92
92
  - Gemfile.lock
93
93
  - README.rdoc
94
94
  - Rakefile
95
+ - bench/profiler.rb
96
+ - bench/profiler_1000.xls
97
+ - bench/profiler_runner.rb
95
98
  - examples/basic.rb
99
+ - examples/basic.xls
96
100
  - examples/basic_with_templates.rb
101
+ - examples/basic_with_templates.xls
97
102
  - examples/formats.rb
103
+ - examples/formats.xls
98
104
  - examples/formula.rb
105
+ - examples/formula.xls
99
106
  - examples/styles.rb
107
+ - examples/styles.xls
100
108
  - examples/trivial.rb
109
+ - examples/trivial.xls
101
110
  - lib/osheet.rb
102
111
  - lib/osheet/associations.rb
103
112
  - lib/osheet/cell.rb
@@ -172,7 +181,7 @@ files:
172
181
  - test/xmlss_writer/base_test.rb
173
182
  - test/xmlss_writer/elements_test.rb
174
183
  - test/xmlss_writer/styles_test.rb
175
- homepage: http://github.com/kelredd/osheet
184
+ homepage: http://github.com/kellyredding/osheet
176
185
  licenses: []
177
186
 
178
187
  post_install_message:
@@ -201,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
210
  requirements: []
202
211
 
203
212
  rubyforge_project:
204
- rubygems_version: 1.8.10
213
+ rubygems_version: 1.8.11
205
214
  signing_key:
206
215
  specification_version: 3
207
216
  summary: A DSL for specifying and generating spreadsheets using Ruby