omnidocx 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 02ce6fcf18a2fed5a782906ddc88086c2a17f468
4
- data.tar.gz: 0d9bce7af42f738c9bccadfc50b1c23e5db96f2e
3
+ metadata.gz: a89c615f613daca6054a2f6273a69ed1a4a2dd1d
4
+ data.tar.gz: c174498247a47e8d5e0e9e5b371da29bcb1a2067
5
5
  SHA512:
6
- metadata.gz: 2850e26980b32160c47a1ebee5878b3160b91408263d6a07bcccb12d68ec7a9546405f839b076bd73ab6092519f87a7152ea7b381c8671b53d86a6c7ddc53c5d
7
- data.tar.gz: 2e6eab4c57522baafdfa9a6496ac81799bbbc334e34f324f9c9b6355143b22b462c52be2137498dd180c917bdb3883d3294afe55897fc406c16f9d62b869b420
6
+ metadata.gz: c8a12f714b55740e555271575a6683fc02fc4c29450c281fc1915f99b68485fd84d11c222a906bdc9db4c919f8ab5ff4021e5ebe97065132efa782b055bb7f30
7
+ data.tar.gz: 24be637cf6510ce7da8d4b3648f4b3cc6dd7ef7c9a38b24aaac2f5a6089c2d2f0a300e76acd6ccff21b2adec89980d07d6c26bdccaef9cb3b59b65c23c4a967e
data/.DS_Store CHANGED
Binary file
data/lib/omnidocx.rb CHANGED
@@ -36,7 +36,7 @@ module Omnidocx
36
36
 
37
37
 
38
38
  def self.write_images_to_doc(images_to_write=[], doc_path, final_path)
39
-
39
+
40
40
  temp_file = Tempfile.new('docxedit-')
41
41
 
42
42
  #every docx file is ultimately a zip file with the extension as docx
@@ -53,11 +53,11 @@ module Omnidocx
53
53
 
54
54
  cnt = 20
55
55
  media_hash = {}
56
-
56
+
57
57
  #to maintain a list of all the content type info to be added upon adding media with different extensions
58
58
  media_content_type_hash = {}
59
59
 
60
-
60
+
61
61
  @document_zip.entries.each do |e|
62
62
  if e.name == RELATIONSHIP_FILE_PATH
63
63
  in_stream = e.get_input_stream.read
@@ -66,7 +66,7 @@ module Omnidocx
66
66
  if e.name == CONTENT_TYPES_FILE
67
67
  in_stream = e.get_input_stream.read
68
68
  @cont_type_doc = Nokogiri::XML in_stream #Content types XML to be updated later on with the additional media type info
69
- end
69
+ end
70
70
  end
71
71
 
72
72
  Zip::OutputStream.open(temp_file.path) do |zos|
@@ -74,14 +74,14 @@ module Omnidocx
74
74
  @document_zip.entries.each do |e|
75
75
  unless [DOCUMENT_FILE_PATH, RELATIONSHIP_FILE_PATH, CONTENT_TYPES_FILE].include?(e.name)
76
76
  #writing the files not needed to be edited back to the new zip
77
- zos.put_next_entry(e.name)
77
+ zos.put_next_entry(e.name)
78
78
  zos.print e.get_input_stream.read
79
79
  end
80
80
  end
81
81
 
82
82
  images_to_write.each_with_index do |img, index|
83
83
  data = ''
84
-
84
+
85
85
  #checking if image path is a url or a local path
86
86
  uri = URI.parse(img[:path])
87
87
  if %w( http https ).include?(uri.scheme)
@@ -101,16 +101,16 @@ module Omnidocx
101
101
  #making an entry for a new media type
102
102
  media_content_type_hash["#{extension}"] = MIME::Types.type_for(img_url_no_params)[0].to_s
103
103
  end
104
-
104
+
105
105
  zos.put_next_entry("word/media/image#{cnt}.#{extension}")
106
106
  zos.print data #storing the image in the new zip
