docxify 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
  SHA256:
3
- metadata.gz: '02588568aa1d05caf048a8a3b861ffc9b5ec2109817b6931006ce4c36c97adea'
4
- data.tar.gz: 7f2647fdf663f8fb222c544592c4910ec54aedcdd26cf8fef30a610c7a163d6f
3
+ metadata.gz: 7440bb498b7d16a2e1abb5a6a65edfa8cafe69f9e9edc5175431a685becec44e
4
+ data.tar.gz: 0f099f0d7213de1d3c9d3d32e18d150b5cf119b6b2be53b9b4d74dd21fe90a53
5
5
  SHA512:
6
- metadata.gz: bf43c3a7194169d9cb01e0f96a44d3498dffbde8fa7f829dbf8fff1226ea9adffa4f648a06158cc7ad3450203858e2211cf2423f064a683129ef2e23c825353b
7
- data.tar.gz: b4990b99e150a9f2e3aae3a45873799e91fc850c7180485caa4559ed2eca97d301672bd0181f3e5b703d3c44f32b4c3f6e64c32c36895b0c62a002659f76b83d
6
+ metadata.gz: f7761058786959073a9cf63d72206f6861a9afcc65df64e209e1ecd365b9ca47f99bbd7c11435f1d2688af8dc4f4734ff56cf4249767d1e3ab0c829f3d9aea1f
7
+ data.tar.gz: c4fefd656f6d9a3bf3c87ffc21c94f8c85e41700e880588bd16d266eeb734b98a874e5805a85a767b06596f2a6bdeff17e71c00d9a3d05f43bdbeee6c87ef6b1
data/CHANGELOG.md CHANGED
@@ -1,10 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.3
4
+
5
+ Bugfix:
6
+
7
+ - Files that contain a PNG but weren't named ending in .png (e.g. a Tempfile in Ruby) were causing corrupted Docx files (which Word could auto-recover)
8
+
3
9
  ## 0.1.2
4
10
 
5
11
  Features:
6
12
 
7
- - "Add 'after' to images and paragraphs to adjust spacing after those elements
13
+ - Add 'after' to images and paragraphs to adjust spacing after those elements
8
14
 
9
15
  ## 0.1.1
10
16
 
@@ -46,7 +46,7 @@ module DocXify
46
46
  def build_xml(container)
47
47
  xml = <<~XML
48
48
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
49
- <w:document mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
49
+ <w:document mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh w16du wp14" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16du="http://schemas.microsoft.com/office/word/2023/wordml/word16du" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
50
50
  <w:body>
51
51
  XML
52
52
 
@@ -15,16 +15,18 @@ module DocXify
15
15
  end
16
16
 
17
17
  def load_file_data(file_path_or_data)
18
+ if ::File.exist?(file_path_or_data)
19
+ file_path_or_data = ::File.read(file_path_or_data, mode: "rb")
20
+ end
21
+
18
22
  if contains_png_image?(file_path_or_data)
19
23
  @data = file_path_or_data
20
24
  @filename = "#{Digest::SHA1.hexdigest(@data)}.png"
25
+ puts "Contains PNG image #{@filename}"
21
26
  elsif contains_jpeg_image?(file_path_or_data)
22
27
  @data = file_path_or_data
23
28
  @filename = "#{Digest::SHA1.hexdigest(@data)}.jpg"
24
- elsif ::File.exist?(file_path_or_data)
25
- @filename = ::File.basename(file_path_or_data)
26
- @data = ::File.read(file_path_or_data, mode: "rb")
27
- raise ArgumentError.new("Unsupported file type - images must be PNG or JPEG") unless contains_png_image?(@data) || contains_jpeg_image?(@data)
29
+ puts "Contains JPEG image #{@filename}"
28
30
  else
29
31
  raise ArgumentError.new("Unsupported file type - images must be PNG or JPEG")
30
32
  end
@@ -1,3 +1,3 @@
1
1
  module DocXify
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docxify
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
  - Andy Jeffries