workbook 0.8.2 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19f7a4905a129fba73781bb8ef9f672573419b5b754508bc3cc28aff968d5fb8
4
- data.tar.gz: 7bd07336aaee461b7ff487c683b427ba29d717bee23731d80c1e74d1a1f7cd1e
3
+ metadata.gz: ec0bdb507a80fb55be5230a13bf28eab6b650dd8f7c8609895dcba90d53b02f3
4
+ data.tar.gz: dab18c494f909fd3f486ab0e3cd971992aa40984d2e780f433adb6c96721ebb7
5
5
  SHA512:
6
- metadata.gz: 5d20a391aee1d3338f08ecddb104cca25411626787bec16a2c0a25e125efa6bbee91f79350a919afcca7d6443fac62ca34d2f2da20985e1eae3b59c73e6f6b7f
7
- data.tar.gz: 93d1ffe829d5fb3f591b9ef5244c013f4268d982f8e148893439b7788d8422f99e1449577fd708e753cb26db9029db1a08a1e46e8db0d12860e23db4124a8a82
6
+ metadata.gz: 7e4e6e75a967577561848fe714857a044192331362674a68a20a63248e47bb65e5cd34ad2847ed20ff8c3ebe2c195c9a8c52f589350a06d720fc2bdec003fd50
7
+ data.tar.gz: 9ac507805db929954970ea95f88483665c3e1f8a63d64be94be09f76d0e527b2eec0e0d1e4886055b27c25f1e2e9c0284b157bf7681beba261fb35c8f695ff70
data/CHANGELOG.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Changelog
2
2
 
3
- ### 0.9.0 (in progress)
3
+ ### 0.9.0
4
4
 
5
5
  * Dropped inheritance from Array and borrowed from the Enumerable module instead (this might break some existing implementations; please create pull request if you miss Array like functionality)
6
+ * Fix: ODS: Currency formatted cell now no longer returns String
6
7
 
7
8
  ### 0.8.1
8
9
 
data/json_test.json ADDED
@@ -0,0 +1 @@
1
+ [{"a":1,"b":2},{"a":"2012-01-01","b":null}]
@@ -138,6 +138,7 @@ module Workbook
138
138
  def parse_local_value(valuetype)
139
139
  value = CGI.unescapeHTML(@cell.xpath("text:p//text()").to_s)
140
140
  value = value == "" ? nil : value
141
+
141
142
  case valuetype
142
143
  when "integer"
143
144
  value = @cell.xpath("@office:value").to_s.to_i
@@ -146,6 +147,8 @@ module Workbook
146
147
  value = value.to_i unless /\./.match?(@cell.xpath("@office:value").to_s) # sadly most integers are typed as floats...
147
148
  when "date"
148
149
  value = DateTime.parse(@cell.xpath("@office:date-value").to_s)
150
+ when "currency"
151
+ value = @cell.xpath("@office:value").to_s.to_f
149
152
  end
150
153
  value
151
154
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # frozen_string_literal: true
3
2
 
4
3
  module Workbook
5
- VERSION = "0.8.2"
4
+ VERSION = "0.9.1"
6
5
  end
Binary file
@@ -142,6 +142,14 @@ class TestModulesCell < Minitest::Test
142
142
  assert_equal(2, t[2][2].index)
143
143
  end
144
144
 
145
+ def test_inspect
146
+ c = Workbook::Cell.new(1)
147
+ assert_equal("<Workbook::Cell @value=1 @cell_type=integer>", c.inspect)
148
+ c = Workbook::Cell.new(Date.new(2023,12,1))
149
+ assert_equal("<Workbook::Cell @value=2023-12-01 @cell_type=date>", c.inspect)
150
+ end
151
+
152
+
145
153
  def test_key
146
154
  t = Workbook::Table.new [[:a, :b, :c], [1, 2, 3], [4, 5, 6]]
147
155
  assert_equal(:c, t[2][2].key)
@@ -31,6 +31,14 @@ module Readers
31
31
  assert_equal(1.2, w.sheet.table[3][1].value)
32
32
  end
33
33
 
34
+ def test_currency
35
+ w = Workbook::Book.new
36
+ w.import File.join(File.dirname(__FILE__), "artifacts/currency_test.ods")
37
+
38
+ assert_equal(1200, w.sheet.table["H2"].value)
39
+ assert_equal(1200.4, w.sheet.table["H4"].value)
40
+ end
41
+
34
42
  def test_excel_standardized_open
35
43
  w = Workbook::Book.new
36
44
  w.import File.join(File.dirname(__FILE__), "artifacts/excel_different_types.ods")