107
-
107
+
108
108
  new_rel_node = Nokogiri::XML::Node.new("Relationship", @rel_doc)
109
109
  new_rel_node["Id"] = "rid#{cnt}"
110
110
  new_rel_node["Type"] = MEDIA_TYPE
111
111
  new_rel_node["Target"] = "media/image#{cnt}.#{extension}"
112
112
  @rel_doc.at('Relationships').add_child(new_rel_node) #adding a new relationship node to the relationships xml
113
-
113
+
114
114
  hdpi = img[:hdpi] || HORIZONTAL_DPI
115
115
  vdpi = img[:vdpi] || VERTICAL_DPI
116
116
 
@@ -136,7 +136,7 @@ module Omnidocx
136
136
  pic_cNvPr = dr_node.xpath(".//pic:cNvPr", NAMESPACES).last
137
137
  pic_cNvPr["name"] = "image#{cnt}.#{extension}"
138
138
  pic_cNvPr["id"] = "#{cnt}"
139
-
139
+
140
140
  blip = dr_node.xpath(".//a:blip", NAMESPACES).last
141
141
  blip.attributes["embed"].value = "rid#{cnt}"
142
142
  end
@@ -147,7 +147,7 @@ module Omnidocx
147
147
  media_hash[cnt] = index
148
148
  end
149
149
  cnt+=1
150
- end
150
+ end
151
151
 
152
152
  #updating the content type info
153
153
  media_content_type_hash.each do |ext, cont_type|
@@ -174,19 +174,18 @@ module Omnidocx
174
174
  FileUtils.mv(temp_file.path, final_path)
175
175
  end
176
176
 
177
- def self.merge_documents(documents_to_merge=[], final_path, page_break)
177
+ def self.merge_documents(documents_to_merge = [], final_path, page_break)
178
178
  temp_file = Tempfile.new('docxedit-')
179
+ documents_to_merge_count = documents_to_merge.count
179
180
 
180
- if documents_to_merge.count < 2
181
+ if documents_to_merge_count < 2
181
182
  return "Pass atleast two documents to be merged" #minimum two documents required to merge
182
183
  end
183
184
 
184
185
  #first document to which the others will be appended (header/footer will be picked from this document)
185
186
  @main_document_zip = Zip::File.new(documents_to_merge.first)
186
- @main_document_content = @main_document_zip.read(DOCUMENT_FILE_PATH)
187
- @main_document_xml = Nokogiri::XML @main_document_content
187
+ @main_document_xml = Nokogiri::XML(@main_document_zip.read(DOCUMENT_FILE_PATH))
188
188
  @main_body = @main_document_xml.xpath("//w:body")
189
- @rel_nodes = ""
190
189
  @rel_doc = ""
191
190
  @cont_type_doc = ""
192
191
  @style_doc = ""
@@ -213,32 +212,26 @@ module Omnidocx
213
212
  #array to store information about additional content types other than the ones present in the first(main) document
214
213
  additional_cont_type_entries = []
215
214
 
215
+ # prepare initial set of data from first document
216
+ @main_document_zip.entries.each do |zip_entrie|
217
+ in_stream = zip_entrie.get_input_stream.read
216
218
 
217
- @main_document_zip.entries.each do |e|
218
- if e.name == RELATIONSHIP_FILE_PATH
219
- @in_stream = e.get_input_stream.read
220
- @rel_doc = Nokogiri::XML @in_stream #Relationship XML
221
- @rel_nodes = @rel_doc.css "Relationship"
222
- end
223
- if e.name == CONTENT_TYPES_FILE
224
- in_stream = e.get_input_stream.read
225
- @cont_type_doc = Nokogiri::XML in_stream #Content types XML to be updated later on with the additional media type info
219
+ #Relationship XML
220
+ @rel_doc = Nokogiri::XML(in_stream) if zip_entrie.name == RELATIONSHIP_FILE_PATH
221
+
222
+ #Styles XML to be updated later on with the additional tables info
223
+ @style_doc = Nokogiri::XML(in_stream) if zip_entrie.name == STYLES_FILE_PATH
224
+
225
+ #Content types XML to be updated later on with the additional media type info
226
+ if zip_entrie.name == CONTENT_TYPES_FILE
227
+ @cont_type_doc = Nokogiri::XML in_stream
226
228
  default_nodes = @cont_type_doc.css "Default"
