lm_docstache 1.3.4 → 1.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3268400635c8fd94b49786b4509b78f3acc649e8fb1bea2b65ba4a7f520b6b22
4
- data.tar.gz: 19a429793e0699e2026a726c73d8c579f3644b4f88425ef57944dada31e878cc
3
+ metadata.gz: f6ab6dff16fa851d40af9c350e4be33c01536dc9a8a9df53f7fd543cb81a9b31
4
+ data.tar.gz: 92514737372741fdadd2fbf84ed8d00617a1d7ba0e07c54f9e0cb08c829c665e
5
5
  SHA512:
6
- metadata.gz: a902c19fa827102d3396d317e977031db56071d3bead3900f83f67583f41e96bca042c4f9ab54d215058c0af3d76ff492bc059d17d22c3c710a6ee7aa637492d
7
- data.tar.gz: deb3bda8b3ce6ea84f6334197bf93fd7e10950e84386731ad9426f9f746ab1967485b54b312160c98bae2eac7a1752b0c35e65e36c54208ea8177af03db730ec
6
+ metadata.gz: c5232508c9ddd3eeaf52df714639d934baba80c613c35fa42239b242aad0243fff39f73b781b1392394cdb9c57bf702146a95d2456bc061382cd7f9d76b51385
7
+ data.tar.gz: c3a81aea4a97040b5f7157f727c4c616810a676e7d38038b50564bee3fbf8d4739b04f19310c2ccd78e7ff59e0d9eb3eb2a09d1d127931f98344787e9ea7025b
@@ -1,4 +1,7 @@
1
1
  # Changelog
2
+ ## 1.3.5
3
+ * Replace signatures by roles. Add unique roles name collector.
4
+
2
5
  ## 1.3.4
3
6
  * Change signature signs identifiers to be braces instead of brackets.
4
7
 
@@ -1,7 +1,7 @@
1
1
  module LMDocstache
2
2
  class Document
3
3
  TAGS_REGEXP = /\{\{.+?\}\}/
4
- SIGNATURE_REGEXP = /(\{\{(sig|sigfirm|date|check|text|initial)\|(req|noreq)\|(.+?)\}\})/
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 signature_tags
20
+ def role_tags
21
21
  @documents.values.flat_map do |document|
22
- document.text.strip.scan(SIGNATURE_REGEXP)
22
+ document.text.strip.scan(ROLES_REGEXP)
23
23
  .map {|r| r.first }
24
24
  end
25
25
  end
26
26
 
27
- def usable_signature_tags
27
+ def usable_role_tags
28
28
  @documents.values.flat_map do |document|
29
29
  document.css('w|p')
30
- .select { |tag| tag.text =~ SIGNATURE_REGEXP }
30
+ .select { |tag| tag.text =~ ROLES_REGEXP }
31
31
  .flat_map { |tag|
32
- tag.text.scan(SIGNATURE_REGEXP)
32
+ tag.text.scan(ROLES_REGEXP)
33
33
  .map {|r| r.first }
34
34
  }
35
35
  end
36
36
  end
37
37
 
38
- def usable_signature_tag_names
39
- self.usable_signature_tags.map do |tag|
40
- tag.scan(SIGNATURE_REGEXP)
41
- .map {|r| r.first }
42
- end.compact.uniq
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 unusable_signature_tags
46
- unusable_signature_tags = 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 =~ SIGNATURE_REGEXP)}
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 =~ SIGNATURE_REGEXP) }
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
@@ -1,3 +1,3 @@
1
1
  module LMDocstache
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  end
@@ -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 signature tags' do
71
- expect(document.signature_tags.count).to be(6)
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 usable signature tags' do
75
- expect(document.usable_signature_tags.count).to be(6)
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
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