slaw 0.6.4 → 0.6.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 +4 -4
- data/lib/slaw/version.rb +1 -1
- data/lib/slaw/za/act.treetop +7 -1
- data/lib/slaw/za/act_nodes.rb +6 -0
- data/spec/za/act_spec.rb +52 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ba2a75b8de3436b8af7bd0267176fb82a1476a9
|
4
|
+
data.tar.gz: e292f43cb16ce86cd9c599f0f25410216ae1e33c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0f6476e7912dd560d78b59495dc25bdec405c19f91d73dfa33a2a2270f25aa48da7d6545292acf4c9f23e17d66fc0c3e4806f2412b223b5c0415442b76e65c6
|
7
|
+
data.tar.gz: e4ac81e36adb6fe221b3eedcb4f2e761fc01dd0dbd92b7d293c060df50fbbb21984f5af747efbb12f715cd4d2dd25f5ce03e330366b0a39af8a63812446f049b
|
data/lib/slaw/version.rb
CHANGED
data/lib/slaw/za/act.treetop
CHANGED
@@ -38,7 +38,7 @@ module Slaw
|
|
38
38
|
end
|
39
39
|
|
40
40
|
rule subsection
|
41
|
-
statement:(numbered_statement / table / naked_statement)
|
41
|
+
statement:(numbered_statement / table / remark / naked_statement)
|
42
42
|
blocklist:blocklist? <Subsection>
|
43
43
|
end
|
44
44
|
|
@@ -139,6 +139,12 @@ module Slaw
|
|
139
139
|
space? '|}'
|
140
140
|
end
|
141
141
|
|
142
|
+
rule remark
|
143
|
+
# TODO: support (Section 3.5 amended by ... )
|
144
|
+
space? '[' content:[^\n\]]+ ']' eol
|
145
|
+
<Remark>
|
146
|
+
end
|
147
|
+
|
142
148
|
##########
|
143
149
|
# prefixes
|
144
150
|
|
data/lib/slaw/za/act_nodes.rb
CHANGED
@@ -289,6 +289,12 @@ module Slaw
|
|
289
289
|
end
|
290
290
|
end
|
291
291
|
|
292
|
+
class Remark < Treetop::Runtime::SyntaxNode
|
293
|
+
def to_xml(b, idprefix)
|
294
|
+
b.p { |b| b.remark('[' + content.text_value + ']', status: 'editorial') }
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
292
298
|
class Blocklist < Treetop::Runtime::SyntaxNode
|
293
299
|
# Render a block list to xml. If a block is given,
|
294
300
|
# yield to it a builder to insert a listIntroduction node
|
data/spec/za/act_spec.rb
CHANGED
@@ -21,9 +21,9 @@ describe Slaw::ActGenerator do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def to_xml(node, *args)
|
24
|
+
def to_xml(node, indent=nil, *args)
|
25
25
|
s = ""
|
26
|
-
b = Builder::XmlMarkup.new(target: s)
|
26
|
+
b = Builder::XmlMarkup.new(target: s, indent: indent)
|
27
27
|
node.to_xml(b, *args)
|
28
28
|
s
|
29
29
|
end
|
@@ -195,6 +195,50 @@ EOS
|
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
|
+
#-------------------------------------------------------------------------------
|
199
|
+
# Remarks
|
200
|
+
|
201
|
+
describe 'remark' do
|
202
|
+
it 'should handle basic remarks' do
|
203
|
+
should_parse :remark, <<EOS
|
204
|
+
[Section 2 amended by Act 23 of 2004]
|
205
|
+
EOS
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should handle a remark' do
|
209
|
+
node = parse :remark, <<EOS
|
210
|
+
[Section 2 amended by Act 23 of 2004]
|
211
|
+
EOS
|
212
|
+
node.content.text_value.should == "Section 2 amended by Act 23 of 2004"
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'should handle a remark in a section' do
|
216
|
+
node = parse :section, <<EOS
|
217
|
+
1. Section title
|
218
|
+
Some text is a long line.
|
219
|
+
|
220
|
+
[Section 1 amended by Act 23 of 2004]
|
221
|
+
EOS
|
222
|
+
to_xml(node, 2).should == '<section id="section-1">
|
223
|
+
<num>1.</num>
|
224
|
+
<heading>Section title</heading>
|
225
|
+
<subsection id="section-1.subsection-0">
|
226
|
+
<content>
|
227
|
+
<p>Some text is a long line.</p>
|
228
|
+
</content>
|
229
|
+
</subsection>
|
230
|
+
<subsection id="section-1.subsection-1">
|
231
|
+
<content>
|
232
|
+
<p>
|
233
|
+
<remark status="editorial">[Section 1 amended by Act 23 of 2004]</remark>
|
234
|
+
</p>
|
235
|
+
</content>
|
236
|
+
</subsection>
|
237
|
+
</section>
|
238
|
+
'
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
198
242
|
#-------------------------------------------------------------------------------
|
199
243
|
# Numbered statements
|
200
244
|
|
@@ -399,13 +443,8 @@ Baz
|
|
399
443
|
Boom
|
400
444
|
EOS
|
401
445
|
|
402
|
-
s =
|
403
|
-
builder = ::Builder::XmlMarkup.new(indent: 2, target: s)
|
404
|
-
|
405
|
-
node.to_xml(builder)
|
406
|
-
|
446
|
+
s = to_xml(node, 2)
|
407
447
|
today = Time.now.strftime('%Y-%m-%d')
|
408
|
-
|
409
448
|
s.should == <<EOS
|
410
449
|
<components>
|
411
450
|
<component id="component-1">
|
@@ -497,13 +536,8 @@ Other than as is set out hereinbelow, no signs other than locality bound signs,
|
|
497
536
|
2. Bar
|
498
537
|
EOS
|
499
538
|
|
500
|
-
s =
|
501
|
-
builder = ::Builder::XmlMarkup.new(indent: 2, target: s)
|
502
|
-
|
503
|
-
node.to_xml(builder)
|
504
|
-
|
539
|
+
s = to_xml(node, 2)
|
505
540
|
today = Time.now.strftime('%Y-%m-%d')
|
506
|
-
|
507
541
|
s.should == <<EOS
|
508
542
|
<components>
|
509
543
|
<component id="component-1">
|
@@ -562,7 +596,7 @@ EOS
|
|
562
596
|
EOS
|
563
597
|
|
564
598
|
node.text_value.should == "{|\n| r1c1\n| r1c2\n|-\n| r2c1\n| r2c2\n|}\n"
|
565
|
-
to_xml(node, "prefix.").should == '<table id="prefix.table0"><tr><td><p>r1c1</p></td>
|
599
|
+
to_xml(node, nil, "prefix.").should == '<table id="prefix.table0"><tr><td><p>r1c1</p></td>
|
566
600
|
<td><p>r1c2</p></td></tr>
|
567
601
|
<tr><td><p>r2c1</p></td>
|
568
602
|
<td><p>r2c2</p></td></tr></table>'
|
@@ -605,8 +639,9 @@ Heres a table:
|
|
605
639
|
|}
|
606
640
|
EOS
|
607
641
|
|
608
|
-
xml = to_xml(node, "")
|
609
|
-
|
642
|
+
xml = to_xml(node, nil, "")
|
643
|
+
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>
|
610
645
|
<td><p>r1c2</p></td></tr>
|
611
646
|
<tr><td><p>r2c1</p></td>
|
612
647
|
<td><p>r2c2</p></td></tr></table></content></article></mainBody></doc>'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slaw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Kempe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|