workbook 0.4.11 → 0.4.12

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
  SHA1:
3
- metadata.gz: ff139530b00ab86d7a7cc2e63329253f15f90959
4
- data.tar.gz: 4c82a23c6e61d24f16635033fa721f0b3d46539a
3
+ metadata.gz: c05c947e639810533b5d77b7f66cca14bf2880b3
4
+ data.tar.gz: 623d1d9ca5e9bceac0cb0a18bec19d79a869a193
5
5
  SHA512:
6
- metadata.gz: f06054fa85e28d7eea8f5d97e3a20aeff0294c9b25c310a42080ed021242881abecb3ca802143b12fa2cbac0be13bd8b497cd01e069e3d7a4b0eb9afd76b9d11
7
- data.tar.gz: 9d3b19c3ebdee818778c33e88713c1a8c26323f537e66c89f881d187e392511e4a2e55cf8c9827df5e197aedb4eb361444889930dd0233e0f7b88b0bc2bd775a
6
+ metadata.gz: e972dc3fbcc4d1c29860b5966c4c3d54407b6a24344450279410ee029f163555c00d8b1cec240d224c5d47ffc4d8b4f0a96e23f2b13d2cb0a5a575cb8631380e
7
+ data.tar.gz: 74538baa3d9d1ce6644a4a35e2aab5aed98b213abd4d6cc89392fcf29a34a77524f9dbdc75d9156377965a39056e06cfc36a5e3738b2320a8a796b4ad596e11e
data/.gitignore CHANGED
@@ -10,4 +10,5 @@ empty.png
10
10
  minus.png
11
11
  plus.png
12
12
  profile.*
13
- untitled document.xlsx*
13
+ untitled document.xlsx*
14
+ .DS_Store
@@ -153,9 +153,12 @@ module Workbook
153
153
  return @to_sym if @to_sym
154
154
  v = nil
155
155
  if value
156
- ends_with_exclamationmark = (value[-1] == '!')
157
- ends_with_questionmark = (value[-1] == '?')
158
156
  v = value.to_s.downcase
157
+ if v.to_i != 0
158
+ v = "num#{v}"
159
+ end
160
+ ends_with_exclamationmark = (v[-1] == '!')
161
+ ends_with_questionmark = (v[-1] == '?')
159
162
 
160
163
  replacements = {
161
164
  [/[\(\)\.\?\,\!\=\$\:]/,] => '',
@@ -52,8 +52,21 @@ module Workbook
52
52
  end
53
53
  end
54
54
 
55
+ # Set the header of this table (typically the first row, but can be a different row).
56
+ # The header row is also used for finding values in a aribrary row.
57
+ #
58
+ # @param [Workbook::Row, Integer]
59
+ # @return [Workbook::Row] The header
55
60
  def header= h
56
- @header = h
61
+ if h.is_a? Numeric
62
+ @header = self[h]
63
+ else
64
+ @header = h
65
+ end
66
+ end
67
+
68
+ def header_row_index(h=nil)
69
+ self.index(h ? h : self.header)
57
70
  end
58
71
 
59
72
  def define_columns_with_row(r)
@@ -139,7 +152,6 @@ module Workbook
139
152
  def clone
140
153
  t = self
141
154
  c = super
142
- header_row_index = t.index(t.header)
143
155
  c.delete_all
144
156
  t.each{|r| c << r.clone}
145
157
  c.header = c[header_row_index] if header_row_index
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Workbook
3
- VERSION = '0.4.11'
3
+ VERSION = '0.4.12'
4
4
  end
@@ -55,7 +55,7 @@ module Workbook
55
55
  if header
56
56
  doc.tr do
57
57
  header.each do |cell|
58
- th_options = build_cell_options cell, options
58
+ th_options = build_cell_options cell, options.merge(classnames: [cell.to_sym])
59
59
  unless cell.value.class == Workbook::NilValue
60
60
  doc.th(th_options) do
61
61
  doc.text cell.value
@@ -87,7 +87,9 @@ module Workbook
87
87
  end
88
88
  private
89
89
  def build_cell_options cell, options={}
90
- classnames = cell.format.all_names.join(" ").strip
90
+ classnames = cell.format.all_names
91
+ classnames = classnames + options[:classnames] if options[:classnames]
92
+ classnames = classnames.join(" ").strip
91
93
  td_options = classnames != "" ? {:class=>classnames} : {}
92
94
  td_options = td_options.merge({:style=>cell.format.to_css}) if options[:style_with_inline_css] and cell.format.to_css != ""
93
95
  td_options = td_options.merge({:colspan=>cell.colspan}) if cell.colspan
@@ -0,0 +1 @@
1
+ ,murb,murb-top.local,03.02.2016 16:38,file:///Users/murb/Library/Application%20Support/LibreOffice/4;
Binary file
@@ -80,7 +80,9 @@ class TestModulesCell < Minitest::Test
80
80
  "A - c (B123)!" => :a_c_b123!,
81
81
  "A-B?" => :ab?,
82
82
  "A-B!" => :ab!,
83
- "éåšžÌ?" => :easzi?
83
+ "éåšžÌ?" => :easzi?,
84
+ 1 => :num1,
85
+ 1.0 => :num10
84
86
  }
85
87
  examples.each do |k,v|
86
88
  assert_equal(v, Workbook::Cell.new(k).to_sym)
@@ -20,8 +20,9 @@ module Readers
20
20
  w.open File.join(File.dirname(__FILE__), 'artifacts/complex_types.xls')
