write_xlsx 0.85.7 → 0.85.8

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
- SHA1:
3
- metadata.gz: 9321ad366de31af18f34ce1898368f6d754759b9
4
- data.tar.gz: 7ad3e41824e5e9443d211766fb285ca56550ff0b
2
+ SHA256:
3
+ metadata.gz: 1a8ed1e139d973baf49fc349d874da19de256e10ac34f2b4f5a08ec6dcac1eba
4
+ data.tar.gz: a553667cbe7443f9c9bbfc74d28a9a30e830c95dec213e2d70ca48862bb0505a
5
5
  SHA512:
6
- metadata.gz: 7aa745d393ba1664d8e59bcbf56c3eaf2430d4000dda9b4e929c6766bdf852ea1686af0fb0e30e7cec90fa94e49432ef0383aa871bec7c0ae45f13c4cc53f1ce
7
- data.tar.gz: f321d7ddd751e9a4e757b75c519859be73cee90966f31ad1089e15cd8f2ce97b2f03a0d6abc89931d68862facd442000b88fc2177e421c488ed31d91db370aef
6
+ metadata.gz: ec4e891ca22e53564f6a715aca9efce06c19782a4274d71ddb485b2bc34f1bf4f11a5f70b736b5fd4f23d74b47e68235c8ef4781fd3c014cad7cbf7c07501963
7
+ data.tar.gz: e262a4b65b0da4703894ab831f36a1058dcae5d71d103d7f83c313c0ada4e30db534eaabc3273b4c784c1b06d14de4730506b142ea49c8dc32c283339604f0c3
data/Changes CHANGED
@@ -1,5 +1,8 @@
1
1
  Change history of write_xlsx rubygem.
2
2
 
3
+ 2020-09-03 v0.85.8
4
+ apply pull-request #58 and #52
5
+
3
6
  2019-06-20 v0.85.7
4
7
  apply pull-request #26
5
8
 
@@ -287,11 +287,10 @@ def set_format_properties(*properties) # :nodoc:
287
287
 
288
288
  # Create a sub to set the property.
289
289
  if value.respond_to?(:to_str) || !value.respond_to?(:+)
290
- s = "set_#{key}('#{value}')"
290
+ send("set_#{key}", value.to_s)
291
291
  else
292
- s = "set_#{key}(#{value})"
292
+ send("set_#{key}", value)
293
293
  end
294
- eval s
295
294
  end
296
295
  end
297
296
  end
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  #
3
4
  # XMLWriterSimple
4
5
  #
@@ -29,10 +30,9 @@ def tag_elements(tag, attributes = [])
29
30
  end
30
31
 
31
32
  def tag_elements_str(tag, attributes = [])
32
- str = ''
33
- str << start_tag_str(tag, attributes)
34
- str << yield
35
- str << end_tag_str(tag)
33
+ str = start_tag_str(tag, attributes) +
34
+ yield +
35
+ end_tag_str(tag)
36
36
  end
37
37
 
38
38
  def start_tag(tag, attr = [])
@@ -65,7 +65,7 @@ def empty_tag_encoded_str(tag, attr = [])
65
65
  end
66
66
 
67
67
  def data_element(tag, data, attr = [])
68
- tag_elements(tag, attr) { io_write("#{escape_data(data)}") }
68
+ tag_elements(tag, attr) { io_write(escape_data(data)) }
69
69
  end
70
70
 
71
71
  #
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  require 'write_xlsx/col_name'
3
4
 
4
5
  module Writexlsx
@@ -303,11 +304,12 @@ def write_color(writer, name, value) #:nodoc:
303
304
  writer.empty_tag('color', attributes)
304
305
  end
305
306
 
307
+ PERL_TRUE_VALUES = [false, nil, 0, "0", "", [], {}].freeze
306
308
  #
307
309
  # return perl's boolean result
308
310
  #
309
311
  def ptrue?(value)
310
- if [false, nil, 0, "0", "", [], {}].include?(value)
312
+ if PERL_TRUE_VALUES.include?(value)
311
313
  false
312
314
  else
313
315
  true
@@ -1 +1 @@
1
- WriteXLSX_VERSION = "0.85.7"
1
+ WriteXLSX_VERSION = "0.85.8"
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  require 'write_xlsx/package/xml_writer_simple'
3
4
  require 'write_xlsx/package/packager'
4
5
  require 'write_xlsx/sheets'
@@ -972,8 +973,9 @@ def date_1904? #:nodoc:
972
973
  # Add a string to the shared string table, if it isn't already there, and
973
974
  # return the string index.
974
975
  #
975
- def shared_string_index(str, params = {}) #:nodoc:
976
- @shared_strings.index(str, params)
976
+ EMPTY_HASH = {}.freeze
977
+ def shared_string_index(str) #:nodoc:
978
+ @shared_strings.index(str, EMPTY_HASH)
977
979
  end
978
980
 
979
981
  def str_unique # :nodoc:
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  require 'write_xlsx/package/xml_writer_simple'
3
4
  require 'write_xlsx/package/button'
4
5
  require 'write_xlsx/colors'
@@ -2188,7 +2189,7 @@ def write_comment(*args)
2188
2189
  def write_number(*args)
