osheet 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. data/.gitignore +5 -3
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +13 -37
  4. data/Rakefile +3 -3
  5. data/lib/osheet/format/numeric.rb +0 -2
  6. data/lib/osheet/instance.rb +1 -3
  7. data/lib/osheet/version.rb +2 -2
  8. data/osheet.gemspec +3 -9
  9. data/test/cell_test.rb +96 -104
  10. data/test/column_test.rb +90 -97
  11. data/test/format/accounting_test.rb +115 -128
  12. data/test/format/currency_test.rb +115 -128
  13. data/test/format/custom_test.rb +13 -13
  14. data/test/format/datetime_test.rb +13 -13
  15. data/test/format/fraction_test.rb +63 -63
  16. data/test/format/general_test.rb +11 -11
  17. data/test/format/number_test.rb +67 -69
  18. data/test/format/percentage_test.rb +89 -91
  19. data/test/format/scientific_test.rb +89 -91
  20. data/test/format/special_test.rb +35 -35
  21. data/test/format/text_test.rb +9 -9
  22. data/test/format_test.rb +24 -24
  23. data/test/helper.rb +42 -47
  24. data/test/irb.rb +9 -0
  25. data/test/mixin_test.rb +55 -59
  26. data/test/osheet_test.rb +7 -10
  27. data/test/partial_set_test.rb +41 -61
  28. data/test/partial_test.rb +44 -46
  29. data/test/row_test.rb +92 -99
  30. data/test/style_set_test.rb +34 -37
  31. data/test/style_test.rb +72 -97
  32. data/test/template_set_test.rb +52 -73
  33. data/test/template_test.rb +31 -49
  34. data/test/workbook_test.rb +186 -199
  35. data/test/worksheet_test.rb +99 -103
  36. data/test/xmlss_writer/base_test.rb +72 -73
  37. data/test/xmlss_writer/elements_test.rb +141 -140
  38. data/test/xmlss_writer/styles_test.rb +197 -208
  39. metadata +27 -247
  40. data/.bundle/config +0 -2
  41. data/test/app_helper.rb +0 -66
  42. data/test/env.rb +0 -10
  43. data/test/rails/three/.gitignore +0 -4
  44. data/test/rails/three/Gemfile +0 -5
  45. data/test/rails/three/Gemfile.lock +0 -88
  46. data/test/rails/three/app/controllers/application_controller.rb +0 -3
  47. data/test/rails/three/app/controllers/things_controller.rb +0 -10
  48. data/test/rails/three/app/helpers/application_helper.rb +0 -2
  49. data/test/rails/three/app/views/layouts/application.html.erb +0 -14
  50. data/test/rails/three/app/views/things/index.xls.osheet +0 -13
  51. data/test/rails/three/config/application.rb +0 -42
  52. data/test/rails/three/config/boot.rb +0 -13
  53. data/test/rails/three/config/database.yml +0 -22
  54. data/test/rails/three/config/environment.rb +0 -5
  55. data/test/rails/three/config/environments/development.rb +0 -26
  56. data/test/rails/three/config/environments/production.rb +0 -49
  57. data/test/rails/three/config/environments/test.rb +0 -35
  58. data/test/rails/three/config/initializers/app.rb +0 -0
  59. data/test/rails/three/config/initializers/backtrace_silencers.rb +0 -7
  60. data/test/rails/three/config/initializers/inflections.rb +0 -10
  61. data/test/rails/three/config/initializers/mime_types.rb +0 -5
  62. data/test/rails/three/config/initializers/secret_token.rb +0 -7
  63. data/test/rails/three/config/initializers/session_store.rb +0 -8
  64. data/test/rails/three/config/locales/en.yml +0 -5
  65. data/test/rails/three/config/routes.rb +0 -3
  66. data/test/rails/three/config.ru +0 -4
  67. data/test/rails/three/db/seeds.rb +0 -7
  68. data/test/rails/three/doc/README_FOR_APP +0 -2
  69. data/test/rails/three/lib/tasks/.gitkeep +0 -0
  70. data/test/rails/three/script/rails +0 -6
  71. data/test/rails/two/.bundle/config +0 -2
  72. data/test/rails/two/Booting +0 -0
  73. data/test/rails/two/Gemfile +0 -5
  74. data/test/rails/two/Gemfile.lock +0 -45
  75. data/test/rails/two/Rails +0 -0
  76. data/test/rails/two/app/controllers/application_controller.rb +0 -20
  77. data/test/rails/two/app/controllers/things_controller.rb +0 -10
  78. data/test/rails/two/app/helpers/application_helper.rb +0 -3
  79. data/test/rails/two/app/views/things/index.xls.osheet +0 -15
  80. data/test/rails/two/config/boot.rb +0 -128
  81. data/test/rails/two/config/database.yml +0 -22
  82. data/test/rails/two/config/environment.rb +0 -41
  83. data/test/rails/two/config/environments/development.rb +0 -17
  84. data/test/rails/two/config/environments/production.rb +0 -28
  85. data/test/rails/two/config/environments/test.rb +0 -28
  86. data/test/rails/two/config/initializers/app.rb +0 -2
  87. data/test/rails/two/config/initializers/backtrace_silencers.rb +0 -7
  88. data/test/rails/two/config/initializers/cookie_verification_secret.rb +0 -7
  89. data/test/rails/two/config/initializers/inflections.rb +0 -10
  90. data/test/rails/two/config/initializers/mime_types.rb +0 -5
  91. data/test/rails/two/config/initializers/new_rails_defaults.rb +0 -21
  92. data/test/rails/two/config/initializers/session_store.rb +0 -15
  93. data/test/rails/two/config/locales/en.yml +0 -5
  94. data/test/rails/two/config/routes.rb +0 -3
  95. data/test/rails/two/db/development.sqlite3 +0 -0
  96. data/test/rails/two/db/seeds.rb +0 -7
  97. data/test/rails/two/script/about +0 -4
  98. data/test/rails/two/script/console +0 -3
  99. data/test/rails/two/script/dbconsole +0 -3
  100. data/test/rails/two/script/destroy +0 -3
  101. data/test/rails/two/script/generate +0 -3
  102. data/test/rails/two/script/performance/benchmarker +0 -3
  103. data/test/rails/two/script/performance/profiler +0 -3
  104. data/test/rails/two/script/plugin +0 -3
  105. data/test/rails/two/script/runner +0 -3
  106. data/test/rails/two/script/server +0 -3
  107. data/test/rails/two/tmp/pids/server.pid +0 -1
  108. data/test/rails_test.rb +0 -38
  109. data/test/sinatra/app.rb +0 -16
  110. data/test/sinatra/views/index.osheet +0 -13
  111. data/test/sinatra_test.rb +0 -19
@@ -1,257 +1,244 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require 'osheet/workbook'
3
3
  require 'test/mixins'
4
4
 
5
5
  module Osheet
6
6
 
7
- class WorkbookTest < Test::Unit::TestCase
7
+ class WorkbookTest < Assert::Context
8
+ desc "Osheet::Workbook"
9
+ before { @wkbk = Workbook.new }
10
+ subject { @wkbk }
8
11
 
9
- context "Osheet::Workbook" do
10
- subject do
11
- Workbook.new
12
- end
13
-
14
- should_have_readers :styles, :templates, :partials
15
- should_have_instance_methods :title, :attributes, :use, :add
16
- should_have_instance_methods :style, :template, :partial
12
+ should have_readers :styles, :templates, :partials
13
+ should have_instance_methods :title, :attributes, :use, :add
14
+ should have_instance_methods :style, :template, :partial
17
15
 
18
- should_hm(Workbook, :worksheets, Worksheet)
16
+ should_hm(Workbook, :worksheets, Worksheet)
19
17
 
20
- should "set it's defaults" do
21
- assert_equal nil, subject.send(:get_ivar, "title")
22
- assert_equal [], subject.worksheets
23
- assert_equal StyleSet.new, subject.styles
24
- assert_equal TemplateSet.new, subject.templates
25
- assert_equal PartialSet.new, subject.partials
26
- end
18
+ should "set it's defaults" do
19
+ assert_equal nil, subject.send(:get_ivar, "title")
20
+ assert_equal [], subject.worksheets
21
+ assert_equal StyleSet.new, subject.styles
22
+ assert_equal TemplateSet.new, subject.templates
23
+ assert_equal PartialSet.new, subject.partials
24
+ end
27
25
 
