lm_docstache 2.0.0 → 2.0.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 +7 -0
- data/lib/lm_docstache/document.rb +15 -9
- data/lib/lm_docstache/version.rb +1 -1
- data/spec/example_input/ExampleTemplate.docx +0 -0
- data/spec/integration_spec.rb +10 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e91a22653fad2e7b3afb24e170d5c8ccc8d7c5153b2a8b7cdc8caae19643e158
|
4
|
+
data.tar.gz: 9225014ab71170af0d2cfba5050d1202a531daf125a56b7c921b9beaeb3e2fa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fa5b87cddcbb5e3d6c43dc8f0f4a27f2b3f0a192c9a8dd8973ea7107d69ed53959d95c8d17dc422360e225b3c3943519a46491988e03c64da494c01da4b801c
|
7
|
+
data.tar.gz: fb75e6b190061328b857a82a967514fe4ba28a8ff983ad314d3f6fcebd2c3135b3700cc28a8353fcbad0eddcb488806fcd78ea8c51bafe0d3ee28ad5447d10ab
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module LMDocstache
|
2
2
|
class Document
|
3
3
|
TAGS_REGEXP = /{{.+?}}/
|
4
|
-
ROLES_REGEXP = /(
|
4
|
+
ROLES_REGEXP = /({{(sig|sigfirm|date|check|text|initial)\|(req|noreq)\|(.+?)}})/
|
5
5
|
|
6
6
|
def initialize(*paths)
|
7
7
|
raise ArgumentError if paths.empty?
|
@@ -65,7 +65,7 @@ module LMDocstache
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def fix_errors
|
68
|
-
problem_paragraphs.each { |
|
68
|
+
problem_paragraphs.each { |pg| flatten_paragraph(pg) if pg }
|
69
69
|
end
|
70
70
|
|
71
71
|
def errors?
|
@@ -125,15 +125,21 @@ module LMDocstache
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def flatten_paragraph(paragraph)
|
128
|
-
run_nodes = paragraph.css('w|r')
|
129
|
-
host_run_node = run_nodes.shift
|
128
|
+
return if (run_nodes = paragraph.css('w|r')).size < 2
|
130
129
|
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
while run_node = run_nodes.pop
|
131
|
+
next if run_nodes.empty?
|
132
|
+
|
133
|
+
style_node = run_node.at_css('w|rPr')
|
134
|
+
style_html = style_node ? style_node.inner_html : ''
|
135
|
+
previous_run_node = run_nodes.last
|
136
|
+
previous_style_node = previous_run_node.at_css('w|rPr')
|
137
|
+
previous_style_html = previous_style_node ? previous_style_node.inner_html : ''
|
138
|
+
|
139
|
+
next if style_html != previous_style_html
|
134
140
|
|
135
|
-
|
136
|
-
|
141
|
+
previous_text_node = previous_run_node.at_css('w|t')
|
142
|
+
previous_text_node.content = previous_text_node.text + run_node.text
|
137
143
|
run_node.unlink
|
138
144
|
end
|
139
145
|
end
|
data/lib/lm_docstache/version.rb
CHANGED
Binary file
|
data/spec/integration_spec.rb
CHANGED
@@ -58,22 +58,26 @@ describe 'integration test', integration: true do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'fixes nested xml errors breaking tags' do
|
61
|
-
expect
|
62
|
-
|
63
|
-
|
61
|
+
expect { document.fix_errors }.to change {
|
62
|
+
document.send(:problem_paragraphs).size
|
63
|
+
}.from(6).to(1)
|
64
|
+
|
65
|
+
expect(document.send(:problem_paragraphs).first.text).to eq(
|
66
|
+
'{{TAG123-\\-//WITH WE👻IRD CHARS}}'
|
67
|
+
)
|
64
68
|
end
|
65
69
|
|
66
70
|
it 'has the expected amount of usable tags' do
|
67
|
-
expect(document.usable_tags.count).to
|
71
|
+
expect(document.usable_tags.count).to eq(43)
|
68
72
|
end
|
69
73
|
|
70
74
|
it 'has the expected amount of usable roles tags' do
|
71
75
|
document.fix_errors
|
72
|
-
expect(document.usable_role_tags.count).to
|
76
|
+
expect(document.usable_role_tags.count).to eq(6)
|
73
77
|
end
|
74
78
|
|
75
79
|
it 'has the expected amount of unique tag names' do
|
76
|
-
expect(document.usable_tag_names.count).to
|
80
|
+
expect(document.usable_tag_names.count).to eq(19)
|
77
81
|
end
|
78
82
|
|
79
83
|
it 'renders file using data' do
|
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: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roey Chasman
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2021-
|
15
|
+
date: 2021-03-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: nokogiri
|