lm_docstache 3.0.7 → 3.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/lm_docstache/document.rb +12 -27
- data/lib/lm_docstache/version.rb +1 -1
- data/spec/integration_spec.rb +3 -1
- 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: b414a4508c323651394880630f25af46409778dfc205ebc5621d72e07a6e69a3
|
4
|
+
data.tar.gz: 896ce5a0ef359f2b3a77646a631b66ef74a67fb6f5d8fa2ac218a3d346b8f0f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e14266f143047c25ee683b6544ddca31648ac83b51a7a72756f3f01dfa1800353f684d3c1a82e878f523a29ef829389f99c7e4f60b0c6d5c46708eccffc5c36c
|
7
|
+
data.tar.gz: 0f5ee3910f3a77519fec6ee1db604954c49f3ecc5b0e12af4bcc4d7844b0f10bc9ee410070291381fbd90cce25f974c246a8bca6a107b8d63021b8e38ed3cef9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.0.8
|
4
|
+
|
5
|
+
#### Bug fixes
|
6
|
+
|
7
|
+
* Fix a bug on `usable_tags` method, so it now properly and expectedly
|
8
|
+
includes conditional tag names that have its opening tag markup as the sole
|
9
|
+
content of paragraphs (which represents conditional blocks where both
|
10
|
+
opening and closing tags are in separate parapraghs sorrounding one or more
|
11
|
+
paragraphs as its conditional block content).
|
12
|
+
|
3
13
|
## 3.0.7
|
4
14
|
|
5
15
|
#### Bug fixes
|
@@ -38,7 +38,7 @@ module LMDocstache
|
|
38
38
|
def tags
|
39
39
|
@documents.values.flat_map do |document|
|
40
40
|
document_text = document.text
|
41
|
-
extract_tag_names(document_text) + extract_tag_names(document_text,
|
41
|
+
extract_tag_names(document_text) + extract_tag_names(document_text, :full_block)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -47,7 +47,8 @@ module LMDocstache
|
|
47
47
|
document.css('w|t').reduce(tags) do |document_tags, text_node|
|
48
48
|
text = text_node.text
|
49
49
|
document_tags.push(*extract_tag_names(text))
|
50
|
-
document_tags.push(*extract_tag_names(text,
|
50
|
+
document_tags.push(*extract_tag_names(text, :start_block))
|
51
|
+
document_tags.push(*extract_tag_names(text, :full_block))
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -62,20 +63,10 @@ module LMDocstache
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def unusable_tags
|
65
|
-
conditional_start_tags = text_nodes_containing_only_starting_conditionals.map(&:text)
|
66
|
-
|
67
66
|
usable_tags.reduce(tags) do |broken_tags, usable_tag|
|
68
67
|
next broken_tags unless index = broken_tags.index(usable_tag)
|
69
68
|
|
70
69
|
broken_tags.delete_at(index) && broken_tags
|
71
|
-
end.reject do |broken_tag|
|
72
|
-
operator = broken_tag.is_a?(Regexp) ? :=~ : :==
|
73
|
-
start_tags_index = conditional_start_tags.find_index do |start_tag|
|
74
|
-
broken_tag.send(operator, start_tag)
|
75
|
-
end
|
76
|
-
|
77
|
-
conditional_start_tags.delete_at(start_tags_index) if start_tags_index
|
78
|
-
!!start_tags_index
|
79
70
|
end
|
80
71
|
end
|
81
72
|
|
@@ -123,23 +114,17 @@ module LMDocstache
|
|
123
114
|
.gsub('\\ ', ' ')
|
124
115
|
end
|
125
116
|
|
126
|
-
def
|
127
|
-
|
128
|
-
|
129
|
-
|
117
|
+
def extract_tag_names(text, tag_type = :variable)
|
118
|
+
text, regex, extractor =
|
119
|
+
if tag_type == :variable
|
120
|
+
[text, Parser::VARIABLE_MATCHER, ->(match) { "{{%s}}" % match }]
|
121
|
+
else
|
122
|
+
extractor = ->(match) { /#{Regexp.escape("{{%s%s %s %s}}" % match)}/ }
|
123
|
+
tag_type == :full_block ? [text, Parser::BLOCK_MATCHER, extractor] :
|
124
|
+
[text.strip, WHOLE_BLOCK_START_REGEX, extractor]
|
130
125
|
end
|
131
|
-
end
|
132
|
-
end
|
133
126
|
|
134
|
-
|
135
|
-
if conditional_tag
|
136
|
-
text.scan(Parser::BLOCK_MATCHER).map do |match|
|
137
|
-
start_block_tag = "{{#{match[0]}#{match[1]} #{match[2]} #{match[3]}}}"
|
138
|
-
/#{Regexp.escape(start_block_tag)}/
|
139
|
-
end
|
140
|
-
else
|
141
|
-
text.scan(Parser::VARIABLE_MATCHER).map { |match| "{{#{match[0]}}}" }
|
142
|
-
end
|
127
|
+
text.scan(regex).map(&extractor)
|
143
128
|
end
|
144
129
|
|
145
130
|
def render_documents(data, text = nil, render_options = {})
|
data/lib/lm_docstache/version.rb
CHANGED
data/spec/integration_spec.rb
CHANGED
@@ -70,7 +70,9 @@ describe 'integration test', integration: true do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'has the expected amount of usable tags' do
|
73
|
-
expect
|
73
|
+
expect { document.fix_errors }.to change {
|
74
|
+
document.usable_tags.count
|
75
|
+
}.from(29).to(34)
|
74
76
|
end
|
75
77
|
|
76
78
|
it 'has the expected amount of usable roles tags' 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: 3.0.
|
4
|
+
version: 3.0.8
|
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-06-
|
15
|
+
date: 2021-06-25 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: nokogiri
|