227
229
  override_nodes = @cont_type_doc.css "Override"
228
- default_nodes.each do |node|
229
- default_extensions << node["Extension"]
230
- end
231
- override_nodes.each do |node|
232
- override_partnames << node["PartName"]
233
- end
230
+ default_nodes.each { |node| default_extensions << node["Extension"] }
231
+ override_nodes.each { |node| override_partnames << node["PartName"] }
234
232
  end
235
- if e.name == STYLES_FILE_PATH
236
- in_stream = e.get_input_stream.read
237
- @style_doc = Nokogiri::XML in_stream #Styles XML to be updated later on with the additional tables info
238
- end
239
233
  end
240
234
 
241
-
242
235
  #opening a new zip for the final document
243
236
  Zip::OutputStream.open(temp_file.path) do |zos|
244
237
  documents_to_merge.each do |doc_path|
@@ -247,32 +240,30 @@ module Omnidocx
247
240
  head_foot_media["doc#{doc_cnt}"] = []
248
241
  table_hash["doc#{doc_cnt}"] = {}
249
242
  zip_file = Zip::File.new(doc_path)
250
-
243
+
251
244
  zip_file.entries.each do |e|
252
245
  if [HEADER_RELS_FILE_PATH, FOOTER_RELS_FILE_PATH].include?(e.name)
253
- hf_content = e.get_input_stream.read
254
- hf_xml = Nokogiri::XML hf_content
246
+ hf_xml = Nokogiri::XML(e.get_input_stream.read)
255
247
  hf_xml.css("Relationship").each do |rel_node|
256
248
  #media file names in header & footer need not be changed as they will be picked from the first document only and not the subsequent documents, so no chance of duplication
257
- head_foot_media["doc#{doc_cnt}"] << rel_node["Target"].gsub("media/","")
249
+ head_foot_media["doc#{doc_cnt}"] << rel_node["Target"].gsub("media/", "")
258
250
  end
259
251
  end
260
252
  if e.name == CONTENT_TYPES_FILE
261
- cont_types = e.get_input_stream.read
262
- cont_type_xml = Nokogiri::XML cont_types
253
+ cont_type_xml = Nokogiri::XML(e.get_input_stream.read)
263
254
  default_nodes = cont_type_xml.css "Default"
264
255
  override_nodes = cont_type_xml.css "Override"
265
256
 
266
257
  default_nodes.each do |node|
267
258
  #checking if extension type already present in the content types xml extracted from the first document
268
- if !default_extensions.include?(node["Extension"]) && !node.to_xml.empty?
259
+ if !default_extensions.include?(node["Extension"]) && !node.to_xml.empty?
269
260
  additional_cont_type_entries << node
270
261
  default_extensions << node["Extension"] #extra extension type to be added to the content types XML
271
262
  end
272
263
  end
273
264
 
274
265
  override_nodes.each do |node|
275
- #checking if override content tpye infoalready present in the content types xml extracted from the first document
266
+ #checking if override content type info already present in the content types xml extracted from the first document
276
267
  if !override_partnames.include?(node["PartName"]) && !node.to_xml.empty?
277
268
  additional_cont_type_entries << node
278
269
  override_partnames << node["Partname"] #extra content type info to be added to the content types XML
@@ -281,26 +272,22 @@ module Omnidocx
281
272
  end
282
273
  end
283
274
 
284
-
285
275
  zip_file.entries.each do |e|
286
276
  unless e.name == DOCUMENT_FILE_PATH || [RELATIONSHIP_FILE_PATH, CONTENT_TYPES_FILE, STYLES_FILE_PATH].include?(e.name)
