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
data/test/style_test.rb CHANGED
@@ -1,129 +1,104 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require "osheet/style"
3
3
 
4
4
  module Osheet
5
5
 
6
- class StyleTest < Test::Unit::TestCase
7
- context "Osheet::Style" do
8
- subject { Style.new('.test') }
6
+ class StyleTest < Assert::Context
7
+ desc "Osheet::Style"
8
+ before { @st = Style.new('.test') }
9
+ subject { @st }
9
10
 
10
- should_have_reader :selectors
11
- should_have_instance_methods :align, :font, :bg
12
- should_have_instance_methods :border, :border_left, :border_top, :border_right, :border_bottom
13
- should_have_instance_method :match?
11
+ should have_reader :selectors
12
+ should have_instance_methods :align, :font, :bg
13
+ should have_instance_methods :border, :border_left, :border_top, :border_right, :border_bottom
14
+ should have_instance_method :match?
14
15
 
15
- should "set it's defaults" do
16
- assert_equal 1, subject.selectors.size
17
- assert_equal '.test', subject.selectors.first
18
- [ :align, :font, :bg,
19
- :border_left, :border_top, :border_right, :border_bottom
20
- ].each do |a|
21
- assert_equal [], subject.send(:get_ivar, a)
22
- end
16
+ should "set it's defaults" do
17
+ assert_equal 1, subject.selectors.size
18
+ assert_equal '.test', subject.selectors.first
19
+ [ :align, :font, :bg,
20
+ :border_left, :border_top, :border_right, :border_bottom
21
+ ].each do |a|
22
+ assert_equal [], subject.send(:get_ivar, a)
23
23
  end
24
+ end
24
25
 
25
- should "know it's attribute(s)" do
26
- [ :align, :font, :bg,
27
- :border_left, :border_top, :border_right, :border_bottom
28
- ].each do |a|
29
- assert subject.attributes.has_key?(a)
30
- end
26
+ should "know it's attribute(s)" do
27
+ [ :align, :font, :bg,
28
+ :border_left, :border_top, :border_right, :border_bottom
29
+ ].each do |a|
30
+ assert subject.attributes.has_key?(a)
31
31
  end
32
-
33
32
  end
34
- end
35
-
36
- class StyleSelectorTest < Test::Unit::TestCase
37
- context "A Style" do
38
- subject { Style.new('.test') }
39
33
 
40
- should "complain about bad selectors" do
41
- ['poo', '#poo', 'poo poo', 'poo > poo', :poo, 123].each do |s|
42
- assert_raises ArgumentError do
43
- Style.new(s)
44
- end
34
+ should "complain about bad selectors" do
35
+ ['poo', '#poo', 'poo poo', 'poo > poo', :poo, 123].each do |s|
36
+ assert_raises ArgumentError do
37
+ Style.new(s)
45
38
  end
46
39
  end
40
+ end
47
41
 
48
- should "not complain about good selectors" do
49
- ['.poo', '.poo.poo', '.poo-poo', '.poo_poo'].each do |s|
50
- assert_nothing_raised do
51
- Style.new(s)
52
- end
42
+ should "not complain about good selectors" do
43
+ ['.poo', '.poo.poo', '.poo-poo', '.poo_poo'].each do |s|
44
+ assert_nothing_raised do
45
+ Style.new(s)
53
46
  end
54
47
  end
55
-
56
48
  end
57
- end
58
49
 
59
- class StyleCollectorTest < Test::Unit::TestCase
60
- context "A Style" do
61
- subject { Style.new }
62
-
63
- [ :align, :font, :bg,
64
- :border_left, :border_top, :border_right, :border_bottom
65
- ].each do |a|
66
- should "collect styles for #{a}" do
67
- args = [1, "#FF0000", "Verdana", :love, 1.2]
68
- subject.send(a, *args)
69
- assert_equal args, subject.send(:get_ivar, a)
70
- end
50
+ [ :align, :font, :bg,
51
+ :border_left, :border_top, :border_right, :border_bottom
52
+ ].each do |a|
53
+ should "collect styles for #{a}" do
54
+ args = [1, "#FF0000", "Verdana", :love, 1.2]
55
+ subject.send(a, *args)
56
+ assert_equal args, subject.send(:get_ivar, a)
71
57
  end
58
+ end
72
59
 
73
- should "set all border positions to the same styles using 'border' macro collector" do
74
- args = [:thick, '#FF00FF', :dot]
75
- subject.border *args
76
- [ :border_left, :border_top, :border_right, :border_bottom].each do |a|
77
- assert_equal args, subject.send(:get_ivar, a)
78
- end
60
+ should "set all border positions to the same styles using 'border' macro collector" do
61
+ args = [:thick, '#FF00FF', :dot]
62
+ subject.border *args
63
+ [ :border_left, :border_top, :border_right, :border_bottom].each do |a|
64
+ assert_equal args, subject.send(:get_ivar, a)
79
65
  end
80
-
81
66
  end
82
- end
83
-
84
- class StyleMatcherTest < Test::Unit::TestCase
85
- context "A Style" do
86
- subject { Style.new }
87
67
 
88
- should "match on style class strings" do
89
- a = Style.new('.awesome') {}
90
- at = Style.new('.awesome.thing') {}
91
- b = Style.new('.boring') {}
92
- bt = Style.new('.boring.thing') {}
93
- a_b = Style.new('.awesome', '.boring') {}
94
- t = Style.new('.thing') {}
95
- s = Style.new('.stupid') {}
96
-
97
- { 'awesome' => [a, a_b],
98
- 'boring' => [b, a_b],
99
- 'thing' => [t],
100
- 'awesome thing' => [a, at, a_b, t],
101
- 'thing awesome' => [a, at, a_b, t],
102
- 'other' => []
103
- }.each do |style_class, styles|
104
- styles.each do |style|
105
- assert_equal true, style.match?(style_class)
106
- end
68
+ should "match on style class strings" do
69
+ a = Style.new('.awesome') {}
70
+ at = Style.new('.awesome.thing') {}
71
+ b = Style.new('.boring') {}
72
+ bt = Style.new('.boring.thing') {}
73
+ a_b = Style.new('.awesome', '.boring') {}
74
+ t = Style.new('.thing') {}
75
+ s = Style.new('.stupid') {}
76
+
77
+ { 'awesome' => [a, a_b],
78
+ 'boring' => [b, a_b],
79
+ 'thing' => [t],
80
+ 'awesome thing' => [a, at, a_b, t],
81
+ 'thing awesome' => [a, at, a_b, t],
82
+ 'other' => []
83
+ }.each do |style_class, styles|
84
+ styles.each do |style|
85
+ assert_equal true, style.match?(style_class)
107
86
  end
108
- assert_equal false, a.match?('stupid')
109
87
  end
110
-
88
+ assert_equal false, a.match?('stupid')
111
89
  end
112
- end
113
90
 
114
- class StyleBindingTest < Test::Unit::TestCase
115
- context "a style defined w/ a block" do
116
- should "access instance vars from that block's binding" do
117
- @test = 20
118
- @style = Style.new('.test') { font @test }
91
+ should "access instance vars from that block's binding" do
92
+ @test = 20
93
+ @style = Style.new('.test') { font @test }
119
94
 
120
- assert !@style.send(:instance_variable_get, "@test").nil?
121
- assert_equal @test, @style.send(:instance_variable_get, "@test")
122
- assert_equal @test.object_id, @style.send(:instance_variable_get, "@test").object_id
123
- assert_equal @test, @style.attributes[:font].first
124
- assert_equal @test.object_id, @style.attributes[:font].first.object_id
125
- end
95
+ assert !@style.send(:instance_variable_get, "@test").nil?
96
+ assert_equal @test, @style.send(:instance_variable_get, "@test")
97
+ assert_equal @test.object_id, @style.send(:instance_variable_get, "@test").object_id
98
+ assert_equal @test, @style.attributes[:font].first
99
+ assert_equal @test.object_id, @style.attributes[:font].first.object_id
126
100
  end
101
+
127
102
  end
128
103
 
129
104
  end
@@ -1,95 +1,74 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require "osheet/template_set"
3
3
 
4
4
  module Osheet
5
- class TemplateSetTest < Test::Unit::TestCase
6
-
7
- context "Osheet::TemplateSet" do
8
- subject { TemplateSet.new }
9
-
10
- should "be a PartialSet" do
11
- assert_kind_of PartialSet, subject
12
- end
13
-
14
- should "verify set objs are templates" do
15
- assert_raises ArgumentError do
16
- subject.send(:verify, {})
17
- end
18
- assert_nothing_raised do
19
- subject.send(:verify, Template.new(:row, :poo) {})
20
- end
21
- end
5
+ class TemplateSetTest < Assert::Context
6
+ desc "Osheet::TemplateSet"
7
+ before { @set = TemplateSet.new }
8
+ subject { @set }
22
9
 