data/test/test_sheet.rb CHANGED
@@ -71,18 +71,6 @@ class TestWorkbook < Minitest::Test
71
71
  assert_equal(false, table1 == table0)
72
72
  end
73
73
 
74
- def test_profile_speed
75
- w = Workbook::Book.new [["a", "b"], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4]]
76
- require "ruby-prof"
77
- RubyProf.start
78
- w.sheet.table.each do |row|
79
- row[:a].value
80
- end
81
- result = RubyProf.stop
82
- printer = RubyProf::MultiPrinter.new(result)
83
- printer.print(path: ".", profile: "profile")
84
- end
85
-
86
74
  def test_name
87
75
  b = Workbook::Book.new [["a", "b"], [1, 2]]
88
76
  b.push Workbook::Sheet.new([["a", "b"], [2, 2]])
@@ -17,5 +17,12 @@ module Writers
17
17
  assert_equal("[{\"a\":1,\"b\":2},{\"a\":\"2012-01-01\",\"b\":null}]",
18
18
  Workbook::Table.new([["a", "b"], [1, 2], [Date.new(2012, 1, 1), nil]]).to_json)
19
19
  end
20
+
21
+ def test_write_to_json
22
+ filename = Workbook::Table.new([["a", "b"], [1, 2], [Date.new(2012, 1, 1), nil]]).write_to_json("json_test.json")
23
+ json_written = File.read(filename)
24
+ assert_equal("[{\"a\":1,\"b\":2},{\"a\":\"2012-01-01\",\"b\":null}]",json_written)
25
+
26
+ end
20
27
  end
21
28
  end
data/workbook.gemspec CHANGED
@@ -11,23 +11,21 @@ Gem::Specification.new do |s|
11
11
  s.summary = "Workbook is a datastructure to contain books of tables (an anlogy used in e.g. Excel)"
12
12
  s.description = "Workbook contains workbooks, as in a table, contains rows, contains cells, reads/writes excel, ods and csv and tab separated files, and offers basic diffing and sorting capabilities."
13
13
  s.authors = ["Maarten Brouwers"]
14
- s.add_development_dependency "ruby-prof", "~> 0.14"
15
- s.add_development_dependency("rake", "~> 12.0")
16
- s.add_development_dependency("minitest", "~> 5.4")
14
+ s.add_development_dependency("rake", "> 12.0")
15
+ s.add_development_dependency("minitest", "> 5.4")
17
16
  s.add_development_dependency("byebug", "> 10")
18
- s.add_development_dependency("standard", "~> 0.1.0")
19
- s.add_development_dependency("simplecov", "~> 0.17.0")
17
+ s.add_development_dependency("standard", "> 1.0")
18
+ s.add_development_dependency("simplecov", "> 0.17.0")
20
19
  s.add_dependency("spreadsheet", "> 1.2")
21
20
  s.add_dependency("rchardet", ">= 1.8.0")
22
21
  s.add_dependency("json", "> 2.3")
23
22
  s.add_dependency("rubyzip", "> 1.2", ">= 1.2.1")
24
23
  s.add_dependency("caxlsx", "> 3.0")
25
24
  s.add_dependency("nokogiri", "> 1.10")
26
-
25
+ s.add_dependency("csv", "> 3.0.0")
27
26
 
28
27
  s.platform = Gem::Platform::RUBY
29
28
  s.files = `git ls-files`.split($/)
30
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
31
29
  s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
32
30
  s.require_paths = ["lib"]
33
31
  s.email = ["gem@murb.nl"]
metadata CHANGED
@@ -1,55 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten Brouwers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-11 00:00:00.000000000 Z
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ruby-prof
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.14'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.14'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">"
32
18
  - !ruby/object:Gem::Version
33
19
  version: '12.0'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">"
39
25
  - !ruby/object:Gem::Version
40
26
  version: '12.0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: minitest
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">"
46
32
  - !ruby/object:Gem::Version
47
33
  version: '5.4'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">"
53
39
  - !ruby/object:Gem::Version
54
40
  version: '5.4'
55
41
  - !ruby/object:Gem::Dependency
@@ -70,28 +56,28 @@ dependencies:
70
56
  name: standard
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - ">"
74
60
  - !ruby/object:Gem::Version
75
- version: 0.1.0
61
+ version: '1.0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">"
81
67
  - !ruby/object:Gem::Version
82
- version: 0.1.0
68
+ version: '1.0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: simplecov
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - "~>"
73
+ - - ">"
88
74
  - !ruby/object:Gem::Version
89
75
  version: 0.17.0
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ">"
95
81
  - !ruby/object:Gem::Version
96
82
  version: 0.17.0
97
83
  - !ruby/object:Gem::Dependency
@@ -184,6 +170,20 @@ dependencies:
184
170
  - - ">"
