standard-procedure-consolidate 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/checksums/standard-procedure-consolidate-0.4.1.gem.sha512 +1 -0
- data/lib/consolidate/docx/merge.rb +15 -5
- data/lib/consolidate/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ffce925315399bd4432936d929e995114acc2dea081f3835eb437fe2787f612
|
4
|
+
data.tar.gz: b64ae5181ae92d5e66be79e5861787c3355fe08870dbb4ee3ab8355ef4ce149d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e56547c32223cf66f807c804cdfff2897f63887729dcf1ff80d51c35a0615115f47b16347b582d58a6ae128c3ecad91a67ca128e0d7c89b6e55a3e88b2d5a6c9
|
7
|
+
data.tar.gz: 4b351ad3a367dd4382abc18e18fbc978095fec92aa8b258a90feb82f2e0a65ffbcca26a8177383d75fab07d711a170b10b541e48c195c4b8b7db0eea2cfd1b26
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
dfd2ec36154a632f86dd8f99a2b85c59ed6048dbb6b8100f84645ea1cf49e3e77ad73b3367ef89d46e055c860f1b1e82c5b0d0d37c969a19c2644a3e42ebbe21
|
@@ -70,6 +70,7 @@ module Consolidate
|
|
70
70
|
@output[contents_xml] = @contents_xml.serialize save_with: 0
|
71
71
|
|
72
72
|
@images.each do |field_name, image|
|
73
|
+
next if image.nil?
|
73
74
|
puts "... writing image #{field_name} to #{image.storage_path}" if verbose
|
74
75
|
out.get_output_stream(image.storage_path) { |o| o.write image.contents }
|
75
76
|
end
|
@@ -120,7 +121,7 @@ module Consolidate
|
|
120
121
|
def relation_number_for(field_name) = @mapping.keys.index(field_name) + 1000
|
121
122
|
|
122
123
|
# Identifier to use when linking a merge field to the actual image file contents
|
123
|
-
def relation_id_for(field_name) = "rId#{
|
124
|
+
def relation_id_for(field_name) = "rId#{field_name}"
|
124
125
|
|
125
126
|
# Empty elations document for documents that do not already have one
|
126
127
|
def default_relations_document = %(<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>)
|
@@ -156,8 +157,8 @@ module Consolidate
|
|
156
157
|
# Build a mapping of image paths to the image data so that the image data can be stored in the output docx
|
157
158
|
def load_images
|
158
159
|
image_field_names.each_with_object({}) do |field_name, result|
|
159
|
-
result[field_name] = Consolidate::Docx::Image.new(@mapping[field_name])
|
160
|
-
puts "... #{field_name} => #{result[field_name]
|
160
|
+
result[field_name] = @mapping[field_name].nil? ? nil : Consolidate::Docx::Image.new(@mapping[field_name])
|
161
|
+
puts "... #{field_name} => #{result[field_name]&.media_path}" if verbose
|
161
162
|
end
|
162
163
|
end
|
163
164
|
|
@@ -166,6 +167,8 @@ module Consolidate
|
|
166
167
|
@relations.each do |name, xml|
|
167
168
|
puts "... linking images in #{name}" if verbose
|
168
169
|
images.each do |field_name, image|
|
170
|
+
# Has an actual image file been supplied?
|
171
|
+
next if image.nil?
|
169
172
|
# Is this image already referenced in this relationship document?
|
170
173
|
next unless xml.at_xpath("//Relationship[@Target=\"#{image.media_path}\"]").nil?
|
171
174
|
puts "... #{relation_id_for(field_name)} => #{image.media_path}" if verbose
|
@@ -245,8 +248,15 @@ module Consolidate
|
|
245
248
|
field_name = piece.strip
|
246
249
|
if field_names.include? field_name
|
247
250
|
image = @images[field_name]
|
248
|
-
|
249
|
-
|
251
|
+
# if no image was provided then insert blank text
|
252
|
+
# otherwise insert a w:drawing node that references the image contents
|
253
|
+
if image.nil?
|
254
|
+
puts "... substituting '#{field_name}' with blank as no image was provided" if verbose
|
255
|
+
Nokogiri::XML::Node.new("w:t", document) { |t| t.content = "" }
|
256
|
+
else
|
257
|
+
puts "... substituting '#{field_name}' with '<#{relation_id_for(field_name)}/>'" if verbose
|
258
|
+
ImageReferenceNodeBuilder.new(field_name: field_name, image: image, node_id: relation_id_for(field_name), image_number: relation_number_for(field_name), document: document).call
|
259
|
+
end
|
250
260
|
else
|
251
261
|
Nokogiri::XML::Node.new("w:t", document) { |t| t.content = piece }
|
252
262
|
end
|
data/lib/consolidate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standard-procedure-consolidate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rahoul Baruah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- checksums/standard-procedure-consolidate-0.3.1.gem.sha512
|
66
66
|
- checksums/standard-procedure-consolidate-0.3.9.gem.sha512
|
67
67
|
- checksums/standard-procedure-consolidate-0.4.0.gem.sha512
|
68
|
+
- checksums/standard-procedure-consolidate-0.4.1.gem.sha512
|
68
69
|
- exe/consolidate
|
69
70
|
- exe/examine
|
70
71
|
- lib/consolidate.rb
|