21
21
  assert_equal(Date.new(2011,11,15), w.sheet.table[2][3].value)
22
22
  assert_equal("http://murb.nl", w.sheet.table[3][2].value)
23
- assert_equal("sadfasdfsd", w.sheet.table[4][2].value)
24
- assert_equal(1.2, w.sheet.table[3][1].value)
23
+ assert_equal("sadfasdfsd!", w.sheet.table[4][2].value)
24
+ assert_equal(1.2, w.sheet.table[2][1].value)
25
+ assert_equal(1, w.sheet.table[3][1].value)
25
26
  end
26
27
 
27
28
  def test_xls_excel_standardized_open
data/test/test_table.rb CHANGED
@@ -183,7 +183,6 @@ class TestTable< Minitest::Test
183
183
  last_line = table.count-1
184
184
  first_few_lines = table[12][0].value - table[2][0].value
185
185
  last_few_lines = table[last_line][0].value - table[last_line-10][0].value
186
- # puts [first_few_lines,last_few_lines].join(" vs ")
187
186
  assert_equal(true, first_few_lines*1.20 > last_few_lines) # 10% slower is acceptable
188
187
  end
189
188
  def test_columns
@@ -14,7 +14,7 @@ module Writers
14
14
  assert_equal(false, match)
15
15
  match = html.match(/<td>1<\/td>/) ? true : false
16
16
  assert_equal(true, match)
17
- match = html.match(/<th>a<\/th>/) ? true : false
17
+ match = html.match(/<th class=\"a\">a<\/th>/) ? true : false
18
18
  assert_equal(true, match)
19
19
  end
20
20
  def test_to_html_format_names
@@ -24,7 +24,7 @@ module Writers
24
24
  c = b[0][0][1][0]
25
25
  c.format.name="testname"
26
26
  html = b.to_html
27
- match = html.match(/<th class=\"testname\">a<\/th>/) ? true : false
27
+ match = html.match(/<th class=\"testname a\">a<\/th>/) ? true : false
28
28
  assert_equal(true, match)
29
29
  match = html.match(/<td class=\"testname\">1<\/td>/) ? true : false
30
30
  assert_equal(true, match)
@@ -36,7 +36,7 @@ module Writers
36
36
  c = b[0][0][1][0]
37
37
  c.format[:background]="#ff0"
38
38
  html = b.to_html
39
- match = html.match(/<th>a<\/th>/) ? true : false
39
+ match = html.match(/<th class=\"a\">a<\/th>/) ? true : false
40
40
  match = html.match(/<td>1<\/td>/) ? true : false
41
41
  assert_equal(true, match)
42
42
  html = b.to_html({:style_with_inline_css=>true})
data/workbook.gemspec CHANGED
@@ -15,15 +15,12 @@ Gem::Specification.new do |s|
15
15
  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."
16
16
  s.authors = ["Maarten Brouwers"]
17
17
  s.add_development_dependency 'ruby-prof', '~> 0.14'
18
- s.add_dependency('rubyzip', '~>1')
19
18
  s.add_dependency('spreadsheet', '~> 1.0')
20
19
  s.add_development_dependency('minitest', '~> 5.4')
21
20
  s.add_dependency('fastercsv') if RUBY_VERSION < "1.9"
22
21
  s.add_dependency("rchardet", "~> 1.3")
23
22
  s.add_dependency("rake", '~> 10.0')
24
23
  s.add_dependency("json", '~> 1.8')
25
- s.add_dependency("zip-zip", '~> 0.2') #actually a hack...
26
- #s.add_dependency('rubyXL', '~> 3.3')
27
24
  s.add_dependency('roo', '~> 1.13')
28
25
  s.add_dependency('axlsx', '~> 2.0.1')
29
26
  if RUBY_VERSION < "1.9"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten Brouwers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-prof
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.14'
27
- - !ruby/object:Gem::Dependency
28
- name: rubyzip
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: spreadsheet
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +94,6 @@ dependencies:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
96
  version: '1.8'
111
- - !ruby/object:Gem::Dependency
112
- name: zip-zip
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.2'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0.2'
125
97
  - !ruby/object:Gem::Dependency
126
98
  name: roo
127
99
  requirement: !ruby/object:Gem::Requirement
@@ -266,6 +238,7 @@ files:
266
238
  - lib/workbook/writers/xls_writer.rb
267
239
  - lib/workbook/writers/xlsx_writer.rb
268
240
  - rbeautify.rb
241
+ - test/artifacts/.~lock.complex_types.xls#
269
242
  - test/artifacts/bigtable.xls
270
243
  - test/artifacts/bigtable.xlsx
271
244
  - test/artifacts/book_with_colspans.ods
@@ -337,12 +310,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
337
310
  version: '0'
338
311
  requirements: []
339
312
  rubyforge_project: workbook
340
- rubygems_version: 2.2.2
313
+ rubygems_version: 2.4.5
341
314
  signing_key:
342
315
  specification_version: 4
343
316
  summary: Workbook is a datastructure to contain books of tables (an anlogy used in
344
317
  e.g. Excel)
345
318
  test_files:
319
+ - test/artifacts/.~lock.complex_types.xls#
346
320
  - test/artifacts/bigtable.xls
347
321
  - test/artifacts/bigtable.xlsx
348
322
  - test/artifacts/book_with_colspans.ods
@@ -393,4 +367,3 @@ test_files:
393
367
  - test/test_writers_json_writer.rb
394
368
  - test/test_writers_xls_writer.rb
395
369
  - test/test_writers_xlsx_writer.rb
396
- has_rdoc: