docx 0.10.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fc798e71a79265389a2dcf22d0ecff1268a920f92463c23b9ccbce94517b7be
4
- data.tar.gz: 1b21fef113ce8a84a7aeaf97b05139822763a4ac96835efd59971b52fb34ce98
3
+ metadata.gz: 00fd317c3d0d2f4ee4aafddd30ff41f29830f23c2e5f913c114cbc95b2bb58d1
4
+ data.tar.gz: 0ad6844aeb26d84f5275f86c43bb592f821be2541e797fa1318416dd20e77bf1
5
5
  SHA512:
6
- metadata.gz: eab6dae181b61b9b7103460a4e5d582ef534b36f2f09cbfaba9c5ef16d880b9bca6a97d76e7c671fbb24a897189e6b1861a6f4874e589075d781b3a660e796c9
7
- data.tar.gz: ca39d10248be1d18d173293fc8a918fe86e615cbd6fbdb5340a532792d9ef478ac563fb3ef61a6fdd4e1542a9d7258015e5bc34ecd69c86e6edb39ce422ec636
6
+ metadata.gz: 32e693b1114347678865a0b5f409a745e1f4a3a195ef70d2ab6cc255022abaad79b3bed9dd66426746b2b207ab176af19178207c4e2e6af790cd8213575ee605
7
+ data.tar.gz: 438dbbb6ca717e985c80f0ff4eca824c44fd1d2c94832b40121fb4423e6bf59389b03dce6d66b2f6bbbf9715e68df62c9db3db8e5a4cc60772b7cd1cdd95983d
data/lib/docx/document.rb CHANGED
@@ -128,40 +128,44 @@ module Docx
128
128
  # call-seq:
129
129
  # save(filepath) => void
130
130
  def save(path)
131
- update
132
- Zip::OutputStream.open(path) do |out|
133
- zip.each do |entry|
134
- next unless entry.file?
131
+ with_zip64_disabled do
132
+ update
133
+ Zip::OutputStream.open(path) do |out|
134
+ zip.each do |entry|
135
+ next unless entry.file?
135
136
 
136
- out.put_next_entry(entry.name)
137
- value = @replace[entry.name] || zip.read(entry.name)
137
+ out.put_next_entry(entry.name)
138
+ value = @replace[entry.name] || zip.read(entry.name)
138
139
 
139
- out.write(value)
140
- end
140
+ out.write(value)
141
+ end
141
142
 
143
+ end
144
+ zip.close
142
145
  end
143
- zip.close
144
146
  end
145
147
 
146
148
  # Output entire document as a StringIO object
147
149
  def stream
148
- update
149
- stream = Zip::OutputStream.write_buffer do |out|
150
- zip.each do |entry|
151
- next unless entry.file?
152
-
153
- out.put_next_entry(entry.name)
154
-
155
- if @replace[entry.name]
156
- out.write(@replace[entry.name])
157
- else
158
- out.write(zip.read(entry.name))
150
+ with_zip64_disabled do
151
+ update
152
+ stream = Zip::OutputStream.write_buffer do |out|
153
+ zip.each do |entry|
154
+ next unless entry.file?
155
+
156
+ out.put_next_entry(entry.name)
157
+
158
+ if @replace[entry.name]
159
+ out.write(@replace[entry.name])
160
+ else
161
+ out.write(zip.read(entry.name))
162
+ end
159
163
  end
160
164
  end
161
- end
162
165
 
163
- stream.rewind
164
- stream
166
+ stream.rewind
167
+ stream
168
+ end
165
169
  end
166
170
 
167
171
  alias text to_s
@@ -184,6 +188,18 @@ module Docx
184
188
 
185
189
  private
186
190
 
191
+ # rubyzip 3.x enables ZIP64 by default, which breaks readers (e.g. pandoc)
192
+ # that don't support it for small files (issue #168). Disable ZIP64 only
193
+ # while writing, and restore the previous global value afterwards so we
194
+ # don't affect other rubyzip users in the consuming application.
195
+ def with_zip64_disabled
196
+ previous = Zip.write_zip64_support
197
+ Zip.write_zip64_support = false
198
+ yield
199
+ ensure
200
+ Zip.write_zip64_support = previous
201
+ end
202
+
187
203
  def load_styles
188
204
  @styles_xml = @zip.read('word/styles.xml')
189
205
  @styles = Nokogiri::XML(@styles_xml)
data/lib/docx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Docx #:nodoc:
4
- VERSION = '0.10.0'
4
+ VERSION = '0.10.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Hunt