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 +4 -4
- data/lib/docx/document.rb +39 -23
- data/lib/docx/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 00fd317c3d0d2f4ee4aafddd30ff41f29830f23c2e5f913c114cbc95b2bb58d1
|
|
4
|
+
data.tar.gz: 0ad6844aeb26d84f5275f86c43bb592f821be2541e797fa1318416dd20e77bf1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
137
|
-
|
|
137
|
+
out.put_next_entry(entry.name)
|
|
138
|
+
value = @replace[entry.name] || zip.read(entry.name)
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
164
|
-
|
|
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