sheng 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sheng/block.rb +2 -2
- data/lib/sheng/version.rb +1 -1
- data/spec/fixtures/xml_fragments/input/sequence/sequence_with_misleading_fields.xml +77 -0
- data/spec/fixtures/xml_fragments/output/sequence/sequence_with_misleading_fields.xml +60 -0
- data/spec/lib/sheng/sequence_spec.rb +17 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20f74c4e33aa2c6d02047cba5d9939aae549a4d6
|
4
|
+
data.tar.gz: 9e5f6b49e52c00e894d799fb9e000d7fb070efad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98a4c1d780fb682610f7745dee718bad9b9d2ada521e8ac92f62b86e36ade25cc87f125a47fc2e701228d997b06d6d468eceda32e77d08a6554ddb9026f7875c
|
7
|
+
data.tar.gz: 4540354d8578d52ca6d26a9f4b186ec1eeaa051c74857ec13b189bb642673cf554d88c8f95b88f2c08efd55d8df73783c718e732ab700934b72d5ea07c2a1b33
|
data/lib/sheng/block.rb
CHANGED
@@ -16,11 +16,11 @@ module Sheng
|
|
16
16
|
|
17
17
|
def extract_mergefields(fragment)
|
18
18
|
if fragment.name == "fldSimple"
|
19
|
-
return [MergeField.
|
19
|
+
return [MergeField.from_element(fragment)].compact
|
20
20
|
end
|
21
21
|
fragment.xpath(".//#{mergefield_element_path}|.//#{new_mergefield_element_path}").map do |field_simple|
|
22
22
|
unless field_simple.at('.//w:checkBox')
|
23
|
-
MergeField.
|
23
|
+
MergeField.from_element(field_simple)
|
24
24
|
end
|
25
25
|
end.compact
|
26
26
|
end
|
data/lib/sheng/version.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
2
|
+
<w:p>
|
3
|
+
<w:r>
|
4
|
+
<w:fldChar w:fldCharType="begin"/>
|
5
|
+
</w:r>
|
6
|
+
<w:r>
|
7
|
+
<w:instrText xml:space="preserve">MERGEFIELD start:castles \* MERGEFORMAT </w:instrText>
|
8
|
+
</w:r>
|
9
|
+
<w:r>
|
10
|
+
<w:fldChar w:fldCharType="separate"/>
|
11
|
+
</w:r>
|
12
|
+
<w:r>
|
13
|
+
<w:t>«start:castles»</w:t>
|
14
|
+
</w:r>
|
15
|
+
<w:r>
|
16
|
+
<w:fldChar w:fldCharType="end"/>
|
17
|
+
</w:r>
|
18
|
+
</w:p>
|
19
|
+
<w:p>
|
20
|
+
<w:r>
|
21
|
+
<w:fldChar w:fldCharType="begin"/>
|
22
|
+
</w:r>
|
23
|
+
<w:r>
|
24
|
+
<w:instrText xml:space="preserve">MERGEFIELD color \* MERGEFORMAT </w:instrText>
|
25
|
+
</w:r>
|
26
|
+
<w:r>
|
27
|
+
<w:fldChar w:fldCharType="separate"/>
|
28
|
+
</w:r>
|
29
|
+
<w:r>
|
30
|
+
<w:t>«color»</w:t>
|
31
|
+
</w:r>
|
32
|
+
<w:r>
|
33
|
+
<w:fldChar w:fldCharType="end"/>
|
34
|
+
</w:r>
|
35
|
+
</w:p>
|
36
|
+
<w:p>
|
37
|
+
<w:r>
|
38
|
+
<w:fldChar w:fldCharType="begin"/>
|
39
|
+
</w:r>
|
40
|
+
<w:r>
|
41
|
+
<w:instrText xml:space="preserve">PAGE \* MERGEFORMAT </w:instrText>
|
42
|
+
</w:r>
|
43
|
+
<w:r>
|
44
|
+
<w:fldChar w:fldCharType="separate"/>
|
45
|
+
</w:r>
|
46
|
+
<w:r>
|
47
|
+
<w:t>1</w:t>
|
48
|
+
</w:r>
|
49
|
+
<w:r>
|
50
|
+
<w:fldChar w:fldCharType="end"/>
|
51
|
+
</w:r>
|
52
|
+
</w:p>
|
53
|
+
<w:p>
|
54
|
+
<w:fldSimple w:instr=" PAGE \* MERGEFORMAT ">
|
55
|
+
<w:r>
|
56
|
+
<w:t>1</w:t>
|
57
|
+
</w:r>
|
58
|
+
</w:fldSimple>
|
59
|
+
</w:p>
|
60
|
+
<w:p>
|
61
|
+
<w:r>
|
62
|
+
<w:fldChar w:fldCharType="begin"/>
|
63
|
+
</w:r>
|
64
|
+
<w:r>
|
65
|
+
<w:instrText xml:space="preserve">MERGEFIELD end:castles \* MERGEFORMAT </w:instrText>
|
66
|
+
</w:r>
|
67
|
+
<w:r>
|
68
|
+
<w:fldChar w:fldCharType="separate"/>
|
69
|
+
</w:r>
|
70
|
+
<w:r>
|
71
|
+
<w:t>«end:castles»</w:t>
|
72
|
+
</w:r>
|
73
|
+
<w:r>
|
74
|
+
<w:fldChar w:fldCharType="end"/>
|
75
|
+
</w:r>
|
76
|
+
</w:p>
|
77
|
+
</w:document>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
2
|
+
<w:p>
|
3
|
+
<w:r>
|
4
|
+
<w:t>browns</w:t>
|
5
|
+
</w:r>
|
6
|
+
</w:p>
|
7
|
+
<w:p>
|
8
|
+
<w:r>
|
9
|
+
<w:fldChar w:fldCharType="begin"/>
|
10
|
+
</w:r>
|
11
|
+
<w:r>
|
12
|
+
<w:instrText xml:space="preserve">PAGE \* MERGEFORMAT </w:instrText>
|
13
|
+
</w:r>
|
14
|
+
<w:r>
|
15
|
+
<w:fldChar w:fldCharType="separate"/>
|
16
|
+
</w:r>
|
17
|
+
<w:r>
|
18
|
+
<w:t>1</w:t>
|
19
|
+
</w:r>
|
20
|
+
<w:r>
|
21
|
+
<w:fldChar w:fldCharType="end"/>
|
22
|
+
</w:r>
|
23
|
+
</w:p>
|
24
|
+
<w:p>
|
25
|
+
<w:fldSimple w:instr=" PAGE \* MERGEFORMAT ">
|
26
|
+
<w:r>
|
27
|
+
<w:t>1</w:t>
|
28
|
+
</w:r>
|
29
|
+
</w:fldSimple>
|
30
|
+
</w:p>
|
31
|
+
<w:p>
|
32
|
+
<w:r>
|
33
|
+
<w:t>totally rad</w:t>
|
34
|
+
</w:r>
|
35
|
+
</w:p>
|
36
|
+
<w:p>
|
37
|
+
<w:r>
|
38
|
+
<w:fldChar w:fldCharType="begin"/>
|
39
|
+
</w:r>
|
40
|
+
<w:r>
|
41
|
+
<w:instrText xml:space="preserve">PAGE \* MERGEFORMAT </w:instrText>
|
42
|
+
</w:r>
|
43
|
+
<w:r>
|
44
|
+
<w:fldChar w:fldCharType="separate"/>
|
45
|
+
</w:r>
|
46
|
+
<w:r>
|
47
|
+
<w:t>1</w:t>
|
48
|
+
</w:r>
|
49
|
+
<w:r>
|
50
|
+
<w:fldChar w:fldCharType="end"/>
|
51
|
+
</w:r>
|
52
|
+
</w:p>
|
53
|
+
<w:p>
|
54
|
+
<w:fldSimple w:instr=" PAGE \* MERGEFORMAT ">
|
55
|
+
<w:r>
|
56
|
+
<w:t>1</w:t>
|
57
|
+
</w:r>
|
58
|
+
</w:fldSimple>
|
59
|
+
</w:p>
|
60
|
+
</w:document>
|
@@ -175,6 +175,23 @@ describe Sheng::Sequence do
|
|
175
175
|
expect(subject.xml_document).to be_equivalent_to xml_fragment('output/sequence/embedded_sequence')
|
176
176
|
end
|
177
177
|
end
|
178
|
+
|
179
|
+
context "with non-mergefield fields in the repeating block" do
|
180
|
+
let(:fragment) { xml_fragment('input/sequence/sequence_with_misleading_fields') }
|
181
|
+
let(:element) { fragment.xpath("//w:fldChar[contains(@w:fldCharType, 'begin')]").first }
|
182
|
+
|
183
|
+
it "ignores the non-mergefields fldchars" do
|
184
|
+
dataset = Sheng::DataSet.new({
|
185
|
+
:castles => [
|
186
|
+
{ :color => 'browns' },
|
187
|
+
{ :color => 'totally rad' }
|
188
|
+
]
|
189
|
+
})
|
190
|
+
|
191
|
+
subject.interpolate(dataset)
|
192
|
+
expect(subject.xml_document).to be_equivalent_to xml_fragment('output/sequence/sequence_with_misleading_fields')
|
193
|
+
end
|
194
|
+
end
|
178
195
|
end
|
179
196
|
|
180
197
|
describe '#new' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sheng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ravi Gadad
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- spec/fixtures/xml_fragments/input/sequence/overridden_iterator_array_sequence.xml
|
209
209
|
- spec/fixtures/xml_fragments/input/sequence/sequence.xml
|
210
210
|
- spec/fixtures/xml_fragments/input/sequence/sequence_in_table.xml
|
211
|
+
- spec/fixtures/xml_fragments/input/sequence/sequence_with_misleading_fields.xml
|
211
212
|
- spec/fixtures/xml_fragments/input/sequence/sequence_with_section_formatting.xml
|
212
213
|
- spec/fixtures/xml_fragments/input/sequence/series_with_commas.xml
|
213
214
|
- spec/fixtures/xml_fragments/output/check_box/check_box.xml
|
@@ -234,6 +235,7 @@ files:
|
|
234
235
|
- spec/fixtures/xml_fragments/output/sequence/overridden_iterator_array_sequence.xml
|
235
236
|
- spec/fixtures/xml_fragments/output/sequence/sequence.xml
|
236
237
|
- spec/fixtures/xml_fragments/output/sequence/sequence_in_table.xml
|
238
|
+
- spec/fixtures/xml_fragments/output/sequence/sequence_with_misleading_fields.xml
|
237
239
|
- spec/fixtures/xml_fragments/output/sequence/sequence_with_section_formatting.xml
|
238
240
|
- spec/fixtures/xml_fragments/output/sequence/series_with_commas.xml
|
239
241
|
- spec/fixtures/xml_fragments/output/sequence/series_with_commas_two_items.xml
|
@@ -313,6 +315,7 @@ test_files:
|
|
313
315
|
- spec/fixtures/xml_fragments/input/sequence/overridden_iterator_array_sequence.xml
|
314
316
|
- spec/fixtures/xml_fragments/input/sequence/sequence.xml
|
315
317
|
- spec/fixtures/xml_fragments/input/sequence/sequence_in_table.xml
|
318
|
+
- spec/fixtures/xml_fragments/input/sequence/sequence_with_misleading_fields.xml
|
316
319
|
- spec/fixtures/xml_fragments/input/sequence/sequence_with_section_formatting.xml
|
317
320
|
- spec/fixtures/xml_fragments/input/sequence/series_with_commas.xml
|
318
321
|
- spec/fixtures/xml_fragments/output/check_box/check_box.xml
|
@@ -339,6 +342,7 @@ test_files:
|
|
339
342
|
- spec/fixtures/xml_fragments/output/sequence/overridden_iterator_array_sequence.xml
|
340
343
|
- spec/fixtures/xml_fragments/output/sequence/sequence.xml
|
341
344
|
- spec/fixtures/xml_fragments/output/sequence/sequence_in_table.xml
|
345
|
+
- spec/fixtures/xml_fragments/output/sequence/sequence_with_misleading_fields.xml
|
342
346
|
- spec/fixtures/xml_fragments/output/sequence/sequence_with_section_formatting.xml
|
343
347
|
- spec/fixtures/xml_fragments/output/sequence/series_with_commas.xml
|
344
348
|
- spec/fixtures/xml_fragments/output/sequence/series_with_commas_two_items.xml
|