287
277
  if e.name.include?("word/media/image")
288
- if !head_foot_media["doc#{doc_cnt}"].include?(e.name.gsub("word/media/",""))
289
- #renaming media files with a higher counter to avoid duplicaiton in case multiple documents have images present
290
- e_name = e.name.gsub(/image[0-9]*./,"image#{cnt}.")
291
- #writing the media file back to the new zip with the new name
292
- zos.put_next_entry(e_name)
293
- zos.print e.get_input_stream.read
294
- #storing the old media file name to new media file name to mapping in the media hash
295
- media_hash["doc#{doc_cnt}"][e.name.gsub("word/media/","")] = cnt
296
- cnt+=1
278
+ # media files from header & footer from first document shouldn't be changed
279
+ if head_foot_media["doc#{doc_cnt}"].include?(e.name.gsub("word/media/", ""))
280
+ e_name = e.name
297
281
  else
298
- #writing the media files present in the header and footer as their names are not needed to be changed
299
- zos.put_next_entry(e.name)
300
- zos.print e.get_input_stream.read
301
- end
282
+ e_name = e.name.gsub(/image[0-9]*./, "image#{cnt}.")
283
+ #storing the old media file name to new media file name to mapping in the media hash
284
+ media_hash["doc#{doc_cnt}"][e.name.gsub("word/media/", "")] = cnt
285
+ cnt += 1
286
+ end
287
+ zos.put_next_entry(e_name)
288
+ zos.print e.get_input_stream.read
302
289
  else
303
- #writing the files not needed to be edited back to the new zip (only from the first document, so as to avoid duplication)
290
+ #writing the files not needed to be edited back to the new zip (only from the first document, so as to avoid duplication)
304
291
  if doc_cnt == 0
305
292
  zos.put_next_entry(e.name)
306
293
  zos.print e.get_input_stream.read
@@ -309,112 +296,90 @@ module Omnidocx
309
296
  end
310
297
  end
311
298
 
312
- if doc_cnt == 0
313
- doc_content = @main_document_xml #first document's content XML
314
- else
315
- document_content = zip_file.read(DOCUMENT_FILE_PATH)
316
- doc_content = Nokogiri::XML document_content #subsequent documents' content XML
299
+ #updating the stlye ids in the table elements present in the document content XML
300
+ doc_content = doc_cnt == 0 ? @main_body : Nokogiri::XML(zip_file.read(DOCUMENT_FILE_PATH))
301
+ doc_content.xpath("//w:tbl").each do |tbl_node|
302
+ val_attr = tbl_node.xpath('.//w:tblStyle').last.attributes['val']
303
+ table_hash["doc#{doc_cnt}"][val_attr.value.to_s] = tbl_cnt
304
+ val_attr.value = val_attr.value.gsub(/[0-9]+/, tbl_cnt.to_s)
305
+ tbl_cnt += 1
317
306
  end
318
307
 
319
- #updating the stlye ids in the table elements present in the document content XML
320
- doc_content.xpath("//w:tbl").each do |tbl_node|
321
- tblStyle = tbl_node.xpath('.//w:tblStyle').last
308
+ zip_file.entries.each do |e|
309
+ #updating the relationship ids with the new media file names in the relationships XML
310
+ if e.name == RELATIONSHIP_FILE_PATH
311
+ rel_xml = doc_cnt == 0 ? @rel_doc : Nokogiri::XML(e.get_input_stream.read)
322
312
 
323
- table_hash["doc#{doc_cnt}"]["#{tblStyle.attributes['val'].value}"] = tbl_cnt
324
- tblStyle.attributes['val'].value = tblStyle.attributes['val'].value.gsub(/[0-9]+/,"#{tbl_cnt}")
325
- tbl_cnt+=1
326
- end
313
+ rel_xml.css("Relationship").each do |node|
314
+ next unless node.values.to_s.include?("image")
327
315
 
