caxlsx 3.0.0 → 3.0.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: 1ed41402c88039c2627ffba600babaf4891f260c120262d40a8ae2759ca9dca3
4
- data.tar.gz: ed7540073afe8febc4435eb3bdf0503843e61ce3edb52c2df22fe79708727a2a
3
+ metadata.gz: 19ed8a99faeb1aed190458ebbafb65c6e4f9c2a08770ca366f55d2b4279aadf7
4
+ data.tar.gz: 88714dcfc3922ac44990181d63ade2d555c1f5328e3ed5af7ae0e4c2008f1e46
5
5
  SHA512:
6
- metadata.gz: 6562cf90cfbf0b9a42012ac225a586e0900486e44930ca5c8ee3e6c3f4c2d3f6d66b8566ac81854f48106bf78732e076ee5cf2771d1cc2ba6abf2cf22dc966e2
7
- data.tar.gz: fd1af696b89b4d4a6594e6ef4eb55d98a3170dfa23d9b96bf06de13692b0957bf4c0a329014b2c9be9ca05337845e83bad0b5644c14ac7862eb26ab981f41f7b
6
+ metadata.gz: bf267db5ffc5b32ac9e0c8a1d17590da46acf8005fdb6dbe2caa94adc46b1fffa8acf8416a8947e503e9dd2b8bed7bb970f01dd82947bb2a01200dfabda11903
7
+ data.tar.gz: 342555ba2c32d49c896c407be8877b194df97ddfa3a107ccd19ce1950e452983aef0469575bd60f18701cc06e0d8faf34b71b4dd1479909bb2d01a1c8a75fe70
@@ -1,10 +1,5 @@
1
1
  CHANGELOG
2
2
  ---------
3
- - **April.1.17**:3.0.0-pre
4
- - Support for ruby versions limited to officially supported version
5
- - Updates to dependency gems, especially nokogiri and ruby-zip
6
- - Patch options parsing for two cell anchor
7
- - Remove support for depreciated worksheet members
8
3
  - **November.25.12**:1.3.4
9
4
  - Support for headers and footers for worksheets
10
5
  - bug fix: Properly escape hyperlink urls
@@ -12,7 +7,6 @@ CHANGELOG
12
7
  - Improvements in autowidth calculation.
13
8
  - **November.8.12**:1.3.3
14
9
  - Patched cell run styles for u and validation for family
15
-
16
10
  - **November.5.12**:1.3.2
17
11
  - MASSIVE REFACTORING
18
12
  - Patch for apostrophes in worksheet names
data/README.md CHANGED
@@ -2,24 +2,22 @@ Notice: Community Axlsx organization
2
2
  ===================================================
3
3
  All Axlsx related gems have been forked or moved to a community organization: http://github.com/caxlsx
4
4
  * Axlsx
5
- * acts_as_axlsx
5
+ * acts_as_caxlsx
6
6
  * axlsx_rails
7
- * activeadmin-axlsx
8
-
9
- The gems will be released as is as a starting point to allow releases of other gems that depend on these gems. Submit issues as usual.
7
+ * activeadmin-caxlsx
10
8
 
11
9
  Please consider helping develop and test these gems.
12
10
 
13
11
  Axlsx: Office Open XML Spreadsheet Generation
14
12
  ====================================
