tables 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ #
2
+ # Author:: Saul Caganoff (mailto:scaganoff@gmail.com)
3
+ # Copyright:: Copyright (c) 2010, Saul Caganoff
4
+ # License:: Creative Commons Attribution 3.0 Australia License (http://creativecommons.org/licenses/by/3.0/au/)
5
+ #
6
+
7
+ module Tables
8
+
9
+ class TableReader
10
+
11
+ attr_reader :tables
12
+
13
+ def initialize
14
+ @tables=[]
15
+ end
16
+
17
+ def get_tables
18
+ result=[]
19
+ if block_given? then
20
+ @tables.each {|t| result<<t if yield(t)}
21
+ else
22
+ result=@tables.clone
23
+ end
24
+ result
25
+ end
26
+
27
+ def merge_tables
28
+ sortmerge={}
29
+ @tables.each do |t|
30
+ key=t.header
31
+ if sortmerge.has_key?(key) then
32
+ sortmerge[key].merge!(t)
33
+ else
34
+ sortmerge[key]=t
35
+ end
36
+ end
37
+ @tables=[]
38
+ sortmerge.values.each {|v| @tables << v}
39
+ end
40
+
41
+ def extract_all_tables(idx_array=[*0..(table_count-1)]) # table_count is defined by the concrete class
42
+ idx_array.each do |idx|
43
+ table = extract_table(idx)
44
+ unless table.nil? then
45
+ status = ">> Extracted table '#{table.name}'"
46
+ sig=">> signature - #{table.signature}"
47
+ if block_given? then
48
+ match=yield(table)
49
+ if match then
50
+ @tables << table
51
+ else
52
+ status += " - (filtered out)"
53
+ end
54
+ else
55
+ @tables << table
56
+ end
57
+ puts status
58
+ puts sig
59
+ end
60
+ end
61
+ end
62
+
63
+ end
64
+
65
+ end
@@ -0,0 +1,83 @@
1
+ #
2
+ # Author:: Saul Caganoff (mailto:scaganoff@gmail.com)
3
+ # Copyright:: Copyright (c) 2010, Saul Caganoff
4
+ # License:: Creative Commons Attribution 3.0 Australia License (http://creativecommons.org/licenses/by/3.0/au/)
5
+ #
6
+ require 'win32ole'
7
+
8
+ module Tables
9
+
10
+ class WordTableReader < TableReader
11
+
12
+ attr_reader :doc
13
+
14
+ def initialize(filename, opts={})
15
+ fso=WIN32OLE.new('Scripting.FileSystemObject')
16
+ path=fso.GetAbsolutePathName(filename)
17
+ @app=WIN32OLE.new("Word.Application")
18
+ @doc=@app.Documents.Open(path, opts)
19
+ super()
20
+ end
21
+
22
+ def table_count
23
+ @doc.tables.count
24
+ end
25
+
26
+ def extract_table(idx)
27
+ name="Table #{idx+1}"
28
+ table=@doc.tables(idx+1)
29
+ result=[]
30
+ jdx=0
31
+ table.rows.each do |row|
32
+ jdx+=1
33
+ begin
34
+ result << WordTableReader.extract_row(row)
35
+ rescue Exception=>e1
36
+ puts "ERROR: Error extracting row #{jdx} from table '#{name}'"
37
+ puts "ERROR: #{e1.message}"
38
+ end
39
+ end
40
+ Table.new(result, name)
41
+
42
+ rescue Exception=>e2
43
+ puts "ERROR: Error extracting table '#{name}'"
44
+ puts "ERROR: #{e2.message}"
45
+ end
46
+
47
+ def exit
48
+ @app.quit
49
+ end
50
+
51
+ private
52
+
53
+ def WordTableReader.extract_row(ole_row)
54
+ row=[]
55
+ ole_row.cells.each do |cell|
56
+ row << WordTableReader.extract_text(cell.range)
57
+ end
58
+ row
59
+ end
60
+
61
+ def WordTableReader.extract_text(range)
62
+ paragraphs=[]
63
+ range_text=range.Text
64
+ range.paragraphs.each do |p|
65
+ text = clean_bytes(p.range.Text)
66
+ list_text = clean_bytes(p.range.ListFormat.ListString)
67
+ list_type = p.range.ListFormat.ListType
68
+ p_text = text.empty? ? list_text : text # return list_text if text is empty
69
+ p_bullet = list_type==0 ? "" : "\t- "
70
+ paragraphs << p_bullet+p_text.strip
71
+ end
72
+ paragraphs.join("\n")
73
+ end
74
+
75
+ def WordTableReader.clean_bytes(string)
76
+ new_string=""
77
+ string.each_char {|c| new_string<<c unless c=="\r" or c=="\a"}
78
+ new_string
79
+ end
80
+
81
+ end
82
+
83
+ end
@@ -0,0 +1,64 @@
1
+ #
2
+ # Author:: Saul Caganoff (mailto:scaganoff@gmail.com)
3
+ # Copyright:: Copyright (c) 2010, Saul Caganoff
4
+ # License:: Creative Commons Attribution 3.0 Australia License (http://creativecommons.org/licenses/by/3.0/au/)
5
+ #
6
+ require 'win32ole'
7
+
8
+ module Tables
9
+
10
+ class WordTableWriter
11
+ attr_reader :doc
12
+
13
+ def initialize
14
+ @app=WIN32OLE.new 'Word.Application'
15
+ @doc=@app.Documents.Add
16
+ super()
17
+ end
18
+
19
+ def save_as(filename)
20
+ fso=WIN32OLE.new('Scripting.FileSystemObject')
21
+ @path=fso.GetAbsolutePathName(filename)
22
+ @doc.SaveAs(@path)
23
+ end
24
+
25
+ def exit(save_changes=true)
26
+ code=-1
27
+ code=0 unless save_changes
28
+ @app.quit(code)
29
+ end
30
+
31
+ def append_table(table, caption=nil)
32
+ @app.Selection.EndKey(6)
33
+ word_table=@doc.Tables.Add(@app.Selection.Range, table.row_count, table.column_count)
34
+ table.each_row_with_index do |row, idx|
35
+ word_row=word_table.Rows(idx+1)
36
+ row.each_with_index do |cell_value, jdx|
37
+ word_row.Cells(jdx+1).Range.Text=cell_value.to_s
38
+ end
39
+ end
40
+
41
+ style_borders(word_table)
42
+ set_caption(word_table,caption) unless caption.nil?
43
+ end
44
+
45
+ private
46
+ def style_borders(word_table)
47
+ (1..6).each do |border|
48
+ word_table.Borders(border).LineStyle=1
49
+ end
50
+
51
+ (1..4).each do |border|
52
+ word_table.Borders(border).LineWidth=12
53
+ end
54
+ word_table.Rows(1).Borders(3).LineWidth=12
55
+ end
56
+
57
+ def set_caption(word_table, caption)
58
+ word_table.Range.InsertCaption("Table",": #{caption}",nil,0)
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+
@@ -0,0 +1,33 @@
1
+ #
2
+ # Author:: Saul Caganoff (mailto:scaganoff@gmail.com)
3
+ # Copyright:: Copyright (c) 2010, Saul Caganoff
4
+ # License:: Creative Commons Attribution 3.0 Australia License (http://creativecommons.org/licenses/by/3.0/au/)
5
+ #
6
+
7
+ require "rspec"
8
+ require "tables"
9
+
10
+ describe Tables::Table do
11
+
12
+ it "should do a columnwise copy of one table to another" do
13
+ t1=Tables::Table.new([
14
+ [:a,:b,:d,:f],
15
+ [1,1,1,1],
16
+ [2,2,2,2],
17
+ [3,3,3,3]
18
+ ])
19
+ t2=Tables::Table.new([
20
+ [:a,:b,:c,:d,:e,:f]
21
+ ])
22
+ t_expect=Tables::Table.new([
23
+ [:a,:b,:c,:d,:e,:f],
24
+ [1,1,nil,1,nil,1],
25
+ [2,2,nil,2,nil,2],
26
+ [3,3,nil,3,nil,3]
27
+ ])
28
+
29
+ t2.column_copy(t1)
30
+ (t2==t_expect).should==true
31
+ end
32
+
33
+ end
@@ -0,0 +1,132 @@
1
+ #
2
+ # Author:: Saul Caganoff (mailto:scaganoff@gmail.com)
3
+ # Copyright:: Copyright (c) 2010, Saul Caganoff
4
+ # License:: Creative Commons Attribution 3.0 Australia License (http://creativecommons.org/licenses/by/3.0/au/)
5
+ #
6
+
7
+ require 'tables'
8
+
9
+ describe Tables::ExcelTableReader do
10
+
11
+ it "should read an excel document" do
12
+ filename=File.dirname(__FILE__)+"/../test/rtm.xlsx"
13
+ @xtr = Tables::ExcelTableReader.new(filename)
14
+ @xtr.workbook.should_not==nil
15
+ @xtr.exit
16
+ end
17
+
18
+ it "should extract a table" do
19
+ filename=File.dirname(__FILE__)+"/../test/rtm.xlsx"
20
+ @xtr = Tables::ExcelTableReader.new(filename)
21
+ t=@xtr.extract_table(0)
22
+ # t.each_row {|r| puts "#{r[0]}, #{r[1]}, #{r[2]}"}
23
+ t.rows.should==457
24
+ t[1][0].should=~/Unique ID/
25
+ t[2][0].should=~/CAMM\.AC\.101/
26
+ t[1].last.should=~/PolicyNet Doc Ref/
27
+ end
28
+
29
+ it "should extract multiple tables" do
30
+ filename=File.dirname(__FILE__)+"/../test/rtm.xlsx"
31
+ @xtr = Tables::ExcelTableReader.new(filename)
32
+ @xtr.extract_all_tables([0,1,2])
33
+ @xtr.tables.count.should==3
34
+ end
35
+
36
+ it "should clean up a table" do
37
+ filename=File.dirname(__FILE__)+"/../test/rtm.xlsx"
38
+ @xtr = Tables::ExcelTableReader.new(filename)
39
+ @xtr.extract_all_tables([2])
40
+ @xtr.tables.count.should==1
41
+ @xtr.clean
42
+ t=@xtr.tables[0]
43
+ t.rows.should==55
44
+
45
+ col1=[]
46
+ t.each_row {|row| col1<< row[0].strip }
47
+ col1_expected=["Unique ID", "CAMM.GE.101", "CAMM.GE.102", "CAMM.GE.103", "CAMM.GE.104", "CAMM.GE.105", "CAMM.GE.106", "CAMM.GE.107", "CAMM.GE.108", "CAMM.GE.109", "CAMM.GE.110", "CAMM.GE.111", "CAMM.GE.112", "CAMM.GE.113", "CAMM.GE.114", "CAMM.GE.115", "CAMM.SM.101", "CAMM.SM.102", "CAMM.SM.103", "CAMM.BP.101", "CAMM.BP.102", "CAMM.BP.103", "CAMM.BP.104", "CAMM.BP.105", "CAMM.BP.106", "CAMM.BP.107", "CAMM.BP.108", "CAMM.GP.101", "CAMM.SI.101", "CAMM.SI.102", "CAMM.HW.101", "CAMM.HW.102", "CAMM.HW.103", "CAMM.HW.104", "CAMM.HA.101", "CAMM.HA.102", "CAMM.HA.103", "CAMM.HA.104", "CAMM.HA.105", "CAMM.HA.106", "CAMM.HA.107", "CAMM.HA.108", "CAMM.HA.109", "CAMM.HA.110", "CAMM.HA.111", "CAMM.HA.112", "CAMM.AI.101", "CAMM.AI.102", "CAMM.AI.103", "CAMM.WG.101", "CAMM.WG.102", "CAMM.WG.103", "CAMM.WG.104", "CAMM.WG.105", "CAMM.MU.101"]
48
+ col1.should.eql? col1_expected
49
+ end
50
+
51
+ it "should write a table" do
52
+ t=Tables::Table.new([
53
+ [:a,:b,:c,:d],
54
+ [1,1,1,1],
55
+ [2,2,2,2],
56
+ [3,3,3,3]
57
+ ])
58
+ outfile=File.dirname(__FILE__)+"/../test/writetest.xlsx"
59
+ File.delete(outfile) if File.exist?(outfile)
60
+ @xtr=Tables::ExcelTableReader.new()
61
+ @xtr.create_file(outfile)
62
+ @xtr.write_table(t)
63
+ @xtr.save
64
+ @xtr.exit
65
+ end
66
+
67
+ it "should write a table to a named worksheet" do
68
+ t=Tables::Table.new([
69
+ [:a,:b,:c,:d],
70
+ [1,1,1,1],
71
+ [2,2,2,2],
72
+ [3,3,3,3]
73
+ ])
74
+ outfile=File.dirname(__FILE__)+"/../test/writetest1.xlsx"
75
+ File.delete(outfile) if File.exist?(outfile)
76
+ @xtr=Tables::ExcelTableReader.new()
77
+ @xtr.create_file(outfile)
78
+ @xtr.write_table(t, "Sheet2")
79
+ @xtr.save
80
+ @xtr.exit
81
+ end
82
+
83
+ it "should write a column" do
84
+ t=Tables::Table.new([
85
+ [:a,:b,:c,:d],
86
+ [1,1,1,1],
87
+ [2,2,2,2],
88
+ [3,3,3,3]
89
+ ])
90
+ outfile=File.dirname(__FILE__)+"/../test/writetest2.xlsx"
91
+ File.delete(outfile) if File.exist?(outfile)
92
+ @xtr=Tables::ExcelTableReader.new()
93
+ @xtr.create_file(outfile)
94
+ @xtr.write_column(t,:c)
95
+ @xtr.save
96
+ @xtr.exit
97
+ end
98
+
99
+ it "should write a column to a named worksheet" do
100
+ t=Tables::Table.new([
101
+ [:a,:b,:c,:d],
102
+ [1,1,1,1],
103
+ [2,2,2,2],
104
+ [3,3,3,3]
105
+ ])
106
+ outfile=File.dirname(__FILE__)+"/../test/writetest2a.xlsx"
107
+ File.delete(outfile) if File.exist?(outfile)
108
+ @xtr=Tables::ExcelTableReader.new()
109
+ @xtr.create_file(outfile)
110
+ @xtr.write_column(t,:c, "Sheet3")
111
+ @xtr.save
112
+ @xtr.exit
113
+ end
114
+
115
+ it "should append worksheets automatically" do
116
+ t=Tables::Table.new([
117
+ [:a,:b,:c,:d],
118
+ [1,1,1,1],
119
+ [2,2,2,2],
120
+ [3,3,3,3]
121
+ ])
122
+ outfile=File.dirname(__FILE__)+"/../test/writetest3.xlsx"
123
+ File.delete(outfile) if File.exist?(outfile)
124
+ @xtr=Tables::ExcelTableReader.new()
125
+ @xtr.create_file(outfile)
126
+ 10.times {|idx| @xtr.write_table(t,idx)}
127
+ @xtr.save
128
+ @xtr.exit
129
+ end
130
+
131
+ end
132
+
@@ -0,0 +1,55 @@
1
+ #
2
+ # Author:: Saul Caganoff (mailto:scaganoff@gmail.com)
3
+ # Copyright:: Copyright (c) 2010, Saul Caganoff
4
+ # License:: Creative Commons Attribution 3.0 Australia License (http://creativecommons.org/licenses/by/3.0/au/)
5
+ #
6
+
7
+ require "rspec"
8
+ require 'tables'
9
+
10
+ describe Tables::WordTableReader do
11
+
12
+ it "should copy word table to excel" do
13
+ filename=File.dirname(__FILE__)+"/../test/rtm.docx"
14
+ @wtr = Tables::WordTableReader.new(filename)
15
+ ntables=@wtr.table_count
16
+ @wtr.extract_all_tables((0..ntables-2).to_a) {|table| table[0][0]=~/Unique ID/}
17
+ @wtr.merge_tables
18
+ @wtr.tables.should have(1).item
19
+ table=@wtr.tables[0]
20
+ @wtr.exit
21
+
22
+ outfile=File.dirname(__FILE__)+"/../test/copytest.xlsx"
23
+ File.delete(outfile) if File.exist?(outfile)
24
+ @xtr=Tables::ExcelTableReader.new()
25
+ @xtr.create_file(outfile)
26
+ @xtr.write_table(table)
27
+ @xtr.save
28
+ @xtr.exit
29
+ end
30
+
31
+ it "should copy word table to an excel template" do
32
+ filename=File.dirname(__FILE__)+"/../test/rtm.docx"
33
+ @wtr = Tables::WordTableReader.new(filename)
34
+ ntables=@wtr.table_count
35
+ @wtr.extract_all_tables((0..ntables-2).to_a) {|table| table[0][0]=~/Unique ID/}
36
+ @wtr.merge_tables
37
+ @wtr.tables.should have(1).item
38
+ table=@wtr.tables[0]
39
+ @wtr.exit
40
+
41
+ template_file=File.dirname(__FILE__)+"/../test/rtm_template.xlsx"
42
+ ttr=Tables::ExcelTableReader.new(template_file)
43
+ template=ttr.extract_table(1)
44
+ template.column_copy(table)
45
+ ttr.exit
46
+
47
+ outfile=File.dirname(__FILE__)+"/../test/copytest2.xlsx"
48
+ File.delete(outfile) if File.exist?(outfile)
49
+ @xtr=Tables::ExcelTableReader.new()
50
+ @xtr.create_file(outfile)
51
+ @xtr.write_table(template)
52
+ @xtr.save
53
+ @xtr.exit
54
+ end
55
+ end
@@ -0,0 +1,237 @@
1
+ #
2
+ # Author:: Saul Caganoff (mailto:scaganoff@gmail.com)
3
+ # Copyright:: Copyright (c) 2010, Saul Caganoff
4
+ # License:: Creative Commons Attribution 3.0 Australia License (http://creativecommons.org/licenses/by/3.0/au/)
5
+ #
6
+
7
+ require 'tables'
8
+
9
+ describe Tables::Table do
10
+ before(:each) do
11
+ @t1=Tables::Table.new([
12
+ [:a,:b,:c,:d],
13
+ [1,1,1,1],
14
+ [2,2,9,2],
15
+ [3,3,3,3]
16
+ ])
17
+ @t2=Tables::Table.new([
18
+ [:a,:b,:c,:d],
19
+ [4,4,4,4],
20
+ [5,5,5,5]
21
+ ])
22
+ @t3=Tables::Table.new([
23
+ [:x,:y,:z],
24
+ [4,4,4],
25
+ [5,5,5]
26
+ ])
27
+ @texpect=Tables::Table.new([
28
+ [:a,:b,:c,:d],
29
+ [1,1,1,1],
30
+ [2,2,9,2],
31
+ [3,3,3,3],
32
+ [4,4,4,4],
33
+ [5,5,5,5]
34
+ ])
35
+ end
36
+
37
+ #it "should determine equality" do
38
+ # t=Tables::Table.new([
39
+ # [:a,:b,:c,:d],
40
+ # [1,1,1,1],
41
+ # [2,2,9,2],
42
+ # [3,3,3,3]
43
+ # ])
44
+ # (t==@t1).should==true
45
+ #end
46
+ #it "should determine similarity" do
47
+ # @t1.similar?(@t2).should==true
48
+ # @t1.similar?(@t3).should==false
49
+ #end
50
+ #
51
+ #it "should merge tables cleanly" do
52
+ # @t1.merge!(@t2)
53
+ # (@t1==@texpect).should==true
54
+ #end
55
+ #
56
+ #it "should accept a new row" do
57
+ # @t1 << [4,4,4,4]
58
+ # @t1 << [5,5,5,5]
59
+ # (@t1==@texpect).should==true
60
+ #end
61
+ #
62
+ #it "should report columns" do
63
+ # @t1.column_count.should==4
64
+ #end
65
+ #
66
+ #it "should report rows" do
67
+ # @t1.row_count.should==4
68
+ #end
69
+ #
70
+ #it "should access cell value by column name" do
71
+ # @t1.get_value(:c, 2).should==9
72
+ # lambda { t.get_value(:z,2) }.should raise_error
73
+ #end
74
+ #
75
+ #it "should provide row as a hash" do
76
+ # row=@t1.get_row(2)
77
+ # row.should.is_a? Hash
78
+ # row[:c].should==9
79
+ # row[:a].should==2
80
+ #end
81
+ #
82
+ #it "should get a named column" do
83
+ # c=@t1.get_column(:c)
84
+ # c.should.eql? [:c,1,9,3]
85
+ #end
86
+ #
87
+ #it "should delete a named column" do
88
+ # c=@t1.get_column(:c)
89
+ # c.should.eql? [:c,1,9,3]
90
+ # t=@t1.delete_column(:c)
91
+ # t_expect=Tables::Table.new([
92
+ # [:a,:b,:d],
93
+ # [1,1,1],
94
+ # [2,2,2],
95
+ # [3,3,3]
96
+ # ])
97
+ # lambda { t.get_column(:c) }.should raise_error
98
+ #end
99
+ #
100
+ #it "should delete the last column" do
101
+ # @t1.delete_column(@t1.header.last)
102
+ # texpect=Tables::Table.new([
103
+ # [:a,:b,:c],
104
+ # [1,1,1],
105
+ # [2,2,9],
106
+ # [3,3,3]
107
+ # ])
108
+ # (@t1==texpect).should==true
109
+ #end
110
+ #
111
+ #it "should remove blank rows" do
112
+ # t_blankrow=Tables::Table.new([
113
+ # [:a,:b,:c,:d],
114
+ # [1,1,1,1],
115
+ # ["","","",""],
116
+ # [3,3,3,3]
117
+ # ])
118
+ # t_noblankrow=Tables::Table.new([
119
+ # [:a,:b,:c,:d],
120
+ # [1,1,1,1],
121
+ # [3,3,3,3]
122
+ # ])
123
+ # t_blankrow.remove_blank_rows!
124
+ # t_blankrow.row_count.should==3
125
+ # (t_blankrow==t_noblankrow).should==true
126
+ #end
127
+ #
128
+ #it "should remove head rows" do
129
+ # t_blankrow=Tables::Table.new([
130
+ # [:a,:b,:c,:d],
131
+ # [1,1,1,1],
132
+ # ["head","","",""],
133
+ # [3,3,3,3]
134
+ # ])
135
+ # t_noblankrow=Tables::Table.new([
136
+ # [:a,:b,:c,:d],
137
+ # [1,1,1,1],
138
+ # [3,3,3,3]
139
+ # ])
140
+ # t_blankrow.remove_blank_rows!(1)
141
+ # (t_blankrow==t_noblankrow).should==true
142
+ # t_blankrow.row_count.should==3
143
+ #end
144
+ #
145
+ #it "should remove repeated headers" do
146
+ # t=Tables::Table.new([
147
+ # [:a,:b,:c,:d],
148
+ # [1,1,1,1],
149
+ # [2,2,2,2],
150
+ # [3,3,3,3],
151
+ # [:a,:b,:c,:d],
152
+ # [4,4,4,4],
153
+ # [5,5,5,5]
154
+ # ])
155
+ # t_expect=Tables::Table.new([
156
+ # [:a,:b,:c,:d],
157
+ # [1,1,1,1],
158
+ # [2,2,2,2],
159
+ # [3,3,3,3],
160
+ # [4,4,4,4],
161
+ # [5,5,5,5]
162
+ # ])
163
+ # t.remove_repeat_headers!
164
+ # (t==t_expect).should==true
165
+ # t.row_count.should==6
166
+ #end
167
+ #
168
+ #it "should demerge on default column 0" do
169
+ # t_merged=Tables::Table.new([
170
+ # ["a","foo","45"],
171
+ # ["","sub-foo","46"],
172
+ # ["","sub-foo-2",""],
173
+ # ["b","bar","47"],
174
+ # ["c","baz",""]
175
+ # ])
176
+ # t=t_merged.demerge!
177
+ # t_expect=Tables::Table.new([
178
+ # ["a","foo\nsub-foo\nsub-foo-2","45\n46"],
179
+ # ["b","bar","47"],
180
+ # ["c","baz",""]
181
+ # ])
182
+ # (t==t_expect).should==true
183
+ #end
184
+ #
185
+ #it "should demerge on any specified column" do
186
+ # t_merged=Tables::Table.new([
187
+ # ["a","foo","45"],
188
+ # ["","sub-foo","46"],
189
+ # ["","sub-foo-2",""],
190
+ # ["b","bar","47"],
191
+ # ["c","baz",""]
192
+ # ])
193
+ # t=t_merged.demerge!(2)
194
+ # t_expect=Tables::Table.new([
195
+ # ["a","foo","45"],
196
+ # ["","sub-foo\nsub-foo-2","46"],
197
+ # ["b\nc","bar\nbaz","47"]
198
+ # ])
199
+ # (t==t_expect).should==true
200
+ #end
201
+ #
202
+ #it "should allow build Tables::Table" do
203
+ # t=Tables::Table.new
204
+ # t.add_row([:a,:b,:c,:d])
205
+ # t.add_row([1,1,1,1])
206
+ # t.add_row([2,2,9,2])
207
+ # t.add_row([3,3,3,3])
208
+ # (t==@t1).should==true
209
+ # t.get_value(:c,2).should==9
210
+ #end
211
+ #
212
+ #it "should allow rename of column" do
213
+ # t=Tables::Table.new
214
+ # t.add_row([:a,:b,:c,:d])
215
+ # t.add_row([1,1,1,1])
216
+ # t.add_row([2,2,9,2])
217
+ # t.add_row([3,3,3,3])
218
+ # t.rename_column(:c, :z)
219
+ # t.get_value(:z,2).should==9
220
+ # lambda { t.get_value(:c,2) }.should raise_error
221
+ #end
222
+
223
+ it "should update a row via get" do
224
+ t_expect=Tables::Table.new([
225
+ [:a,:b,:c,:d],
226
+ [1,1,9,1],
227
+ [2,2,9,2],
228
+ [3,3,9,3]])
229
+ @t1.get_each_row do |row|
230
+ row[:c]=9
231
+ @t1.set_row(row)
232
+ end
233
+ (@t1==t_expect).should==true
234
+ end
235
+
236
+ end
237
+