write_xlsx 0.77.1 → 0.77.2

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: d84fbde72d5ae92bdabc292730d086aeb5881437
4
- data.tar.gz: eb113ebb668a2efe7b9357b4e15f94c370aa3c6e
3
+ metadata.gz: 4fff0ad728ab04118c85e81ac51f896a2977b5dc
4
+ data.tar.gz: 0c47ce7030705137f1f737c52586a75134a3fad0
5
5
  SHA512:
6
- metadata.gz: defcb8385cf355374a7687ff2d8ce3914cf736ff317e77ef767e38f6beef76f96560c89ed2aeaf26fb572f2afbd8810127f8cd1ec807e5dd5b87f41171b5e8b1
7
- data.tar.gz: d8a35bdc7167e7a45cafec89c0188ed68e7139d093ad7107f73c8849ec409bae8c5637114db5a7d5e908e90723c173ec3b631fcd1cd4165bb6e092e9d344fa23
6
+ metadata.gz: bd8f0752cfd08e0ce6fa02d73f9652e811f47a06f96b5ca3e6c1c4e99a35cf8f7490d9f23497f688cb8c6270d16f45c0de8920aec9e06f68404f169a7a22e7b7
7
+ data.tar.gz: a1a9bdd2c569b3b81773f08b911e044501d29534d05f9b9c0d10b34fad8b240bb1df3c73e8e6666cfa4841fe6b974b1296354a87bc648965228006b9a54d5d82
data/Changes CHANGED
@@ -1,4 +1,7 @@
1
1
  Change history of write_xlsx rubygem.
2
+ 2014-08-19 v0.77.2
3
+ Fix for issue #16.
4
+
2
5
  2014-07-02 v0.77.1
3
6
  Fix for issue #14. thanks leonid-pavlov.
4
7
 
@@ -1,5 +1,5 @@
1
1
  require 'write_xlsx/workbook'
2
2
 
3
3
  class WriteXLSX < Writexlsx::Workbook
4
- VERSION = "0.77.1"
4
+ VERSION = "0.77.2"
5
5
  end
@@ -1680,13 +1680,13 @@ def write(*args)
1680
1680
  elsif token =~ /^\d+$/
1681
1681
  write_number(*args)
1682
1682
  # Match http, https or ftp URL
1683
- elsif token =~ %r|^[fh]tt?ps?://|
1683
+ elsif token =~ %r|\A[fh]tt?ps?://|
1684
1684
  write_url(*args)
1685
1685
  # Match mailto:
1686
- elsif token =~ %r|^mailto:|
1686
+ elsif token =~ %r|\Amailto:|
1687
1687
  write_url(*args)
1688
1688
  # Match internal or external sheet link
1689
- elsif token =~ %r!^(?:in|ex)ternal:!
1689
+ elsif token =~ %r!\A(?:in|ex)ternal:!
1690
1690
  write_url(*args)
1691
1691
  # Match formula
1692
1692
  elsif token =~ /^=/
@@ -3216,21 +3216,22 @@ def merge_range_type(type, *args)
3216
3216
  others << format
3217
3217
  end
3218
3218
 
3219
- if type == 'string'
3219
+ case type
3220
+ when 'string'
3220
3221
  write_string(row_first, col_first, token, format, *others)
3221
- elsif type == 'number'
3222
+ when 'number'
3222
3223
  write_number(row_first, col_first, token, format, *others)
3223
- elsif type == 'blank'
3224
+ when 'blank'
3224
3225
  write_blank(row_first, col_first, *others)
3225
- elsif type == 'date_time'
3226
+ when 'date_time'
3226
3227
  write_date_time(row_first, col_first, token, format, *others)
3227
- elsif type == 'rich_string'
3228
+ when 'rich_string'
3228
3229
  write_rich_string(row_first, col_first, *others)
3229
- elsif type == 'url'
3230
+ when 'url'
3230
3231
  write_url(row_first, col_first, token, format, *others)
3231
- elsif type == 'formula'
3232
+ when 'formula'
3232
3233
  write_formula(row_first, col_first, token, format, *others)
3233
- elsif type == 'array_formula'
3234
+ when 'array_formula'
3234
3235
  write_formula_array(row_first, col_first, *others)
3235
3236
  else
3236
3237
  raise "Unknown type '#{type}'"
@@ -7,6 +7,8 @@ class Hyperlink # :nodoc:
7
7
 
8
8
  attr_reader :str, :tip
9
9
 
10
+ MAXIMUM_URLS_SIZE = 255
11
+
10
12
  def self.factory(url, str = nil, tip = nil)
11
13
  if url =~ /^internal:(.+)/
12
14
  InternalHyperlink.new($~[1], str, tip)
@@ -87,8 +89,8 @@ def initialize(url, str, tip)
87
89
  @url_str = @str.dup
88
90
 
89
91
  # Excel limits escaped URL to 255 characters.
90
- if @url.bytesize > 255
91
- raise "URL '#{@url}' > 255 characters, it exceeds Excel's limit for URLS."
92
+ if @url.bytesize > MAXIMUM_URLS_SIZE
93
+ raise "URL '#{@url}' > #{MAXIMUM_URLS_SIZE} characters, it exceeds Excel's limit for URLS."
92
94
  end
93
95
 
94
96
  @tip = tip
@@ -0,0 +1,30 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestWriteMultilineStringWithUrl < Test::Unit::TestCase
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet('')
10
+ end
11
+
12
+ def test_write_with_url_after_cr_string
13
+ url_strings = %w(http:// https:// ftp:// ftps:// mailto: internal: external:)
14
+ col = 0
15
+ row = 0
16
+
17
+ url_strings.each do |url_string|
18
+ assert_nothing_raised do
19
+ @worksheet.write(row, col, long_string(url_string))
20
+ row += 1
21
+ end
22
+ end
23
+ end
24
+
25
+ def long_string(url_string)
26
+ "*" * Writexlsx::Worksheet::Hyperlink::MAXIMUM_URLS_SIZE <<
27
+ "\n" <<
28
+ url_string
29
+ end
30
+ end
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.77.1
4
+ version: 0.77.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hideo NAKAMURA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -1347,6 +1347,7 @@ files:
1347
1347
  - test/worksheet/test_write_merge_cell.rb
1348
1348
  - test/worksheet/test_write_merge_cells.rb
1349
1349
  - test/worksheet/test_write_methods.rb
1350
+ - test/worksheet/test_write_multiline_string_with_url.rb
1350
1351
  - test/worksheet/test_write_page_margins.rb
1351
1352
  - test/worksheet/test_write_page_set_up_pr.rb
1352
1353
  - test/worksheet/test_write_page_setup.rb
@@ -2579,6 +2580,7 @@ test_files:
2579
2580
  - test/worksheet/test_write_merge_cell.rb
2580
2581
  - test/worksheet/test_write_merge_cells.rb
2581
2582
  - test/worksheet/test_write_methods.rb
2583
+ - test/worksheet/test_write_multiline_string_with_url.rb
2582
2584
  - test/worksheet/test_write_page_margins.rb
2583
2585
  - test/worksheet/test_write_page_set_up_pr.rb
2584
2586
  - test/worksheet/test_write_page_setup.rb