10
+ should "be a PartialSet" do
11
+ assert_kind_of PartialSet, subject
23
12
  end
24
- end
25
-
26
- class TemplateSetKeyTest < Test::Unit::TestCase
27
- context "A template set" do
28
- subject { TemplateSet.new }
29
13
 
30
- should "key templates using an array of their element and name" do
31
- assert_equal ['row','poo'], subject.send(:key, :row, :poo)
14
+ should "verify set objs are templates" do
15
+ assert_raises ArgumentError do
16
+ subject.send(:verify, {})
32
17
  end
33
-
34
- should "key on templates objs" do
35
- assert_equal ['row', 'poo'], subject.send(:template_key, Template.new(:row, :poo) {})
18
+ assert_nothing_raised do
19
+ subject.send(:verify, Template.new(:row, :poo) {})
36
20
  end
21
+ end
37
22
 
38
- should "init the key in the set when verifying" do
39
- key = subject.send(:verify, Template.new(:row, :poo) {})
40
- assert_equal ['row', 'poo'], key
41
- assert_equal({
42
- key.first => { key.last => nil }
43
- }, subject)
44
- end
23
+ should "key templates using an array of their element and name" do
24
+ assert_equal ['row','poo'], subject.send(:key, :row, :poo)
25
+ end
45
26
 
27
+ should "key on templates objs" do
28
+ assert_equal ['row', 'poo'], subject.send(:template_key, Template.new(:row, :poo) {})
46
29
  end
47
- end
48
30
 
49
- class TemplateSetPushTest < Test::Unit::TestCase
50
- context "A template set" do
51
- subject { TemplateSet.new }
52
- should "push templates onto the set" do
53
- assert_nothing_raised do
54
- subject << Template.new(:row, :poo) {}
55
- subject << Template.new(:row, :not_poo) {}
56
- subject << Template.new(:column, :awesome) {}
57
- subject << Template.new(:column, :not_awesome) {}
58
- end
31
+ should "init the key in the set when verifying" do
32
+ key = subject.send(:verify, Template.new(:row, :poo) {})
33
+ assert_equal ['row', 'poo'], key
34
+ assert_equal({
35
+ key.first => { key.last => nil }
36
+ }, subject)
37
+ end
59
38
 
60
- assert_equal 2, subject.keys.size
61
- assert subject["row"]
62
- assert_equal 2, subject["row"].keys.size
63
- assert subject["row"]["poo"]
64
- assert_kind_of Template, subject["row"]["poo"]
65
- assert subject["row"]["not_poo"]
66
- assert_kind_of Template, subject["row"]["not_poo"]
67
- assert subject["column"]
68
- assert_equal 2, subject["column"].keys.size
69
- assert subject["column"]["awesome"]
70
- assert_kind_of Template, subject["column"]["awesome"]
71
- assert subject["column"]["not_awesome"]
72
- assert_kind_of Template, subject["column"]["not_awesome"]
39
+ should "push templates onto the set" do
40
+ assert_nothing_raised do
41
+ subject << Template.new(:row, :poo) {}
42
+ subject << Template.new(:row, :not_poo) {}
43
+ subject << Template.new(:column, :awesome) {}
44
+ subject << Template.new(:column, :not_awesome) {}
73
45
  end
74
46
 
47
+ assert_equal 2, subject.keys.size
48
+ assert subject["row"]
49
+ assert_equal 2, subject["row"].keys.size
50
+ assert subject["row"]["poo"]
51
+ assert_kind_of Template, subject["row"]["poo"]
52
+ assert subject["row"]["not_poo"]
53
+ assert_kind_of Template, subject["row"]["not_poo"]
54
+ assert subject["column"]
55
+ assert_equal 2, subject["column"].keys.size
56
+ assert subject["column"]["awesome"]
57
+ assert_kind_of Template, subject["column"]["awesome"]
58
+ assert subject["column"]["not_awesome"]
59
+ assert_kind_of Template, subject["column"]["not_awesome"]
75
60
  end
76
- end
77
61
 
