svg_template_to_pdf 0.1.0 → 0.1.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/svg_template_to_pdf.rb +2 -2
- data/lib/svg_template_to_pdf/version.rb +1 -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: a6c8933ec11c846615351647706591beb904f458
|
4
|
+
data.tar.gz: e3af2100151911bddc88c3009d82ea3eb0e4db68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d4e36a00627e1538daadab41cdaa84f0d5482c612c5a7ee975e8aedb79cd7897042f2ea325b425bf5ed65109e736eaef5d46e82b45e97afd351cd80a0c22c4f
|
7
|
+
data.tar.gz: afc8920352d9aab9665970a39d1a827898dfdd7b4c365ae22c86f98fe0bcd08e5c5c46525c09a9593c35cb44e0168f9f63f00ddea73903fd7d55d6cf538b2262
|
data/lib/svg_template_to_pdf.rb
CHANGED
@@ -14,7 +14,7 @@ class SvgTemplateToPdf
|
|
14
14
|
|
15
15
|
# Get header names from svg
|
16
16
|
def variables
|
17
|
-
result = @
|
17
|
+
result = @svg_input.scan(/%VAR_(\w+)%/).flatten
|
18
18
|
duplicates = get_duplicates(result)
|
19
19
|
raise StandardError, "More than 1 use of variables #{duplicates.join(", ")} in the SVG file." if duplicates.size != 0
|
20
20
|
result
|
@@ -23,7 +23,7 @@ class SvgTemplateToPdf
|
|
23
23
|
def process
|
24
24
|
output_files = []
|
25
25
|
CSV.read(@csv_filename, headers: true).each_with_index do |row, i| # for each row produce pdf with data
|
26
|
-
content = @
|
26
|
+
content = @svg_input.dup
|
27
27
|
variables.each { |col| content.sub!("%VAR_#{col}%", row[col].to_s) }
|
28
28
|
output_files << Svg2pdf.convert_from_data(content, :pdf, working_dir: @output_folder, output_name: "#{@pdf_filename}#{i}")
|
29
29
|
end
|