28
- should "know it's attribute(s)" do
29
- subject.send(:title, "The Poo")
30
- [:title].each do |a|
31
- assert subject.attributes.has_key?(a)
32
- end
33
- assert_equal "The Poo", subject.attributes[:title]
26
+ should "know it's attribute(s)" do
27
+ subject.send(:title, "The Poo")
28
+ [:title].each do |a|
29
+ assert subject.attributes.has_key?(a)
34
30
  end
35
-
31
+ assert_equal "The Poo", subject.attributes[:title]
36
32
  end
37
- end
38
33
 
39
- class WorkbookTitleTest < Test::Unit::TestCase
40
- context "A workbook with a title" do
41
- subject do
42
- Workbook.new { title "The Poo" }
43
- end
34
+ end
44
35
 
45
- should "know it's title" do
46
- assert_equal "The Poo", subject.title
47
- end
36
+ class WorkbookTitleTest < WorkbookTest
37
+ desc "A workbook with a title"
38
+ before { @wkbk = Workbook.new { title "The Poo" } }
48
39
 
49
- should "set it's title" do
50
- subject.title(false)
51
- assert_equal false, subject.title
52
- subject.title('la')
53
- assert_equal 'la', subject.title
54
- subject.title(nil)
55
- assert_equal 'la', subject.title
56
- end
40
+ should "know it's title" do
41
+ assert_equal "The Poo", subject.title
42
+ end
57
43
 
44
+ should "set it's title" do
45
+ subject.title(false)
46
+ assert_equal false, subject.title
47
+ subject.title('la')
48
+ assert_equal 'la', subject.title
49
+ subject.title(nil)
50
+ assert_equal 'la', subject.title
58
51
  end
52
+
59
53
  end
60
54
 
61
- class WorkbookWorksheetsTest < Test::Unit::TestCase
62
- context "A workbook with worksheets" do
63
- subject do
64
- Workbook.new {
65
- worksheet {
66
- name "Poo!"
67
- column
68
- row {
69
- cell {
70
- format :number
71
- data 1
72
- }
55
+ class WorkbookWorksheetsTest < WorkbookTest
56
+ desc "A workbook with worksheets"
57
+ before do
58
+ @wkbk = Workbook.new {
59
+ worksheet {
60
+ name "Poo!"
61
+ column
62
+ row {
63
+ cell {
64
+ format :number
65
+ data 1
73
66
  }
74
67
  }
75
68
  }
76
- end
77
-
78
- should "set it's worksheets" do
79
- assert_equal 1, subject.worksheets.size
80
- assert_kind_of Worksheet, subject.worksheets.first
81
- end
82
-
83
- should "not allow multiple worksheets with the same name" do
84
- assert_raises ArgumentError do
85
- Workbook.new {
86
- worksheet { name "awesome" }
87
- worksheet { name "awesome" }
88
- }
89
- end
90
- assert_nothing_raised do
91
- Workbook.new {
92
- worksheet { name "awesome" }
93
- worksheet { name "awesome1" }
94
- }
95
- end
96
- end
69
+ }
70
+ end
97
71
 
72
+ should "set it's worksheets" do
73
+ assert_equal 1, subject.worksheets.size
74
+ assert_kind_of Worksheet, subject.worksheets.first
98
75
  end
99
- end
100
76
 
101
- class WorkbookStyleTest < Test::Unit::TestCase
102
- context "A workbook that defines styles" do
103
- subject do
77
+ should "not allow multiple worksheets with the same name" do
78
+ assert_raises ArgumentError do
104
79
  Workbook.new {
105
- style('.test')
106
- style('.test.awesome')
80
+ worksheet { name "awesome" }
81
+ worksheet { name "awesome" }
107
82
  }
108
83
  end
109
-
110
- should "add them to it's styles" do
111
- assert_equal 2, subject.styles.size
112
- assert_equal 1, subject.styles.first.selectors.size
113
- assert_equal '.test', subject.styles.first.selectors.first
114
- assert_equal 1, subject.styles.last.selectors.size
115
- assert_equal '.test.awesome', subject.styles.last.selectors.first
116
- end
117
-
118
- end
119
- end
120
-
121
- class WorkbookPartialTest < Test::Unit::TestCase
122
- context "A workbook that defines partials" do
123
- subject do
84
+ assert_nothing_raised do
124
85
  Workbook.new {
125
- partial(:named_styles) { |name|
126
- style(".#{name}")
127
- style(".#{name}.awesome")
128
- }
129
- partial(:stuff) {}
86
+ worksheet { name "awesome" }
87
+ worksheet { name "awesome1" }
130
88
  }
131
89
  end
90
+ end
132
91
 
133
- should "add them to it's partials" do
134
- assert_equal 2, subject.partials.keys.size
135
- assert subject.partials.has_key?('named_styles')
136
- assert subject.partials.has_key?('stuff')
137
- assert_kind_of Partial, subject.partials.get('stuff')
138
- end
92
+ end
139
93
 
140
- should "add it's partials to it's markup" do
141
- subject.add(:named_styles, 'test')
142
- assert_equal 2, subject.styles.size
143
- assert_equal '.test', subject.styles.first.selectors.first
144
- assert_equal '.test.awesome', subject.styles.last.selectors.first
145
- end
94
+ class WorkbookStyleTest < WorkbookTest
95
+ desc "A workbook that defines styles"
96
+ before do
97
+ @wkbk = Workbook.new {
98
+ style('.test')
99
+ style('.test.awesome')
100
+ }
101
+ end
146
102
 
103
+ should "add them to it's styles" do
104
+ assert_equal 2, subject.styles.size
105
+ assert_equal 1, subject.styles.first.selectors.size
106
+ assert_equal '.test', subject.styles.first.selectors.first
107
+ assert_equal 1, subject.styles.last.selectors.size
108
+ assert_equal '.test.awesome', subject.styles.last.selectors.first
147
109
  end
110
+
148
111
  end
149
112
 
150
- class WorkbookTemplateTest < Test::Unit::TestCase
151
- context "A workbook that defines templates" do
152
- subject do
153
- Workbook.new {
154
- template(:column, :yo) { |color|
155
- width 200
156
- meta(:color => color)
157
- }
158
- template(:row, :yo_yo) {
159
- height 500
160
- }
161
- template(:worksheet, :go) {
162
- column(:yo, 'blue')
163
- row(:yo_yo)
164
- }
113
+ class WorkbookPartialTest < WorkbookTest
114
+ desc "A workbook that defines partials"
115
+ before do
116
+ @wkbk = Workbook.new {
117
+ partial(:named_styles) { |name|
118
+ style(".#{name}")
119
+ style(".#{name}.awesome")
165
120
  }
166
- end
167
-
168
- should "add them to it's templates" do
169
- assert subject.templates
170
- assert_kind_of TemplateSet, subject.templates
171
- assert_equal 3, subject.templates.keys.size
172
- assert_kind_of Template, subject.templates.get('column', 'yo')
173
- assert_kind_of Template, subject.templates.get('row', 'yo_yo')
174
- assert_kind_of Template, subject.templates.get('worksheet', 'go')
175
- end
121
+ partial(:stuff) {}
122
+ }
123
+ end
176
124
 
177
- should "apply it's templates" do
178
- subject.worksheet(:go)
179
- assert_equal 1, subject.worksheets.size
180
- assert_equal 'blue', subject.worksheets.first.columns.first.meta[:color]
181
- assert_equal 500, subject.worksheets.first.rows.first.attributes[:height]
182
- end
125
+ should "add them to it's partials" do
126
+ assert_equal 2, subject.partials.keys.size
127
+ assert subject.partials.has_key?('named_styles')
128
+ assert subject.partials.has_key?('stuff')
129
+ assert_kind_of Partial, subject.partials.get('stuff')
130
+ end
183
131
 
132
+ should "add it's partials to it's markup" do
133
+ subject.add(:named_styles, 'test')
134
+ assert_equal 2, subject.styles.size
135
+ assert_equal '.test', subject.styles.first.selectors.first
136
+ assert_equal '.test.awesome', subject.styles.last.selectors.first
184
137
  end
138
+
185
139
  end
186
140
 
187
- class WorkbookBindingTest < Test::Unit::TestCase
188
- context "a workbook defined w/ a block" do
189
- should "access instance vars from that block's binding" do
190
- @test = 'test'
191
- @workbook = Workbook.new { title @test }
192
-
193
- assert !@workbook.send(:instance_variable_get, "@test").nil?
194
- assert_equal @test, @workbook.send(:instance_variable_get, "@test")
195
- assert_equal @test.object_id, @workbook.send(:instance_variable_get, "@test").object_id
196
- assert_equal @test, @workbook.attributes[:title]
197
- assert_equal @test.object_id, @workbook.attributes[:title].object_id
198
- end
141
+ class WorkbookTemplateTest < WorkbookTest
142
+ desc "A workbook that defines templates"
143
+ before do
144
+ @wkbk = Workbook.new {
145
+ template(:column, :yo) { |color|
146
+ width 200
147
+ meta(:color => color)
148
+ }
149
+ template(:row, :yo_yo) {
150
+ height 500
151
+ }
152
+ template(:worksheet, :go) {
153
+ column(:yo, 'blue')
154
+ row(:yo_yo)
155
+ }
156
+ }
157
+ end
158
+
159
+ should "add them to it's templates" do
160
+ assert subject.templates
161
+ assert_kind_of TemplateSet, subject.templates
162
+ assert_equal 3, subject.templates.keys.size
163
+ assert_kind_of Template, subject.templates.get('column', 'yo')
164
+ assert_kind_of Template, subject.templates.get('row', 'yo_yo')
165
+ assert_kind_of Template, subject.templates.get('worksheet', 'go')
166
+ end
199
167
 
168
+ should "apply it's templates" do
169
+ subject.worksheet(:go)
170
+ assert_equal 1, subject.worksheets.size
171
+ assert_equal 'blue', subject.worksheets.first.columns.first.meta[:color]
172
+ assert_equal 500, subject.worksheets.first.rows.first.attributes[:height]
200
173
  end
174
+
201
175
  end
202
176
 
203
- class WorkbookMixins < Test::Unit::TestCase
204
- context "a workbook w/ mixins" do
205
- subject do
206
- Workbook.new {
207
- use StyledMixin
208
- use TemplatedMixin
209
- }
210
- end
177
+ class WorkbookBindingTest < WorkbookTest
178
+ desc "a workbook defined w/ a block"
179
+ should "access instance vars from that block's binding" do
180
+ @test = 'test'
181
+ @workbook = Workbook.new { title @test }
182
+
183
+ assert !@workbook.send(:instance_variable_get, "@test").nil?
184
+ assert_equal @test, @workbook.send(:instance_variable_get, "@test")
185
+ assert_equal @test.object_id, @workbook.send(:instance_variable_get, "@test").object_id
186
+ assert_equal @test, @workbook.attributes[:title]
187
+ assert_equal @test.object_id, @workbook.attributes[:title].object_id
188
+ end
211
189
 
212
- should "add the mixin styles to it's styles" do
213
- assert_equal 2, subject.styles.size
214
- assert_equal 1, subject.styles.first.selectors.size
215
- assert_equal '.test', subject.styles.first.selectors.first
216
- assert_equal 1, subject.styles.last.selectors.size
217
- assert_equal '.test.awesome', subject.styles.last.selectors.first
218
- end
190
+ end
219
191
 
220
- should "add the mixin templates to it's templates" do
221
- assert subject.templates
222
- assert_kind_of TemplateSet, subject.templates
223
- assert_equal 3, subject.templates.keys.size
224
- assert_kind_of Template, subject.templates.get('column', 'yo')
225
- assert_kind_of Template, subject.templates.get('row', 'yo_yo')
226
- assert_kind_of Template, subject.templates.get('worksheet', 'go')
227
-
228
- subject.worksheet(:go)
229
- assert_equal 1, subject.worksheets.size
230
- assert_equal 'blue', subject.worksheets.first.columns.first.meta[:color]
231
- assert_equal 500, subject.worksheets.first.rows.first.attributes[:height]
232
- end
192
+ class WorkbookMixins < WorkbookTest
193
+ desc "a workbook w/ mixins"
194
+ before do
195
+ @wkbk = Workbook.new {
196
+ use StyledMixin
197
+ use TemplatedMixin
198
+ }
199
+ end
233
200
 
201
+ should "add the mixin styles to it's styles" do
202
+ assert_equal 2, subject.styles.size
203
+ assert_equal 1, subject.styles.first.selectors.size
204
+ assert_equal '.test', subject.styles.first.selectors.first
205
+ assert_equal 1, subject.styles.last.selectors.size
206
+ assert_equal '.test.awesome', subject.styles.last.selectors.first
234
207
  end
235
- end
236
208
 
237
- class WorkbookWriter < Test::Unit::TestCase
238
- context "a workbook" do
239
- subject do
240
- Workbook.new {
241
- style('.test')
242
- style('.test.awesome')
243
- }
244
- end
209
+ should "add the mixin templates to it's templates" do
210
+ assert subject.templates
211
+ assert_kind_of TemplateSet, subject.templates
212
+ assert_equal 3, subject.templates.keys.size
213
+ assert_kind_of Template, subject.templates.get('column', 'yo')
214
+ assert_kind_of Template, subject.templates.get('row', 'yo_yo')
215
+ assert_kind_of Template, subject.templates.get('worksheet', 'go')
216
+
217
+ subject.worksheet(:go)
218
+ assert_equal 1, subject.worksheets.size
219
+ assert_equal 'blue', subject.worksheets.first.columns.first.meta[:color]
220
+ assert_equal 500, subject.worksheets.first.rows.first.attributes[:height]
221
+ end
245
222
 
246
- should_have_instance_method :writer, :to_data, :to_file
223
+ end
247
224
 
248
- should "provide a writer for itself" do
249
- writer = subject.writer
250
- assert writer
251
- assert_kind_of XmlssWriter::Base, writer
252
- end
225
+ class WorkbookWriter < WorkbookTest
226
+ desc "a workbook"
227
+ before do
228
+ @wkbk = Workbook.new {
229
+ style('.test')
230
+ style('.test.awesome')
231
+ }
232
+ end
253
233
 
234
+ should have_instance_method :writer, :to_data, :to_file
235
+
236
+ should "provide a writer for itself" do
237
+ writer = subject.writer
238
+ assert writer
239
+ assert_kind_of XmlssWriter::Base, writer
254
240
  end
241
+
255
242
  end
256
243
 
257
244
  end