78
- class TemplateSetLookupTest < Test::Unit::TestCase
79
- context "A template set" do
80
- subject { TemplateSet.new }
81
-
82
- should "lookup a template by element, name" do
83
- t = Template.new(:row, :poo) {}
84
- subject << t
85
- assert_equal t, subject.get(:row, :poo)
86
- assert_equal t, subject.get('row', 'poo')
87
-
88
- assert_equal nil, subject.get(:row, :ugh)
89
- assert_equal nil, subject.get(:col, :ugh)
90
- end
62
+ should "lookup a template by element, name" do
63
+ t = Template.new(:row, :poo) {}
64
+ subject << t
65
+ assert_equal t, subject.get(:row, :poo)
66
+ assert_equal t, subject.get('row', 'poo')
91
67
 
68
+ assert_equal nil, subject.get(:row, :ugh)
69
+ assert_equal nil, subject.get(:col, :ugh)
92
70
  end
71
+
93
72
  end
94
73
 
95
74
  end
@@ -1,66 +1,48 @@
1
- require "test/helper"
1
+ require "assert"
2
2
  require "osheet/template"
3
3
 
4
4
  module Osheet
5
5
 
6
- class TemplateTest < Test::Unit::TestCase
7
- context "Osheet::Template" do
8
- subject do
9
- Template.new('column', :thing) {}
10
- end
6
+ class TemplateTest < Assert::Context
7
+ desc "Osheet::Template"
8
+ before do
9
+ @tmpl = Template.new('column', :thing) {}
10
+ end
11
+ subject { @tmpl }
11
12
 
12
- should "define what elements it is valid for" do
13
- assert_equal ['worksheet', 'column', 'row', 'cell'], Template::ELEMENTS
14
- end
13
+ should "define what elements it is valid for" do
14
+ assert_equal ['worksheet', 'column', 'row', 'cell'], Template::ELEMENTS
15
+ end
15
16
 
16
- should_have_accessor :element
17
+ should have_accessor :element
17
18
 
18
- should "be a Partial" do
19
- assert_kind_of Partial, subject
20
- end
21
-
22
- should "convert the element ars to string and store off" do
23
- assert_equal 'column', subject.element
24
- end
19
+ should "be a Partial" do
20
+ assert_kind_of Partial, subject
21
+ end
25
22
 
23
+ should "convert the element ars to string and store off" do
24
+ assert_equal 'column', subject.element
26
25
  end
26
+
27
27
  end
28
28
 
29
- class TemplateElementTest < Test::Unit::TestCase
30
- context "a template" do
31
- should "verify the element argument" do
32
- assert_raises ArgumentError do
33
- Template.new({}, :poo) {}
34
- end
35
- assert_raises ArgumentError do
36
- Template.new('workbook', :poo) {}
37
- end
38
- Template::ELEMENTS.each do |elem|
39
- assert_nothing_raised do
40
- Template.new(elem, :poo) {}
41
- end
29
+ class TemplateElementTest < TemplateTest
30
+ desc "a template"
31
+
32
+ should "verify the element argument" do
33
+ assert_raises ArgumentError do
34
+ Template.new({}, :poo) {}
35
+ end
36
+ assert_raises ArgumentError do
37
+ Template.new('workbook', :poo) {}
38
+ end
39
+ Template::ELEMENTS.each do |elem|
40
+ assert_nothing_raised do
41
+ Template.new(elem, :poo) {}
42
42
  end
43
43
  end
44
-
45
44
  end
46
- end
47
45
 
48
- # class TemplateBindingTest < Test::Unit::TestCase
49
- # context "a template defined w/ a block" do
50
- # should "access instance vars from that block's binding" do
51
- # @test = 'test thing'
52
- # @workbook = Workbook.new {
53
- # template('worksheet', :thing) { name @test }
54
- # worksheet(:thing)
55
- # }
56
- #
57
- # assert !@workbook.worksheets.first.send(:instance_variable_get, "@test").nil?
58
- # assert_equal @test, @workbook.worksheets.first.send(:instance_variable_get, "@test")
59
- # assert_equal @test.object_id, @workbook.worksheets.first.send(:instance_variable_get, "@test").object_id
60
- # assert_equal @test, @workbook.worksheets.first.attributes[:name]
61
- # assert_equal @test.object_id, @workbook.worksheets.first.attributes[:name].object_id
62
- # end
63
- # end
64
- # end
46
+ end
65
47
 
66
48
  end