sablon 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e21664d93631483d0c03a94ef0e459c386487e0d
4
- data.tar.gz: ea8c86cb3c1b325c88ea696d622fed0286f1c068
3
+ metadata.gz: 5407a184ceb161ef62b83c2df14b219cb6711f6b
4
+ data.tar.gz: fa4c9f089dc648d75ef8b2be51c53c5702c0541a
5
5
  SHA512:
6
- metadata.gz: 1f64f332f7cd6c2831cae719fce8eb4bced5ce6c71e427e7a0fb316d21a361aedc95bb8fca9ca7920da0147ad17f4d0f5cfa8b29b8651a16d4b4ee0004b82eeb
7
- data.tar.gz: 52c537c73248d4c9bb578864786e42849389ed90785645d72ebb848f205b950bdf1159fec73f58583f1578715c86680bb0a6e2e04e1a848038b9bff3158b647a
6
+ metadata.gz: f6da7577308e61e55a61c8f544ecc985d6c3f929d9adb47f07e7ff7fd2ba0e2aecf800765a55beb87434d19cfb096c569cc42e8ecacde6ad7adc2dbcc74830f6
7
+ data.tar.gz: 3810028838dc0b53deda64ff0d24e8773f917783092b3cce70d725d097a3e9104b63e1c98be3cf724342f57b9176fa99551a7f577ecc260ff7dfd4a1e622d567
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sablon (0.0.16)
4
+ sablon (0.0.17)
5
5
  nokogiri (>= 1.6.0)
6
6
  redcarpet (>= 3.2)
7
7
  rubyzip (>= 1.1)
@@ -15,10 +15,14 @@ module Sablon
15
15
  private
16
16
  def replace_field_display(node, content)
17
17
  paragraph = node.ancestors(".//w:p").first
18
- display_node = node.search(".//w:t").first
18
+ display_node = get_display_node(node)
19
19
  content.append_to(paragraph, display_node)
20
20
  display_node.remove
21
21
  end
22
+
23
+ def get_display_node(node)
24
+ node.search(".//w:t").first
25
+ end
22
26
  end
23
27
 
24
28
  class ComplexField < MergeField
@@ -28,7 +32,7 @@ module Sablon
28
32
  end
29
33
 
30
34
  def valid?
31
- separate_node && expression
35
+ separate_node && get_display_node(pattern_node) && expression
32
36
  end
33
37
 
34
38
  def replace(content)
@@ -1,3 +1,3 @@
1
1
  module Sablon
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
@@ -146,6 +146,39 @@ xml
146
146
  end
147
147
  end
148
148
 
149
+ class FldCharWithoutDisplayNodeTest < Sablon::TestCase
150
+ include SharedBehavior
151
+
152
+ def test_is_ignoredd
153
+ assert_equal [], fields.map(&:class)
154
+ end
155
+
156
+ private
157
+ def xml
158
+ xml = <<-xml.strip
159
+ <w:p>
160
+ <w:r w:rsidR="00AE229C">
161
+ <w:rPr></w:rPr>
162
+ <w:fldChar w:fldCharType="begin"/>
163
+ </w:r>
164
+ <w:r w:rsidR="00AE229C">
165
+ <w:rPr></w:rPr>
166
+ <w:instrText xml:space="preserve"> MERGEFIELD =client.lname \\* MERGEFORMAT </w:instrText>
167
+ </w:r>
168
+ <w:r w:rsidR="00AE229C">
169
+ <w:rPr></w:rPr>
170
+ <w:fldChar w:fldCharType="separate"/>
171
+ </w:r>
172
+ <w:r w:rsidR="00AE229C">
173
+ <w:rPr></w:rPr>
174
+ <w:fldChar w:fldCharType="end"/>
175
+ </w:r>
176
+ </w:p>
177
+ xml
178
+ wrap(xml)
179
+ end
180
+ end
181
+
149
182
  class NonSablonFieldTest < Sablon::TestCase
150
183
  include SharedBehavior
151
184
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sablon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Senn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-19 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri