osheet 1.0.0.rc.2 → 1.0.0.rc.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/osheet/format.rb +1 -1
- data/lib/osheet/format/currency.rb +1 -1
- data/lib/osheet/format/numeric.rb +17 -8
- data/lib/osheet/style.rb +8 -7
- data/lib/osheet/version.rb +1 -1
- data/lib/osheet/workbook.rb +6 -26
- data/osheet.gemspec +0 -1
- data/test/format/accounting_test.rb +2 -2
- data/test/format/currency_test.rb +2 -2
- data/test/format/number_test.rb +1 -1
- data/test/format/percentage_test.rb +1 -1
- data/test/format/scientific_test.rb +1 -1
- data/test/format_test.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/osheet/format.rb
CHANGED
@@ -20,7 +20,7 @@ module Osheet::Format
|
|
20
20
|
|
21
21
|
class << self
|
22
22
|
def new(type, *args)
|
23
|
-
unless VALUES.include?(type)
|
23
|
+
unless VALUES.include?(type.to_sym)
|
24
24
|
raise ArgumentError, "'#{type.inspect}' is not a valid format type"
|
25
25
|
end
|
26
26
|
self.const_get(type.to_s.capitalize).new(*args)
|
@@ -8,8 +8,17 @@ module Osheet::Format
|
|
8
8
|
include Enumeration
|
9
9
|
|
10
10
|
attr_accessor :decimal_places, :comma_separator
|
11
|
-
enum :symbol,
|
12
|
-
|
11
|
+
enum :symbol, {
|
12
|
+
:none => "none",
|
13
|
+
:dollar => "dollar",
|
14
|
+
:euro => "euro"
|
15
|
+
}
|
16
|
+
enum :negative_numbers, {
|
17
|
+
:black => "black",
|
18
|
+
:black_parenth => "black_parenth",
|
19
|
+
:red => "red",
|
20
|
+
:red_parenth => "red_parenth"
|
21
|
+
}
|
13
22
|
|
14
23
|
def initialize(opts={})
|
15
24
|
self.symbol = opts[:symbol] || :none
|
@@ -66,13 +75,13 @@ module Osheet::Format
|
|
66
75
|
|
67
76
|
def negative_numbers_style
|
68
77
|
case @negative_numbers
|
69
|
-
when
|
78
|
+
when 'black'
|
70
79
|
numeric_style
|
71
|
-
when
|
80
|
+
when 'red'
|
72
81
|
"#{numeric_style};[Red]#{numeric_style}"
|
73
|
-
when
|
82
|
+
when 'black_parenth'
|
74
83
|
"#{numeric_style}_);\(#{numeric_style}\)"
|
75
|
-
when
|
84
|
+
when 'red_parenth'
|
76
85
|
"#{numeric_style}_);[Red]\(#{numeric_style}\)"
|
77
86
|
end
|
78
87
|
end
|
@@ -99,9 +108,9 @@ module Osheet::Format
|
|
99
108
|
|
100
109
|
def symbol_style
|
101
110
|
case @symbol
|
102
|
-
when
|
111
|
+
when 'dollar'
|
103
112
|
"\"$\"#{symbol_suffix}"
|
104
|
-
when
|
113
|
+
when 'euro'
|
105
114
|
"\"€\"#{symbol_suffix}"
|
106
115
|
else
|
107
116
|
''
|
data/lib/osheet/style.rb
CHANGED
@@ -17,13 +17,14 @@ module Osheet
|
|
17
17
|
SETTINGS.each { |s| instance_variable_set("@#{s}", []) }
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
20
|
+
def align(*args); @align += args; end
|
21
|
+
def font(*args); @font += args; end
|
22
|
+
def bg(*args); @bg += args; end
|
23
|
+
|
24
|
+
def border_top(*args); @border_top += args; end
|
25
|
+
def border_right(*args); @border_right += args; end
|
26
|
+
def border_bottom(*args); @border_bottom += args; end
|
27
|
+
def border_left(*args); @border_left += args; end
|
27
28
|
|
28
29
|
def border(*args)
|
29
30
|
BORDERS.each { |border| send(border, *args) }
|
data/lib/osheet/version.rb
CHANGED
data/lib/osheet/workbook.rb
CHANGED
@@ -27,9 +27,9 @@ module Osheet
|
|
27
27
|
|
28
28
|
# setup the writer, element stack, and workbook_element
|
29
29
|
writer.bind(self) if writer
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
@_osheet_writer = writer
|
31
|
+
@_osheet_element_stack = Workbook::ElementStack.new
|
32
|
+
@_osheet_workbook_element = WorkbookElement.new
|
33
33
|
|
34
34
|
# push the workbook element onto the element stack
|
35
35
|
element_stack.push(workbook)
|
@@ -39,15 +39,15 @@ module Osheet
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def writer
|
42
|
-
|
42
|
+
@_osheet_writer
|
43
43
|
end
|
44
44
|
|
45
45
|
def element_stack
|
46
|
-
|
46
|
+
@_osheet_element_stack
|
47
47
|
end
|
48
48
|
|
49
49
|
def workbook_element
|
50
|
-
|
50
|
+
@_osheet_workbook_element
|
51
51
|
end
|
52
52
|
alias_method :workbook, :workbook_element
|
53
53
|
|
@@ -94,26 +94,6 @@ module Osheet
|
|
94
94
|
define_method(meth) {|*args| writer.send(meth, *args) }
|
95
95
|
end
|
96
96
|
|
97
|
-
private
|
98
|
-
|
99
|
-
OSHEET_IVAR_NS = "_osheet_"
|
100
|
-
|
101
|
-
def get_ivar(name)
|
102
|
-
instance_variable_get(ivar_name(name))
|
103
|
-
end
|
104
|
-
|
105
|
-
def set_ivar(name, value)
|
106
|
-
instance_variable_set(ivar_name(name), value)
|
107
|
-
end
|
108
|
-
|
109
|
-
def push_ivar(name, value)
|
110
|
-
get_ivar(name) << value
|
111
|
-
end
|
112
|
-
|
113
|
-
def ivar_name(name)
|
114
|
-
"@#{OSHEET_IVAR_NS}#{name}"
|
115
|
-
end
|
116
|
-
|
117
97
|
end
|
118
98
|
|
119
99
|
|
data/osheet.gemspec
CHANGED
@@ -26,9 +26,9 @@ module Osheet::Format
|
|
26
26
|
|
27
27
|
should "set default values" do
|
28
28
|
assert_equal 2, subject.decimal_places
|
29
|
-
assert_equal
|
29
|
+
assert_equal 'dollar', subject.symbol
|
30
30
|
assert_equal true, subject.comma_separator
|
31
|
-
assert_equal
|
31
|
+
assert_equal 'black', subject.negative_numbers
|
32
32
|
end
|
33
33
|
|
34
34
|
should "only allow Fixnum decimal places between 0 and 30" do
|
@@ -26,9 +26,9 @@ module Osheet::Format
|
|
26
26
|
|
27
27
|
should "set default values" do
|
28
28
|
assert_equal 2, subject.decimal_places
|
29
|
-
assert_equal
|
29
|
+
assert_equal 'dollar', subject.symbol
|
30
30
|
assert_equal true, subject.comma_separator
|
31
|
-
assert_equal
|
31
|
+
assert_equal 'black', subject.negative_numbers
|
32
32
|
end
|
33
33
|
|
34
34
|
should "only allow Fixnum decimal places between 0 and 30" do
|
data/test/format/number_test.rb
CHANGED
@@ -20,7 +20,7 @@ module Osheet::Format
|
|
20
20
|
should "set default values" do
|
21
21
|
assert_equal 0, subject.decimal_places
|
22
22
|
assert_equal false, subject.comma_separator
|
23
|
-
assert_equal
|
23
|
+
assert_equal 'black', subject.negative_numbers
|
24
24
|
end
|
25
25
|
|
26
26
|
should "only allow Fixnum decimal places between 0 and 30" do
|
@@ -20,7 +20,7 @@ module Osheet::Format
|
|
20
20
|
should "set default values" do
|
21
21
|
assert_equal 2, subject.decimal_places
|
22
22
|
assert_equal false, subject.comma_separator
|
23
|
-
assert_equal
|
23
|
+
assert_equal 'black', subject.negative_numbers
|
24
24
|
end
|
25
25
|
|
26
26
|
should "only allow Fixnum decimal places between 0 and 30" do
|
@@ -20,7 +20,7 @@ module Osheet::Format
|
|
20
20
|
should "set default values" do
|
21
21
|
assert_equal 2, subject.decimal_places
|
22
22
|
assert_equal false, subject.comma_separator
|
23
|
-
assert_equal
|
23
|
+
assert_equal 'black', subject.negative_numbers
|
24
24
|
end
|
25
25
|
|
26
26
|
should "only allow Fixnum decimal places between 0 and 30" do
|
data/test/format_test.rb
CHANGED
@@ -18,7 +18,7 @@ module Osheet
|
|
18
18
|
assert_kind_of Format::Number, subject
|
19
19
|
assert_equal 4, subject.decimal_places
|
20
20
|
assert_equal true, subject.comma_separator
|
21
|
-
assert_equal
|
21
|
+
assert_equal 'black_parenth', subject.negative_numbers
|
22
22
|
end
|
23
23
|
|
24
24
|
should "error for invalid format types" do
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424051
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 1.0.0.rc.
|
11
|
+
- 3
|
12
|
+
version: 1.0.0.rc.3
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Kelly Redding
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-
|
20
|
+
date: 2012-04-18 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
type: :development
|