axlsx 2.0.0 → 2.0.1
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/README.md +3 -1
- data/lib/axlsx.rb +2 -2
- data/lib/axlsx/package.rb +10 -10
- data/lib/axlsx/version.rb +1 -1
- data/test/tc_package.rb +4 -4
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36ce715dcecdf3de554b7683d87d35eccf159a81
|
4
|
+
data.tar.gz: d9550ff6639b90f612e45c0bf40f5a50ac88928e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9939c4e2c0bba3911171ae36441f61175d3b4604dfe878a125ac9b391c38c88430426a2c9660e2d1bafe0f7ae1c4a039a09d4410890978bad70509204a43e9d0
|
7
|
+
data.tar.gz: 0b58dc0cb79601febcc3782410e36225d2154c788f7dfe38e11d98a5845554ad0cd8a649656712e058f52e0ad884dafc9a3aa2a6379d5e1784585ca66f7f5b20
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ appreciation for the gem, please don't hesitate to make a donation.
|
|
21
21
|
|
22
22
|
**License**: MIT License
|
23
23
|
|
24
|
-
**Latest Version**: 2.0.
|
24
|
+
**Latest Version**: 2.0.1
|
25
25
|
|
26
26
|
**Ruby Version**: 1.9.2, 1.9.3, 2.0.0
|
27
27
|
|
@@ -165,6 +165,8 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem,
|
|
165
165
|
#Change log
|
166
166
|
---------
|
167
167
|
|
168
|
+
- **September.12.13**:2.0.1
|
169
|
+
- Unpinned rubyzip version
|
168
170
|
- **September.12.13**:2.0.0
|
169
171
|
- DROPPED support for ruby 1.8.7
|
170
172
|
- Altered readme to link to contributors
|
data/lib/axlsx.rb
CHANGED
@@ -23,7 +23,7 @@ require 'axlsx/workbook/workbook.rb'
|
|
23
23
|
require 'axlsx/package.rb'
|
24
24
|
#required gems
|
25
25
|
require 'nokogiri'
|
26
|
-
require 'zip
|
26
|
+
require 'zip'
|
27
27
|
|
28
28
|
#core dependencies
|
29
29
|
require 'bigdecimal'
|
@@ -136,7 +136,7 @@ module Axlsx
|
|
136
136
|
end
|
137
137
|
|
138
138
|
|
139
|
-
# Instructs the serializer to not try to escape cell value input.
|
139
|
+
# Instructs the serializer to not try to escape cell value input.
|
140
140
|
# This will give you a huge speed bonus, but if you content has <, > or other xml character data
|
141
141
|
# the workbook will be invalid and excel will complain.
|
142
142
|
def self.trust_input
|
data/lib/axlsx/package.rb
CHANGED
@@ -70,7 +70,7 @@ module Axlsx
|
|
70
70
|
|
71
71
|
#def self.parse(input, confirm_valid = false)
|
72
72
|
# p = Package.new
|
73
|
-
# z = Zip::
|
73
|
+
# z = Zip::File.open(input)
|
74
74
|
# p.workbook = Workbook.parse z.get_entry(WORKBOOK_PN)
|
75
75
|
# p
|
76
76
|
#end
|
@@ -101,7 +101,7 @@ module Axlsx
|
|
101
101
|
def serialize(output, confirm_valid=false)
|
102
102
|
return false unless !confirm_valid || self.validate.empty?
|
103
103
|
Relationship.clear_cached_instances
|
104
|
-
Zip::
|
104
|
+
Zip::OutputStream.open(output) do |zip|
|
105
105
|
write_parts(zip)
|
106
106
|
end
|
107
107
|
true
|
@@ -114,7 +114,7 @@ module Axlsx
|
|
114
114
|
def to_stream(confirm_valid=false)
|
115
115
|
return false unless !confirm_valid || self.validate.empty?
|
116
116
|
Relationship.clear_cached_instances
|
117
|
-
zip = write_parts(Zip::
|
117
|
+
zip = write_parts(Zip::OutputStream.new("streamed", true))
|
118
118
|
stream = zip.close_buffer
|
119
119
|
stream.rewind
|
120
120
|
stream
|
@@ -154,8 +154,8 @@ module Axlsx
|
|
154
154
|
private
|
155
155
|
|
156
156
|
# Writes the package parts to a zip archive.
|
157
|
-
# @param [Zip::
|
158
|
-
# @return [Zip::
|
157
|
+
# @param [Zip::OutputStream] zip
|
158
|
+
# @return [Zip::OutputStream]
|
159
159
|
def write_parts(zip)
|
160
160
|
p = parts
|
161
161
|
p.each do |part|
|
@@ -173,8 +173,8 @@ module Axlsx
|
|
173
173
|
zip
|
174
174
|
end
|
175
175
|
|
176
|
-
# Generate a
|
177
|
-
# The important part here is to explicitly set the timestamp for the zip entry: Serializing axlsx packages
|
176
|
+
# Generate a Entry for the given package part.
|
177
|
+
# The important part here is to explicitly set the timestamp for the zip entry: Serializing axlsx packages
|
178
178
|
# with identical contents should result in identical zip files – however, the timestamp of a zip entry
|
179
179
|
# defaults to the time of serialization and therefore the zip file contents would be different every time
|
180
180
|
# the package is serialized.
|
@@ -183,12 +183,12 @@ module Axlsx
|
|
183
183
|
# to set this explicitly, too (eg. with `Package.new(created_at: Time.local(2013, 1, 1))`).
|
184
184
|
#
|
185
185
|
# @param part A hash describing a part of this pacakge (see {#parts})
|
186
|
-
# @return [Zip::
|
186
|
+
# @return [Zip::Entry]
|
187
187
|
def zip_entry_for_part(part)
|
188
188
|
timestamp = Zip::DOSTime.at(@core.created.to_i)
|
189
|
-
Zip::
|
189
|
+
Zip::Entry.new("", part[:entry], "", "", 0, 0, Zip::Entry::DEFLATED, 0, timestamp)
|
190
190
|
end
|
191
|
-
|
191
|
+
|
192
192
|
# The parts of a package
|
193
193
|
# @return [Array] An array of hashes that define the entry, document and schema for each part of the package.
|
194
194
|
# @private
|
data/lib/axlsx/version.rb
CHANGED
data/test/tc_package.rb
CHANGED
@@ -118,7 +118,7 @@ class TestPackage < Test::Unit::TestCase
|
|
118
118
|
assert_nothing_raised do
|
119
119
|
begin
|
120
120
|
@package.serialize(@fname)
|
121
|
-
zf = Zip::
|
121
|
+
zf = Zip::File.open(@fname)
|
122
122
|
@package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }
|
123
123
|
File.delete(@fname)
|
124
124
|
rescue Errno::EACCES
|
@@ -126,7 +126,7 @@ class TestPackage < Test::Unit::TestCase
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
# See comment for Package#zip_entry_for_part
|
131
131
|
def test_serialization_creates_identical_files_at_any_time_if_created_at_is_set
|
132
132
|
@package.core.created = Time.now
|
@@ -136,9 +136,9 @@ class TestPackage < Test::Unit::TestCase
|
|
136
136
|
assert zip_content_then == zip_content_now, "zip files are not identical"
|
137
137
|
end
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
def test_serialization_creates_identical_files_for_identical_packages
|
141
|
-
package_1, package_2 = 2.times.map do
|
141
|
+
package_1, package_2 = 2.times.map do
|
142
142
|
Axlsx::Package.new(:created_at => Time.utc(2013, 1, 1)).tap do |p|
|
143
143
|
p.workbook.add_worksheet(:name => "Basic Worksheet") do |sheet|
|
144
144
|
sheet.add_row [1, 2, 3]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: axlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Randy Morgan
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rubyzip
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 1.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 1.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: htmlentities
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -406,7 +406,8 @@ files:
|
|
406
406
|
- test/workbook/worksheet/tc_worksheet.rb
|
407
407
|
- test/workbook/worksheet/tc_worksheet_hyperlink.rb
|
408
408
|
homepage: https://github.com/randym/axlsx
|
409
|
-
licenses:
|
409
|
+
licenses:
|
410
|
+
- MIT
|
410
411
|
metadata: {}
|
411
412
|
post_install_message:
|
412
413
|
rdoc_options: []
|