15
- [![Build Status](https://secure.travis-ci.org/randym/axlsx.svg?branch=master)](http://travis-ci.org/randym/axlsx/)
13
+ [![Build Status](https://travis-ci.com/caxlsx/caxlsx.svg?branch=master)](https://travis-ci.com/caxlsx/caxlsx)
16
14
 
17
15
  If you are using axlsx for commercial purposes, or just want to show your
18
16
  appreciation for the gem, please don't hesitate to make a donation.
19
17
 
20
18
  **IRC**:[irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
21
19
 
22
- **Git**:[http://github.com/caxlsx/axlsx](http://github.com/randym/axlsx)
20
+ **Git**:[http://github.com/caxlsx/caxlsx](http://github.com/caxlsx/caxlsx)
23
21
 
24
22
  **Google Group**: [https://groups.google.com/forum/?fromgroups#!forum/axlsx](https://groups.google.com/forum/?fromgroups#!forum/axlsx)
25
23
 
@@ -29,9 +27,9 @@ appreciation for the gem, please don't hesitate to make a donation.
29
27
 
30
28
  **License**: MIT License
31
29
 
32
- **Latest Version**: 3.0.0
30
+ **Latest Version**: 3.0.1
33
31
 
34
- **Ruby Version**: 2.2.7, 2.3.4, 2.4.1
32
+ **Ruby Version**: 2.3.8, 2.4.5, 2.5.3, 2.6.3
35
33
 
36
34
  **JRuby Version**: 1.9 modes
37
35
 
@@ -40,9 +38,9 @@ appreciation for the gem, please don't hesitate to make a donation.
40
38
  **Release Date**: September 12th 2013
41
39
 
42
40
  If you are working in rails, or with active record see:
43
- [acts_as_xlsx](http://github.com/caxlsx/acts_as_xlsx)
41
+ [acts_as_caxlsx](http://github.com/caxlsx/acts_as_caxlsx)
44
42
 
45
- acts_as_xlsx is a simple ActiveRecord mixin that lets you generate a workbook with:
43
+ acts_as_caxlsx is a simple ActiveRecord mixin that lets you generate a workbook with:
46
44
 
47
45
  ```ruby
48
46
  Posts.where(created_at > Time.now-30.days).to_xlsx
@@ -58,7 +56,7 @@ There are guides for using axlsx and acts_as_xlsx here:
58
56
 
59
57
  If you are working with ActiveAdmin see:
60
58
 
61
- [activeadmin-axlsx](http://github.com/caxlsx/activeadmin-axlsx)
59
+ [activeadmin-caxlsx](http://github.com/caxlsx/activeadmin-caxlsx)
62
60
 
63
61
  It provides a plugin and dsl for generating downloadable reports.
64
62
 
@@ -127,9 +125,9 @@ Installing
127
125
 
128
126
  To install Axlsx, use the following command:
129
127
 
130
- $ gem install axlsx
128
+ $ gem install caxlsx
131
129
 
132
- #Examples
130
+ Examples
133
131
  ------
134
132
 
135
133
  The example listing is getting overly large to maintain here.
@@ -156,7 +154,7 @@ Please see the [examples](https://github.com/caxlsx/axlsx/tree/master/examples/e
156
154
 
157
155
  There is much, much more you can do with this gem. If you get stuck, grab me on IRC or submit an issue to GitHub. Chances are that it has already been implemented. If it hasn't - let's take a look at adding it in.
158
156
 
159
- #Documentation
157
+ Documentation
160
158
  --------------
161
159
 
162
160
  This gem is 100% documented with YARD, an exceptional documentation library. To see documentation for this, and all the gems installed on your system use:
@@ -165,13 +163,25 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
165
163
 
166
164
  yard server -g
167
165
 
168
- #Specs
166
+ Specs
169
167
  ------
170
168
 
171
169
  This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
172
170
 
173
- #Change log
171
+ Change log
174
172
  ---------
173
+ - **October.4.19**:3.0.1
174
+ - Support for ruby versions limited to officially supported version
175
+ - Updates to dependency gems, especially nokogiri and ruby-zip
176
+ - Fix Relationship.instances cache
177
+ - Autoload fix for Rails
178
+ - **September.17.19**:3.0.0
179
+ - First release of caxlsx, fork of axlsx
180
+ - **April.1.17**:3.0.0-pre
181
+ - Support for ruby versions limited to officially supported version
182
+ - Updates to dependency gems, especially nokogiri and ruby-zip
183
+ - Patch options parsing for two cell anchor
184
+ - Remove support for depreciated worksheet members
175
185
  - **
176
186
  - Added Cell#name so you you can quickly create a defined name for a single cell in your workbook.
177
187
  - Added full book view and sheet state management. This means you can specify how the workbook renders as well as manage sheet visibility.
@@ -251,14 +261,15 @@ related to themes, which axlsx does not implement at this time.
251
261
  - charts do not render
252
262
 
253
263
 
254
- #Thanks!
264
+ Thanks!
265
+ ----------
255
266
 
256
267
  Open source software is a community effort. None of this could have been
257
268
  done without the help of these awesome folks.
258
269
 
259
- [contributors](https://github.com/caxlsx/axlsx/graphs/contributors)
270
+ [contributors](https://github.com/caxlsx/caxlsx/graphs/contributors)
260
271
 
261
- #License
272
+ License
262
273
  ----------
263
274
 
264
275
  Axlsx is licensed under the MIT license. Please see the LICENSE document for more information.
@@ -100,11 +100,13 @@ module Axlsx
100
100
  # File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
101
101
  def serialize(output, confirm_valid=false)
102
102
  return false unless !confirm_valid || self.validate.empty?
103
- Relationship.clear_cached_instances
103
+ Relationship.initialize_ids_cache
104
104
  Zip::OutputStream.open(output) do |zip|
105
105
  write_parts(zip)
106
106
  end
107
107
  true
108
+ ensure
109
+ Relationship.clear_ids_cache
108
110
  end
109
111
 
110
112
 
@@ -113,11 +115,13 @@ module Axlsx
113
115
  # @return [StringIO|Boolean] False if confirm_valid and validation errors exist. rewound string IO if not.
114
116
  def to_stream(confirm_valid=false)
115
117
  return false unless !confirm_valid || self.validate.empty?
116
- Relationship.clear_cached_instances
118
+ Relationship.initialize_ids_cache
117
119
  zip = write_parts(Zip::OutputStream.new(StringIO.new, true))
118
120
  stream = zip.close_buffer
119
121
  stream.rewind
120
122
  stream
123
+ ensure
124
+ Relationship.clear_ids_cache
121
125
  end
122
126
 
123
127
  # Encrypt the package into a CFB using the password provided
@@ -5,32 +5,40 @@ module Axlsx
5
5
  class Relationship
6
6
 
7
7
  class << self
8
- # Keeps track of all instances of this class.
8
+ # Keeps track of relationship ids in use.
9
9
  # @return [Array]
10
- def instances
11
- @instances ||= []
10
+ def ids_cache
11
+ Thread.current[:axlsx_relationship_ids_cache] ||= {}
12
12
  end
13
-
14
- # Clear cached instances.
13
+
14
+ # Initialize cached ids.
15
15
  #
16
16
  # This should be called before serializing a package (see {Package#serialize} and
17
17
  # {Package#to_stream}) to make sure that serialization is idempotent (i.e.
18
18
  # Relationship instances are generated with the same IDs everytime the package
19
19
  # is serialized).
20
+ def initialize_ids_cache
21
+ Thread.current[:axlsx_relationship_ids_cache] = {}
22
+ end
23
+
24
+ # Clear cached ids.
20
25
  #
21
- # Also, calling this avoids memory leaks (cached instances lingering around
26
+ # This should be called after serializing a package (see {Package#serialize} and
27
+ # {Package#to_stream}) to free the memory allocated for cache.
28
+ #
29
+ # Also, calling this avoids memory leaks (cached ids lingering around
22
30
  # forever).
23
- def clear_cached_instances
24
- @instances = []
31
+ def clear_ids_cache
32
+ Thread.current[:axlsx_relationship_ids_cache] = nil
25
33
  end
26
34
 
27
35
  # Generate and return a unique id (eg. `rId123`) Used for setting {#Id}.
28
36
  #
29
- # The generated id depends on the number of cached instances, so using
30
- # {clear_cached_instances} will automatically reset the generated ids, too.
37
+ # The generated id depends on the number of previously cached ids, so using
38
+ # {clear_ids_cache} will automatically reset the generated ids, too.
31
39
  # @return [String]
32
40
  def next_free_id
33
- "rId#{@instances.size + 1}"
41
+ "rId#{ids_cache.size + 1}"
34
42
  end
35
43
  end
36
44
 
@@ -80,12 +88,7 @@ module Axlsx
80
88
  self.Target=target
81
89
  self.Type=type
82
90
  self.TargetMode = options[:target_mode] if options[:target_mode]
83
- @Id = if (existing = self.class.instances.find{ |i| should_use_same_id_as?(i) })
84
- existing.Id
85
- else
86
- self.class.next_free_id
87
- end
88
- self.class.instances << self
91
+ @Id = (self.class.ids_cache[ids_cache_key] ||= self.class.next_free_id)
89
92
  end
90
93
 
91
94
  # @see Target
@@ -106,7 +109,7 @@ module Axlsx
106
109
  str << '/>'
107
110
  end
108
111
 
109
- # Whether this relationship should use the same id as `other`.
112
+ # A key that determines whether this relationship should use already generated id.
110
113
  #
111
114
  # Instances designating the same relationship need to use the same id. We can not simply
112
115
  # compare the {#Target} attribute, though: `foo/bar.xml`, `../foo/bar.xml`,
@@ -116,13 +119,11 @@ module Axlsx
116
119
  # then {#Target} will be an absolute URL and thus can safely be compared).
117
120
  #
118
121
  # @todo Implement comparison of {#Target} based on normalized path names.
119
- # @param other [Relationship]
120
- def should_use_same_id_as?(other)
121
- result = self.source_obj == other.source_obj && self.Type == other.Type && self.TargetMode == other.TargetMode
122
- if self.TargetMode == :External
123
- result &&= self.Target == other.Target
124
- end
125
- result
122
+ # @return [Array]
123
+ def ids_cache_key
124
+ key = [source_obj, self.Type, self.TargetMode]
125
+ key << self.Target if self.TargetMode == :External
126
+ key
126
127
  end
127
128
 
128
129
  end
@@ -1,5 +1,5 @@
1
1
  module Axlsx
2
2
 
3
3
  # The current version
4
- VERSION = "3.0.0"
4
+ VERSION = "3.0.1"
5
5
  end
@@ -0,0 +1,2 @@
1
+ # encoding: UTF-8
2
+ require 'axlsx.rb'
@@ -13,6 +13,14 @@ class TestRelationships < Test::Unit::TestCase
13
13
  instance = Axlsx::Relationship.new(source_obj, Axlsx::WORKSHEET_R, 'target')
14
14
  assert_equal instance.Id, Axlsx::Relationship.new(source_obj, Axlsx::WORKSHEET_R, 'target').Id
15
15
  end
16
+
17
+ def test_ids_cache_is_thread_safe
18
+ cache1, cache2 = nil
19
+ t1 = Thread.new { cache1 = Axlsx::Relationship.ids_cache }
20
+ t2 = Thread.new { cache2 = Axlsx::Relationship.ids_cache }
21
+ [t1, t2].each(&:join)
22
+ assert_not_same(cache1, cache2)
23
+ end
16
24
 
17
25
  def test_target_is_only_considered_for_same_attributes_check_if_target_mode_is_external
18
26
  source_obj = Object.new
@@ -236,6 +236,8 @@ class TestPackage < Test::Unit::TestCase
236
236
  # this is just a roundabout guess for a package as it is build now
237
237
  # in testing.
238
238
  assert(stream.size > 80000)
239
+ # Cached ids should be cleared
240
+ assert(Axlsx::Relationship.ids_cache.empty?)
239
241
  end
240
242
 
241
243
  def test_encrypt
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caxlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randy Morgan
8
8
  - Jurriaan Pruis
9
- - Noel Peden
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2019-09-08 00:00:00.000000000 Z
12
+ date: 2019-10-04 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: nokogiri
@@ -18,40 +17,40 @@ dependencies:
18
17
  requirements:
19
18
  - - "~>"
20
19
  - !ruby/object:Gem::Version
21
- version: '1.8'
20
+ version: '1.10'
22
21
  - - ">="
23
22
  - !ruby/object:Gem::Version
24
- version: 1.8.2
23
+ version: 1.10.4
25
24
  type: :runtime
26
25
  prerelease: false
27
26
  version_requirements: !ruby/object:Gem::Requirement
28
27
  requirements:
29
28
  - - "~>"
30
29
  - !ruby/object:Gem::Version
31
- version: '1.8'
30
+ version: '1.10'
32
31
  - - ">="
33
32
  - !ruby/object:Gem::Version
34
- version: 1.8.2
33
+ version: 1.10.4
35
34
  - !ruby/object:Gem::Dependency
36
35
  name: rubyzip
37
36
  requirement: !ruby/object:Gem::Requirement
38
37
  requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '1.2'
42
38
  - - ">="
43
39
  - !ruby/object:Gem::Version
44
- version: 1.2.1
40
+ version: 1.3.0
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '3'
45
44
  type: :runtime
46
45
  prerelease: false
47
46
  version_requirements: !ruby/object:Gem::Requirement
48
47
  requirements:
49
- - - "~>"
50
- - !ruby/object:Gem::Version
51
- version: '1.2'
52
48
  - - ">="
53
49
  - !ruby/object:Gem::Version
54
- version: 1.2.1
50
+ version: 1.3.0
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '3'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: htmlentities
57
56
  requirement: !ruby/object:Gem::Requirement
@@ -320,6 +319,7 @@ files:
320
319
  - lib/axlsx/workbook/worksheet/worksheet_drawing.rb
321
320
  - lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb
322
321
  - lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb
322
+ - lib/caxlsx.rb
323
323
  - lib/schema/dc.xsd
324
324
  - lib/schema/dcmitype.xsd
325
325
  - lib/schema/dcterms.xsd
@@ -474,7 +474,7 @@ files:
474
474
  - test/workbook/worksheet/tc_table_style_info.rb
475
475
  - test/workbook/worksheet/tc_worksheet.rb
476
476
  - test/workbook/worksheet/tc_worksheet_hyperlink.rb
477
- homepage: https://github.com/caxlsx/axlsx
477
+ homepage: https://github.com/caxlsx/caxlsx
478
478
  licenses:
479
479
  - MIT
480
480
  metadata: {}
@@ -484,9 +484,9 @@ require_paths:
484
484
  - lib
485
485
  required_ruby_version: !ruby/object:Gem::Requirement
486
486
  requirements:
487
- - - ">="
487
+ - - "~>"
488
488
  - !ruby/object:Gem::Version
489
- version: 1.9.2
489
+ version: '2.3'
490
490
  required_rubygems_version: !ruby/object:Gem::Requirement
491
491
  requirements:
492
492
  - - ">="