185
171
  - !ruby/object:Gem::Version
186
172
  version: '1.10'
173
+ - !ruby/object:Gem::Dependency
174
+ name: csv
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">"
178
+ - !ruby/object:Gem::Version
179
+ version: 3.0.0
180
+ type: :runtime
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">"
185
+ - !ruby/object:Gem::Version
186
+ version: 3.0.0
187
187
  description: Workbook contains workbooks, as in a table, contains rows, contains cells,
188
188
  reads/writes excel, ods and csv and tab separated files, and offers basic diffing
189
189
  and sorting capabilities.
@@ -209,6 +209,7 @@ files:
209
209
  - README.md
210
210
  - Rakefile
211
211
  - bin/axldiff
212
+ - json_test.json
212
213
  - lib/workbook.rb
213
214
  - lib/workbook/book.rb
214
215
  - lib/workbook/cell.rb
@@ -255,6 +256,7 @@ files:
255
256
  - test/artifacts/book_with_tabs_and_colours.xlsx
256
257
  - test/artifacts/complex_types.ods
257
258
  - test/artifacts/complex_types.xls
259
+ - test/artifacts/currency_test.ods
258
260
  - test/artifacts/excel_different_types.csv
259
261
  - test/artifacts/excel_different_types.ods
260
262
  - test/artifacts/excel_different_types.txt
@@ -323,65 +325,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
323
325
  - !ruby/object:Gem::Version
324
326
  version: '0'
325
327
  requirements: []
326
- rubygems_version: 3.4.6
328
+ rubygems_version: 3.5.18
327
329
  signing_key:
328
330
  specification_version: 4
329
331
  summary: Workbook is a datastructure to contain books of tables (an anlogy used in
330
332
  e.g. Excel)
331
- test_files:
332
- - test/artifacts/bigtable.xls
333
- - test/artifacts/bigtable.xlsx
334
- - test/artifacts/book_with_colspans.ods
335
- - test/artifacts/book_with_tabs_and_colours.ods
336
- - test/artifacts/book_with_tabs_and_colours.xls
337
- - test/artifacts/book_with_tabs_and_colours.xlsx
338
- - test/artifacts/complex_types.ods
339
- - test/artifacts/complex_types.xls
340
- - test/artifacts/excel_different_types.csv
341
- - test/artifacts/excel_different_types.ods
342
- - test/artifacts/excel_different_types.txt
343
- - test/artifacts/excel_different_types.xls
344
- - test/artifacts/excel_different_types.xlsx
345
- - test/artifacts/failing_import1.xls
346
- - test/artifacts/heavy.xlsx
347
- - test/artifacts/integer_test.xlsx
348
- - test/artifacts/native_xlsx.xlsx
349
- - test/artifacts/semicolonseparated_in_csv.csv
350
- - test/artifacts/sheet_with_combined_cells.ods
351
- - test/artifacts/sheetduplication.xls
352
- - test/artifacts/simple_csv.csv
353
- - test/artifacts/simple_excel_csv.csv
354
- - test/artifacts/simple_sheet.ods
355
- - test/artifacts/simple_sheet.xls
356
- - test/artifacts/simple_sheet.xlsx
357
- - test/artifacts/simple_sheet_many_sheets.xls
358
- - test/artifacts/skippingcells.xlsx
359
- - test/artifacts/txt_in_xls.xls
360
- - test/artifacts/xls_with_txt_extension.txt
361
- - test/artifacts/xlsx_with_empty_start.xlsx
362
- - test/artifacts/zip_in_xls.xls
363
- - test/helper.rb
364
- - test/test_book.rb
365
- - test/test_column.rb
366
- - test/test_format.rb
367
- - test/test_functional.rb
368
- - test/test_modules_cache.rb
369
- - test/test_modules_cell.rb
370
- - test/test_modules_table_diff_sort.rb
371
- - test/test_modules_type_parser.rb
372
- - test/test_readers_csv_reader.rb
373
- - test/test_readers_ods_reader.rb
374
- - test/test_readers_txt_reader.rb
375
- - test/test_readers_xls_reader.rb
376
- - test/test_readers_xls_shared.rb
377
- - test/test_readers_xlsx_reader.rb
378
- - test/test_row.rb
379
- - test/test_sheet.rb
380
- - test/test_table.rb
381
- - test/test_template.rb
382
- - test/test_types_date.rb
383
- - test/test_writers_csv_writer.rb
384
- - test/test_writers_html_writer.rb
385
- - test/test_writers_json_writer.rb
386
- - test/test_writers_xls_writer.rb
387
- - test/test_writers_xlsx_writer.rb
333
+ test_files: []