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.
- data/.gitignore +5 -3
- data/Gemfile +2 -0
- data/Gemfile.lock +13 -37
- data/Rakefile +3 -3
- data/lib/osheet/format/numeric.rb +0 -2
- data/lib/osheet/instance.rb +1 -3
- data/lib/osheet/version.rb +2 -2
- data/osheet.gemspec +3 -9
- data/test/cell_test.rb +96 -104
- data/test/column_test.rb +90 -97
- data/test/format/accounting_test.rb +115 -128
- data/test/format/currency_test.rb +115 -128
- data/test/format/custom_test.rb +13 -13
- data/test/format/datetime_test.rb +13 -13
- data/test/format/fraction_test.rb +63 -63
- data/test/format/general_test.rb +11 -11
- data/test/format/number_test.rb +67 -69
- data/test/format/percentage_test.rb +89 -91
- data/test/format/scientific_test.rb +89 -91
- data/test/format/special_test.rb +35 -35
- data/test/format/text_test.rb +9 -9
- data/test/format_test.rb +24 -24
- data/test/helper.rb +42 -47
- data/test/irb.rb +9 -0
- data/test/mixin_test.rb +55 -59
- data/test/osheet_test.rb +7 -10
- data/test/partial_set_test.rb +41 -61
- data/test/partial_test.rb +44 -46
- data/test/row_test.rb +92 -99
- data/test/style_set_test.rb +34 -37
- data/test/style_test.rb +72 -97
- data/test/template_set_test.rb +52 -73
- data/test/template_test.rb +31 -49
- data/test/workbook_test.rb +186 -199
- data/test/worksheet_test.rb +99 -103
- data/test/xmlss_writer/base_test.rb +72 -73
- data/test/xmlss_writer/elements_test.rb +141 -140
- data/test/xmlss_writer/styles_test.rb +197 -208
- metadata +27 -247
- data/.bundle/config +0 -2
- data/test/app_helper.rb +0 -66
- data/test/env.rb +0 -10
- data/test/rails/three/.gitignore +0 -4
- data/test/rails/three/Gemfile +0 -5
- data/test/rails/three/Gemfile.lock +0 -88
- data/test/rails/three/app/controllers/application_controller.rb +0 -3
- data/test/rails/three/app/controllers/things_controller.rb +0 -10
- data/test/rails/three/app/helpers/application_helper.rb +0 -2
- data/test/rails/three/app/views/layouts/application.html.erb +0 -14
- data/test/rails/three/app/views/things/index.xls.osheet +0 -13
- data/test/rails/three/config/application.rb +0 -42
- data/test/rails/three/config/boot.rb +0 -13
- data/test/rails/three/config/database.yml +0 -22
- data/test/rails/three/config/environment.rb +0 -5
- data/test/rails/three/config/environments/development.rb +0 -26
- data/test/rails/three/config/environments/production.rb +0 -49
- data/test/rails/three/config/environments/test.rb +0 -35
- data/test/rails/three/config/initializers/app.rb +0 -0
- data/test/rails/three/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails/three/config/initializers/inflections.rb +0 -10
- data/test/rails/three/config/initializers/mime_types.rb +0 -5
- data/test/rails/three/config/initializers/secret_token.rb +0 -7
- data/test/rails/three/config/initializers/session_store.rb +0 -8
- data/test/rails/three/config/locales/en.yml +0 -5
- data/test/rails/three/config/routes.rb +0 -3
- data/test/rails/three/config.ru +0 -4
- data/test/rails/three/db/seeds.rb +0 -7
- data/test/rails/three/doc/README_FOR_APP +0 -2
- data/test/rails/three/lib/tasks/.gitkeep +0 -0
- data/test/rails/three/script/rails +0 -6
- data/test/rails/two/.bundle/config +0 -2
- data/test/rails/two/Booting +0 -0
- data/test/rails/two/Gemfile +0 -5
- data/test/rails/two/Gemfile.lock +0 -45
- data/test/rails/two/Rails +0 -0
- data/test/rails/two/app/controllers/application_controller.rb +0 -20
- data/test/rails/two/app/controllers/things_controller.rb +0 -10
- data/test/rails/two/app/helpers/application_helper.rb +0 -3
- data/test/rails/two/app/views/things/index.xls.osheet +0 -15
- data/test/rails/two/config/boot.rb +0 -128
- data/test/rails/two/config/database.yml +0 -22
- data/test/rails/two/config/environment.rb +0 -41
- data/test/rails/two/config/environments/development.rb +0 -17
- data/test/rails/two/config/environments/production.rb +0 -28
- data/test/rails/two/config/environments/test.rb +0 -28
- data/test/rails/two/config/initializers/app.rb +0 -2
- data/test/rails/two/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails/two/config/initializers/cookie_verification_secret.rb +0 -7
- data/test/rails/two/config/initializers/inflections.rb +0 -10
- data/test/rails/two/config/initializers/mime_types.rb +0 -5
- data/test/rails/two/config/initializers/new_rails_defaults.rb +0 -21
- data/test/rails/two/config/initializers/session_store.rb +0 -15
- data/test/rails/two/config/locales/en.yml +0 -5
- data/test/rails/two/config/routes.rb +0 -3
- data/test/rails/two/db/development.sqlite3 +0 -0
- data/test/rails/two/db/seeds.rb +0 -7
- data/test/rails/two/script/about +0 -4
- data/test/rails/two/script/console +0 -3
- data/test/rails/two/script/dbconsole +0 -3
- data/test/rails/two/script/destroy +0 -3
- data/test/rails/two/script/generate +0 -3
- data/test/rails/two/script/performance/benchmarker +0 -3
- data/test/rails/two/script/performance/profiler +0 -3
- data/test/rails/two/script/plugin +0 -3
- data/test/rails/two/script/runner +0 -3
- data/test/rails/two/script/server +0 -3
- data/test/rails/two/tmp/pids/server.pid +0 -1
- data/test/rails_test.rb +0 -38
- data/test/sinatra/app.rb +0 -16
- data/test/sinatra/views/index.osheet +0 -13
- data/test/sinatra_test.rb +0 -19
|
@@ -3,266 +3,255 @@ require 'osheet/xmlss_writer'
|
|
|
3
3
|
|
|
4
4
|
module Osheet
|
|
5
5
|
|
|
6
|
-
class XmlssWriter::
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
subject.workbook = Workbook.new {
|
|
12
|
-
style('.font.size') { font 14 }
|
|
13
|
-
style('.font.weight') { font :bold }
|
|
14
|
-
style('.font.style') { font :italic }
|
|
15
|
-
style('.align.center') { align :center }
|
|
16
|
-
}
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
should "key styles based off class str and format" do
|
|
20
|
-
assert_equal '', subject.send(:style_key, '', nil)
|
|
21
|
-
assert_equal '.awesome', subject.send(:style_key, 'awesome', nil)
|
|
22
|
-
assert_equal '.awesome.thing', subject.send(:style_key, 'awesome thing', nil)
|
|
23
|
-
assert_equal '.awesome..something', subject.send(:style_key, 'awesome', 'something')
|
|
24
|
-
assert_equal '..something', subject.send(:style_key, '', 'something')
|
|
25
|
-
end
|
|
6
|
+
class XmlssWriter::StylesTest < Assert::Context
|
|
7
|
+
before do
|
|
8
|
+
@writer = XmlssWriter::Base.new
|
|
9
|
+
end
|
|
10
|
+
subject { @writer }
|
|
26
11
|
|
|
27
|
-
|
|
28
|
-
assert_equal nil, subject.send(:style, '')
|
|
29
|
-
end
|
|
12
|
+
end
|
|
30
13
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
class XmlssWriter::Style < XmlssWriter::StylesTest
|
|
15
|
+
desc "Xmlss style writer"
|
|
16
|
+
before do
|
|
17
|
+
subject.workbook = Workbook.new {
|
|
18
|
+
style('.font.size') { font 14 }
|
|
19
|
+
style('.font.weight') { font :bold }
|
|
20
|
+
style('.font.style') { font :italic }
|
|
21
|
+
style('.align.center') { align :center }
|
|
22
|
+
}
|
|
23
|
+
end
|
|
38
24
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
should "key styles based off class str and format" do
|
|
26
|
+
assert_equal '', subject.send(:style_key, '', nil)
|
|
27
|
+
assert_equal '.awesome', subject.send(:style_key, 'awesome', nil)
|
|
28
|
+
assert_equal '.awesome.thing', subject.send(:style_key, 'awesome thing', nil)
|
|
29
|
+
assert_equal '.awesome..something', subject.send(:style_key, 'awesome', 'something')
|
|
30
|
+
assert_equal '..something', subject.send(:style_key, '', 'something')
|
|
31
|
+
end
|
|
45
32
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
assert_equal '..number_none_0_nocomma_black', subject.send(:style_id, '', Osheet::Format.new(:number))
|
|
50
|
-
assert_equal 2, subject.styles.size
|
|
51
|
-
end
|
|
33
|
+
should "not build a style obj when writing styles with no class str or format" do
|
|
34
|
+
assert_equal nil, subject.send(:style, '')
|
|
35
|
+
end
|
|
52
36
|
|
|
37
|
+
should "build a style obj and add it to the writers styles" do
|
|
38
|
+
xmlss_style = subject.send(:style, 'awesome')
|
|
39
|
+
assert_kind_of ::Xmlss::Style::Base, xmlss_style
|
|
40
|
+
assert_equal '.awesome', xmlss_style.id
|
|
41
|
+
assert_equal 1, subject.styles.size
|
|
42
|
+
assert_equal xmlss_style, subject.styles.first
|
|
53
43
|
end
|
|
54
|
-
end
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
[
|
|
63
|
-
:left, :center, :right,
|
|
64
|
-
:top, :middle, :bottom,
|
|
65
|
-
:wrap
|
|
66
|
-
].each do |s|
|
|
67
|
-
style(".align.#{s}") { align s }
|
|
68
|
-
end
|
|
69
|
-
style('.align.rotate') { align 90 }
|
|
70
|
-
}
|
|
71
|
-
end
|
|
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?
|
|
50
|
+
end
|
|
72
51
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
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
|
|
57
|
+
end
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
assert_equal ::Xmlss::Style::Alignment.horizontal(:left), subject.send(:style, 'align left').alignment.horizontal
|
|
79
|
-
assert_equal ::Xmlss::Style::Alignment.horizontal(:center), subject.send(:style, 'align center').alignment.horizontal
|
|
80
|
-
assert_equal ::Xmlss::Style::Alignment.horizontal(:right), subject.send(:style, 'align right').alignment.horizontal
|
|
81
|
-
end
|
|
59
|
+
end
|
|
82
60
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
61
|
+
class XmlssWriter::Alignment < XmlssWriter::StylesTest
|
|
62
|
+
desc "Alignment style writer"
|
|
63
|
+
before do
|
|
64
|
+
subject.workbook = Workbook.new {
|
|
65
|
+
[
|
|
66
|
+
:left, :center, :right,
|
|
67
|
+
:top, :middle, :bottom,
|
|
68
|
+
:wrap
|
|
69
|
+
].each do |s|
|
|
70
|
+
style(".align.#{s}") { align s }
|
|
71
|
+
end
|
|
72
|
+
style('.align.rotate') { align 90 }
|
|
73
|
+
}
|
|
74
|
+
end
|
|
88
75
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
76
|
+
should "build a style obj with empty alignment settings by default" do
|
|
77
|
+
assert_equal nil, subject.send(:style, 'align').alignment
|
|
78
|
+
end
|
|
92
79
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
|
84
|
+
end
|
|
96
85
|
|
|
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
|
|
97
90
|
end
|
|
98
|
-
end
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
subject { XmlssWriter::Base.new }
|
|
104
|
-
before do
|
|
105
|
-
subject.workbook = Workbook.new {
|
|
106
|
-
[ :underline, :double_underline, :accounting_underline, :double_accounting_underline,
|
|
107
|
-
:subscript, :superscript, :shadow, :strikethrough, :wrap,
|
|
108
|
-
:bold, :italic
|
|
109
|
-
].each do |s|
|
|
110
|
-
style(".font.#{s}") { font s }
|
|
111
|
-
end
|
|
112
|
-
style('.font.size') { font 14 }
|
|
113
|
-
style('.font.color') { font '#FF0000' }
|
|
114
|
-
}
|
|
115
|
-
end
|
|
92
|
+
should "build style objs for text wrap settings" do
|
|
93
|
+
assert_equal true, subject.send(:style, 'align wrap').alignment.wrap_text?
|
|
94
|
+
end
|
|
116
95
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
96
|
+
should "build style objs for text rotation settings" do
|
|
97
|
+
assert_equal 90, subject.send(:style, 'align rotate').alignment.rotate
|
|
98
|
+
end
|
|
120
99
|
|
|
121
|
-
|
|
122
|
-
assert_equal ::Xmlss::Style::Font.underline(:single), subject.send(:style, 'font underline').font.underline
|
|
123
|
-
assert_equal ::Xmlss::Style::Font.underline(:double), subject.send(:style, 'font double_underline').font.underline
|
|
124
|
-
assert_equal ::Xmlss::Style::Font.underline(:single_accounting), subject.send(:style, 'font accounting_underline').font.underline
|
|
125
|
-
assert_equal ::Xmlss::Style::Font.underline(:double_accounting), subject.send(:style, 'font double_accounting_underline').font.underline
|
|
126
|
-
end
|
|
100
|
+
end
|
|
127
101
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
102
|
+
class XmlssWriter::Font < XmlssWriter::StylesTest
|
|
103
|
+
desc "Font style writer"
|
|
104
|
+
before do
|
|
105
|
+
subject.workbook = Workbook.new {
|
|
106
|
+
[ :underline, :double_underline, :accounting_underline, :double_accounting_underline,
|
|
107
|
+
:subscript, :superscript, :shadow, :strikethrough, :wrap,
|
|
108
|
+
:bold, :italic
|
|
109
|
+
].each do |s|
|
|
110
|
+
style(".font.#{s}") { font s }
|
|
111
|
+
end
|
|
112
|
+
style('.font.size') { font 14 }
|
|
113
|
+
style('.font.color') { font '#FF0000' }
|
|
114
|
+
}
|
|
115
|
+
end
|
|
132
116
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
assert_equal true, subject.send(:style, 'font strikethrough').font.strike_through?
|
|
137
|
-
assert_equal true, subject.send(:style, 'font shadow').font.shadow?
|
|
138
|
-
end
|
|
117
|
+
should "build a style obj with empty font settings by default" do
|
|
118
|
+
assert_equal nil, subject.send(:style, 'font').font
|
|
119
|
+
end
|
|
139
120
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
121
|
+
should "build style objs for font underline settings" do
|
|
122
|
+
assert_equal ::Xmlss::Style::Font.underline(:single), subject.send(:style, 'font underline').font.underline
|
|
123
|
+
assert_equal ::Xmlss::Style::Font.underline(:double), subject.send(:style, 'font double_underline').font.underline
|
|
124
|
+
assert_equal ::Xmlss::Style::Font.underline(:single_accounting), subject.send(:style, 'font accounting_underline').font.underline
|
|
125
|
+
assert_equal ::Xmlss::Style::Font.underline(:double_accounting), subject.send(:style, 'font double_accounting_underline').font.underline
|
|
126
|
+
end
|
|
143
127
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
128
|
+
should "build style objs for font alignment settings" do
|
|
129
|
+
assert_equal ::Xmlss::Style::Font.alignment(:subscript), subject.send(:style, 'font subscript').font.alignment
|
|
130
|
+
assert_equal ::Xmlss::Style::Font.alignment(:superscript), subject.send(:style, 'font superscript').font.alignment
|
|
131
|
+
end
|
|
147
132
|
|
|
133
|
+
should "build style objs for font style settings" do
|
|
134
|
+
assert_equal true, subject.send(:style, 'font bold').font.bold?
|
|
135
|
+
assert_equal true, subject.send(:style, 'font italic').font.italic?
|
|
136
|
+
assert_equal true, subject.send(:style, 'font strikethrough').font.strike_through?
|
|
137
|
+
assert_equal true, subject.send(:style, 'font shadow').font.shadow?
|
|
148
138
|
end
|
|
149
|
-
end
|
|
150
139
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
subject { XmlssWriter::Base.new }
|
|
155
|
-
before do
|
|
156
|
-
subject.workbook = Workbook.new {
|
|
157
|
-
style('.bg.color') { bg '#FF0000' }
|
|
158
|
-
style('.bg.pattern-only') { bg :solid }
|
|
159
|
-
style('.bg.pattern-color') { bg :horz_stripe => '#0000FF' }
|
|
160
|
-
style('.bg.color-first') { bg '#00FF00', {:horz_stripe => '#0000FF'} }
|
|
161
|
-
style('.bg.pattern-first') { bg({:horz_stripe => '#0000FF'}, '#00FF00') }
|
|
162
|
-
}
|
|
163
|
-
end
|
|
140
|
+
should "build style objs for font size" do
|
|
141
|
+
assert_equal 14, subject.send(:style, 'font size').font.size
|
|
142
|
+
end
|
|
164
143
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
should "build style objs for font color" do
|
|
145
|
+
assert_equal '#FF0000', subject.send(:style, 'font color').font.color
|
|
146
|
+
end
|
|
168
147
|
|
|
169
|
-
|
|
170
|
-
assert_equal '#FF0000', subject.send(:style, 'bg color').interior.color
|
|
171
|
-
end
|
|
148
|
+
end
|
|
172
149
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
150
|
+
class XmlssWriter::Bg < XmlssWriter::StylesTest
|
|
151
|
+
desc "Bg writer"
|
|
152
|
+
before do
|
|
153
|
+
subject.workbook = Workbook.new {
|
|
154
|
+
style('.bg.color') { bg '#FF0000' }
|
|
155
|
+
style('.bg.pattern-only') { bg :solid }
|
|
156
|
+
style('.bg.pattern-color') { bg :horz_stripe => '#0000FF' }
|
|
157
|
+
style('.bg.color-first') { bg '#00FF00', {:horz_stripe => '#0000FF'} }
|
|
158
|
+
style('.bg.pattern-first') { bg({:horz_stripe => '#0000FF'}, '#00FF00') }
|
|
159
|
+
}
|
|
160
|
+
end
|
|
179
161
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
162
|
+
should "build a style obj with empty bg settings by default" do
|
|
163
|
+
assert_equal nil, subject.send(:style, 'bg').interior
|
|
164
|
+
end
|
|
183
165
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
166
|
+
should "build style objs for bg color and auto set the pattern to solid" do
|
|
167
|
+
assert_equal '#FF0000', subject.send(:style, 'bg color').interior.color
|
|
168
|
+
end
|
|
187
169
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
170
|
+
should "build style objs for bg pattern settings" do
|
|
171
|
+
assert_equal ::Xmlss::Style::Interior.pattern(:solid), subject.send(:style, 'bg pattern-only').interior.pattern
|
|
172
|
+
assert_equal nil, subject.send(:style, 'bg pattern-only').interior.pattern_color
|
|
173
|
+
assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg pattern-color').interior.pattern
|
|
174
|
+
assert_equal '#0000FF', subject.send(:style, 'bg pattern-color').interior.pattern_color
|
|
175
|
+
end
|
|
191
176
|
|
|
177
|
+
should "set pattern to solid when setting bg color" do
|
|
178
|
+
assert_equal ::Xmlss::Style::Interior.pattern(:solid), subject.send(:style, 'bg color').interior.pattern
|
|
192
179
|
end
|
|
193
|
-
end
|
|
194
180
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
subject { XmlssWriter::Base.new }
|
|
199
|
-
before do
|
|
200
|
-
subject.workbook = Workbook.new {
|
|
201
|
-
::Osheet::Style::BORDER_POSITIONS.each do |p|
|
|
202
|
-
style(".border.#{p}") { send("border_#{p}", :thin) }
|
|
203
|
-
end
|
|
204
|
-
[:hairline, :thin, :medium, :thick].each do |w|
|
|
205
|
-
style(".border.#{w}") { border_top w }
|
|
206
|
-
end
|
|
207
|
-
[:none, :continuous, :dash, :dot, :dash_dot, :dash_dot_dot].each do |s|
|
|
208
|
-
style(".border.#{s}") { border_top s }
|
|
209
|
-
end
|
|
210
|
-
style('.border.color') { border_top '#FF0000' }
|
|
211
|
-
style('.border.all') { border :thick, :dash, '#FF0000' }
|
|
212
|
-
}
|
|
213
|
-
end
|
|
181
|
+
should "set pattern to pattern setting when first setting bg color then pattern" do
|
|
182
|
+
assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg color-first').interior.pattern
|
|
183
|
+
end
|
|
214
184
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
assert_equal [], style.borders
|
|
219
|
-
end
|
|
185
|
+
should "set pattern to pattern setting when first setting bg pattern then color" do
|
|
186
|
+
assert_equal ::Xmlss::Style::Interior.pattern(:horz_stripe), subject.send(:style, 'bg pattern-first').interior.pattern
|
|
187
|
+
end
|
|
220
188
|
|
|
221
|
-
|
|
222
|
-
style = subject.send(:style, 'border all')
|
|
223
|
-
assert_equal 4, style.borders.size
|
|
224
|
-
assert_equal 1, style.borders.collect{|p| p.weight}.uniq.size
|
|
225
|
-
assert_equal 1, style.borders.collect{|p| p.line_style}.uniq.size
|
|
226
|
-
assert_equal 1, style.borders.collect{|p| p.color}.uniq.size
|
|
227
|
-
end
|
|
189
|
+
end
|
|
228
190
|
|
|
229
|
-
|
|
191
|
+
class XmlssWriter::Border < XmlssWriter::StylesTest
|
|
192
|
+
desc "Font border writer"
|
|
193
|
+
before do
|
|
194
|
+
subject.workbook = Workbook.new {
|
|
230
195
|
::Osheet::Style::BORDER_POSITIONS.each do |p|
|
|
231
|
-
|
|
196
|
+
style(".border.#{p}") { send("border_#{p}", :thin) }
|
|
232
197
|
end
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
should "build style objs for border weight settings" do
|
|
236
198
|
[:hairline, :thin, :medium, :thick].each do |w|
|
|
237
|
-
|
|
199
|
+
style(".border.#{w}") { border_top w }
|
|
238
200
|
end
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
should "build style objs for border style settings" do
|
|
242
201
|
[:none, :continuous, :dash, :dot, :dash_dot, :dash_dot_dot].each do |s|
|
|
243
|
-
|
|
202
|
+
style(".border.#{s}") { border_top s }
|
|
244
203
|
end
|
|
245
|
-
|
|
204
|
+
style('.border.color') { border_top '#FF0000' }
|
|
205
|
+
style('.border.all') { border :thick, :dash, '#FF0000' }
|
|
206
|
+
}
|
|
207
|
+
end
|
|
246
208
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
209
|
+
should "build a style obj with empty border settings by default" do
|
|
210
|
+
style = subject.send(:style, 'border')
|
|
211
|
+
assert_kind_of ::Xmlss::ItemSet, style.borders
|
|
212
|
+
assert_equal [], style.borders
|
|
213
|
+
end
|
|
250
214
|
|
|
215
|
+
should "build style objs with identical settings for all positions when using 'border'" do
|
|
216
|
+
style = subject.send(:style, 'border all')
|
|
217
|
+
assert_equal 4, style.borders.size
|
|
218
|
+
assert_equal 1, style.borders.collect{|p| p.weight}.uniq.size
|
|
219
|
+
assert_equal 1, style.borders.collect{|p| p.line_style}.uniq.size
|
|
220
|
+
assert_equal 1, style.borders.collect{|p| p.color}.uniq.size
|
|
251
221
|
end
|
|
252
|
-
end
|
|
253
222
|
|
|
254
|
-
|
|
255
|
-
|
|
223
|
+
should "build style objs for border specific positions" do
|
|
224
|
+
::Osheet::Style::BORDER_POSITIONS.each do |p|
|
|
225
|
+
assert_equal ::Xmlss::Style::Border.position(p), subject.send(:style, "border #{p}").borders.first.position
|
|
226
|
+
end
|
|
227
|
+
end
|
|
256
228
|
|
|
257
|
-
|
|
229
|
+
should "build style objs for border weight settings" do
|
|
230
|
+
[:hairline, :thin, :medium, :thick].each do |w|
|
|
231
|
+
assert_equal ::Xmlss::Style::Border.weight(w), subject.send(:style, "border #{w}").borders.first.weight
|
|
232
|
+
end
|
|
233
|
+
end
|
|
258
234
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
assert_equal
|
|
235
|
+
should "build style objs for border style settings" do
|
|
236
|
+
[:none, :continuous, :dash, :dot, :dash_dot, :dash_dot_dot].each do |s|
|
|
237
|
+
assert_equal ::Xmlss::Style::Border.line_style(s), subject.send(:style, "border #{s}").borders.first.line_style
|
|
262
238
|
end
|
|
239
|
+
end
|
|
263
240
|
|
|
241
|
+
should "build style objs for border color" do
|
|
242
|
+
assert_equal '#FF0000', subject.send(:style, 'border color').borders.first.color
|
|
264
243
|
end
|
|
244
|
+
|
|
265
245
|
end
|
|
266
246
|
|
|
247
|
+
class XmlssWriter::NumberFormat < XmlssWriter::StylesTest
|
|
248
|
+
desc "Xmlss style number format writer"
|
|
249
|
+
|
|
250
|
+
should "build a style obj with formatting" do
|
|
251
|
+
assert_equal '@', subject.send(:style, '', Osheet::Format.new(:text)).number_format.format
|
|
252
|
+
assert_equal 'mm/dd/yy', subject.send(:style, '', Osheet::Format.new(:datetime, 'mm/dd/yy')).number_format.format
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
end
|
|
267
256
|
|
|
268
257
|
end
|