328
- #updating the relationship ids with the new media file names in the relationships XML
329
- if doc_cnt == 0
330
- zip_file.entries.each do |e|
331
- if e.name == RELATIONSHIP_FILE_PATH
332
- @rel_nodes.each do |node|
333
- if node.values.to_s.include?("image")
334
- i = media_hash["doc#{doc_cnt}"]["#{node['Target']}".gsub("media/","")]
335
- target_val = node["Target"].gsub(/image[0-9]*./,"image#{i}.")
336
- node["Target"] = target_val
337
- rid_hash["doc#{doc_cnt}"]["#{node['Id']}"] = "#{i}"
338
- node.attributes["Id"].value = node.attributes["Id"].value.gsub(/[0-9]+/,"#{i}")
339
- end
340
- end
341
- end
342
- #adding the table style information to the styles xml, if any tables present in the document being merged
343
- if e.name == STYLES_FILE_PATH
344
- table_nodes = @style_doc.xpath('//w:style').select{|n| n.attributes["type"].value == "table"}
345
- table_nodes.each do |table_node|
346
- tab_val = table_hash["doc#{doc_cnt}"]["#{table_node.attributes['styleId'].value}"]
347
- table_node.attributes['styleId'].value = table_node.attributes['styleId'].value.gsub(/[0-9]+/,"#{tab_val}")
316
+ i = media_hash["doc#{doc_cnt}"][node['Target'].to_s.gsub("media/", "")]
317
+ target_val = node["Target"].gsub(/image[0-9]*./, "image#{i}.")
318
+ rid_hash["doc#{doc_cnt}"][node['Id'].to_s] = i.to_s
319
+
320
+ id_attr = node.attributes["Id"]
321
+ new_id = id_attr.value.gsub(/[0-9]+/, i.to_s)
322
+ if doc_cnt == 0
323
+ node["Target"] = target_val
324
+ id_attr.value = new_id
325
+ else
326
+ # adding the extra relationship nodes for the media files to the relationship XML
327
+ new_rel_node = "<Relationship Id=#{new_id} Type=#{node["Type"]} Target=#{target_val} />"
328
+ @rel_doc.at('Relationships').add_child(new_rel_node)
348
329
  end
349
330
  end
350
331
  end
351
- else
352
- zip_file.entries.each do |e|
353
- if e.name == RELATIONSHIP_FILE_PATH
354
- input_stream = e.get_input_stream.read
355
- rel_xml = Nokogiri::XML input_stream
356
- rel_xml_nodes = rel_xml.css "Relationship"
357
- rel_xml_nodes.each do |node|
358
- if node.values.to_s.include?("image")
359
- i = media_hash["doc#{doc_cnt}"]["#{node['Target']}".gsub("media/","")]
360
- target_val = node["Target"].gsub(/image[0-9]*./,"image#{i}.")
361
- rid_hash["doc#{doc_cnt}"]["#{node['Id']}"] = "#{i}"
362
-
363
- new_rel_node = Nokogiri::XML::Node.new("Relationship", @rel_doc)
364
- new_rel_node["Id"] = node.attributes["Id"].value.gsub(/[0-9]+/,"#{i}")
365
- new_rel_node["Type"] = node["Type"]
366
- new_rel_node["Target"] = target_val
367
-
368
- #adding the extra relationship nodes for the media files from the subsequent documents (apart from first) to the relationship XML
369
- @rel_doc.at('Relationships').add_child(new_rel_node)
370
- end
371
- end
372
- end
373
332
 
