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
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,52 +1,28 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
osheet (0.
|
|
5
|
-
enumeration (~> 1.
|
|
6
|
-
xmlss (~> 0.2
|
|
4
|
+
osheet (0.8.0)
|
|
5
|
+
enumeration (~> 1.2)
|
|
6
|
+
xmlss (~> 0.2)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: http://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
rack (1.2.2)
|
|
20
|
-
rack-test (0.5.7)
|
|
21
|
-
rack (>= 1.0)
|
|
22
|
-
rest-client (1.6.1)
|
|
23
|
-
mime-types (>= 1.16)
|
|
24
|
-
shoulda (2.11.3)
|
|
25
|
-
sinatra (1.2.1)
|
|
26
|
-
rack (~> 1.1)
|
|
27
|
-
tilt (>= 1.2.2, < 2.0)
|
|
28
|
-
test-belt (0.2.1)
|
|
29
|
-
kelredd-useful (~> 0.4.0)
|
|
30
|
-
leftright (~> 0.9.0)
|
|
31
|
-
shoulda (~> 2.11)
|
|
32
|
-
tilt (1.2.2)
|
|
33
|
-
webrat (0.7.3)
|
|
34
|
-
nokogiri (>= 1.2.0)
|
|
35
|
-
rack (>= 1.0)
|
|
36
|
-
rack-test (>= 0.5.3)
|
|
37
|
-
xmlss (0.2.0)
|
|
38
|
-
enumeration (~> 1.1.0)
|
|
11
|
+
ansi (1.3.0)
|
|
12
|
+
assert (0.3.0)
|
|
13
|
+
ansi (~> 1.3)
|
|
14
|
+
enumeration (1.2.1)
|
|
15
|
+
nokogiri (1.4.7)
|
|
16
|
+
rake (0.9.2)
|
|
17
|
+
xmlss (0.2.1)
|
|
18
|
+
enumeration (~> 1.2)
|
|
39
19
|
nokogiri (~> 1.4.0)
|
|
40
20
|
|
|
41
21
|
PLATFORMS
|
|
42
22
|
ruby
|
|
43
23
|
|
|
44
24
|
DEPENDENCIES
|
|
25
|
+
assert (~> 0.3)
|
|
45
26
|
bundler (~> 1.0)
|
|
46
|
-
open4
|
|
47
27
|
osheet!
|
|
48
|
-
|
|
49
|
-
rest-client
|
|
50
|
-
sinatra (>= 0.9.4)
|
|
51
|
-
test-belt (= 0.2.1)
|
|
52
|
-
webrat (>= 0.6.0)
|
|
28
|
+
rake (~> 0.9.2)
|
data/Rakefile
CHANGED
data/lib/osheet/instance.rb
CHANGED
|
@@ -24,9 +24,7 @@ module Osheet::Instance
|
|
|
24
24
|
binding.eval('instance_variables').
|
|
25
25
|
reject{|ivar| ivar =~ /^@#{OSHEET_IVAR_NS}/}.
|
|
26
26
|
each do |ivar|
|
|
27
|
-
|
|
28
|
-
instance_variable_set(ivar, binding.eval(ivar))
|
|
29
|
-
# puts "inst #{ivar}: "+ instance_variable_get(ivar).object_id.to_s
|
|
27
|
+
instance_variable_set(ivar, binding.eval(ivar.to_s))
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
end
|
data/lib/osheet/version.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module Osheet
|
|
2
|
-
VERSION = "0.
|
|
3
|
-
end
|
|
2
|
+
VERSION = "0.8.0"
|
|
3
|
+
end
|
data/osheet.gemspec
CHANGED
|
@@ -18,14 +18,8 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.require_paths = ["lib"]
|
|
19
19
|
|
|
20
20
|
s.add_development_dependency("bundler", ["~> 1.0"])
|
|
21
|
-
s.add_development_dependency("
|
|
22
|
-
s.
|
|
23
|
-
s.
|
|
24
|
-
s.add_development_dependency("webrat", [">= 0.6.0"])
|
|
25
|
-
s.add_development_dependency("open4")
|
|
26
|
-
s.add_development_dependency("rest-client")
|
|
27
|
-
|
|
28
|
-
s.add_dependency("enumeration", ["~>1.1.0"])
|
|
29
|
-
s.add_dependency("xmlss", "~>0.2.0")
|
|
21
|
+
s.add_development_dependency("assert", ["~> 0.3"])
|
|
22
|
+
s.add_dependency("enumeration", ["~> 1.2"])
|
|
23
|
+
s.add_dependency("xmlss", ["~> 0.2"])
|
|
30
24
|
|
|
31
25
|
end
|
data/test/cell_test.rb
CHANGED
|
@@ -1,138 +1,130 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/cell'
|
|
3
3
|
|
|
4
4
|
module Osheet
|
|
5
5
|
|
|
6
|
-
class CellTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class CellTest < Assert::Context
|
|
7
|
+
desc "Osheet::Cell"
|
|
8
|
+
before { @c = Cell.new }
|
|
9
|
+
subject { @c }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
should_be_a_styled_element(Cell)
|
|
12
|
+
should_be_a_worksheet_element(Cell)
|
|
13
|
+
should_be_a_workbook_element(Cell)
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
should "set it's defaults" do
|
|
17
|
-
assert_equal nil, subject.send(:get_ivar, "data")
|
|
18
|
-
assert_kind_of Format::General, subject.send(:get_ivar, "format")
|
|
19
|
-
assert_equal 1, subject.send(:get_ivar, "colspan")
|
|
20
|
-
assert_equal 1, subject.send(:get_ivar, "rowspan")
|
|
21
|
-
assert_equal nil, subject.send(:get_ivar, "href")
|
|
22
|
-
assert_equal nil, subject.send(:get_ivar, "index")
|
|
23
|
-
end
|
|
15
|
+
should have_instance_methods :data, :format, :colspan, :rowspan, :href, :index
|
|
24
16
|
|
|
17
|
+
should "set it's defaults" do
|
|
18
|
+
assert_equal nil, subject.send(:get_ivar, "data")
|
|
19
|
+
assert_kind_of Format::General, subject.send(:get_ivar, "format")
|
|
20
|
+
assert_equal 1, subject.send(:get_ivar, "colspan")
|
|
21
|
+
assert_equal 1, subject.send(:get_ivar, "rowspan")
|
|
22
|
+
assert_equal nil, subject.send(:get_ivar, "href")
|
|
23
|
+
assert_equal nil, subject.send(:get_ivar, "index")
|
|
25
24
|
end
|
|
26
|
-
end
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
style_class 'more poo'
|
|
33
|
-
data "Poo"
|
|
34
|
-
format :number
|
|
35
|
-
colspan 4
|
|
36
|
-
rowspan 2
|
|
37
|
-
index 3
|
|
38
|
-
href "http://www.google.com"
|
|
39
|
-
end
|
|
26
|
+
should "type cast data strings/symbols" do
|
|
27
|
+
['a string', :symbol].each do |thing|
|
|
28
|
+
cell = Cell.new{data thing}
|
|
29
|
+
assert_kind_of ::String, cell.send(:get_ivar, "data")
|
|
40
30
|
end
|
|
31
|
+
end
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
assert_equal 2, subject.send(:get_ivar, "rowspan")
|
|
47
|
-
assert_equal 3, subject.send(:get_ivar, "index")
|
|
48
|
-
assert_equal "http://www.google.com", subject.send(:get_ivar, "href")
|
|
49
|
-
end
|
|
33
|
+
should "type cast data dates" do
|
|
34
|
+
cell = Cell.new{data Date.today}
|
|
35
|
+
assert_kind_of ::Date, cell.send(:get_ivar, "data")
|
|
36
|
+
end
|
|
50
37
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
assert_equal "more poo", subject.attributes[:style_class]
|
|
57
|
-
assert_equal "Poo", subject.attributes[:data]
|
|
58
|
-
assert_kind_of Format::Number, subject.attributes[:format]
|
|
59
|
-
assert_equal 4, subject.attributes[:colspan]
|
|
60
|
-
assert_equal 2, subject.attributes[:rowspan]
|
|
61
|
-
assert_equal 3, subject.attributes[:index]
|
|
62
|
-
assert_equal "http://www.google.com", subject.attributes[:href]
|
|
38
|
+
should "type cast data numerics" do
|
|
39
|
+
[1, 1.0].each do |thing|
|
|
40
|
+
cell = Cell.new{data thing}
|
|
41
|
+
assert_kind_of ::Numeric, cell.send(:get_ivar, "data")
|
|
63
42
|
end
|
|
64
|
-
|
|
65
43
|
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
class CellDataTest < Test::Unit::TestCase
|
|
69
|
-
context "A cell" do
|
|
70
|
-
subject { Cell.new }
|
|
71
44
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
end
|
|
45
|
+
should "type cast all other data to string" do
|
|
46
|
+
[Osheet, [:a, 'Aye'], {:a => 'Aye'}].each do |thing|
|
|
47
|
+
cell = Cell.new{data thing}
|
|
48
|
+
assert_kind_of ::String, cell.send(:get_ivar, "data")
|
|
77
49
|
end
|
|
50
|
+
end
|
|
78
51
|
|
|
79
|
-
|
|
80
|
-
cell = Cell.new{data Date.today}
|
|
81
|
-
assert_kind_of ::Date, cell.send(:get_ivar, "data")
|
|
82
|
-
end
|
|
52
|
+
end
|
|
83
53
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
54
|
+
class CellAttributeTest < CellTest
|
|
55
|
+
desc "a celll that has attributes"
|
|
56
|
+
before do
|
|
57
|
+
@c = Cell.new do
|
|
58
|
+
style_class 'more poo'
|
|
59
|
+
data "Poo"
|
|
60
|
+
format :number
|
|
61
|
+
colspan 4
|
|
62
|
+
rowspan 2
|
|
63
|
+
index 3
|
|
64
|
+
href "http://www.google.com"
|
|
89
65
|
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
should "should set them correctly" do
|
|
69
|
+
assert_equal "Poo", subject.send(:get_ivar, "data")
|
|
70
|
+
assert_kind_of Format::Number, subject.send(:get_ivar, "format")
|
|
71
|
+
assert_equal 4, subject.send(:get_ivar, "colspan")
|
|
72
|
+
assert_equal 2, subject.send(:get_ivar, "rowspan")
|
|
73
|
+
assert_equal 3, subject.send(:get_ivar, "index")
|
|
74
|
+
assert_equal "http://www.google.com", subject.send(:get_ivar, "href")
|
|
75
|
+
end
|
|
90
76
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
assert_kind_of ::String, cell.send(:get_ivar, "data")
|
|
95
|
-
end
|
|
77
|
+
should "know it's attribute(s)" do
|
|
78
|
+
[:style_class, :data, :format, :rowspan, :colspan, :index, :href].each do |a|
|
|
79
|
+
assert subject.attributes.has_key?(a)
|
|
96
80
|
end
|
|
97
81
|
|
|
82
|
+
assert_equal "more poo", subject.attributes[:style_class]
|
|
83
|
+
assert_equal "Poo", subject.attributes[:data]
|
|
84
|
+
assert_kind_of Format::Number, subject.attributes[:format]
|
|
85
|
+
assert_equal 4, subject.attributes[:colspan]
|
|
86
|
+
assert_equal 2, subject.attributes[:rowspan]
|
|
87
|
+
assert_equal 3, subject.attributes[:index]
|
|
88
|
+
assert_equal "http://www.google.com", subject.attributes[:href]
|
|
98
89
|
end
|
|
90
|
+
|
|
99
91
|
end
|
|
100
92
|
|
|
101
|
-
class CellPartialTest <
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
worksheet { row { cell {
|
|
111
|
-
add :cell_stuff
|
|
112
|
-
} } }
|
|
93
|
+
class CellPartialTest < Assert::Context
|
|
94
|
+
desc "A workbook that defines column partials"
|
|
95
|
+
before do
|
|
96
|
+
@wkbk = Workbook.new {
|
|
97
|
+
partial(:cell_stuff) {
|
|
98
|
+
style_class 'more poo'
|
|
99
|
+
data "Poo"
|
|
113
100
|
}
|
|
114
|
-
end
|
|
115
101
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
102
|
+
worksheet { row { cell {
|
|
103
|
+
add :cell_stuff
|
|
104
|
+
} } }
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
subject { @wkbk }
|
|
120
108
|
|
|
109
|
+
should "add it's partials to it's markup" do
|
|
110
|
+
assert_equal 'more poo', subject.worksheets.first.rows.first.cells.first.attributes[:style_class]
|
|
111
|
+
assert_equal 'Poo', subject.worksheets.first.rows.first.cells.first.attributes[:data]
|
|
121
112
|
end
|
|
113
|
+
|
|
122
114
|
end
|
|
123
115
|
|
|
124
|
-
class CellBindingTest <
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
116
|
+
class CellBindingTest < Assert::Context
|
|
117
|
+
desc "a cell defined w/ a block"
|
|
118
|
+
|
|
119
|
+
should "access instance vars from that block's binding" do
|
|
120
|
+
@test = 'test'
|
|
121
|
+
@cell = Cell.new { data @test}
|
|
122
|
+
|
|
123
|
+
assert !@cell.send(:instance_variable_get, "@test").nil?
|
|
124
|
+
assert_equal @test, @cell.send(:instance_variable_get, "@test")
|
|
125
|
+
assert_equal @test.object_id, @cell.send(:instance_variable_get, "@test").object_id
|
|
126
|
+
assert_equal @test, @cell.attributes[:data]
|
|
127
|
+
assert_equal @test.object_id, @cell.attributes[:data].object_id
|
|
136
128
|
end
|
|
137
129
|
end
|
|
138
130
|
|
data/test/column_test.rb
CHANGED
|
@@ -1,128 +1,121 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require "osheet/column"
|
|
3
3
|
|
|
4
4
|
module Osheet
|
|
5
5
|
|
|
6
|
-
class ColumnTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class ColumnTest < Assert::Context
|
|
7
|
+
desc "Osheet::Column"
|
|
8
|
+
before { @c = Column.new }
|
|
9
|
+
subject { @c }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
should_be_a_styled_element(Column)
|
|
12
|
+
should_be_a_worksheet_element(Column)
|
|
13
|
+
should_be_a_workbook_element(Column)
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
should have_instance_method :width
|
|
16
|
+
should have_instance_methods :autofit, :autofit?
|
|
17
|
+
should have_instance_methods :hidden, :hidden?
|
|
18
|
+
should have_instance_method :meta
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
should "set it's defaults" do
|
|
21
|
+
assert_equal nil, subject.send(:get_ivar, "width")
|
|
22
|
+
assert_equal false, subject.send(:get_ivar, "autofit")
|
|
23
|
+
assert !subject.autofit?
|
|
24
|
+
assert_equal false, subject.send(:get_ivar, "hidden")
|
|
25
|
+
assert !subject.hidden?
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
assert_equal nil, subject.meta
|
|
28
|
+
end
|
|
28
29
|
|
|
30
|
+
should "set it's width" do
|
|
31
|
+
subject.width(false)
|
|
32
|
+
assert_equal false, subject.width
|
|
33
|
+
subject.width(180)
|
|
34
|
+
assert_equal 180, subject.width
|
|
35
|
+
subject.width(nil)
|
|
36
|
+
assert_equal 180, subject.width
|
|
29
37
|
end
|
|
30
|
-
end
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
width 100
|
|
38
|
-
autofit true
|
|
39
|
-
hidden true
|
|
40
|
-
meta(
|
|
41
|
-
{}
|
|
42
|
-
)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
39
|
+
should "cast autofit and hidden to bool" do
|
|
40
|
+
col = Column.new { autofit :true; hidden 'false'}
|
|
41
|
+
assert_kind_of ::TrueClass, col.send(:get_ivar, "autofit")
|
|
42
|
+
assert_kind_of ::TrueClass, col.send(:get_ivar, "hidden")
|
|
43
|
+
end
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
assert_equal 100, subject.send(:get_ivar, "width")
|
|
48
|
-
assert_equal true, subject.send(:get_ivar, "autofit")
|
|
49
|
-
assert subject.autofit?
|
|
50
|
-
assert_equal true, subject.send(:get_ivar, "hidden")
|
|
51
|
-
assert subject.hidden?
|
|
52
|
-
assert_equal({}, subject.meta)
|
|
53
|
-
end
|
|
45
|
+
end
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
class ColumnAttributesTest < ColumnTest
|
|
48
|
+
desc "that has attributes"
|
|
49
|
+
before do
|
|
50
|
+
@c = Column.new do
|
|
51
|
+
style_class "more poo"
|
|
52
|
+
width 100
|
|
53
|
+
autofit true
|
|
54
|
+
hidden true
|
|
55
|
+
meta(
|
|
56
|
+
{}
|
|
57
|
+
)
|
|
63
58
|
end
|
|
64
|
-
|
|
65
59
|
end
|
|
66
|
-
end
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
assert_equal 180, subject.width
|
|
77
|
-
subject.width(nil)
|
|
78
|
-
assert_equal 180, subject.width
|
|
79
|
-
end
|
|
61
|
+
should "should set them correctly" do
|
|
62
|
+
assert_equal 100, subject.send(:get_ivar, "width")
|
|
63
|
+
assert_equal true, subject.send(:get_ivar, "autofit")
|
|
64
|
+
assert subject.autofit?
|
|
65
|
+
assert_equal true, subject.send(:get_ivar, "hidden")
|
|
66
|
+
assert subject.hidden?
|
|
67
|
+
assert_equal({}, subject.meta)
|
|
68
|
+
end
|
|
80
69
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
assert_kind_of ::TrueClass, col.send(:get_ivar, "hidden")
|
|
70
|
+
should "know it's attribute(s)" do
|
|
71
|
+
[:style_class, :width, :autofit, :hidden].each do |a|
|
|
72
|
+
assert subject.attributes.has_key?(a)
|
|
85
73
|
end
|
|
86
|
-
|
|
74
|
+
assert_equal 'more poo', subject.attributes[:style_class]
|
|
75
|
+
assert_equal 100, subject.attributes[:width]
|
|
76
|
+
assert_equal true, subject.attributes[:autofit]
|
|
77
|
+
assert_equal true, subject.attributes[:hidden]
|
|
87
78
|
end
|
|
79
|
+
|
|
88
80
|
end
|
|
89
81
|
|
|
90
|
-
class ColumnPartialTest <
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
worksheet { column {
|
|
100
|
-
add :column_stuff
|
|
101
|
-
} }
|
|
82
|
+
class ColumnPartialTest < Assert::Context
|
|
83
|
+
desc "A workbook that defines column partials"
|
|
84
|
+
before do
|
|
85
|
+
@wkbk = Workbook.new {
|
|
86
|
+
partial(:column_stuff) {
|
|
87
|
+
width 200
|
|
88
|
+
meta(:label => 'awesome')
|
|
102
89
|
}
|
|
103
|
-
end
|
|
104
90
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
worksheet { column {
|
|
92
|
+
add :column_stuff
|
|
93
|
+
} }
|
|
94
|
+
}
|
|
95
|
+
end
|
|
96
|
+
subject { @wkbk }
|
|
109
97
|
|
|
98
|
+
should "add it's partials to it's markup" do
|
|
99
|
+
assert_equal 200, subject.worksheets.first.columns.first.width
|
|
100
|
+
assert_equal({:label => 'awesome'}, subject.worksheets.first.columns.first.meta)
|
|
110
101
|
end
|
|
102
|
+
|
|
111
103
|
end
|
|
112
104
|
|
|
113
|
-
class ColumnBindingTest <
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
105
|
+
class ColumnBindingTest < Assert::Context
|
|
106
|
+
desc "a column defined w/ a block"
|
|
107
|
+
|
|
108
|
+
should "access instance vars from that block's binding" do
|
|
109
|
+
@test = 50
|
|
110
|
+
@col = Column.new { width @test }
|
|
111
|
+
|
|
112
|
+
assert !@col.send(:instance_variable_get, "@test").nil?
|
|
113
|
+
assert_equal @test, @col.send(:instance_variable_get, "@test")
|
|
114
|
+
assert_equal @test.object_id, @col.send(:instance_variable_get, "@test").object_id
|
|
115
|
+
assert_equal @test, @col.attributes[:width]
|
|
116
|
+
assert_equal @test.object_id, @col.attributes[:width].object_id
|
|
125
117
|
end
|
|
118
|
+
|
|
126
119
|
end
|
|
127
120
|
|
|
128
121
|
end
|