write_xlsx 0.77.1 → 0.77.2
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/Changes +3 -0
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/worksheet.rb +12 -11
- data/lib/write_xlsx/worksheet/hyperlink.rb +4 -2
- data/test/worksheet/test_write_multiline_string_with_url.rb +30 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fff0ad728ab04118c85e81ac51f896a2977b5dc
|
4
|
+
data.tar.gz: 0c47ce7030705137f1f737c52586a75134a3fad0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd8f0752cfd08e0ce6fa02d73f9652e811f47a06f96b5ca3e6c1c4e99a35cf8f7490d9f23497f688cb8c6270d16f45c0de8920aec9e06f68404f169a7a22e7b7
|
7
|
+
data.tar.gz: a1a9bdd2c569b3b81773f08b911e044501d29534d05f9b9c0d10b34fad8b240bb1df3c73e8e6666cfa4841fe6b974b1296354a87bc648965228006b9a54d5d82
|
data/Changes
CHANGED
data/lib/write_xlsx/version.rb
CHANGED
data/lib/write_xlsx/worksheet.rb
CHANGED
@@ -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
|
1683
|
+
elsif token =~ %r|\A[fh]tt?ps?://|
|
1684
1684
|
write_url(*args)
|
1685
1685
|
# Match mailto:
|
1686
|
-
elsif token =~ %r
|
1686
|
+
elsif token =~ %r|\Amailto:|
|
1687
1687
|
write_url(*args)
|
1688
1688
|
# Match internal or external sheet link
|
1689
|
-
elsif token =~ %r
|
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
|
-
|
3219
|
+
case type
|
3220
|
+
when 'string'
|
3220
3221
|
write_string(row_first, col_first, token, format, *others)
|
3221
|
-
|
3222
|
+
when 'number'
|
3222
3223
|
write_number(row_first, col_first, token, format, *others)
|
3223
|
-
|
3224
|
+
when 'blank'
|
3224
3225
|
write_blank(row_first, col_first, *others)
|
3225
|
-
|
3226
|
+
when 'date_time'
|
3226
3227
|
write_date_time(row_first, col_first, token, format, *others)
|
3227
|
-
|
3228
|
+
when 'rich_string'
|
3228
3229
|
write_rich_string(row_first, col_first, *others)
|
3229
|
-
|
3230
|
+
when 'url'
|
3230
3231
|
write_url(row_first, col_first, token, format, *others)
|
3231
|
-
|
3232
|
+
when 'formula'
|
3232
3233
|
write_formula(row_first, col_first, token, format, *others)
|
3233
|
-
|
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 >
|
91
|
-
raise "URL '#{@url}' >
|
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.
|
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-
|
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
|