surpass 0.0.3
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/History.txt +0 -0
- data/README.txt +133 -0
- data/Rakefile +35 -0
- data/examples/big-16mb.rb +25 -0
- data/examples/big-random-strings.rb +28 -0
- data/examples/blanks.rb +34 -0
- data/examples/col_width.rb +16 -0
- data/examples/dates.rb +31 -0
- data/examples/format.rb +23 -0
- data/examples/hello-world.rb +9 -0
- data/examples/image.rb +10 -0
- data/examples/merged.rb +36 -0
- data/examples/merged0.rb +27 -0
- data/examples/merged1.rb +99 -0
- data/examples/num_formats.rb +55 -0
- data/examples/numbers.rb +24 -0
- data/examples/outline.rb +110 -0
- data/examples/panes.rb +48 -0
- data/examples/protection.rb +132 -0
- data/examples/python.bmp +0 -0
- data/examples/row_styles.rb +16 -0
- data/examples/row_styles_empty.rb +15 -0
- data/examples/set_cell_and_range_style.rb +12 -0
- data/examples/wrapped-text.rb +13 -0
- data/examples/write_arrays.rb +16 -0
- data/examples/ws_props.rb +80 -0
- data/lib/biff_record.rb +2168 -0
- data/lib/bitmap.rb +218 -0
- data/lib/cell.rb +214 -0
- data/lib/chart.rb +16 -0
- data/lib/column.rb +40 -0
- data/lib/document.rb +406 -0
- data/lib/excel_formula.rb +6 -0
- data/lib/excel_magic.rb +1013 -0
- data/lib/formatting.rb +554 -0
- data/lib/row.rb +137 -0
- data/lib/style.rb +179 -0
- data/lib/surpass.rb +51 -0
- data/lib/utilities.rb +86 -0
- data/lib/workbook.rb +206 -0
- data/lib/worksheet.rb +561 -0
- data/spec/biff_record_spec.rb +268 -0
- data/spec/cell_spec.rb +56 -0
- data/spec/data/random-strings.txt +10000 -0
- data/spec/document_spec.rb +168 -0
- data/spec/excel_formula_spec.rb +0 -0
- data/spec/formatting_spec.rb +53 -0
- data/spec/reference/P-0508-0000507647-3280-5298.xls +0 -0
- data/spec/reference/all-cell-styles.bin +0 -0
- data/spec/reference/all-number-formats.bin +0 -0
- data/spec/reference/all-styles.bin +0 -0
- data/spec/reference/mini.xls +0 -0
- data/spec/row_spec.rb +19 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/style_spec.rb +89 -0
- data/spec/utilities_spec.rb +57 -0
- data/spec/workbook_spec.rb +48 -0
- data/spec/worksheet_spec.rb +0 -0
- data/stats/cloc.txt +8 -0
- data/stats/rcov.txt +0 -0
- data/stats/specdoc.txt +158 -0
- data/surpass-manual-0-0-3.pdf +0 -0
- data/surpass.gemspec +34 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/excel.rake +6 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/metrics.rake +42 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +292 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- metadata +144 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe ExcelDocument do
|
4
|
+
it "should save" do
|
5
|
+
w = Workbook.new
|
6
|
+
w.country_code = 0x01
|
7
|
+
s = w.add_sheet("Hello World!")
|
8
|
+
s.write(0, 0, 99)
|
9
|
+
s.write(1, 1, "Hello!")
|
10
|
+
w.save("spec/output/mini.xls")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# describe Reader do
|
15
|
+
# before(:each) do
|
16
|
+
# @doc = Reader.new("spec/reference/mini.xls")
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# it "should read in the entire file" do
|
20
|
+
# @doc.header.length.should == 512
|
21
|
+
# @doc.data.length.should == 5120
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# it "should correctly parse doc_magic" do
|
25
|
+
# @doc.doc_magic.should === [0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1].to_bin
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# it "should correctly parse file_uid" do
|
29
|
+
# @doc.file_uid.should === [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00].to_bin
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# it "should correctly parse rev_num" do
|
33
|
+
# @doc.rev_num.should === [0x3E, 0x00].to_bin
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# it "should correctly parse ver_num" do
|
37
|
+
# @doc.ver_num.should === [0x03, 0x00].to_bin
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# it "should correctly parse byte_order" do
|
41
|
+
# @doc.byte_order.should === [0xFE, 0xFF].to_bin
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# it "should correctly parse sector size" do
|
45
|
+
# @doc.sect_size.should === 512
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# it "should correctly parse short sector size" do
|
49
|
+
# @doc.short_sect_size.should == 64
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# it "should correctly parse total sat sectors" do
|
53
|
+
# @doc.total_sat_sectors.should == 1
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# it "should correctly parse dir start sid" do
|
57
|
+
# @doc.dir_start_sid.should == 8
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# it "should correctly parse min stream size" do
|
61
|
+
# @doc.min_stream_size.should == 4096
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# it "should correctly parse ssat start sid" do
|
65
|
+
# @doc.ssat_start_sid.should == -2
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# it "should correctly parse total ssat sectors" do
|
69
|
+
# @doc.total_ssat_sectors.should == 0
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# it "should correctly parse msat start sid" do
|
73
|
+
# @doc.msat_start_sid.should == -2
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
# it "should correctly parse total msat sectors" do
|
77
|
+
# @doc.total_msat_sectors.should == 0
|
78
|
+
# end
|
79
|
+
#
|
80
|
+
# it "should correctly parse the msat" do
|
81
|
+
# @doc.msat.should == [9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
82
|
+
# end
|
83
|
+
#
|
84
|
+
# it "should correctly parse the sat" do
|
85
|
+
# @doc.sat.should == [1, 2, 3, 4, 5, 6, 7, -2, -2, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
86
|
+
# end
|
87
|
+
#
|
88
|
+
# it "should correctly parse the directory list" do
|
89
|
+
# @doc.dir_entry_list.length.should == 4
|
90
|
+
# end
|
91
|
+
# end
|
92
|
+
|
93
|
+
# from pyExcelerator import *
|
94
|
+
# doc = CompoundDoc.Reader("museum/mini.xls", True)
|
95
|
+
|
96
|
+
# file magic:
|
97
|
+
# 0xD0 0xCF 0x11 0xE0 0xA1 0xB1 0x1A 0xE1
|
98
|
+
# file uid:
|
99
|
+
# 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
100
|
+
# revision number:
|
101
|
+
# 0x3E 0x00
|
102
|
+
# version number:
|
103
|
+
# 0x03 0x00
|
104
|
+
# byte order:
|
105
|
+
# 0xFE 0xFF
|
106
|
+
# sector size : 0x200 512
|
107
|
+
# short sector size : 0x40 64
|
108
|
+
# Total number of sectors used for the SAT : 0x1 1
|
109
|
+
# SID of first sector of the directory stream: 0x8 8
|
110
|
+
# Minimum size of a standard stream : 0x1000 4096
|
111
|
+
# SID of first sector of the SSAT : -0x2 -2
|
112
|
+
# Total number of sectors used for the SSAT : 0x0 0
|
113
|
+
# SID of first additional sector of the MSAT : -0x2 -2
|
114
|
+
# Total number of sectors used for the MSAT : 0x0 0
|
115
|
+
# MSAT (header part):
|
116
|
+
# [9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
117
|
+
# additional MSAT sectors:
|
118
|
+
# []
|
119
|
+
# SAT sid count:
|
120
|
+
# 128
|
121
|
+
# SAT content:
|
122
|
+
# (1, 2, 3, 4, 5, 6, 7, -2, -2, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1)
|
123
|
+
# total directory entries: 4
|
124
|
+
# DID 0
|
125
|
+
# Size of the used area of the character buffer of the name: 22
|
126
|
+
# dir entry name: u'Root Entry'
|
127
|
+
# type of entry: 5 Root storage
|
128
|
+
# entry colour: 0 Red
|
129
|
+
# left child DID : -1
|
130
|
+
# right child DID: -1
|
131
|
+
# root DID : 1
|
132
|
+
# start SID : -2
|
133
|
+
# stream size : 0
|
134
|
+
# stream is empty
|
135
|
+
# DID 1
|
136
|
+
# Size of the used area of the character buffer of the name: 18
|
137
|
+
# dir entry name: u'Workbook'
|
138
|
+
# type of entry: 2 User stream
|
139
|
+
# entry colour: 0 Red
|
140
|
+
# left child DID : -1
|
141
|
+
# right child DID: -1
|
142
|
+
# root DID : -1
|
143
|
+
# start SID : 0
|
144
|
+
# stream size : 4096
|
145
|
+
# stream stored as normal stream
|
146
|
+
# DID 2
|
147
|
+
# Size of the used area of the character buffer of the name: 0
|
148
|
+
# dir entry name: u''
|
149
|
+
# type of entry: 0 Empty
|
150
|
+
# entry colour: 0 Red
|
151
|
+
# left child DID : -1
|
152
|
+
# right child DID: -1
|
153
|
+
# root DID : -1
|
154
|
+
# start SID : 0
|
155
|
+
# stream size : 0
|
156
|
+
# stream is empty
|
157
|
+
# DID 3
|
158
|
+
# Size of the used area of the character buffer of the name: 0
|
159
|
+
# dir entry name: u''
|
160
|
+
# type of entry: 0 Empty
|
161
|
+
# entry colour: 0 Red
|
162
|
+
# left child DID : -1
|
163
|
+
# right child DID: -1
|
164
|
+
# root DID : -1
|
165
|
+
# start SID : 0
|
166
|
+
# stream size : 0
|
167
|
+
# stream is empty
|
168
|
+
#
|
File without changes
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Alignment do
|
4
|
+
before(:each) do
|
5
|
+
@a = Alignment.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should not wrap text by default" do
|
9
|
+
@a.wrap.should eql(Alignment::NOT_WRAP_AT_RIGHT)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should wrap text when wrap = true" do
|
13
|
+
@a.wrap = true
|
14
|
+
@a.wrap.should eql(Alignment::WRAP_AT_RIGHT)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should wrap text when wrap = WRAP_AT_RIGHT" do
|
18
|
+
@a.wrap = Alignment::WRAP_AT_RIGHT
|
19
|
+
@a.wrap.should eql(Alignment::WRAP_AT_RIGHT)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should not wrap text when wrap = false" do
|
23
|
+
@a.wrap = true
|
24
|
+
@a.wrap = false
|
25
|
+
@a.wrap.should eql(Alignment::NOT_WRAP_AT_RIGHT)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not wrap text when wrap = NOT_WRAP_AT_RIGHT" do
|
29
|
+
@a.wrap = true
|
30
|
+
@a.wrap = Alignment::NOT_WRAP_AT_RIGHT
|
31
|
+
@a.wrap.should eql(Alignment::NOT_WRAP_AT_RIGHT)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should raise an error if anything else passed" do
|
35
|
+
lambda {@a.wrap = :yes}.should raise_error("I don't know how to set wrap to :yes.")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe Font do
|
40
|
+
it "should raise a helpful error if someone tries to pass a string to font family" do
|
41
|
+
font = Font.new
|
42
|
+
lambda { font.family = 'Arial' }.should raise_error "Oops, font_family doesn't take a string. Do you want font_name instead?"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should raise a helpful error if someone tries to initialize a font with a string for font family" do
|
46
|
+
lambda{ StyleFormat.new(:font_family => "Arial") }.should raise_error "Oops, font_family doesn't take a string. Do you want font_name instead?"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should not raise an error if you properly initialize font family" do
|
50
|
+
font = Font.new
|
51
|
+
lambda { font.family = 1 }.should_not raise_error
|
52
|
+
end
|
53
|
+
end
|
Binary file
|
Binary file
|
File without changes
|
Binary file
|
Binary file
|
data/spec/row_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Row, "various classes of input" do
|
4
|
+
it "should write" do
|
5
|
+
@w = Workbook.new
|
6
|
+
@s = @w.add_sheet
|
7
|
+
|
8
|
+
data = []
|
9
|
+
data << ["Empty String", ""]
|
10
|
+
data << ["Nil", nil]
|
11
|
+
|
12
|
+
data.each_with_index do |a, i|
|
13
|
+
label, value = a
|
14
|
+
@s.write(i, 0, label + ":")
|
15
|
+
@s.write(i, 1, value)
|
16
|
+
end
|
17
|
+
@w.save("spec/output/cells.xls")
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/style_spec.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe StyleCollection, "initialization" do
|
4
|
+
before(:each) do
|
5
|
+
@s = StyleCollection.new
|
6
|
+
@font_index, @number_format_index, @alignment, @borders, @pattern, @protection = @s.default_format
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should properly initialize the fonts hash" do
|
10
|
+
# There is a font no. 6 here because of @default_style = StyleFormat.new
|
11
|
+
@s.fonts.keys.sort.should eql([0,1,2,3,5,6])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should property initialize the number_formats hash" do
|
15
|
+
keys = (0..23).to_a + (38..49).to_a
|
16
|
+
@s.number_formats.keys.sort.should eql(keys)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should properly initialize the styles hash" do
|
20
|
+
@s.styles.keys.sort.should eql([16])
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should property initialize a default style" do
|
24
|
+
@s.default_style.should be_kind_of(StyleFormat)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have a valid font_index in the default_format" do
|
28
|
+
@font_index.should eql(6)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have a valid number_format_index in the default_format" do
|
32
|
+
@number_format_index.should eql(0)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have a valid alignment in the default_format" do
|
36
|
+
@alignment.should be_kind_of(Alignment)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have a valid borders in the default_format" do
|
40
|
+
@borders.should be_kind_of(Borders)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have a valid pattern in the default_format" do
|
44
|
+
@pattern.should be_kind_of(Pattern)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have a valid protection in the default_format" do
|
48
|
+
@protection.should be_kind_of(Protection)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe StyleCollection, "adding new styles" do
|
53
|
+
before(:each) do
|
54
|
+
@s = StyleCollection.new
|
55
|
+
@s.styles.should have(1).elements
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return the default style index when trying to add a nil style" do
|
59
|
+
@s.add(nil).should === 16
|
60
|
+
@s.styles.should have(1).elements
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should correctly add a new blank style" do
|
64
|
+
@s.add(StyleFormat.new).should === 0x10 + 1
|
65
|
+
@s.styles.should have(2).elements
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should not re-add an existing number format" do
|
69
|
+
@s.number_format_index('General').should == 0
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should add a new number format" do
|
73
|
+
@s.number_format_index('never seen this before').should == 164
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe StyleCollection, "biff" do
|
78
|
+
before(:each) do
|
79
|
+
@s = StyleCollection.new
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should correctly convert number format data to biff" do
|
83
|
+
@s.number_formats_biff.should === "" # Since there are no custom number formats.
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should correctly convert cell styles data to biff" do
|
87
|
+
@s.cell_styles_biff.should === File.read("spec/reference/all-cell-styles.bin")
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
include Utilities
|
4
|
+
|
5
|
+
describe Utilities do
|
6
|
+
it "should round trip pixels to twips" do
|
7
|
+
pixels_to_twips(twips_to_pixels(5)).should == 5.0
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should round trip points to pixels" do
|
11
|
+
points_to_pixels(pixels_to_points(5)).should == 5.0
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Utilities, "Excel boolean conversion" do
|
16
|
+
it "should convert true values to 1" do
|
17
|
+
as_numeric(true).should == 1
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should convert false values to 0" do
|
21
|
+
as_numeric(false).should == 0
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should convert 1 to true" do
|
25
|
+
as_boolean(1).should be_true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should convert 0 to false" do
|
29
|
+
as_boolean(0).should be_false
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should raise an error with anything else" do
|
33
|
+
lambda { as_boolean(5) }.should raise_error("Can't convert 5 from excel boolean!")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe Utilities, "Excel date converter" do
|
38
|
+
it "should convert objects of class Date" do
|
39
|
+
as_excel_date(Date.civil(2008,1,1)).should == 39448
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should convert objects of class DateTime" do
|
43
|
+
as_excel_date(DateTime.new(2008,1,1,12,45)).should == 39448.53125
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should convert objects of class Time" do
|
47
|
+
as_excel_date(Time.gm(2008,1,1,12,45)).should == 39448.53125
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe Utilities, "hex function" do
|
52
|
+
it "should description" do
|
53
|
+
(0...200).each do |i|
|
54
|
+
hex(i).to_i(16).should == i
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Workbook, "to_biff" do
|
4
|
+
before(:each) do
|
5
|
+
@w = Workbook.new
|
6
|
+
ws = @w.add_sheet('Image')
|
7
|
+
ws.insert_bitmap('examples/python.bmp', 2, 2)
|
8
|
+
ws.insert_bitmap('examples/python.bmp', 10, 2)
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
# Use this to run code in python source and compare resulting binaries.
|
13
|
+
it "should not raise an error" do
|
14
|
+
if false
|
15
|
+
ruby_biff = @w.to_biff
|
16
|
+
python_biff = File.read("/Users/ana/src/pyexcelerator/trunk/workbook.bin")
|
17
|
+
|
18
|
+
0.upto(ruby_biff.length) do |i|
|
19
|
+
next if ruby_biff[0,i] === python_biff[0,i]
|
20
|
+
puts ruby_biff[i-5, 10].inspect
|
21
|
+
puts python_biff[i-5, 10].inspect
|
22
|
+
raise "files are identical up to #{i.to_s}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe Workbook, "description" do
|
29
|
+
before(:all) do
|
30
|
+
strings = File.read("spec/data/random-strings.txt").split("\n")
|
31
|
+
|
32
|
+
@book = Workbook.new
|
33
|
+
@sheet = @book.add_sheet
|
34
|
+
|
35
|
+
colcount = 20 + 1
|
36
|
+
rowcount = 20 + 1
|
37
|
+
|
38
|
+
colcount.times do |c|
|
39
|
+
rowcount.times do |r|
|
40
|
+
i = c * rowcount + r
|
41
|
+
@sheet.write(r, c, strings[i])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
it "should description" do
|
46
|
+
# @book.window_1_record
|
47
|
+
end
|
48
|
+
end
|
File without changes
|
data/stats/cloc.txt
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
http://cloc.sourceforge.net v 1.03 T=0.5 s (30.0 files/s, 10646.0 lines/s)
|
2
|
+
-------------------------------------------------------------------------------
|
3
|
+
Language files blank comment code
|
4
|
+
-------------------------------------------------------------------------------
|
5
|
+
Ruby 15 494 1457 3372
|
6
|
+
-------------------------------------------------------------------------------
|
7
|
+
SUM: 15 494 1457 3372
|
8
|
+
-------------------------------------------------------------------------------
|
data/stats/rcov.txt
ADDED
File without changes
|
data/stats/specdoc.txt
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
|
2
|
+
InterfaceHeaderRecord
|
3
|
+
- should pack correctly
|
4
|
+
|
5
|
+
InterfaceEndRecord
|
6
|
+
- should pack correctly
|
7
|
+
|
8
|
+
MMSRecord
|
9
|
+
- should pack correctly
|
10
|
+
|
11
|
+
WriteAccessRecord
|
12
|
+
- should pack correctly
|
13
|
+
|
14
|
+
DSFRecord
|
15
|
+
- should pack correctly
|
16
|
+
|
17
|
+
TabIDRecord
|
18
|
+
- should pack correctly
|
19
|
+
|
20
|
+
FnGroupCountRecord
|
21
|
+
- should pack correctly
|
22
|
+
|
23
|
+
WindowProtectRecord
|
24
|
+
- should pack correctly
|
25
|
+
|
26
|
+
ObjectProtectRecord
|
27
|
+
- should pack correctly
|
28
|
+
|
29
|
+
ScenarioProtectRecord
|
30
|
+
- should pack correctly
|
31
|
+
|
32
|
+
PasswordRecord
|
33
|
+
- should pack correctly with blank password
|
34
|
+
- should pack correctly with a password of 123456
|
35
|
+
- should pack correctly with a password of abcdefghij
|
36
|
+
- should pack correctly with a password of ok
|
37
|
+
|
38
|
+
Prot4RevRecord
|
39
|
+
- should pack correctly
|
40
|
+
|
41
|
+
Prot4RevPassRecord
|
42
|
+
- should pack correctly
|
43
|
+
|
44
|
+
BackupRecord
|
45
|
+
- should pack correctly
|
46
|
+
|
47
|
+
HideObjRecord
|
48
|
+
- should pack correctly
|
49
|
+
|
50
|
+
RefreshAllRecord
|
51
|
+
- should pack correctly
|
52
|
+
|
53
|
+
BookBoolRecord
|
54
|
+
- should pack correctly
|
55
|
+
|
56
|
+
CountryRecord
|
57
|
+
- should pack correctly
|
58
|
+
|
59
|
+
UseSelfsRecord
|
60
|
+
- should pack correctly
|
61
|
+
|
62
|
+
EOFRecord
|
63
|
+
- should pack correctly
|
64
|
+
|
65
|
+
DateModeRecord
|
66
|
+
- should pack correctly when passed true
|
67
|
+
- should pack correctly when passed false
|
68
|
+
|
69
|
+
PrecisionRecord
|
70
|
+
- should pack correctly when passed true
|
71
|
+
- should pack correctly when passed false
|
72
|
+
|
73
|
+
CodepageBiff8Record
|
74
|
+
- should pack correctly
|
75
|
+
|
76
|
+
Window1Record
|
77
|
+
- should pack correctly
|
78
|
+
|
79
|
+
StyleRecord
|
80
|
+
- should pack correctly
|
81
|
+
|
82
|
+
BoundSheetRecord
|
83
|
+
- should pack correctly
|
84
|
+
|
85
|
+
DimensionsRecord
|
86
|
+
- should pack correctly
|
87
|
+
|
88
|
+
ExcelDocument
|
89
|
+
- should save
|
90
|
+
|
91
|
+
Reader
|
92
|
+
- should read in the entire file
|
93
|
+
- should correctly parse doc_magic
|
94
|
+
- should correctly parse file_uid
|
95
|
+
- should correctly parse rev_num
|
96
|
+
- should correctly parse ver_num
|
97
|
+
- should correctly parse byte_order
|
98
|
+
- should correctly parse sector size
|
99
|
+
- should correctly parse short sector size
|
100
|
+
- should correctly parse total sat sectors
|
101
|
+
- should correctly parse dir start sid
|
102
|
+
- should correctly parse min stream size
|
103
|
+
- should correctly parse ssat start sid
|
104
|
+
- should correctly parse total ssat sectors
|
105
|
+
- should correctly parse msat start sid
|
106
|
+
- should correctly parse total msat sectors
|
107
|
+
- should correctly parse the msat
|
108
|
+
- should correctly parse the sat
|
109
|
+
- should correctly parse the directory list
|
110
|
+
|
111
|
+
StyleCollection initialization
|
112
|
+
- should properly initialize the fonts hash
|
113
|
+
- should property initialize the number_formats hash
|
114
|
+
- should properly initialize the styles hash
|
115
|
+
- should property initialize a default style
|
116
|
+
- should have a valid font_index in the default_format
|
117
|
+
- should have a valid number_format_index in the default_format
|
118
|
+
- should have a valid alignment in the default_format
|
119
|
+
- should have a valid borders in the default_format
|
120
|
+
- should have a valid pattern in the default_format
|
121
|
+
- should have a valid protection in the default_format
|
122
|
+
|
123
|
+
StyleCollection adding new styles
|
124
|
+
- should return the default style index when trying to add a nil style
|
125
|
+
- should correctly add a new blank style
|
126
|
+
- should not re-add an existing number format
|
127
|
+
- should add a new number format
|
128
|
+
|
129
|
+
StyleCollection biff
|
130
|
+
- should correctly convert font data to biff
|
131
|
+
- should correctly convert number format data to biff
|
132
|
+
- should correctly convert cell styles data to biff
|
133
|
+
|
134
|
+
Utilities
|
135
|
+
- should round trip pixels to twips
|
136
|
+
- should round trip points to pixels
|
137
|
+
|
138
|
+
Utilities Excel boolean conversion
|
139
|
+
- should convert true values to 1
|
140
|
+
- should convert false values to 0
|
141
|
+
- should convert 1 to true
|
142
|
+
- should convert 0 to false
|
143
|
+
- should raise an error with anything else
|
144
|
+
|
145
|
+
Utilities Excel date converter
|
146
|
+
- should convert objects of class Date
|
147
|
+
- should convert objects of class DateTime
|
148
|
+
- should convert objects of class Time
|
149
|
+
|
150
|
+
Utilities hex function
|
151
|
+
- should description
|
152
|
+
|
153
|
+
Workbook to_biff
|
154
|
+
- should not raise an error
|
155
|
+
|
156
|
+
Finished in 0.100042 seconds
|
157
|
+
|
158
|
+
80 examples, 0 failures
|
Binary file
|
data/surpass.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{surpass}
|
5
|
+
s.version = "0.0.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Ana Nelson"]
|
9
|
+
s.date = %q{2009-03-21}
|
10
|
+
s.description = %q{Surpass is writing (and eventually reading) excel workbooks in pure Ruby. Surpass is based on xlwt (and pyExcelerator).}
|
11
|
+
s.email = %q{ana@ananelson.com}
|
12
|
+
s.extra_rdoc_files = ["History.txt", "README.txt", "spec/data/random-strings.txt", "stats/cloc.txt", "stats/rcov.txt", "stats/specdoc.txt"]
|
13
|
+
s.files = ["History.txt", "README.txt", "Rakefile", "examples/big-16mb.rb", "examples/big-random-strings.rb", "examples/blanks.rb", "examples/col_width.rb", "examples/dates.rb", "examples/format.rb", "examples/hello-world.rb", "examples/image.rb", "examples/merged.rb", "examples/merged0.rb", "examples/merged1.rb", "examples/num_formats.rb", "examples/numbers.rb", "examples/outline.rb", "examples/panes.rb", "examples/protection.rb", "examples/python.bmp", "examples/row_styles.rb", "examples/row_styles_empty.rb", "examples/set_cell_and_range_style.rb", "examples/wrapped-text.rb", "examples/write_arrays.rb", "examples/ws_props.rb", "lib/biff_record.rb", "lib/bitmap.rb", "lib/cell.rb", "lib/chart.rb", "lib/column.rb", "lib/document.rb", "lib/excel_formula.rb", "lib/excel_magic.rb", "lib/formatting.rb", "lib/row.rb", "lib/style.rb", "lib/surpass.rb", "lib/utilities.rb", "lib/workbook.rb", "lib/worksheet.rb", "spec/biff_record_spec.rb", "spec/cell_spec.rb", "spec/data/random-strings.txt", "spec/document_spec.rb", "spec/excel_formula_spec.rb", "spec/formatting_spec.rb", "spec/reference/P-0508-0000507647-3280-5298.xls", "spec/reference/all-cell-styles.bin", "spec/reference/all-number-formats.bin", "spec/reference/all-styles.bin", "spec/reference/mini.xls", "spec/row_spec.rb", "spec/spec_helper.rb", "spec/style_spec.rb", "spec/utilities_spec.rb", "spec/workbook_spec.rb", "spec/worksheet_spec.rb", "stats/cloc.txt", "stats/rcov.txt", "stats/specdoc.txt", "surpass-manual-0-0-3.pdf", "surpass.gemspec", "tasks/excel.rake", "tasks/metrics.rake"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{https://surpass.rubyforge.org}
|
16
|
+
s.rdoc_options = ["--main", "README.txt"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{surpass}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Surpass is writing (and eventually reading) excel workbooks in pure Ruby}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_development_dependency(%q<bones>, [">= 2.4.2"])
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<bones>, [">= 2.4.2"])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<bones>, [">= 2.4.2"])
|
33
|
+
end
|
34
|
+
end
|