docx-builder 0.2.2 → 0.2.3
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/Gemfile.lock +1 -1
- data/lib/docx/builder/configuration.rb +4 -0
- data/lib/docx/builder/template.rb +5 -1
- data/lib/docx/builder/version.rb +1 -1
- data/lib/docx/builder/xml_processor.rb +1 -1
- data/lib/docx/builder.rb +5 -0
- data/lib/docx/logger.rb +19 -0
- 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: 208b51187c9e384db0e9d585552b8696e0a868709d2ee7348ae57e3d96566e1e
|
4
|
+
data.tar.gz: 54cdcbe11f62f7dcb3ab6fdcd4575f8d2ca09f876da8c0a8e7c8a57209313b42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f1e1c08dd0f604ba920ad88c139e4797e4b8a6ed7b9d2edf2f5d363c92b19bb9e1b889e32f3a6f4b4deb9c5920e8d197a2815320b167b6049ec8a0636506ae
|
7
|
+
data.tar.gz: 3b71f7b11e68f1c8e19616265401c4f03d392fbd503ab34aef98f8d237ff5a08545108593c4f53daf3e4d1e5e195905326bd9e005b91ec422eea87b2e014f24f
|
data/Gemfile.lock
CHANGED
@@ -13,10 +13,13 @@ module Docx
|
|
13
13
|
|
14
14
|
def render(data)
|
15
15
|
@sections.map do |section|
|
16
|
+
Docx::Builder.logger.debug("Cleaning template variables for section #{section}")
|
16
17
|
cleaned_document = clean(@document.read(section))
|
18
|
+
Docx::Builder.logger.debug("Replacing template tags ('{{%' -> '<%') for section #{section}")
|
17
19
|
erb_template = build_erb_template(cleaned_document)
|
20
|
+
Docx::Builder.logger.debug("Rendering template for section #{section} with data")
|
18
21
|
processed_document = render_erb_template(erb_template, data)
|
19
|
-
[section, processed_document]
|
22
|
+
[section, processed_document]
|
20
23
|
end.to_h
|
21
24
|
end
|
22
25
|
|
@@ -39,6 +42,7 @@ module Docx
|
|
39
42
|
|
40
43
|
# creates xml template keys in input docx (template file)
|
41
44
|
def save(path, new_document)
|
45
|
+
Docx::Builder.logger.info("Saving output file into path #{path.to_s}")
|
42
46
|
File.open(path, 'wb') do |f|
|
43
47
|
new_document_xml_string = Docx::Builder::Encoder.build_new_document_xml(@document, new_document)
|
44
48
|
f.write(new_document_xml_string)
|
data/lib/docx/builder/version.rb
CHANGED
data/lib/docx/builder.rb
CHANGED
@@ -4,6 +4,7 @@ require 'rubygems'
|
|
4
4
|
require 'zip'
|
5
5
|
require 'nokogiri'
|
6
6
|
|
7
|
+
require_relative "logger"
|
7
8
|
require_relative "builder/version"
|
8
9
|
require_relative "builder/decoder"
|
9
10
|
require_relative "builder/encoder"
|
@@ -19,6 +20,10 @@ module Docx
|
|
19
20
|
@configuration ||= Configuration.new
|
20
21
|
end
|
21
22
|
|
23
|
+
def logger
|
24
|
+
configuration.logger
|
25
|
+
end
|
26
|
+
|
22
27
|
def configure
|
23
28
|
yield(configuration)
|
24
29
|
end
|
data/lib/docx/logger.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Docx
|
4
|
+
class Logger < ::Logger
|
5
|
+
def initialize(*args, **kwargs)
|
6
|
+
super
|
7
|
+
@formatter = SimpleFormatter.new
|
8
|
+
@level = ENV['LOG_LEVEL'].to_i if ENV.keys.include?('LOG_LEVEL')
|
9
|
+
end
|
10
|
+
|
11
|
+
# Simple formatter which only displays the message
|
12
|
+
class SimpleFormatter < ::Logger::Formatter
|
13
|
+
# This method is invoked when a log event occurs
|
14
|
+
def call(severity, timestamp, progname, msg)
|
15
|
+
"#{String === msg ? msg : msg.inspect}\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docx-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tecnologia Cashme
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Builds a new docx file using ERB template
|
14
14
|
email:
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/docx/builder/template.rb
|
39
39
|
- lib/docx/builder/version.rb
|
40
40
|
- lib/docx/builder/xml_processor.rb
|
41
|
+
- lib/docx/logger.rb
|
41
42
|
- publish.sh
|
42
43
|
- tmp/.gitkeep
|
43
44
|
homepage: https://github.com/cash-me/docx-builder
|