docx_template 0.3 → 0.4
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/docx_template.gemspec +1 -1
- data/lib/docx_template/docx.rb +1 -0
- data/lib/docx_template/version.rb +1 -1
- data/spec/docx_spec.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9e5c61512728c9721f735f6b99886842b018124
|
4
|
+
data.tar.gz: 07314e9b8fff4b95a5c0842bf3731acc261e9c6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ee47ea120c24ee5ae6121267865aafa6bcf2b3a8c74420fdecdbc44c477757051fd81d7bf94e46a3336dac88a836028944f2b87cbdac6fa4241c2817da589c2
|
7
|
+
data.tar.gz: f886701167cd30d1bbb8ad8a9f6edc3e00ec030bf2f3b014b38e68b7b429750c33f2572d7365c01c3df7524b297980cb9c9224cb89e20d6c664f4acfdbe9316f
|
data/docx_template.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'docx_template/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "docx_template"
|
8
|
-
spec.version = "0.
|
8
|
+
spec.version = "0.4"
|
9
9
|
spec.authors = ["Maniankara"]
|
10
10
|
spec.email = ["Maniankara@gmail.com"]
|
11
11
|
spec.summary = %q{Docx templating library which could replace docx contents such as text, images etc. in one go.}
|
data/lib/docx_template/docx.rb
CHANGED
@@ -43,6 +43,7 @@ module DocxTemplate
|
|
43
43
|
end
|
44
44
|
# image part
|
45
45
|
@image_replacer_list.each do |replacer|
|
46
|
+
next unless File.exist?(replacer.dest_entity) # silently skip non-existent files
|
46
47
|
out.put_next_entry("#{IMAGES_DIR_PATH}/#{replacer.src_entity}")
|
47
48
|
out.write File.read(replacer.dest_entity)
|
48
49
|
end
|
data/spec/docx_spec.rb
CHANGED
@@ -35,12 +35,18 @@ RSpec.describe DocxTemplate::Docx do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Negative cases
|
38
|
-
it "Handling nil substitutions" do
|
38
|
+
it "Handling nil substitutions for replace_text" do
|
39
39
|
template = DocxTemplate::Docx.new "spec/unit/templates/docx_template.docx"
|
40
40
|
template.replace_text("##MULTIPLE_REPLACE_TEXT##", nil)
|
41
41
|
template.save("/tmp/a.docx")
|
42
42
|
expect(@docx_verifier.verify_text_exists?("/tmp/a.docx", "##MULTIPLE_REPLACE_TEXT##")).to be(false)
|
43
43
|
end
|
44
44
|
|
45
|
+
it "Handling non existing file for replace_image" do
|
46
|
+
template = DocxTemplate::Docx.new "spec/unit/templates/docx_template.docx"
|
47
|
+
template.replace_image("image1.jpeg", "a/non/existing/image.jpg")
|
48
|
+
template.save("/tmp/a.docx")
|
49
|
+
expect(@docx_verifier.verify_image_exists?("/tmp/a.docx", "image1.jpeg", "spec/unit/images/image5.jpg")).to be(false)
|
50
|
+
end
|
45
51
|
|
46
52
|
end
|