2189
2190
  # Check for a cell reference in A1 notation and substitute row and column
2190
2191
  row, col, num, xf = row_col_notation(args)
2191
- raise WriteXLSXInsufficientArgumentError if [row, col, num].include?(nil)
2192
+ raise WriteXLSXInsufficientArgumentError if row.nil? || col.nil? || num.nil?
2192
2193
 
2193
2194
  # Check that row and col are valid and store max and min values
2194
2195
  check_dimensions(row, col)
@@ -2230,13 +2231,13 @@ def write_string(*args)
2230
2231
  # Check for a cell reference in A1 notation and substitute row and column
2231
2232
  row, col, str, xf = row_col_notation(args)
2232
2233
  str &&= str.to_s
2233
- raise WriteXLSXInsufficientArgumentError if [row, col, str].include?(nil)
2234
+ raise WriteXLSXInsufficientArgumentError if row.nil? || col.nil? || str.nil?
2234
2235
 
2235
2236
  # Check that row and col are valid and store max and min values
2236
2237
  check_dimensions(row, col)
2237
2238
  store_row_col_max_min_values(row, col)
2238
2239
 
2239
- index = shared_string_index(str[0, STR_MAX])
2240
+ index = shared_string_index(str.length > STR_MAX ? str[0, STR_MAX] : str)
2240
2241
 
2241
2242
  store_data_to_table(StringCellData.new(self, row, col, index, xf))
2242
2243
  end
@@ -7510,8 +7511,8 @@ def calc_spans(data, row_num, span_min, span_max)
7510
7511
  # Add a string to the shared string table, if it isn't already there, and
7511
7512
  # return the string index.
7512
7513
  #
7513
- def shared_string_index(str, params = {}) #:nodoc:
7514
- @workbook.shared_string_index(str, params)
7514
+ def shared_string_index(str) #:nodoc:
7515
+ @workbook.shared_string_index(str)
7515
7516
  end
7516
7517
 
7517
7518
  #
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Writexlsx
4
5
  class Worksheet
@@ -63,9 +64,10 @@ def data
63
64
  { :sst_id => token }
64
65
  end
65
66
 
67
+ TYPE_STR_ATTRS = ['t', 's'].freeze
66
68
  def write_cell
67
69
  attributes = cell_attributes
68
- attributes << ['t', 's']
70
+ attributes << TYPE_STR_ATTRS
69
71
  @worksheet.writer.tag_elements('c', attributes) do
70
72
  @worksheet.write_cell_value(token)
71
73
  end
@@ -24,7 +24,7 @@ def initialize(url, str, tip)
24
24
  str ||= url.dup
25
25
 
26
26
  # Strip the mailto header.
27
- str.sub!(/^mailto:/, '')
27
+ normalized_str = str.sub(/^mailto:/, '')
28
28
 
29
29
  # Escape URL unless it looks already escaped.
30
30
  url = escape_url(url)
@@ -35,7 +35,7 @@ def initialize(url, str, tip)
35
35
  end
36
36
 
37
37
  @url = url
38
- @str = str
38
+ @str = normalized_str
39
39
  @url_str = nil
40
40
  @tip = tip
41
41
  end
@@ -23,11 +23,11 @@ def test_empty_tag_with_xml_decl
23
23
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
24
24
  <foo/>
25
25
  EOS
26
- assert_equal(expected, @obj.xml_decl << @obj.empty_tag('foo') << "\n")
26
+ assert_equal(expected, @obj.xml_decl + @obj.empty_tag('foo') + "\n")
27
27
  end
28
28
 
29
29
  def test_start_end_tag
30
- assert_equal("<foo></foo>", @obj.start_tag('foo') << @obj.end_tag('foo'))
30
+ assert_equal("<foo></foo>", @obj.start_tag('foo') + @obj.end_tag('foo'))
31
31
  end
32
32
 
33
33
  def test_attribute
@@ -39,7 +39,7 @@ def test_attribute
39
39
  def test_character_data
40
40
  assert_equal(
41
41
  "<foo>&lt;tag&gt;&amp;amp;&lt;/tag&gt;</foo>",
42
- @obj.start_tag('foo') << @obj.characters("<tag>&amp;</tag>") << @obj.end_tag('foo')
42
+ @obj.start_tag('foo') + @obj.characters("<tag>&amp;</tag>") + @obj.end_tag('foo')
43
43
  )
44
44
  end
45
45
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: write_xlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.85.7
4
+ version: 0.85.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hideo NAKAMURA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2020-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -1709,8 +1709,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1709
1709
  - !ruby/object:Gem::Version
1710
1710
  version: '0'
1711
1711
  requirements: []
1712
- rubyforge_project:
1713
- rubygems_version: 2.6.8
1712
+ rubygems_version: 3.0.3
1714
1713
  signing_key:
1715
1714
  specification_version: 4
1716
1715
  summary: write_xlsx is a gem to create a new file in the Excel 2007+ XLSX format.
@@ -3201,4 +3200,3 @@ test_files:
3201
3200
  - test/worksheet/test_write_tab_color.rb
3202
3201
  - test/worksheet/test_write_url.rb
3203
3202
  - test/worksheet/test_write_worksheet_attributes.rb
3204
- has_rdoc: