slaw 0.6.6 → 0.6.7

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
  SHA1:
3
- metadata.gz: 009712e02c75565243c00817f410bcad7bab3501
4
- data.tar.gz: 6166c8595f29d5d3c4aee9e8e5b79d25892c8896
3
+ metadata.gz: 3ffdf08fe85d90cfacaa3c1f054cd907a19b257a
4
+ data.tar.gz: b0b1f5870e4c6e55b3a9e08d979386be93bf6ebd
5
5
  SHA512:
6
- metadata.gz: e3cb9452a3d9f5aac5af56b5d2a580edc674bb5e86499ba35ce87893fd9c5f17f893a662f505687cf53dec325eee6ec58861acd225a647c91a019bf7af9ed6eb
7
- data.tar.gz: 01d1391e92452f88e95fba2044bdf2114e8952b806d5e21e32ea01c93ba1c14932b0571df0081fb8c0ded7b8a209e5109dc28b2f552c57856bb93a46884e501a
6
+ metadata.gz: d2f4e281a3f03af67164b34c932956a53f5c63baf9befe1acce7b739b5d4e2d30e2aea588a8c55f4720c66281db3c6a00695c9007a5e15b6e5746f87c71f5dd2
7
+ data.tar.gz: f47c88f70b3a7c4ce16baa09c97d3e7812665b2ecf8bc570b9b782028257a1d3eebca65d5366aeb03b41ba33b5d2e34d2010d0570a4075a343a4758fe5c067c3
@@ -1,6 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'builder'
4
3
  require 'treetop'
5
4
 
6
5
  module Slaw
@@ -109,13 +108,11 @@ module Slaw
109
108
  #
110
109
  # @return [String] an XML string
111
110
  def xml_from_syntax_tree(tree)
112
- s = ""
113
- builder = ::Builder::XmlMarkup.new(indent: 2, target: s)
111
+ builder = ::Nokogiri::XML::Builder.new
114
112
 
115
- builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
116
113
  builder.akomaNtoso("xmlns:xsi"=> "http://www.w3.org/2001/XMLSchema-instance",
117
114
  "xsi:schemaLocation" => "http://www.akomantoso.org/2.0 akomantoso20.xsd",
118
- "xmlns" => NS) { |b|
115
+ "xmlns" => NS) do |b|
119
116
  args = [b]
120
117
 
121
118
  # should we provide an id prefix?
@@ -124,9 +121,9 @@ module Slaw
124
121
  args << (fragment_id_prefix || "") if arity > 1
125
122
 
126
123
  tree.to_xml(*args)
127
- }
124
+ end
128
125
 
129
- s
126
+ builder.to_xml(encoding: 'UTF-8')
130
127
  end
131
128
 
132
129
  # Parse a string into a Nokogiri::XML::Document
data/lib/slaw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
@@ -38,7 +38,7 @@ module Slaw
38
38
  end
39
39
 
40
40
  rule subsection
41
- statement:(numbered_statement / table / remark / naked_statement)
41
+ statement:(numbered_statement / table / naked_statement)
42
42
  blocklist:blocklist? <Subsection>
43
43
  end
44
44
 
@@ -110,11 +110,11 @@ module Slaw
110
110
  # statements
111
111
 
112
112
  rule numbered_statement
113
- space? numbered_statement_prefix whitespace (!blocklist_item_prefix content eol)? <NumberedStatement>
113
+ space? numbered_statement_prefix whitespace (!blocklist_item_prefix clauses eol)? <NumberedStatement>
114
114
  end
115
115
 
116
116
  rule naked_statement
117
- space? !(part / chapter / section / schedule) content eol
117
+ space? !(part / chapter / section / schedule) clauses eol
118
118
  <NakedStatement>
119
119
  end
120
120
 
@@ -123,6 +123,17 @@ module Slaw
123
123
  <ScheduleStatement>
124
124
  end
125
125
 
126
+ # one or more words, allowing inline elements
127
+ rule clauses
128
+ ((remark / [^ \t\n]+) [ \t]*)+
129
+ <Clauses>
130
+ end
131
+
132
+ rule remark
133
+ '[[' content:(!']]' .)+ ']]'
134
+ <Remark>
135
+ end
136
+
126
137
  ##########
127
138
  # tables
128
139
 
@@ -139,12 +150,6 @@ module Slaw
139
150
  space? '|}'
140
151
  end
141
152
 
142
- rule remark
143
- # TODO: support (Section 3.5 amended by ... )
144
- space? '[[' content:[^\n\]]+ ']]' eol
145
- <Remark>
146
- end
147
-
148
153
  ##########
149
154
  # prefixes
150
155
 
@@ -82,8 +82,8 @@ module Slaw
82
82
  if text_value != ""
83
83
  b.preamble { |b|
84
84
  statements.elements.each { |e|
85
- if not (e.content.text_value =~ /^preamble/i)
86
- b.p(e.content.text_value)
85
+ if not (e.clauses.text_value =~ /^preamble/i)
86
+ b.p(e.clauses.text_value)
87
87
  end
88
88
  }
89
89
  }
@@ -248,7 +248,8 @@ module Slaw
248
248
  b.content { |b|
249
249
  if blocklist and blocklist.is_a?(Blocklist)
250
250
  if statement.content
251
- blocklist.to_xml(b, idprefix, i) { |b| b << statement.content.text_value }
251
+ # provide the statement as the list introduction to the block list
252
+ blocklist.to_xml(b, idprefix, i) { |b| statement.content.to_xml(b, idprefix) }
252
253
  else
253
254
  blocklist.to_xml(b, idprefix, i)
254
255
  end
@@ -274,24 +275,42 @@ module Slaw
274
275
  if elements[3].text_value == ""
275
276
  nil
276
277
  else
277
- elements[3].content
278
+ elements[3].clauses
278
279
  end
279
280
  end
280
281
 
281
282
  def to_xml(b, idprefix)
282
- b.p(content.text_value) if content
283
+ b.p { |b| content.to_xml(b, idprefix) } if content
283
284
  end
284
285
  end
285
286
 
286
287
  class NakedStatement < Treetop::Runtime::SyntaxNode
287
288
  def to_xml(b, idprefix)
288
- b.p(content.text_value) if content
289
+ b.p { |b| clauses.to_xml(b, idprefix) } if clauses
290
+ end
291
+
292
+ def content
293
+ clauses
294
+ end
295
+ end
296
+
297
+ class Clauses < Treetop::Runtime::SyntaxNode
298
+ def to_xml(b, idprefix=nil)
299
+ for e in elements
300
+ for e2 in e.elements
301
+ if e2.respond_to? :to_xml
302
+ e2.to_xml(b, idprefix)
303
+ else
304
+ b << e2.text_value
305
+ end
306
+ end
307
+ end
289
308
  end
290
309
  end
291
310
 
292
311
  class Remark < Treetop::Runtime::SyntaxNode
293
312
  def to_xml(b, idprefix)
294
- b.p { |b| b.remark('[' + content.text_value + ']', status: 'editorial') }
313
+ b.remark('[' + content.text_value + ']', status: 'editorial')
295
314
  end
296
315
  end
297
316
 
@@ -396,7 +415,7 @@ module Slaw
396
415
  comp = "schedule#{n}"
397
416
  id = "#{idprefix}schedule-#{n}"
398
417
 
399
- b.doc(name: "schedule#{n}") { |b|
418
+ b.doc_(name: "schedule#{n}") { |b|
400
419
  b.meta { |b|
401
420
  b.identification(source: "#slaw") { |b|
402
421
  b.FRBRWork { |b|
data/slaw.gemspec CHANGED
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_runtime_dependency "nokogiri", "~> 1.6.0"
26
26
  spec.add_runtime_dependency "treetop", "~> 1.5"
27
- spec.add_runtime_dependency "builder", "~> 3.2.2"
28
27
  spec.add_runtime_dependency "log4r", "~> 1.1.10"
29
28
  spec.add_runtime_dependency "thor", "~> 0.19.1"
30
29
  spec.add_runtime_dependency "mimemagic", "~> 0.2.1"
data/spec/za/act_spec.rb CHANGED
@@ -21,11 +21,10 @@ describe Slaw::ActGenerator do
21
21
  end
22
22
  end
23
23
 
24
- def to_xml(node, indent=nil, *args)
25
- s = ""
26
- b = Builder::XmlMarkup.new(target: s, indent: indent)
24
+ def to_xml(node, *args)
25
+ b = ::Nokogiri::XML::Builder.new
27
26
  node.to_xml(b, *args)
28
- s
27
+ b.doc.root.to_xml(encoding: 'UTF-8')
29
28
  end
30
29
 
31
30
  #-------------------------------------------------------------------------------
@@ -41,7 +40,19 @@ Hello there
41
40
  EOS
42
41
  node.num.should == "2"
43
42
  node.heading.title.should == 'The Chapter Heading'
44
- to_xml(node).should == "<chapter id=\"chapter-2\"><num>2</num><heading>The Chapter Heading</heading><section id=\"section-1\"><num>1.</num><heading>Section</heading><subsection id=\"section-1.subsection-0\"><content><p>Hello there</p></content></subsection></section></chapter>"
43
+ to_xml(node).should == '<chapter id="chapter-2">
44
+ <num>2</num>
45
+ <heading>The Chapter Heading</heading>
46
+ <section id="section-1">
47
+ <num>1.</num>
48
+ <heading>Section</heading>
49
+ <subsection id="section-1.subsection-0">
50
+ <content>
51
+ <p>Hello there</p>
52
+ </content>
53
+ </subsection>
54
+ </section>
55
+ </chapter>'
45
56
  end
46
57
  end
47
58
 
@@ -58,7 +69,19 @@ Hello there
58
69
  EOS
59
70
  node.num.should == "2"
60
71
  node.heading.title.should == 'The Part Heading'
61
- to_xml(node).should == "<part id=\"part-2\"><num>2</num><heading>The Part Heading</heading><section id=\"section-1\"><num>1.</num><heading>Section</heading><subsection id=\"section-1.subsection-0\"><content><p>Hello there</p></content></subsection></section></part>"
72
+ to_xml(node).should == '<part id="part-2">
73
+ <num>2</num>
74
+ <heading>The Part Heading</heading>
75
+ <section id="section-1">
76
+ <num>1.</num>
77
+ <heading>Section</heading>
78
+ <subsection id="section-1.subsection-0">
79
+ <content>
80
+ <p>Hello there</p>
81
+ </content>
82
+ </subsection>
83
+ </section>
84
+ </part>'
62
85
  end
63
86
 
64
87
  it 'should handle part headers with dashes' do
@@ -69,7 +92,19 @@ Hello there
69
92
  EOS
70
93
  node.num.should == "2"
71
94
  node.heading.title.should == 'The Part Heading'
72
- to_xml(node).should == "<part id=\"part-2\"><num>2</num><heading>The Part Heading</heading><section id=\"section-1\"><num>1.</num><heading>Section</heading><subsection id=\"section-1.subsection-0\"><content><p>Hello there</p></content></subsection></section></part>"
95
+ to_xml(node).should == '<part id="part-2">
96
+ <num>2</num>
97
+ <heading>The Part Heading</heading>
98
+ <section id="section-1">
99
+ <num>1.</num>
100
+ <heading>Section</heading>
101
+ <subsection id="section-1.subsection-0">
102
+ <content>
103
+ <p>Hello there</p>
104
+ </content>
105
+ </subsection>
106
+ </section>
107
+ </part>'
73
108
  end
74
109
 
75
110
  it 'should handle part headers with colons' do
@@ -80,7 +115,19 @@ Hello there
80
115
  EOS
81
116
  node.num.should == "2"
82
117
  node.heading.title.should == 'The Part Heading'
83
- to_xml(node).should == "<part id=\"part-2\"><num>2</num><heading>The Part Heading</heading><section id=\"section-1\"><num>1.</num><heading>Section</heading><subsection id=\"section-1.subsection-0\"><content><p>Hello there</p></content></subsection></section></part>"
118
+ to_xml(node).should == '<part id="part-2">
119
+ <num>2</num>
120
+ <heading>The Part Heading</heading>
121
+ <section id="section-1">
122
+ <num>1.</num>
123
+ <heading>Section</heading>
124
+ <subsection id="section-1.subsection-0">
125
+ <content>
126
+ <p>Hello there</p>
127
+ </content>
128
+ </subsection>
129
+ </section>
130
+ </part>'
84
131
  end
85
132
 
86
133
  it 'should handle parts and odd section numbers' do
@@ -122,8 +169,23 @@ EOS
122
169
  (a) foo
123
170
  (b) bar
124
171
  EOS
125
- node.statement.content.text_value.should == "naked statement (c) blah"
172
+ node.statement.clauses.text_value.should == "naked statement (c) blah"
126
173
  node.blocklist.elements.first.num.should == "(a)"
174
+ to_xml(node, "").should == '<subsection id="subsection-0">
175
+ <content>
176
+ <blockList id="subsection-0.list0">
177
+ <listIntroduction>naked statement (c) blah</listIntroduction>
178
+ <item id="subsection-0.list0.a">
179
+ <num>(a)</num>
180
+ <p>foo</p>
181
+ </item>
182
+ <item id="subsection-0.list0.b">
183
+ <num>(b)</num>
184
+ <p>bar</p>
185
+ </item>
186
+ </blockList>
187
+ </content>
188
+ </subsection>'
127
189
  end
128
190
 
129
191
  it 'should handle a blocklist' do
@@ -136,6 +198,30 @@ EOS
136
198
  EOS
137
199
  node.statement.num.should == "(2)"
138
200
  node.statement.content.text_value.should == "title"
201
+ to_xml(node, "").should == '<subsection id="2">
202
+ <num>(2)</num>
203
+ <content>
204
+ <blockList id="2.list0">
205
+ <listIntroduction>title</listIntroduction>
206
+ <item id="2.list0.a">
207
+ <num>(a)</num>
208
+ <p>one</p>
209
+ </item>
210
+ <item id="2.list0.b">
211
+ <num>(b)</num>
212
+ <p>two</p>
213
+ </item>
214
+ <item id="2.list0.c">
215
+ <num>(c)</num>
216
+ <p>three</p>
217
+ </item>
218
+ <item id="2.list0.i">
219
+ <num>(i)</num>
220
+ <p>four</p>
221
+ </item>
222
+ </blockList>
223
+ </content>
224
+ </subsection>'
139
225
  end
140
226
 
141
227
  it 'should handle a subsection that dives straight into a list' do
@@ -149,6 +235,29 @@ EOS
149
235
  node.statement.content.should be_nil
150
236
  node.blocklist.elements.first.num.should == "(a)"
151
237
  node.blocklist.elements.first.content.should == "one"
238
+ to_xml(node, "").should == '<subsection id="1">
239
+ <num>(1)</num>
240
+ <content>
241
+ <blockList id="1.list0">
242
+ <item id="1.list0.a">
243
+ <num>(a)</num>
244
+ <p>one</p>
245
+ </item>
246
+ <item id="1.list0.b">
247
+ <num>(b)</num>
248
+ <p>two</p>
249
+ </item>
250
+ <item id="1.list0.c">
251
+ <num>(c)</num>
252
+ <p>three</p>
253
+ </item>
254
+ <item id="1.list0.i">
255
+ <num>(i)</num>
256
+ <p>four</p>
257
+ </item>
258
+ </blockList>
259
+ </content>
260
+ </subsection>'
152
261
  end
153
262
 
154
263
  it 'should handle a blocklist that dives straight into another list' do
@@ -166,6 +275,29 @@ EOS
166
275
  node.blocklist.elements[1].content.should be_nil
167
276
  node.blocklist.elements[2].num.should == "(i)"
168
277
  node.blocklist.elements[2].content.should == "single"
278
+ to_xml(node, "").should == '<subsection id="1">
279
+ <num>(1)</num>
280
+ <content>
281
+ <blockList id="1.list0">
282
+ <listIntroduction>here\'s my really cool list,</listIntroduction>
283
+ <item id="1.list0.a">
284
+ <num>(a)</num>
285
+ <p>one</p>
286
+ </item>
287
+ <item id="1.list0.b">
288
+ <num>(b)</num>
289
+ </item>
290
+ <item id="1.list0.i">
291
+ <num>(i)</num>
292
+ <p>single</p>
293
+ </item>
294
+ <item id="1.list0.ii">
295
+ <num>(ii)</num>
296
+ <p>double</p>
297
+ </item>
298
+ </blockList>
299
+ </content>
300
+ </subsection>'
169
301
  end
170
302
 
171
303
  context 'dotted numbers' do
@@ -199,17 +331,51 @@ EOS
199
331
  # Remarks
200
332
 
201
333
  describe 'remark' do
202
- it 'should handle basic remarks' do
203
- should_parse :remark, <<EOS
334
+ it 'should handle a plain remark' do
335
+ node = parse :subsection, <<EOS
204
336
  [[Section 2 amended by Act 23 of 2004]]
205
337
  EOS
338
+ to_xml(node, "").should == '<subsection id="subsection-0">
339
+ <content>
340
+ <p>
341
+ <remark status="editorial">[Section 2 amended by Act 23 of 2004]</remark>
342
+ </p>
343
+ </content>
344
+ </subsection>'
206
345
  end
207
346
 
208
- it 'should handle a remark' do
209
- node = parse :remark, <<EOS
210
- [[Section 2 amended by Act 23 of 2004]]
347
+ it 'should handle an inline remark at the end of a sentence' do
348
+ node = parse :subsection, <<EOS
349
+ This statement has an inline remark. [[Section 2 amended by Act 23 of 2004]]
350
+ EOS
351
+ to_xml(node, "").should == '<subsection id="subsection-0">
352
+ <content>
353
+ <p>This statement has an inline remark. <remark status="editorial">[Section 2 amended by Act 23 of 2004]</remark></p>
354
+ </content>
355
+ </subsection>'
356
+ end
357
+
358
+ it 'should handle an inline remark mid-way through' do
359
+ node = parse :subsection, <<EOS
360
+ (1) This statement has an inline remark. [[Section 2 amended by Act 23 of 2004]] And now some more.
211
361
  EOS
212
- node.content.text_value.should == "Section 2 amended by Act 23 of 2004"
362
+ to_xml(node, "").should == '<subsection id="1">
363
+ <num>(1)</num>
364
+ <content>
365
+ <p>This statement has an inline remark. <remark status="editorial">[Section 2 amended by Act 23 of 2004]</remark> And now some more.</p>
366
+ </content>
367
+ </subsection>'
368
+ end
369
+
370
+ it 'should handle many inline remarks' do
371
+ node = parse :subsection, <<EOS
372
+ This statement has an inline remark. [[Section 2 amended by Act 23 of 2004]]. And now some more. [[Another remark]] [[and another]]
373
+ EOS
374
+ to_xml(node, "").should == '<subsection id="subsection-0">
375
+ <content>
376
+ <p>This statement has an inline remark. <remark status="editorial">[Section 2 amended by Act 23 of 2004]</remark>. And now some more. <remark status="editorial">[Another remark]</remark> <remark status="editorial">[and another]</remark></p>
377
+ </content>
378
+ </subsection>'
213
379
  end
214
380
 
215
381
  it 'should handle a remark in a section' do
@@ -219,7 +385,7 @@ EOS
219
385
 
220
386
  [[Section 1 amended by Act 23 of 2004]]
221
387
  EOS
222
- to_xml(node, 2).should == '<section id="section-1">
388
+ to_xml(node).should == '<section id="section-1">
223
389
  <num>1.</num>
224
390
  <heading>Section title</heading>
225
391
  <subsection id="section-1.subsection-0">
@@ -234,8 +400,7 @@ EOS
234
400
  </p>
235
401
  </content>
236
402
  </subsection>
237
- </section>
238
- '
403
+ </section>'
239
404
  end
240
405
  end
241
406
 
@@ -354,7 +519,7 @@ EOS
354
519
  section = node.elements[1].elements[0].elements[1].elements[0].elements[1].elements[1]
355
520
  section.section_title.title.should == ""
356
521
  section.section_title.num.should == "2"
357
- section.subsections.elements[0].statement.content.text_value.should == "Notwithstanding the provision of any other By-law or legislation no person shall—"
522
+ section.subsections.elements[0].statement.clauses.text_value.should == "Notwithstanding the provision of any other By-law or legislation no person shall—"
358
523
  end
359
524
 
360
525
  it 'should handle sections without titles and with subsections' do
@@ -381,7 +546,7 @@ EOS
381
546
  section = node.elements[1].elements[0].elements[1].elements[0].elements[1].elements[0]
382
547
  section.section_title.title.should == ""
383
548
  section.section_title.num.should == "10"
384
- section.subsections.elements[0].statement.content.text_value.should == "The owner of any premises which is let or sublet to more than one tenant, shall maintain at all times in a clean and sanitary condition every part of such premises as may be used in common by more than one tenant."
549
+ section.subsections.elements[0].statement.clauses.text_value.should == "The owner of any premises which is let or sublet to more than one tenant, shall maintain at all times in a clean and sanitary condition every part of such premises as may be used in common by more than one tenant."
385
550
  end
386
551
  end
387
552
 
@@ -443,7 +608,7 @@ Baz
443
608
  Boom
444
609
  EOS
445
610
 
446
- s = to_xml(node, 2)
611
+ s = to_xml(node)
447
612
  today = Time.now.strftime('%Y-%m-%d')
448
613
  s.should == <<EOS
449
614
  <components>
@@ -525,6 +690,7 @@ EOS
525
690
  </component>
526
691
  </components>
527
692
  EOS
693
+ .strip
528
694
 
529
695
  end
530
696
 
@@ -536,7 +702,7 @@ Other than as is set out hereinbelow, no signs other than locality bound signs,
536
702
  2. Bar
537
703
  EOS
538
704
 
539
- s = to_xml(node, 2)
705
+ s = to_xml(node)
540
706
  today = Time.now.strftime('%Y-%m-%d')
541
707
  s.should == <<EOS
542
708
  <components>
@@ -580,6 +746,7 @@ EOS
580
746
  </component>
581
747
  </components>
582
748
  EOS
749
+ .strip
583
750
  end
584
751
  end
585
752
 
@@ -596,7 +763,7 @@ EOS
596
763
  EOS
597
764
 
598
765
  node.text_value.should == "{|\n| r1c1\n| r1c2\n|-\n| r2c1\n| r2c2\n|}\n"
599
- to_xml(node, nil, "prefix.").should == '<table id="prefix.table0"><tr><td><p>r1c1</p></td>
766
+ to_xml(node, "prefix.").should == '<table id="prefix.table0"><tr><td><p>r1c1</p></td>
600
767
  <td><p>r1c2</p></td></tr>
601
768
  <tr><td><p>r2c1</p></td>
602
769
  <td><p>r2c2</p></td></tr></table>'
@@ -618,10 +785,23 @@ Heres a table:
618
785
  EOS
619
786
 
620
787
  xml = to_xml(node)
621
- xml.should == '<section id="section-10"><num>10.</num><heading>A section title</heading><subsection id="section-10.subsection-0"><content><p>Heres a table:</p></content></subsection><subsection id="section-10.subsection-1"><content><table id="section-10.subsection-1.table0"><tr><td><p>r1c1</p></td>
788
+ xml.should == '<section id="section-10">
789
+ <num>10.</num>
790
+ <heading>A section title</heading>
791
+ <subsection id="section-10.subsection-0">
792
+ <content>
793
+ <p>Heres a table:</p>
794
+ </content>
795
+ </subsection>
796
+ <subsection id="section-10.subsection-1">
797
+ <content>
798
+ <table id="section-10.subsection-1.table0"><tr><td><p>r1c1</p></td>
622
799
  <td><p>r1c2</p></td></tr>
623
800
  <tr><td><p>r2c1</p></td>
624
- <td><p>r2c2</p></td></tr></table></content></subsection></section>'
801
+ <td><p>r2c2</p></td></tr></table>
802
+ </content>
803
+ </subsection>
804
+ </section>'
625
805
  end
626
806
 
627
807
  it 'should parse a table in a schedule' do
@@ -639,12 +819,67 @@ Heres a table:
639
819
  |}
640
820
  EOS
641
821
 
642
- xml = to_xml(node, nil, "")
822
+ xml = to_xml(node, "")
643
823
  today = Time.now.strftime('%Y-%m-%d')
644
- xml.should == '<doc name="schedule1"><meta><identification source="#slaw"><FRBRWork><FRBRthis value="/za/act/1980/01/schedule1"/><FRBRuri value="/za/act/1980/01"/><FRBRalias value="Schedule 1"/><FRBRdate date="1980-01-01" name="Generation"/><FRBRauthor href="#council" as="#author"/><FRBRcountry value="za"/></FRBRWork><FRBRExpression><FRBRthis value="/za/act/1980/01/eng@/schedule1"/><FRBRuri value="/za/act/1980/01/eng@"/><FRBRdate date="1980-01-01" name="Generation"/><FRBRauthor href="#council" as="#author"/><FRBRlanguage language="eng"/></FRBRExpression><FRBRManifestation><FRBRthis value="/za/act/1980/01/eng@/schedule1"/><FRBRuri value="/za/act/1980/01/eng@"/><FRBRdate date="' + today + '" name="Generation"/><FRBRauthor href="#slaw" as="#author"/></FRBRManifestation></identification></meta><mainBody><article id="schedule-1"><content><p>Heres a table:</p><table id="schedule-1.table0"><tr><td><p>r1c1</p></td>
824
+ xml.should == '<doc name="schedule1">
825
+ <meta>
826
+ <identification source="#slaw">
827
+ <FRBRWork>
828
+ <FRBRthis value="/za/act/1980/01/schedule1"/>
829
+ <FRBRuri value="/za/act/1980/01"/>
830
+ <FRBRalias value="Schedule 1"/>
831
+ <FRBRdate date="1980-01-01" name="Generation"/>
832
+ <FRBRauthor href="#council" as="#author"/>
833
+ <FRBRcountry value="za"/>
834
+ </FRBRWork>
835
+ <FRBRExpression>
836
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
837
+ <FRBRuri value="/za/act/1980/01/eng@"/>
838
+ <FRBRdate date="1980-01-01" name="Generation"/>
839
+ <FRBRauthor href="#council" as="#author"/>
840
+ <FRBRlanguage language="eng"/>
841
+ </FRBRExpression>
842
+ <FRBRManifestation>
843
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
844
+ <FRBRuri value="/za/act/1980/01/eng@"/>
845
+ <FRBRdate date="' + today + '" name="Generation"/>
846
+ <FRBRauthor href="#slaw" as="#author"/>
847
+ </FRBRManifestation>
848
+ </identification>
849
+ </meta>
850
+ <mainBody>
851
+ <article id="schedule-1">
852
+ <content>
853
+ <p>Heres a table:</p>
854
+ <table id="schedule-1.table0"><tr><td><p>r1c1</p></td>
645
855
  <td><p>r1c2</p></td></tr>
646
856
  <tr><td><p>r2c1</p></td>
647
- <td><p>r2c2</p></td></tr></table></content></article></mainBody></doc>'
857
+ <td><p>r2c2</p></td></tr></table>
858
+ </content>
859
+ </article>
860
+ </mainBody>
861
+ </doc>'
862
+ end
863
+ end
864
+
865
+ #-------------------------------------------------------------------------------
866
+ # clauses
867
+
868
+ context 'clauses' do
869
+ it 'should handle a simple clause' do
870
+ node = parse :clauses, "simple text"
871
+ node.text_value.should == "simple text"
872
+ end
873
+
874
+ it 'should handle a clause with a remark' do
875
+ node = parse :clauses, "simple [[remark]]. text"
876
+ node.text_value.should == "simple [[remark]]. text"
877
+ node.elements[1].elements.first.is_a?(Slaw::ZA::Act::Remark).should be_true
878
+
879
+ node = parse :clauses, "simple [[remark]][[another]] text"
880
+ node.text_value.should == "simple [[remark]][[another]] text"
881
+ node.elements[1].elements.first.is_a?(Slaw::ZA::Act::Remark).should be_true
882
+ node.elements[2].elements.first.is_a?(Slaw::ZA::Act::Remark).should be_true
648
883
  end
649
884
  end
650
885
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slaw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Kempe
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.5'
83
- - !ruby/object:Gem::Dependency
84
- name: builder
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 3.2.2
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 3.2.2
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: log4r
99
85
  requirement: !ruby/object:Gem::Requirement