rspreadsheet 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/DEVEL_BLOG.md +10 -6
- data/README.md +6 -0
- data/lib/rspreadsheet/.row.rb.kate-swp.bak +0 -0
- data/lib/rspreadsheet/cell.rb +139 -105
- data/lib/rspreadsheet/row.rb +235 -87
- data/lib/rspreadsheet/tools.rb +31 -7
- data/lib/rspreadsheet/version.rb +1 -1
- data/lib/rspreadsheet/worksheet.rb +117 -7
- data/reinstall.sh +2 -1
- data/rspreadsheet.gemspec +1 -1
- data/spec/cell_spec.rb +34 -8
- data/spec/row_spec.rb +50 -27
- data/spec/rspreadsheet_spec.rb +1 -13
- data/spec/testfile1.ods +0 -0
- data/spec/tools_spec.rb +25 -0
- data/spec/workbook_spec.rb +22 -4
- data/spec/worksheet_spec.rb +13 -11
- data/spec/xml_tied_array_spec.rb +9 -0
- metadata +10 -4
data/spec/rspreadsheet_spec.rb
CHANGED
@@ -1,14 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Rspreadsheet::Tools do
|
4
|
-
it 'converts correctly cell adresses' do
|
5
|
-
Rspreadsheet::Tools.convert_cell_address('A1')[0].should == 1
|
6
|
-
Rspreadsheet::Tools.convert_cell_address('A1')[1].should == 1
|
7
|
-
Rspreadsheet::Tools.convert_cell_address('C5')[0].should == 5
|
8
|
-
Rspreadsheet::Tools.convert_cell_address('C5')[1].should == 3
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
3
|
describe Rspreadsheet do
|
13
4
|
it 'can open ods testfile and reads its content correctly' do
|
14
5
|
book = Rspreadsheet.new($test_filename)
|
@@ -31,7 +22,7 @@ describe Rspreadsheet do
|
|
31
22
|
@sheet2 = book2.worksheets[1]
|
32
23
|
|
33
24
|
@sheet1.nonemptycells.each do |cell| # and test identity
|
34
|
-
@sheet2[cell.
|
25
|
+
@sheet2[cell.rowi,cell.coli].should == cell.value
|
35
26
|
end
|
36
27
|
end
|
37
28
|
it 'can open and save file, and saved file is exactly same as original' do
|
@@ -61,9 +52,6 @@ describe Rspreadsheet do
|
|
61
52
|
book.worksheets[1].rows(1).cells(1).value ='xyzxyz'
|
62
53
|
book.worksheets[1].rows(1).cells(1).value.should == 'xyzxyz'
|
63
54
|
|
64
|
-
# book.worksheets[1][1,1].should_not == 'xyzxyz'
|
65
|
-
# book.worksheets[1][1,1]='xyzxyz'
|
66
|
-
# book.worksheets[1][1,1].should == 'xyzxyz'
|
67
55
|
book.save(tmp_filename) # and save it as temp file
|
68
56
|
|
69
57
|
# now compare them
|
data/spec/testfile1.ods
CHANGED
Binary file
|
data/spec/tools_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rspreadsheet::Tools do
|
4
|
+
it 'Converts correctly cell adresses to coordinates and back' do
|
5
|
+
Rspreadsheet::Tools.convert_cell_address_to_coordinates('A1').should == [1,1]
|
6
|
+
Rspreadsheet::Tools.convert_cell_address_to_coordinates('C17').should == [17,3]
|
7
|
+
Rspreadsheet::Tools.convert_cell_address_to_coordinates('AM1048576').should == [1048576,39]
|
8
|
+
Rspreadsheet::Tools.convert_cell_address_to_coordinates('ADA2').should == [2,781]
|
9
|
+
Rspreadsheet::Tools.convert_cell_address_to_coordinates('ZZ1').should == [1,702]
|
10
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([1,1]).should == 'A1'
|
11
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([17,3]).should == 'C17'
|
12
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([1,27]).should == 'AA1'
|
13
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([1,39]).should == 'AM1'
|
14
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([1,53]).should == 'BA1'
|
15
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([1,702]).should == 'ZZ1'
|
16
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([2,703]).should == 'AAA2'
|
17
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([1048576,39]).should == 'AM1048576'
|
18
|
+
Rspreadsheet::Tools.convert_cell_coordinates_to_address([2,781]).should == 'ADA2'
|
19
|
+
Rspreadsheet::Tools.c2a([2,781]).should == 'ADA2'
|
20
|
+
Rspreadsheet::Tools.c2a(2,781).should == 'ADA2'
|
21
|
+
Rspreadsheet::Tools.a2c('ADA2').should == [2,781]
|
22
|
+
Rspreadsheet::Tools.a2c('ADA','2').should == [2,781]
|
23
|
+
(1..200).each { |i| Rspreadsheet::Tools.a2c(Rspreadsheet::Tools.c2a(1,i*10)).should == [1,i*10] }
|
24
|
+
end
|
25
|
+
end
|
data/spec/workbook_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Rspreadsheet::Workbook do
|
3
|
+
describe Rspreadsheet::Workbook, :focus=>true do
|
4
4
|
it 'has correct number of sheets' do
|
5
|
-
book = Rspreadsheet.new($test_filename)
|
5
|
+
book = Rspreadsheet::Workbook.new($test_filename)
|
6
6
|
book.worksheets_count.should == 1
|
7
7
|
book.worksheets[0].should be_nil
|
8
8
|
book.worksheets[1].should be_kind_of(Rspreadsheet::Worksheet)
|
@@ -10,10 +10,28 @@ describe Rspreadsheet::Workbook do
|
|
10
10
|
book.worksheets[nil].should be_nil
|
11
11
|
end
|
12
12
|
it 'freshly created has correctly namespaced xmlnode' do
|
13
|
-
@xmlnode = Rspreadsheet.new.xmlnode
|
13
|
+
@xmlnode = Rspreadsheet::Workbook.new.xmlnode
|
14
14
|
@xmlnode.namespaces.to_a.size.should >5
|
15
15
|
@xmlnode.namespaces.find_by_prefix('office').should_not be_nil
|
16
16
|
@xmlnode.namespaces.find_by_prefix('table').should_not be_nil
|
17
17
|
@xmlnode.namespaces.namespace.prefix.should == 'office'
|
18
18
|
end
|
19
|
-
|
19
|
+
it 'can create worksheets, and count them' do
|
20
|
+
book = Rspreadsheet::Workbook.new()
|
21
|
+
book.worksheets_count.should == 0
|
22
|
+
book.create_worksheet
|
23
|
+
book.worksheets_count.should == 1
|
24
|
+
book.create_worksheet
|
25
|
+
book.create_worksheet
|
26
|
+
book.worksheets_count.should == 3
|
27
|
+
end
|
28
|
+
it 'nonemptycells behave correctly' do
|
29
|
+
book = Rspreadsheet::Workbook.new()
|
30
|
+
book.create_worksheet
|
31
|
+
@sheet = book.worksheets[1]
|
32
|
+
@sheet.cells(3,3).value = 'data'
|
33
|
+
@sheet.cells(5,7).value = 'data'
|
34
|
+
@sheet.nonemptycells.collect{|c| c.coordinates}.should =~ [[3,3],[5,7]]
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/spec/worksheet_spec.rb
CHANGED
@@ -7,17 +7,11 @@ describe Rspreadsheet::Worksheet do
|
|
7
7
|
it 'contains nonempty xml in rows for testfile' do
|
8
8
|
@sheet.rows(1).xmlnode.elements.size.should be >1
|
9
9
|
end
|
10
|
-
it '
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@xmlnode.namespaces.to_a.size.should >5
|
15
|
-
@xmlnode.namespaces.find_by_prefix('office').should_not be_nil
|
16
|
-
@xmlnode.namespaces.find_by_prefix('table').should_not be_nil
|
17
|
-
@xmlnode.namespaces.namespace.should_not be_nil
|
18
|
-
@xmlnode.namespaces.namespace.prefix.should == 'table'
|
10
|
+
it 'uses detach_subnode_respect_repeated well' do
|
11
|
+
@xmlnode = @sheet.xmlnode
|
12
|
+
nod = @sheet.detach_subnode_respect_repeated(@xmlnode, 50, {:xml_items_node_name => 'table-row', :xml_repeated_attribute => 'number-rows-repeated'})
|
13
|
+
@sheet.detach_subnode_respect_repeated(nod, 12, {:xml_items_node_name => 'table-cell', :xml_repeated_attribute => 'number-columns-repeated'})
|
19
14
|
end
|
20
|
-
|
21
15
|
end
|
22
16
|
|
23
17
|
describe Rspreadsheet::Worksheet do
|
@@ -25,6 +19,14 @@ describe Rspreadsheet::Worksheet do
|
|
25
19
|
book = Rspreadsheet.new
|
26
20
|
@sheet = book.create_worksheet
|
27
21
|
end
|
22
|
+
it 'freshly created has correctly namespaced xmlnode' do
|
23
|
+
@xmlnode = @sheet.xmlnode
|
24
|
+
@xmlnode.namespaces.to_a.size.should >5
|
25
|
+
@xmlnode.namespaces.find_by_prefix('office').should_not be_nil
|
26
|
+
@xmlnode.namespaces.find_by_prefix('table').should_not be_nil
|
27
|
+
@xmlnode.namespaces.namespace.should_not be_nil
|
28
|
+
@xmlnode.namespaces.namespace.prefix.should == 'table'
|
29
|
+
end
|
28
30
|
it 'remembers the value stored to A1 cell' do
|
29
31
|
@sheet[1,1].should == nil
|
30
32
|
@sheet[1,1] = 'test text'
|
@@ -52,4 +54,4 @@ describe Rspreadsheet::Worksheet do
|
|
52
54
|
@sheet[0,0].should == nil
|
53
55
|
@sheet[999,999].should == nil
|
54
56
|
end
|
55
|
-
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspreadsheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub A.Těšínský
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libxml-ruby
|
@@ -150,8 +150,9 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '2.6'
|
153
|
-
description: Manipulating spreadsheets with Ruby
|
154
|
-
|
153
|
+
description: Manipulating OpenDocument spreadsheets with Ruby. This gem can create
|
154
|
+
new, read existing files abd modify them. When modyfying files, it tries to change
|
155
|
+
as little as possible, making it as much forward compatifle as possible.
|
155
156
|
email:
|
156
157
|
- jAkub.cz (A is at)
|
157
158
|
executables: []
|
@@ -172,6 +173,7 @@ files:
|
|
172
173
|
- investigate.rb
|
173
174
|
- lib/class_extensions.rb
|
174
175
|
- lib/rspreadsheet.rb
|
176
|
+
- lib/rspreadsheet/.row.rb.kate-swp.bak
|
175
177
|
- lib/rspreadsheet/cell.rb
|
176
178
|
- lib/rspreadsheet/empty_file_template.ods
|
177
179
|
- lib/rspreadsheet/empty_file_template.old.ods
|
@@ -187,8 +189,10 @@ files:
|
|
187
189
|
- spec/rspreadsheet_spec.rb
|
188
190
|
- spec/spec_helper.rb
|
189
191
|
- spec/testfile1.ods
|
192
|
+
- spec/tools_spec.rb
|
190
193
|
- spec/workbook_spec.rb
|
191
194
|
- spec/worksheet_spec.rb
|
195
|
+
- spec/xml_tied_array_spec.rb
|
192
196
|
homepage: https://github.com/gorn/rspreadsheet
|
193
197
|
licenses:
|
194
198
|
- GPL
|
@@ -220,5 +224,7 @@ test_files:
|
|
220
224
|
- spec/rspreadsheet_spec.rb
|
221
225
|
- spec/spec_helper.rb
|
222
226
|
- spec/testfile1.ods
|
227
|
+
- spec/tools_spec.rb
|
223
228
|
- spec/workbook_spec.rb
|
224
229
|
- spec/worksheet_spec.rb
|
230
|
+
- spec/xml_tied_array_spec.rb
|