374
- if e.name == STYLES_FILE_PATH
375
- input_stream = e.get_input_stream.read
376
- style_xml = Nokogiri::XML input_stream
377
- table_nodes = style_xml.xpath("//w:style").select{|n| n.attributes["type"].value == "table" && n.attributes["styleId"].value != "TableNormal"}
378
- table_nodes.each do |table_node|
379
- tab_val = table_hash["doc#{doc_cnt}"]["#{table_node.attributes['styleId'].value}"]
380
- table_node.attributes['styleId'].value = table_node.attributes['styleId'].value.gsub(/[0-9]+/,"#{tab_val}")
381
- #adding extra table style nodes to the styles xml, if any tables present in the document being merged
382
- @style_doc.xpath("//w:styles").children.last.add_next_sibling(table_node.to_xml)
383
- end
333
+ #adding the table style information to the styles xml, if any tables present in the document being merged
334
+ if e.name == STYLES_FILE_PATH
335
+ style_xml = doc_cnt == 0 ? @style_doc : Nokogiri::XML(e.get_input_stream.read)
336
+ table_nodes = style_xml.xpath('//w:style').select{ |n| n.attributes["type"].value == "table" }
337
+ table_nodes = table_nodes.select{ |n| n.attributes["styleId"].value != "TableNormal" } if doc_cnt != 0
338
+
339
+ table_nodes.each do |table_node|
340
+ style_id_attr = table_node.attributes['styleId']
341
+ tab_val = table_hash["doc#{doc_cnt}"][style_id_attr.value.to_s]
342
+ style_id_attr.value = style_id_attr.value.gsub(/[0-9]+/, tab_val.to_s)
343
+
344
+ #adding extra table style nodes to the styles xml, if any tables present in the document being merged
345
+ @style_doc.xpath("//w:styles").children.last.add_next_sibling(table_node.to_xml) if doc_cnt != 0
384
346
  end
385
347
  end
386
348
  end
387
349
 
388
350
  #updting the id and rid values for every drawing element in the document XML with the new counters
389
351
  doc_content.xpath("//w:drawing").each do |dr_node|
390
- blip = dr_node.xpath(".//a:blip", NAMESPACES).last
391
- i = rid_hash["doc#{doc_cnt}"][blip.attributes["embed"].value]
392
- blip.attributes["embed"].value = blip.attributes["embed"].value.gsub(/[0-9]+/,i)
393
- docPr = dr_node.xpath(".//wp:docPr").last
394
- docPr["id"] = #{docPr_id}
395
- docPr_id+=1
352
+ docPr_node = dr_node.xpath(".//wp:docPr").last
353
+ docPr_node['id'] = docPr_id.to_s
354
+ docPr_id += 1
355
+
356
+ blip_node = dr_node.xpath(".//a:blip", NAMESPACES).last
357
+ # not all <w:drawing> are images and only image has <a:blip>
358
+ next if blip_node.nil?
359
+ embed_attr = blip_node.attributes["embed"]
360
+ i = rid_hash["doc#{doc_cnt}"][embed_attr.value]
361
+ embed_attr.value = embed_attr.value.gsub(/[0-9]+/, i)
396
362
  end
397
363
 
398
-
399
364
  if doc_cnt > 0
400
- w_p_nodes = doc_content.xpath("//w:p")
401
- #pulling out the <w:p> elements fromt the document body to be appended to the main document's body
402
- body_nodes = doc_content.xpath('//w:body').children[0..doc_content.xpath('//w:body').children.count-2]
403
-
404
- #adding a page break between documents being merged
405
- if doc_cnt > 1 && page_break
406
- @main_body.children.last.add_previous_sibling('<w:p><w:r><w:br w:type="page"/></w:r></w:p>')
407
- end
365
+ #pulling out the <w:sectPr> element from the document body to be appended to the main document's body
366
+ body_nodes = doc_content.xpath('//w:body').children[0..-2]
367
+
408
368
  #appending the body_nodes to main document's body
409
369
  @main_body.children.last.add_previous_sibling(body_nodes.to_xml)
410
370
  end
411
371
 
412
- doc_cnt+=1
372
+ #adding a page break after each documents being merged
373
+ if page_break && doc_cnt < documents_to_merge_count - 1
374
+ @main_body.children.last.add_previous_sibling('<w:p><w:r><w:br w:type="page"/></w:r></w:p>')
375
+ end
376
+
377
+ doc_cnt += 1
413
378
  end
