osheet 1.0.0.rc.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -6
- data/Gemfile +3 -4
- data/LICENSE.txt +22 -0
- data/README.md +129 -0
- data/Rakefile +1 -7
- data/lib/osheet/cell.rb +0 -1
- data/lib/osheet/column.rb +3 -2
- data/lib/osheet/format.rb +9 -9
- data/lib/osheet/format/accounting.rb +0 -1
- data/lib/osheet/format/currency.rb +1 -1
- data/lib/osheet/format/custom.rb +0 -1
- data/lib/osheet/format/datetime.rb +0 -1
- data/lib/osheet/format/fraction.rb +0 -1
- data/lib/osheet/format/general.rb +2 -2
- data/lib/osheet/format/number.rb +0 -1
- data/lib/osheet/format/numeric.rb +2 -1
- data/lib/osheet/format/percentage.rb +2 -1
- data/lib/osheet/format/scientific.rb +2 -1
- data/lib/osheet/format/special.rb +0 -1
- data/lib/osheet/format/text.rb +0 -1
- data/lib/osheet/mixin.rb +1 -0
- data/lib/osheet/row.rb +0 -1
- data/lib/osheet/style.rb +1 -0
- data/lib/osheet/styled_element.rb +1 -0
- data/lib/osheet/version.rb +1 -1
- data/lib/osheet/workbook.rb +0 -4
- data/lib/osheet/workbook_element.rb +0 -10
- data/osheet.gemspec +18 -16
- data/test/helper.rb +6 -2
- data/test/{fixtures → support}/mixins.rb +0 -0
- data/test/{fixtures → support}/test_writer.rb +0 -0
- data/test/{cell_test.rb → unit/cell_tests.rb} +15 -12
- data/test/{column_test.rb → unit/column_tests.rb} +10 -9
- data/test/{format/accounting_test.rb → unit/format/accounting_tests.rb} +35 -26
- data/test/{format/currency_test.rb → unit/format/currency_tests.rb} +35 -26
- data/test/{format/custom_test.rb → unit/format/custom_tests.rb} +6 -5
- data/test/{format/datetime_test.rb → unit/format/datetime_tests.rb} +6 -5
- data/test/{format/fraction_test.rb → unit/format/fraction_tests.rb} +16 -16
- data/test/{format/general_test.rb → unit/format/general_tests.rb} +5 -5
- data/test/unit/format/number_tests.rb +96 -0
- data/test/{format/percentage_test.rb → unit/format/percentage_tests.rb} +32 -23
- data/test/{format/scientific_test.rb → unit/format/scientific_tests.rb} +31 -23
- data/test/{format/special_test.rb → unit/format/special_tests.rb} +11 -11
- data/test/{format/text_test.rb → unit/format/text_tests.rb} +4 -4
- data/test/{format_test.rb → unit/format_tests.rb} +8 -7
- data/test/{mixin_test.rb → unit/mixin_tests.rb} +11 -10
- data/test/{partial_test.rb → unit/partial_tests.rb} +13 -10
- data/test/{row_test.rb → unit/row_tests.rb} +11 -10
- data/test/{style_test.rb → unit/style_tests.rb} +13 -14
- data/test/{template_test.rb → unit/template_tests.rb} +15 -12
- data/test/{workbook_element_test.rb → unit/workbook_element_tests.rb} +48 -54
- data/test/{workbook_test.rb → unit/workbook_tests.rb} +34 -30
- data/test/{worksheet_test.rb → unit/worksheet_tests.rb} +13 -13
- metadata +70 -76
- data/Gemfile.lock +0 -27
- data/README.rdoc +0 -133
- data/test/format/number_test.rb +0 -91
- data/test/irb.rb +0 -9
@@ -3,7 +3,6 @@ require 'osheet/worksheet'
|
|
3
3
|
|
4
4
|
module Osheet
|
5
5
|
|
6
|
-
|
7
6
|
class WorkbookElement
|
8
7
|
|
9
8
|
# This 'WorkbookElement' class handles all workbook state. It is setup
|
@@ -60,8 +59,6 @@ module Osheet
|
|
60
59
|
|
61
60
|
end
|
62
61
|
|
63
|
-
|
64
|
-
|
65
62
|
class WorkbookElement::PartialSet
|
66
63
|
|
67
64
|
# this class is a Hash that behaves kinda like a set. I want to
|
@@ -116,8 +113,6 @@ module Osheet
|
|
116
113
|
|
117
114
|
end
|
118
115
|
|
119
|
-
|
120
|
-
|
121
116
|
class WorkbookElement::TemplateSet < WorkbookElement::PartialSet
|
122
117
|
|
123
118
|
# this class is a PartialSet that keys off of the template element
|
@@ -166,8 +161,6 @@ module Osheet
|
|
166
161
|
|
167
162
|
end
|
168
163
|
|
169
|
-
|
170
|
-
|
171
164
|
class WorkbookElement::StyleSet < ::Array
|
172
165
|
|
173
166
|
# this class is an Array with some helper methods. I want to
|
@@ -201,8 +194,6 @@ module Osheet
|
|
201
194
|
|
202
195
|
end
|
203
196
|
|
204
|
-
|
205
|
-
|
206
197
|
class WorkbookElement::WorksheetSet < ::Array
|
207
198
|
|
208
199
|
# this class is just a wrapper to Array. I want to push worksheets
|
@@ -230,5 +221,4 @@ module Osheet
|
|
230
221
|
|
231
222
|
end
|
232
223
|
|
233
|
-
|
234
224
|
end
|
data/osheet.gemspec
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
4
|
require "osheet/version"
|
4
5
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "osheet"
|
8
|
+
gem.version = Osheet::VERSION
|
9
|
+
gem.authors = ["Kelly Redding"]
|
10
|
+
gem.email = ["kelly@kellyredding.com"]
|
11
|
+
gem.summary = %q{A DSL for specifying and generating spreadsheets using Ruby}
|
12
|
+
gem.description = %q{A DSL for specifying and generating spreadsheets using Ruby}
|
13
|
+
gem.homepage = "http://github.com/kellyredding/osheet"
|
14
|
+
gem.license = 'MIT'
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
gem.add_development_dependency("assert", ["~> 2.0"])
|
22
|
+
|
23
|
+
gem.add_dependency("enumeration", ["~> 1.3"])
|
22
24
|
|
23
25
|
end
|
data/test/helper.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
# this file is automatically required
|
1
|
+
# this file is automatically required when you run `assert`
|
2
|
+
# put any test helpers here
|
2
3
|
|
3
|
-
# add root dir to the load path
|
4
|
+
# add the root dir to the load path
|
4
5
|
$LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
|
5
6
|
|
7
|
+
# require pry for debugging (`binding.pry`)
|
8
|
+
require 'pry'
|
9
|
+
|
6
10
|
class Assert::Context
|
7
11
|
|
8
12
|
# Macros
|
File without changes
|
File without changes
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/cell'
|
3
3
|
|
4
|
-
|
4
|
+
require 'osheet/format/general'
|
5
|
+
require 'osheet/format/datetime'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
class Osheet::Cell
|
8
|
+
|
9
|
+
class UnitTests < Assert::Context
|
10
|
+
desc "Osheet::Cell"
|
11
|
+
before{ @c = Osheet::Cell.new }
|
12
|
+
subject{ @c }
|
10
13
|
|
11
14
|
should be_a_styled_element
|
12
15
|
should be_a_meta_element
|
@@ -21,32 +24,32 @@ module Osheet
|
|
21
24
|
assert_equal nil, subject.href
|
22
25
|
assert_equal nil, subject.index
|
23
26
|
assert_equal nil, subject.formula
|
24
|
-
assert_kind_of Format::General, subject.format
|
27
|
+
assert_kind_of Osheet::Format::General, subject.format
|
25
28
|
end
|
26
29
|
|
27
30
|
should "set its data from an init arg" do
|
28
|
-
assert_equal "something", Cell.new("something").data
|
31
|
+
assert_equal "something", Osheet::Cell.new("something").data
|
29
32
|
end
|
30
33
|
|
31
34
|
should "type cast data strings/symbols" do
|
32
35
|
['a string', :symbol].each do |thing|
|
33
36
|
subject.data thing
|
34
37
|
assert_kind_of ::String, subject.data
|
35
|
-
assert_kind_of ::String, Cell.new(thing).data
|
38
|
+
assert_kind_of ::String, Osheet::Cell.new(thing).data
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
42
|
should "type cast data dates" do
|
40
43
|
subject.data Date.today
|
41
44
|
assert_kind_of ::Date, subject.data
|
42
|
-
assert_kind_of ::Date, Cell.new(Date.today).data
|
45
|
+
assert_kind_of ::Date, Osheet::Cell.new(Date.today).data
|
43
46
|
end
|
44
47
|
|
45
48
|
should "type cast data numerics" do
|
46
49
|
[1, 1.0].each do |thing|
|
47
50
|
subject.data thing
|
48
51
|
assert_kind_of ::Numeric, subject.data
|
49
|
-
assert_kind_of ::Numeric, Cell.new(thing).data
|
52
|
+
assert_kind_of ::Numeric, Osheet::Cell.new(thing).data
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
@@ -54,7 +57,7 @@ module Osheet
|
|
54
57
|
[Osheet, [:a, 'Aye'], {:a => 'Aye'}].each do |thing|
|
55
58
|
subject.data thing
|
56
59
|
assert_kind_of ::String, subject.data
|
57
|
-
assert_kind_of ::String, Cell.new(thing).data
|
60
|
+
assert_kind_of ::String, Osheet::Cell.new(thing).data
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
@@ -62,7 +65,7 @@ module Osheet
|
|
62
65
|
subject.data Time.now
|
63
66
|
subject.format :datetime, 'mm/dd/yyyy'
|
64
67
|
|
65
|
-
assert_kind_of Format::Datetime, subject.format
|
68
|
+
assert_kind_of Osheet::Format::Datetime, subject.format
|
66
69
|
end
|
67
70
|
|
68
71
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require "assert"
|
2
|
-
|
3
2
|
require "osheet/column"
|
4
3
|
|
5
|
-
|
4
|
+
require 'osheet/format/general'
|
5
|
+
|
6
|
+
class Osheet::Column
|
6
7
|
|
7
|
-
class
|
8
|
-
desc "
|
9
|
-
before
|
10
|
-
subject
|
8
|
+
class UnitTests < Assert::Context
|
9
|
+
desc "Osheet::Column"
|
10
|
+
before{ @c = Osheet::Column.new }
|
11
|
+
subject{ @c }
|
11
12
|
|
12
13
|
should be_a_styled_element
|
13
14
|
should be_a_meta_element
|
@@ -23,7 +24,7 @@ module Osheet
|
|
23
24
|
assert !subject.autofit?
|
24
25
|
assert_equal false, subject.hidden
|
25
26
|
assert !subject.hidden?
|
26
|
-
assert_kind_of Format::General, subject.format
|
27
|
+
assert_kind_of Osheet::Format::General, subject.format
|
27
28
|
end
|
28
29
|
|
29
30
|
should "set it's width" do
|
@@ -36,11 +37,11 @@ module Osheet
|
|
36
37
|
subject.width(nil)
|
37
38
|
assert_equal 180, subject.width
|
38
39
|
|
39
|
-
assert_equal 200, Column.new(200).width
|
40
|
+
assert_equal 200, Osheet::Column.new(200).width
|
40
41
|
end
|
41
42
|
|
42
43
|
should "cast autofit and hidden to bool" do
|
43
|
-
col = Column.new
|
44
|
+
col = Osheet::Column.new
|
44
45
|
col.autofit :true
|
45
46
|
col.hidden 'false'
|
46
47
|
|
@@ -1,26 +1,26 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/accounting'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Accounting
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "Accounting format"
|
8
|
-
before
|
9
|
-
subject
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Accounting format"
|
8
|
+
before{ @f = Osheet::Format::Accounting.new }
|
9
|
+
subject{ @f }
|
10
10
|
|
11
11
|
should have_accessors :decimal_places, :symbol, :comma_separator, :negative_numbers
|
12
12
|
|
13
13
|
should "provide symbol options" do
|
14
|
-
assert_equal 3, Accounting.symbol_set.size
|
14
|
+
assert_equal 3, Osheet::Format::Accounting.symbol_set.size
|
15
15
|
[:none, :dollar, :euro].each do |a|
|
16
|
-
assert Accounting.symbol_set.include?(a)
|
16
|
+
assert Osheet::Format::Accounting.symbol_set.include?(a)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
should "provide negative numbers options" do
|
21
|
-
assert_equal 4, Accounting.negative_numbers_set.size
|
21
|
+
assert_equal 4, Osheet::Format::Accounting.negative_numbers_set.size
|
22
22
|
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
23
|
-
assert Accounting.negative_numbers_set.include?(a)
|
23
|
+
assert Osheet::Format::Accounting.negative_numbers_set.include?(a)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -33,27 +33,31 @@ module Osheet::Format
|
|
33
33
|
|
34
34
|
should "only allow Fixnum decimal places between 0 and 30" do
|
35
35
|
assert_raises ArgumentError do
|
36
|
-
Accounting.new({:decimal_places => -1})
|
36
|
+
Osheet::Format::Accounting.new({:decimal_places => -1})
|
37
37
|
end
|
38
|
+
|
38
39
|
assert_raises ArgumentError do
|
39
|
-
Accounting.new({:decimal_places => 31})
|
40
|
+
Osheet::Format::Accounting.new({:decimal_places => 31})
|
40
41
|
end
|
42
|
+
|
41
43
|
assert_raises ArgumentError do
|
42
|
-
Accounting.new({:decimal_places => 'poo'})
|
44
|
+
Osheet::Format::Accounting.new({:decimal_places => 'poo'})
|
43
45
|
end
|
46
|
+
|
44
47
|
assert_nothing_raised do
|
45
|
-
Accounting.new({:decimal_places => 1})
|
48
|
+
Osheet::Format::Accounting.new({:decimal_places => 1})
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
52
|
should "generate decimal place style strings" do
|
50
|
-
assert_equal "0", Accounting.new({
|
53
|
+
assert_equal "0", Osheet::Format::Accounting.new({
|
51
54
|
:decimal_places => 0,
|
52
55
|
:comma_separator => false,
|
53
56
|
:symbol => :none
|
54
57
|
}).style
|
58
|
+
|
55
59
|
(1..5).each do |n|
|
56
|
-
assert_equal "0.#{'0'*n}", Accounting.new({
|
60
|
+
assert_equal "0.#{'0'*n}", Osheet::Format::Accounting.new({
|
57
61
|
:decimal_places => n,
|
58
62
|
:comma_separator => false,
|
59
63
|
:symbol => :none
|
@@ -62,12 +66,13 @@ module Osheet::Format
|
|
62
66
|
end
|
63
67
|
|
64
68
|
should "generate comma separator style strings" do
|
65
|
-
assert_equal "0", Accounting.new({
|
69
|
+
assert_equal "0", Osheet::Format::Accounting.new({
|
66
70
|
:comma_separator => false,
|
67
71
|
:decimal_places => 0,
|
68
72
|
:symbol => :none
|
69
73
|
}).style
|
70
|
-
|
74
|
+
|
75
|
+
assert_equal "#,##0", Osheet::Format::Accounting.new({
|
71
76
|
:comma_separator => true,
|
72
77
|
:decimal_places => 0,
|
73
78
|
:symbol => :none
|
@@ -75,13 +80,14 @@ module Osheet::Format
|
|
75
80
|
end
|
76
81
|
|
77
82
|
should "generate parenth negative numbers style strings" do
|
78
|
-
assert_equal "0", Accounting.new({
|
83
|
+
assert_equal "0", Osheet::Format::Accounting.new({
|
79
84
|
:negative_numbers => :black,
|
80
85
|
:decimal_places => 0,
|
81
86
|
:comma_separator => false,
|
82
87
|
:symbol => :none
|
83
88
|
}).style
|
84
|
-
|
89
|
+
|
90
|
+
assert_equal "0_);\(0\)", Osheet::Format::Accounting.new({
|
85
91
|
:negative_numbers => :black_parenth,
|
86
92
|
:decimal_places => 0,
|
87
93
|
:comma_separator => false,
|
@@ -90,13 +96,14 @@ module Osheet::Format
|
|
90
96
|
end
|
91
97
|
|
92
98
|
should "generate red negative numbers style strings" do
|
93
|
-
assert_equal "0;[Red]0", Accounting.new({
|
99
|
+
assert_equal "0;[Red]0", Osheet::Format::Accounting.new({
|
94
100
|
:negative_numbers => :red,
|
95
101
|
:decimal_places => 0,
|
96
102
|
:comma_separator => false,
|
97
103
|
:symbol => :none
|
98
104
|
}).style
|
99
|
-
|
105
|
+
|
106
|
+
assert_equal "0_);[Red]\(0\)", Osheet::Format::Accounting.new({
|
100
107
|
:negative_numbers => :red_parenth,
|
101
108
|
:decimal_places => 0,
|
102
109
|
:comma_separator => false,
|
@@ -105,12 +112,13 @@ module Osheet::Format
|
|
105
112
|
end
|
106
113
|
|
107
114
|
should "generate symbol style strings" do
|
108
|
-
assert_equal "0", Accounting.new({
|
115
|
+
assert_equal "0", Osheet::Format::Accounting.new({
|
109
116
|
:decimal_places => 0,
|
110
117
|
:comma_separator => false,
|
111
118
|
:symbol => :none
|
112
119
|
}).style
|
113
|
-
|
120
|
+
|
121
|
+
assert_equal "\"$\"* 0", Osheet::Format::Accounting.new({
|
114
122
|
:decimal_places => 0,
|
115
123
|
:comma_separator => false,
|
116
124
|
:symbol => :dollar
|
@@ -118,7 +126,7 @@ module Osheet::Format
|
|
118
126
|
end
|
119
127
|
|
120
128
|
should "generate complex style string" do
|
121
|
-
assert_equal("\"$\"* 0.00_);\(\"$\"* 0.00\)", Accounting.new({
|
129
|
+
assert_equal("\"$\"* 0.00_);\(\"$\"* 0.00\)", Osheet::Format::Accounting.new({
|
122
130
|
:symbol => :dollar,
|
123
131
|
:decimal_places => 2,
|
124
132
|
:negative_numbers => :black_parenth,
|
@@ -127,12 +135,13 @@ module Osheet::Format
|
|
127
135
|
end
|
128
136
|
|
129
137
|
should "provide unique format keys" do
|
130
|
-
assert_equal("accounting_dollar_2_nocomma_blackparenth", Accounting.new({
|
138
|
+
assert_equal("accounting_dollar_2_nocomma_blackparenth", Osheet::Format::Accounting.new({
|
131
139
|
:decimal_places => 2,
|
132
140
|
:negative_numbers => :black_parenth,
|
133
141
|
:comma_separator => false
|
134
142
|
}).key)
|
135
|
-
|
143
|
+
|
144
|
+
assert_equal("accounting_none_4_comma_redparenth", Osheet::Format::Accounting.new({
|
136
145
|
:symbol => :none,
|
137
146
|
:decimal_places => 4,
|
138
147
|
:negative_numbers => :red_parenth,
|
@@ -1,26 +1,26 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/currency'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Currency
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "Currency format"
|
8
|
-
before
|
9
|
-
subject
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Currency format"
|
8
|
+
before{ @f = Osheet::Format::Currency.new }
|
9
|
+
subject{ @f }
|
10
10
|
|
11
11
|
should have_accessors :decimal_places, :symbol, :comma_separator, :negative_numbers
|
12
12
|
|
13
13
|
should "provide symbol options" do
|
14
|
-
assert_equal 3, Currency.symbol_set.size
|
14
|
+
assert_equal 3, Osheet::Format::Currency.symbol_set.size
|
15
15
|
[:none, :dollar, :euro].each do |a|
|
16
|
-
assert Currency.symbol_set.include?(a)
|
16
|
+
assert Osheet::Format::Currency.symbol_set.include?(a)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
should "provide negative numbers options" do
|
21
|
-
assert_equal 4, Currency.negative_numbers_set.size
|
21
|
+
assert_equal 4, Osheet::Format::Currency.negative_numbers_set.size
|
22
22
|
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
23
|
-
assert Currency.negative_numbers_set.include?(a)
|
23
|
+
assert Osheet::Format::Currency.negative_numbers_set.include?(a)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -33,27 +33,31 @@ module Osheet::Format
|
|
33
33
|
|
34
34
|
should "only allow Fixnum decimal places between 0 and 30" do
|
35
35
|
assert_raises ArgumentError do
|
36
|
-
Currency.new({:decimal_places => -1})
|
36
|
+
Osheet::Format::Currency.new({:decimal_places => -1})
|
37
37
|
end
|
38
|
+
|
38
39
|
assert_raises ArgumentError do
|
39
|
-
Currency.new({:decimal_places => 31})
|
40
|
+
Osheet::Format::Currency.new({:decimal_places => 31})
|
40
41
|
end
|
42
|
+
|
41
43
|
assert_raises ArgumentError do
|
42
|
-
Currency.new({:decimal_places => 'poo'})
|
44
|
+
Osheet::Format::Currency.new({:decimal_places => 'poo'})
|
43
45
|
end
|
46
|
+
|
44
47
|
assert_nothing_raised do
|
45
|
-
Currency.new({:decimal_places => 1})
|
48
|
+
Osheet::Format::Currency.new({:decimal_places => 1})
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
52
|
should "generate decimal place style strings" do
|
50
|
-
assert_equal "0", Currency.new({
|
53
|
+
assert_equal "0", Osheet::Format::Currency.new({
|
51
54
|
:decimal_places => 0,
|
52
55
|
:comma_separator => false,
|
53
56
|
:symbol => :none
|
54
57
|
}).style
|
55
58
|
(1..5).each do |n|
|
56
|
-
|
59
|
+
|
60
|
+
assert_equal "0.#{'0'*n}", Osheet::Format::Currency.new({
|
57
61
|
:decimal_places => n,
|
58
62
|
:comma_separator => false,
|
59
63
|
:symbol => :none
|
@@ -62,12 +66,13 @@ module Osheet::Format
|
|
62
66
|
end
|
63
67
|
|
64
68
|
should "generate comma separator style strings" do
|
65
|
-
assert_equal "0", Currency.new({
|
69
|
+
assert_equal "0", Osheet::Format::Currency.new({
|
66
70
|
:comma_separator => false,
|
67
71
|
:decimal_places => 0,
|
68
72
|
:symbol => :none
|
69
73
|
}).style
|
70
|
-
|
74
|
+
|
75
|
+
assert_equal "#,##0", Osheet::Format::Currency.new({
|
71
76
|
:comma_separator => true,
|
72
77
|
:decimal_places => 0,
|
73
78
|
:symbol => :none
|
@@ -75,13 +80,14 @@ module Osheet::Format
|
|
75
80
|
end
|
76
81
|
|
77
82
|
should "generate parenth negative numbers style strings" do
|
78
|
-
assert_equal "0", Currency.new({
|
83
|
+
assert_equal "0", Osheet::Format::Currency.new({
|
79
84
|
:negative_numbers => :black,
|
80
85
|
:decimal_places => 0,
|
81
86
|
:comma_separator => false,
|
82
87
|
:symbol => :none
|
83
88
|
}).style
|
84
|
-
|
89
|
+
|
90
|
+
assert_equal "0_);\(0\)", Osheet::Format::Currency.new({
|
85
91
|
:negative_numbers => :black_parenth,
|
86
92
|
:decimal_places => 0,
|
87
93
|
:comma_separator => false,
|
@@ -90,13 +96,14 @@ module Osheet::Format
|
|
90
96
|
end
|
91
97
|
|
92
98
|
should "generate red negative numbers style strings" do
|
93
|
-
assert_equal "0;[Red]0", Currency.new({
|
99
|
+
assert_equal "0;[Red]0", Osheet::Format::Currency.new({
|
94
100
|
:negative_numbers => :red,
|
95
101
|
:decimal_places => 0,
|
96
102
|
:comma_separator => false,
|
97
103
|
:symbol => :none
|
98
104
|
}).style
|
99
|
-
|
105
|
+
|
106
|
+
assert_equal "0_);[Red]\(0\)", Osheet::Format::Currency.new({
|
100
107
|
:negative_numbers => :red_parenth,
|
101
108
|
:decimal_places => 0,
|
102
109
|
:comma_separator => false,
|
@@ -105,12 +112,13 @@ module Osheet::Format
|
|
105
112
|
end
|
106
113
|
|
107
114
|
should "generate symbol style strings" do
|
108
|
-
assert_equal "0", Currency.new({
|
115
|
+
assert_equal "0", Osheet::Format::Currency.new({
|
109
116
|
:decimal_places => 0,
|
110
117
|
:comma_separator => false,
|
111
118
|
:symbol => :none
|
112
119
|
}).style
|
113
|
-
|
120
|
+
|
121
|
+
assert_equal "\"$\"0", Osheet::Format::Currency.new({
|
114
122
|
:decimal_places => 0,
|
115
123
|
:comma_separator => false,
|
116
124
|
:symbol => :dollar
|
@@ -118,7 +126,7 @@ module Osheet::Format
|
|
118
126
|
end
|
119
127
|
|
120
128
|
should "generate complex style string" do
|
121
|
-
assert_equal("\"$\"0.00_);\(\"$\"0.00\)", Currency.new({
|
129
|
+
assert_equal("\"$\"0.00_);\(\"$\"0.00\)", Osheet::Format::Currency.new({
|
122
130
|
:symbol => :dollar,
|
123
131
|
:decimal_places => 2,
|
124
132
|
:negative_numbers => :black_parenth,
|
@@ -127,12 +135,13 @@ module Osheet::Format
|
|
127
135
|
end
|
128
136
|
|
129
137
|
should "provide unique format keys" do
|
130
|
-
assert_equal("currency_dollar_2_nocomma_blackparenth", Currency.new({
|
138
|
+
assert_equal("currency_dollar_2_nocomma_blackparenth", Osheet::Format::Currency.new({
|
131
139
|
:decimal_places => 2,
|
132
140
|
:negative_numbers => :black_parenth,
|
133
141
|
:comma_separator => false
|
134
142
|
}).key)
|
135
|
-
|
143
|
+
|
144
|
+
assert_equal("currency_none_4_comma_redparenth", Osheet::Format::Currency.new({
|
136
145
|
:symbol => :none,
|
137
146
|
:decimal_places => 4,
|
138
147
|
:negative_numbers => :red_parenth,
|