lm_docstache 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/lm_docstache/document.rb +18 -15
- data/lib/lm_docstache/version.rb +1 -1
- data/spec/example_input/ExampleTemplate2.docx +0 -0
- data/spec/example_input/~$ampleTemplate2.docx +0 -0
- data/spec/integration_spec.rb +8 -4
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ab6dff16fa851d40af9c350e4be33c01536dc9a8a9df53f7fd543cb81a9b31
|
4
|
+
data.tar.gz: 92514737372741fdadd2fbf84ed8d00617a1d7ba0e07c54f9e0cb08c829c665e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5232508c9ddd3eeaf52df714639d934baba80c613c35fa42239b242aad0243fff39f73b781b1392394cdb9c57bf702146a95d2456bc061382cd7f9d76b51385
|
7
|
+
data.tar.gz: c3a81aea4a97040b5f7157f727c4c616810a676e7d38038b50564bee3fbf8d4739b04f19310c2ccd78e7ff59e0d9eb3eb2a09d1d127931f98344787e9ea7025b
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module LMDocstache
|
2
2
|
class Document
|
3
3
|
TAGS_REGEXP = /\{\{.+?\}\}/
|
4
|
-
|
4
|
+
ROLES_REGEXP = /(\{\{(sig|sigfirm|date|check|text|initial)\|(req|noreq)\|(.+?)\}\})/
|
5
5
|
def initialize(*paths)
|
6
6
|
raise ArgumentError if paths.empty?
|
7
7
|
@path = paths.shift
|
@@ -17,33 +17,36 @@ module LMDocstache
|
|
17
17
|
find_documents_to_interpolate
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def role_tags
|
21
21
|
@documents.values.flat_map do |document|
|
22
|
-
document.text.strip.scan(
|
22
|
+
document.text.strip.scan(ROLES_REGEXP)
|
23
23
|
.map {|r| r.first }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def usable_role_tags
|
28
28
|
@documents.values.flat_map do |document|
|
29
29
|
document.css('w|p')
|
30
|
-
.select { |tag| tag.text =~
|
30
|
+
.select { |tag| tag.text =~ ROLES_REGEXP }
|
31
31
|
.flat_map { |tag|
|
32
|
-
tag.text.scan(
|
32
|
+
tag.text.scan(ROLES_REGEXP)
|
33
33
|
.map {|r| r.first }
|
34
34
|
}
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
.
|
42
|
-
|
38
|
+
def unique_role_tag_names
|
39
|
+
@documents.values.flat_map do |document|
|
40
|
+
document.css('w|p')
|
41
|
+
.select { |tag| tag.text =~ ROLES_REGEXP }
|
42
|
+
.flat_map { |tag|
|
43
|
+
tag.text.scan(ROLES_REGEXP).map {|r| r[3].strip }
|
44
|
+
}.compact.uniq
|
45
|
+
end
|
43
46
|
end
|
44
47
|
|
45
|
-
def
|
46
|
-
unusable_signature_tags =
|
48
|
+
def unusable_role_tags
|
49
|
+
unusable_signature_tags = role_tags
|
47
50
|
unusable_signature_tags.each do |usable_tag|
|
48
51
|
index = unusable_signature_tags.index(usable_tag)
|
49
52
|
unusable_signature_tags.delete_at(index) if index
|
@@ -54,14 +57,14 @@ module LMDocstache
|
|
54
57
|
def tags
|
55
58
|
@documents.values.flat_map do |document|
|
56
59
|
document.text.strip.scan(TAGS_REGEXP)
|
57
|
-
.select {|t| !(t =~
|
60
|
+
.select {|t| !(t =~ ROLES_REGEXP)}
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
61
64
|
def usable_tags
|
62
65
|
@documents.values.flat_map do |document|
|
63
66
|
document.css('w|t')
|
64
|
-
.select { |tag| tag.text =~ TAGS_REGEXP && !(tag.text =~
|
67
|
+
.select { |tag| tag.text =~ TAGS_REGEXP && !(tag.text =~ ROLES_REGEXP) }
|
65
68
|
.flat_map { |tag| tag.text.scan(TAGS_REGEXP) }
|
66
69
|
end
|
67
70
|
end
|
data/lib/lm_docstache/version.rb
CHANGED
Binary file
|
Binary file
|
data/spec/integration_spec.rb
CHANGED
@@ -67,12 +67,16 @@ describe 'integration test', integration: true do
|
|
67
67
|
expect(document.usable_tags.count).to be(30)
|
68
68
|
end
|
69
69
|
|
70
|
-
it 'has the expected amount of
|
71
|
-
expect(document.
|
70
|
+
it 'has the expected amount of role tags' do
|
71
|
+
expect(document.role_tags.count).to be(6)
|
72
72
|
end
|
73
73
|
|
74
|
-
it 'has the expected amount of
|
75
|
-
expect(document.
|
74
|
+
it 'has the expected amount of uniq role tags' do
|
75
|
+
expect(document.unique_role_tag_names.count).to be(5)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'has the expected amount of usable roles tags' do
|
79
|
+
expect(document.usable_role_tags.count).to be(6)
|
76
80
|
end
|
77
81
|
|
78
82
|
it 'has the expected amount of unique tag names' 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: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roey Chasman
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- spec/example_input/ExampleTemplate2.docx
|
122
122
|
- spec/example_input/blank.docx
|
123
123
|
- spec/example_input/word/document.xml
|
124
|
+
- spec/example_input/~$ampleTemplate2.docx
|
124
125
|
- spec/integration_spec.rb
|
125
126
|
- spec/spec_helper.rb
|
126
127
|
- spec/template_processor_spec.rb
|
@@ -155,6 +156,7 @@ test_files:
|
|
155
156
|
- spec/example_input/ExampleTemplate2.docx
|
156
157
|
- spec/example_input/blank.docx
|
157
158
|
- spec/example_input/word/document.xml
|
159
|
+
- spec/example_input/~$ampleTemplate2.docx
|
158
160
|
- spec/integration_spec.rb
|
159
161
|
- spec/spec_helper.rb
|
160
162
|
- spec/template_processor_spec.rb
|