414
379
 
415
380
  #writing the updated styles XML to the new zip
416
381
  zos.put_next_entry(STYLES_FILE_PATH)
417
- zos.print @style_doc.to_xml
382
+ zos.print @style_doc.to_xml
418
383
 
419
384
  #writing the updated relationships XML to the new zip
420
385
  zos.put_next_entry(RELATIONSHIP_FILE_PATH)
@@ -426,7 +391,7 @@ module Omnidocx
426
391
  @cont_type_doc.at("Types").add_child(node)
427
392
  end
428
393
  #writing the updated content types XML to the new zip
429
- zos.print @cont_type_doc.to_xml
394
+ zos.print @cont_type_doc.to_xml
430
395
 
431
396
  #writing the updated document content XML to the new zip
432
397
  zos.put_next_entry(DOCUMENT_FILE_PATH)
@@ -434,7 +399,7 @@ module Omnidocx
434
399
  end
435
400
 
436
401
  #moving the temporary docx file to the final_path specified by the user
437
- FileUtils.mv(temp_file.path, final_path)
402
+ FileUtils.mv(temp_file.path, final_path)
438
403
  end
439
404
 
440
405
  def self.replace_doc_content(replacement_hash={}, template_path, final_path)
@@ -453,7 +418,7 @@ module Omnidocx
453
418
  @template_zip.entries.each do |e|
454
419
  unless e.name == DOCUMENT_FILE_PATH
455
420
  #writing the files not needed to be edited back to the new zip
456
- zos.put_next_entry(e.name)
421
+ zos.put_next_entry(e.name)
457
422
  zos.print e.get_input_stream.read
458
423
  end
459
424
  end
@@ -464,7 +429,7 @@ module Omnidocx
464
429
  end
465
430
 
466
431
  #moving the temporary docx file to the final_path specified by the user
467
- FileUtils.mv(temp_file.path, final_path)
432
+ FileUtils.mv(temp_file.path, final_path)
468
433
  end
469
434
 
470
435
  def self.replace_header_content(replacement_hash={}, template_path, final_path)
@@ -488,7 +453,7 @@ module Omnidocx
488
453
  @template_zip.entries.each do |e|
489
454
  unless e.name == HEADER_FILE_PATH
490
455
  #writing the files not needed to be edited back to the new zip
491
- zos.put_next_entry(e.name)
456
+ zos.put_next_entry(e.name)
492
457
  zos.print e.get_input_stream.read
493
458
  end
494
459
  end
@@ -499,7 +464,7 @@ module Omnidocx
499
464
  end
500
465
 
501
466
  #moving the temporary docx file to the final_path specified by the user
502
- FileUtils.mv(temp_file.path, final_path)
467
+ FileUtils.mv(temp_file.path, final_path)
503
468
  end
504
469
 
505
470
  def self.replace_footer_content(replacement_hash={}, template_path, final_path)
@@ -523,7 +488,7 @@ module Omnidocx
523
488
  @template_zip.entries.each do |e|
524
489
  unless e.name == FOOTER_FILE_PATH
525
490
  #writing the files not needed to be edited back to the new zip
526
- zos.put_next_entry(e.name)
491
+ zos.put_next_entry(e.name)
527
492
  zos.print e.get_input_stream.read
528
493
  end
529
494
  end
@@ -534,7 +499,7 @@ module Omnidocx
534
499
  end
535
500
 
536
501
  #moving the temporary docx file to the final_path specified by the user
537
- FileUtils.mv(temp_file.path, final_path)
502
+ FileUtils.mv(temp_file.path, final_path)
538
503
  end
539
504
 
540
505
  end
@@ -1,3 +1,3 @@
1
1
  module Omnidocx
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnidocx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parth Nagori
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-07 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.4.8
132
+ rubygems_version: 2.6.13
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: A gem to merge docx files, write images to docx and other utilities.