lm_docstache 1.2.1 → 1.3.0
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/.gitignore +1 -0
- data/CHANGELOG.md +11 -0
- data/lib/lm_docstache/document.rb +37 -2
- data/lib/lm_docstache/renderer.rb +18 -2
- data/lib/lm_docstache/version.rb +1 -1
- data/lm_docstache.gemspec +3 -3
- metadata +24 -20
- data/.github/workflows/gem-push.yml +0 -42
- data/Gemfile.lock +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ae5d34672eaa5bce54718805fd2984f6a016b258f0376f3aa6707bb7c04d701
|
4
|
+
data.tar.gz: d9aacd28e9f78e7b194e6fd32fa9948d997b171427f8e425f376214eda044602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea353f13320611862bb5081806a05320b99d76fb1ae4cdc5693af1d75c9419d997458b0319142825fc76f302c19613aafc7e232cd506b9ba1134570317db7b5f
|
7
|
+
data.tar.gz: fbbb70c2866c3c344efeb5c99ff748d7b53c51796512c0e485718523f1894aa7dff40a03f5a4fc3b4c9f3cff1f87ec082b3f3d1ad2159acb43d3b907d14441c7
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
# Changelog
|
2
|
+
## 1.3.0
|
3
|
+
* Add support for e-signature tags
|
4
|
+
|
5
|
+
## 1.2.4
|
6
|
+
* Add support for pipe character in merge tags so we can use as a modifier for the context of merge tag.
|
7
|
+
|
8
|
+
## 1.2.3
|
9
|
+
* Fix issue where some paragraphs do not contain text as their first block. If this is the case, we just use the first block that does contain text.
|
10
|
+
|
11
|
+
## 1.2.2
|
12
|
+
* Remove uneccessary runtime dependency on active support.
|
2
13
|
|
3
14
|
## 1.2.1
|
4
15
|
* Fix inline conditional issues such as no support for multi conditionals.
|
@@ -15,6 +15,36 @@ module LMDocstache
|
|
15
15
|
find_documents_to_interpolate
|
16
16
|
end
|
17
17
|
|
18
|
+
def signature_tags
|
19
|
+
@documents.values.flat_map do |document|
|
20
|
+
document.text.strip.scan(/\[\[sig_.+?\]\]/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def usable_signature_tags
|
25
|
+
@documents.values.flat_map do |document|
|
26
|
+
document.css('w|t')
|
27
|
+
.select { |tag| tag.text =~ /\[\[sig_.+?\]\]/ }
|
28
|
+
.flat_map { |tag| tag.text.scan(/\[\[sig_.+?\]\]/) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def usable_signature_tag_names
|
33
|
+
self.usable_signature_tags.map do |tag|
|
34
|
+
tag.scan(/\[\[sig_(.+?)\]\]/)
|
35
|
+
$1
|
36
|
+
end.compact.uniq
|
37
|
+
end
|
38
|
+
|
39
|
+
def unusable_signature_tags
|
40
|
+
unusable_signature_tags = signature_tags
|
41
|
+
unusable_signature_tags.each do |usable_tag|
|
42
|
+
index = unusable_signature_tags.index(usable_tag)
|
43
|
+
unusable_signature_tags.delete_at(index) if index
|
44
|
+
end
|
45
|
+
return unusable_signature_tags
|
46
|
+
end
|
47
|
+
|
18
48
|
def tags
|
19
49
|
@documents.values.flat_map do |document|
|
20
50
|
document.text.strip.scan(/\{\{.+?\}\}/)
|
@@ -58,10 +88,10 @@ module LMDocstache
|
|
58
88
|
File.open(path, "w") { |f| f.write buffer.string }
|
59
89
|
end
|
60
90
|
|
61
|
-
def render_file(output, data={})
|
91
|
+
def render_file(output, data={}, remove_signature_tags = false)
|
62
92
|
rendered_documents = Hash[
|
63
93
|
@documents.map do |(path, document)|
|
64
|
-
[path, LMDocstache::Renderer.new(document.dup, data).render]
|
94
|
+
[path, LMDocstache::Renderer.new(document.dup, data, remove_signature_tags).render]
|
65
95
|
end
|
66
96
|
]
|
67
97
|
buffer = zip_buffer(rendered_documents)
|
@@ -111,7 +141,12 @@ module LMDocstache
|
|
111
141
|
|
112
142
|
def flatten_paragraph(p)
|
113
143
|
runs = p.css('w|r')
|
144
|
+
|
114
145
|
host_run = runs.shift
|
146
|
+
until host_run.at_css('w|t').present? || runs.size == 0 do
|
147
|
+
host_run = runs.shift
|
148
|
+
end
|
149
|
+
|
115
150
|
runs.each do |run|
|
116
151
|
host_run.at_css('w|t').content += run.text
|
117
152
|
run.unlink
|
@@ -2,14 +2,16 @@ module LMDocstache
|
|
2
2
|
class Renderer
|
3
3
|
BLOCK_REGEX = /\{\{([\#\^])([\w\.]+)(?:(\s(?:==|~=)\s?.+?))?\}\}.+?\{\{\/\k<2>\}\}/m
|
4
4
|
|
5
|
-
def initialize(xml, data)
|
5
|
+
def initialize(xml, data, remove_signature_tags = false)
|
6
6
|
@content = xml
|
7
7
|
@data = DataScope.new(data)
|
8
|
+
@remove_signature_tags = remove_signature_tags
|
8
9
|
end
|
9
10
|
|
10
11
|
def render
|
11
12
|
find_and_expand_blocks
|
12
13
|
replace_tags(@content, @data)
|
14
|
+
remove_signature_tags(@content) if @remove_signature_tags
|
13
15
|
return @content
|
14
16
|
end
|
15
17
|
|
@@ -106,7 +108,7 @@ module LMDocstache
|
|
106
108
|
|
107
109
|
def replace_tags(elements, data)
|
108
110
|
elements.css('w|t').each do |text_el|
|
109
|
-
if !(results = text_el.text.scan(/\{\{([\w
|
111
|
+
if !(results = text_el.text.scan(/\{\{([\w\.\|]+)\}\}/).flatten).empty?
|
110
112
|
rendered_string = text_el.text
|
111
113
|
results.each do |r|
|
112
114
|
rendered_string.gsub!("{{#{r}}}", data.get(r).to_s)
|
@@ -117,6 +119,20 @@ module LMDocstache
|
|
117
119
|
return elements
|
118
120
|
end
|
119
121
|
|
122
|
+
def remove_signature_tags(elements)
|
123
|
+
elements.css('w|t').each do |text_el|
|
124
|
+
if !(results = text_el.text.scan(/\[\[sig_(.+?)\]\]/).flatten).empty?
|
125
|
+
rendered_string = text_el.text
|
126
|
+
results.each do |r|
|
127
|
+
padding = "".ljust(r.length + 8, " ")
|
128
|
+
rendered_string.gsub!("[[sig_#{r}]]", padding)
|
129
|
+
end
|
130
|
+
text_el.content = rendered_string
|
131
|
+
end
|
132
|
+
end
|
133
|
+
return elements
|
134
|
+
end
|
135
|
+
|
120
136
|
private
|
121
137
|
|
122
138
|
def get_condition(name, condition, inverted = false)
|
data/lib/lm_docstache/version.rb
CHANGED
data/lm_docstache.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
# specify any dependencies here; for example:
|
20
20
|
s.add_runtime_dependency 'nokogiri', '~> 1.6'
|
21
21
|
s.add_runtime_dependency 'rubyzip', '~> 1.1'
|
22
|
-
s.add_runtime_dependency 'activesupport', '6.0.3.2'
|
23
22
|
|
24
|
-
s.add_development_dependency 'rspec', '>= 3.1.0'
|
25
|
-
s.add_development_dependency 'pry-byebug', '
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
|
24
|
+
s.add_development_dependency 'pry-byebug', '~> 1'
|
25
|
+
s.add_development_dependency 'activesupport', '~> 3'
|
26
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lm_docstache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roey Chasman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -40,20 +40,6 @@ dependencies:
|
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '1.1'
|
43
|
-
- !ruby/object:Gem::Dependency
|
44
|
-
name: activesupport
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - '='
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 6.0.3.2
|
50
|
-
type: :runtime
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - '='
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 6.0.3.2
|
57
43
|
- !ruby/object:Gem::Dependency
|
58
44
|
name: rspec
|
59
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,6 +47,9 @@ dependencies:
|
|
61
47
|
- - ">="
|
62
48
|
- !ruby/object:Gem::Version
|
63
49
|
version: 3.1.0
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.1'
|
64
53
|
type: :development
|
65
54
|
prerelease: false
|
66
55
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -68,20 +57,37 @@ dependencies:
|
|
68
57
|
- - ">="
|
69
58
|
- !ruby/object:Gem::Version
|
70
59
|
version: 3.1.0
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.1'
|
71
63
|
- !ruby/object:Gem::Dependency
|
72
64
|
name: pry-byebug
|
73
65
|
requirement: !ruby/object:Gem::Requirement
|
74
66
|
requirements:
|
75
|
-
- - "
|
67
|
+
- - "~>"
|
76
68
|
- !ruby/object:Gem::Version
|
77
69
|
version: '1'
|
78
70
|
type: :development
|
79
71
|
prerelease: false
|
80
72
|
version_requirements: !ruby/object:Gem::Requirement
|
81
73
|
requirements:
|
82
|
-
- - "
|
74
|
+
- - "~>"
|
83
75
|
- !ruby/object:Gem::Version
|
84
76
|
version: '1'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: activesupport
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3'
|
85
91
|
description: Integrates data into MS Word docx template files. Processing supports
|
86
92
|
loops and replacement of strings of data both outside and within loops.
|
87
93
|
email:
|
@@ -92,12 +98,10 @@ executables: []
|
|
92
98
|
extensions: []
|
93
99
|
extra_rdoc_files: []
|
94
100
|
files:
|
95
|
-
- ".github/workflows/gem-push.yml"
|
96
101
|
- ".github/workflows/ruby.yml"
|
97
102
|
- ".gitignore"
|
98
103
|
- CHANGELOG.md
|
99
104
|
- Gemfile
|
100
|
-
- Gemfile.lock
|
101
105
|
- LICENSE.txt
|
102
106
|
- README.md
|
103
107
|
- Rakefile
|
@@ -1,42 +0,0 @@
|
|
1
|
-
name: Ruby Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ master ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ master ]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
build:
|
11
|
-
name: Build + Publish
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
|
14
|
-
steps:
|
15
|
-
- uses: actions/checkout@v2
|
16
|
-
- name: Set up Ruby 2.6
|
17
|
-
uses: actions/setup-ruby@v1
|
18
|
-
with:
|
19
|
-
ruby-version: 2.6.x
|
20
|
-
|
21
|
-
- name: Publish to GPR
|
22
|
-
run: |
|
23
|
-
mkdir -p $HOME/.gem
|
24
|
-
touch $HOME/.gem/credentials
|
25
|
-
chmod 0600 $HOME/.gem/credentials
|
26
|
-
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
27
|
-
gem build *.gemspec
|
28
|
-
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
29
|
-
env:
|
30
|
-
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
31
|
-
OWNER: ${{ github.repository_owner }}
|
32
|
-
|
33
|
-
- name: Publish to RubyGems
|
34
|
-
run: |
|
35
|
-
mkdir -p $HOME/.gem
|
36
|
-
touch $HOME/.gem/credentials
|
37
|
-
chmod 0600 $HOME/.gem/credentials
|
38
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
39
|
-
gem build *.gemspec
|
40
|
-
gem push *.gem
|
41
|
-
env:
|
42
|
-
GEM_HOST_API_KEY: "Bearer ${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/Gemfile.lock
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
lm_docstache (1.2.0)
|
5
|
-
activesupport (= 6.0.3.2)
|
6
|
-
nokogiri (~> 1.6)
|
7
|
-
rubyzip (~> 1.1)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
activesupport (6.0.3.2)
|
13
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>= 0.7, < 2)
|
15
|
-
minitest (~> 5.1)
|
16
|
-
tzinfo (~> 1.1)
|
17
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
18
|
-
byebug (11.1.3)
|
19
|
-
coderay (1.1.3)
|
20
|
-
concurrent-ruby (1.1.6)
|
21
|
-
diff-lcs (1.4.4)
|
22
|
-
i18n (1.8.3)
|
23
|
-
concurrent-ruby (~> 1.0)
|
24
|
-
method_source (1.0.0)
|
25
|
-
mini_portile2 (2.4.0)
|
26
|
-
minitest (5.14.1)
|
27
|
-
nokogiri (1.10.10)
|
28
|
-
mini_portile2 (~> 2.4.0)
|
29
|
-
pry (0.13.1)
|
30
|
-
coderay (~> 1.1)
|
31
|
-
method_source (~> 1.0)
|
32
|
-
pry-byebug (3.9.0)
|
33
|
-
byebug (~> 11.0)
|
34
|
-
pry (~> 0.13.0)
|
35
|
-
rspec (3.9.0)
|
36
|
-
rspec-core (~> 3.9.0)
|
37
|
-
rspec-expectations (~> 3.9.0)
|
38
|
-
rspec-mocks (~> 3.9.0)
|
39
|
-
rspec-core (3.9.2)
|
40
|
-
rspec-support (~> 3.9.3)
|
41
|
-
rspec-expectations (3.9.2)
|
42
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.9.0)
|
44
|
-
rspec-mocks (3.9.1)
|
45
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.9.0)
|
47
|
-
rspec-support (3.9.3)
|
48
|
-
rubyzip (1.3.0)
|
49
|
-
thread_safe (0.3.6)
|
50
|
-
tzinfo (1.2.7)
|
51
|
-
thread_safe (~> 0.1)
|
52
|
-
zeitwerk (2.4.0)
|
53
|
-
|
54
|
-
PLATFORMS
|
55
|
-
ruby
|
56
|
-
|
57
|
-
DEPENDENCIES
|
58
|
-
lm_docstache!
|
59
|
-
pry-byebug (>= 1)
|
60
|
-
rspec (>= 3.1.0)
|
61
|
-
|
62
|
-
BUNDLED WITH
|
63
|
-
1.17.2
|