slaw 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/slaw/version.rb +1 -1
- data/lib/slaw/za/act.treetop +7 -15
- data/lib/slaw/za/act_nodes.rb +19 -12
- data/spec/za/act_spec.rb +138 -18
- 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: ab4d37da9ebc5aadc6da5bb3b14a9d786541b187
|
4
|
+
data.tar.gz: 3fdf535965572c529ceaa60bcfa8e95ff3ba76bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b08087358bb70d8b17c276fed6501d5ddc67fe84114d5b066409fcd9825a81312dfbac68ec4add9f4481e9e3c44864beebf58a20cdb455d6134fb7751aab07d
|
7
|
+
data.tar.gz: d8a2983bb30778dbfee1d07822552d7efa9a0207ed30e2f1b10f7f52de671d3684dbc1a7adc82da9229e0f05f52300c5f1e151612459e40efe8df094d0c8eff7
|
data/README.md
CHANGED
@@ -216,6 +216,10 @@ Akoma Ntoso `component` elements at the end of the XML document, with a name of
|
|
216
216
|
|
217
217
|
## Changelog
|
218
218
|
|
219
|
+
### 0.8.1
|
220
|
+
|
221
|
+
* Schedules can have both a title and a heading, permitting schedules titled "First Schedule" and not just "Schedule 1"
|
222
|
+
|
219
223
|
### 0.8.0
|
220
224
|
|
221
225
|
* FEATURE: parse command only reformats input for PDFs or when --reformat is given
|
data/lib/slaw/version.rb
CHANGED
data/lib/slaw/za/act.treetop
CHANGED
@@ -65,7 +65,7 @@ module Slaw
|
|
65
65
|
end
|
66
66
|
|
67
67
|
rule schedule
|
68
|
-
|
68
|
+
schedule_title
|
69
69
|
body
|
70
70
|
<Schedule>
|
71
71
|
end
|
@@ -135,18 +135,10 @@ module Slaw
|
|
135
135
|
space !numbered_statement_prefix content eol
|
136
136
|
end
|
137
137
|
|
138
|
-
rule
|
139
|
-
space?
|
140
|
-
|
138
|
+
rule schedule_title
|
139
|
+
space? schedule_title_prefix space? "\""? num:alphanums? "\""? [ \t:-]* title:(content)?
|
140
|
+
heading:(newline space? content)?
|
141
141
|
eol
|
142
|
-
schedule_title:schedule_title_content?
|
143
|
-
end
|
144
|
-
|
145
|
-
rule schedule_title_content
|
146
|
-
space? content eol
|
147
|
-
|
148
|
-
# if a schedule title ends in a non-character or it's really long, it's probably content
|
149
|
-
!{ |s| s[1].text_value[-1] =~ /[^a-zA-z]/ or s[1].text_value.length > 100 }
|
150
142
|
end
|
151
143
|
|
152
144
|
##########
|
@@ -157,12 +149,12 @@ module Slaw
|
|
157
149
|
end
|
158
150
|
|
159
151
|
rule naked_statement
|
160
|
-
space? !(chapter_heading / part_heading / section_title /
|
152
|
+
space? !(chapter_heading / part_heading / section_title / schedule_title) clauses eol
|
161
153
|
<NakedStatement>
|
162
154
|
end
|
163
155
|
|
164
156
|
rule schedule_statement
|
165
|
-
space? (!
|
157
|
+
space? (!schedule_title) clauses eol
|
166
158
|
<ScheduleStatement>
|
167
159
|
end
|
168
160
|
|
@@ -204,7 +196,7 @@ module Slaw
|
|
204
196
|
'chapter'i space alphanums [ :-]*
|
205
197
|
end
|
206
198
|
|
207
|
-
rule
|
199
|
+
rule schedule_title_prefix
|
208
200
|
'schedule'i 's'i?
|
209
201
|
end
|
210
202
|
|
data/lib/slaw/za/act_nodes.rb
CHANGED
@@ -407,12 +407,14 @@ module Slaw
|
|
407
407
|
|
408
408
|
class Schedule < Treetop::Runtime::SyntaxNode
|
409
409
|
def num
|
410
|
-
n =
|
410
|
+
n = schedule_title.num.text_value
|
411
411
|
return (n && !n.empty?) ? n : nil
|
412
412
|
end
|
413
413
|
|
414
414
|
def alias
|
415
|
-
if
|
415
|
+
if not schedule_title.title.text_value.blank?
|
416
|
+
schedule_title.title.text_value
|
417
|
+
elsif num
|
416
418
|
"Schedule #{num}"
|
417
419
|
else
|
418
420
|
"Schedule"
|
@@ -420,26 +422,31 @@ module Slaw
|
|
420
422
|
end
|
421
423
|
|
422
424
|
def heading
|
423
|
-
if
|
424
|
-
|
425
|
+
if schedule_title.heading.respond_to? :content
|
426
|
+
schedule_title.heading.content.text_value
|
425
427
|
else
|
426
428
|
nil
|
427
429
|
end
|
428
430
|
end
|
429
431
|
|
430
432
|
def to_xml(b, idprefix=nil, i=1)
|
431
|
-
|
433
|
+
if num
|
434
|
+
n = num
|
435
|
+
component = "schedule#{n}"
|
436
|
+
else
|
437
|
+
n = i
|
438
|
+
# make a component name from the schedule title
|
439
|
+
component = self.alias.downcase().strip().gsub(/[^a-z0-9]/i, '').gsub(/ +/, '')
|
440
|
+
end
|
432
441
|
|
433
|
-
#
|
434
|
-
comp = "schedule#{n}"
|
435
|
-
id = "#{idprefix}schedule-#{n}"
|
442
|
+
id = "#{idprefix}#{component}"
|
436
443
|
|
437
444
|
b.component(id: "component-#{id}") { |b|
|
438
|
-
b.doc_(name:
|
445
|
+
b.doc_(name: component) { |b|
|
439
446
|
b.meta { |b|
|
440
447
|
b.identification(source: "#slaw") { |b|
|
441
448
|
b.FRBRWork { |b|
|
442
|
-
b.FRBRthis(value: "#{Act::WORK_URI}/#{
|
449
|
+
b.FRBRthis(value: "#{Act::WORK_URI}/#{component}")
|
443
450
|
b.FRBRuri(value: Act::WORK_URI)
|
444
451
|
b.FRBRalias(value: self.alias)
|
445
452
|
b.FRBRdate(date: '1980-01-01', name: 'Generation')
|
@@ -447,14 +454,14 @@ module Slaw
|
|
447
454
|
b.FRBRcountry(value: 'za')
|
448
455
|
}
|
449
456
|
b.FRBRExpression { |b|
|
450
|
-
b.FRBRthis(value: "#{Act::EXPRESSION_URI}/#{
|
457
|
+
b.FRBRthis(value: "#{Act::EXPRESSION_URI}/#{component}")
|
451
458
|
b.FRBRuri(value: Act::EXPRESSION_URI)
|
452
459
|
b.FRBRdate(date: '1980-01-01', name: 'Generation')
|
453
460
|
b.FRBRauthor(href: '#council')
|
454
461
|
b.FRBRlanguage(language: 'eng')
|
455
462
|
}
|
456
463
|
b.FRBRManifestation { |b|
|
457
|
-
b.FRBRthis(value: "#{Act::MANIFESTATION_URI}/#{
|
464
|
+
b.FRBRthis(value: "#{Act::MANIFESTATION_URI}/#{component}")
|
458
465
|
b.FRBRuri(value: Act::MANIFESTATION_URI)
|
459
466
|
b.FRBRdate(date: Time.now.strftime('%Y-%m-%d'), name: 'Generation')
|
460
467
|
b.FRBRauthor(href: '#slaw')
|
data/spec/za/act_spec.rb
CHANGED
@@ -683,7 +683,7 @@ EOS
|
|
683
683
|
EOS
|
684
684
|
|
685
685
|
today = Time.now.strftime('%Y-%m-%d')
|
686
|
-
to_xml(node, "").should == '<component id="component-
|
686
|
+
to_xml(node, "").should == '<component id="component-schedule1">
|
687
687
|
<doc name="schedule1">
|
688
688
|
<meta>
|
689
689
|
<identification source="#slaw">
|
@@ -711,7 +711,7 @@ EOS
|
|
711
711
|
</identification>
|
712
712
|
</meta>
|
713
713
|
<mainBody>
|
714
|
-
<article id="
|
714
|
+
<article id="schedule1">
|
715
715
|
<heading>A Title</heading>
|
716
716
|
<paragraph id="paragraph-0">
|
717
717
|
<content>
|
@@ -1071,18 +1071,19 @@ EOS
|
|
1071
1071
|
it 'should handle a simple schedule' do
|
1072
1072
|
node = parse :schedules, <<EOS
|
1073
1073
|
Schedule
|
1074
|
+
|
1074
1075
|
Subject to approval in terms of this By-Law, the erection:
|
1075
1076
|
1. Foo
|
1076
1077
|
2. Bar
|
1077
1078
|
EOS
|
1078
1079
|
s = to_xml(node)
|
1079
1080
|
today = Time.now.strftime('%Y-%m-%d')
|
1080
|
-
s.should == '<component id="component-schedule
|
1081
|
-
<doc name="
|
1081
|
+
s.should == '<component id="component-schedule">
|
1082
|
+
<doc name="schedule">
|
1082
1083
|
<meta>
|
1083
1084
|
<identification source="#slaw">
|
1084
1085
|
<FRBRWork>
|
1085
|
-
<FRBRthis value="/za/act/1980/01/
|
1086
|
+
<FRBRthis value="/za/act/1980/01/schedule"/>
|
1086
1087
|
<FRBRuri value="/za/act/1980/01"/>
|
1087
1088
|
<FRBRalias value="Schedule"/>
|
1088
1089
|
<FRBRdate date="1980-01-01" name="Generation"/>
|
@@ -1090,14 +1091,14 @@ EOS
|
|
1090
1091
|
<FRBRcountry value="za"/>
|
1091
1092
|
</FRBRWork>
|
1092
1093
|
<FRBRExpression>
|
1093
|
-
<FRBRthis value="/za/act/1980/01/eng@/
|
1094
|
+
<FRBRthis value="/za/act/1980/01/eng@/schedule"/>
|
1094
1095
|
<FRBRuri value="/za/act/1980/01/eng@"/>
|
1095
1096
|
<FRBRdate date="1980-01-01" name="Generation"/>
|
1096
1097
|
<FRBRauthor href="#council"/>
|
1097
1098
|
<FRBRlanguage language="eng"/>
|
1098
1099
|
</FRBRExpression>
|
1099
1100
|
<FRBRManifestation>
|
1100
|
-
<FRBRthis value="/za/act/1980/01/eng@/
|
1101
|
+
<FRBRthis value="/za/act/1980/01/eng@/schedule"/>
|
1101
1102
|
<FRBRuri value="/za/act/1980/01/eng@"/>
|
1102
1103
|
<FRBRdate date="' + today + '" name="Generation"/>
|
1103
1104
|
<FRBRauthor href="#slaw"/>
|
@@ -1105,7 +1106,7 @@ EOS
|
|
1105
1106
|
</identification>
|
1106
1107
|
</meta>
|
1107
1108
|
<mainBody>
|
1108
|
-
<article id="schedule
|
1109
|
+
<article id="schedule">
|
1109
1110
|
<paragraph id="paragraph-0">
|
1110
1111
|
<content>
|
1111
1112
|
<p>Subject to approval in terms of this By-Law, the erection:</p>
|
@@ -1141,7 +1142,7 @@ EOS
|
|
1141
1142
|
today = Time.now.strftime('%Y-%m-%d')
|
1142
1143
|
s.should == <<EOS
|
1143
1144
|
<components>
|
1144
|
-
<component id="component-
|
1145
|
+
<component id="component-schedule2">
|
1145
1146
|
<doc name="schedule2">
|
1146
1147
|
<meta>
|
1147
1148
|
<identification source="#slaw">
|
@@ -1169,7 +1170,7 @@ EOS
|
|
1169
1170
|
</identification>
|
1170
1171
|
</meta>
|
1171
1172
|
<mainBody>
|
1172
|
-
<article id="
|
1173
|
+
<article id="schedule2">
|
1173
1174
|
<heading>A Title</heading>
|
1174
1175
|
<section id="section-1">
|
1175
1176
|
<num>1.</num>
|
@@ -1183,7 +1184,7 @@ EOS
|
|
1183
1184
|
</mainBody>
|
1184
1185
|
</doc>
|
1185
1186
|
</component>
|
1186
|
-
<component id="component-
|
1187
|
+
<component id="component-schedule3">
|
1187
1188
|
<doc name="schedule3">
|
1188
1189
|
<meta>
|
1189
1190
|
<identification source="#slaw">
|
@@ -1211,7 +1212,7 @@ EOS
|
|
1211
1212
|
</identification>
|
1212
1213
|
</meta>
|
1213
1214
|
<mainBody>
|
1214
|
-
<article id="
|
1215
|
+
<article id="schedule3">
|
1215
1216
|
<heading>Another Title</heading>
|
1216
1217
|
<paragraph id="paragraph-0">
|
1217
1218
|
<content>
|
@@ -1229,9 +1230,128 @@ EOS
|
|
1229
1230
|
|
1230
1231
|
end
|
1231
1232
|
|
1233
|
+
it 'should handle a schedule with a title and a number' do
|
1234
|
+
node = parse :schedules, <<EOS
|
1235
|
+
Schedule 1 - First Schedule
|
1236
|
+
Schedule Heading
|
1237
|
+
|
1238
|
+
Subject to approval in terms of this By-Law, the erection:
|
1239
|
+
1. Foo
|
1240
|
+
2. Bar
|
1241
|
+
EOS
|
1242
|
+
s = to_xml(node)
|
1243
|
+
today = Time.now.strftime('%Y-%m-%d')
|
1244
|
+
s.should == '<component id="component-schedule1">
|
1245
|
+
<doc name="schedule1">
|
1246
|
+
<meta>
|
1247
|
+
<identification source="#slaw">
|
1248
|
+
<FRBRWork>
|
1249
|
+
<FRBRthis value="/za/act/1980/01/schedule1"/>
|
1250
|
+
<FRBRuri value="/za/act/1980/01"/>
|
1251
|
+
<FRBRalias value="First Schedule"/>
|
1252
|
+
<FRBRdate date="1980-01-01" name="Generation"/>
|
1253
|
+
<FRBRauthor href="#council"/>
|
1254
|
+
<FRBRcountry value="za"/>
|
1255
|
+
</FRBRWork>
|
1256
|
+
<FRBRExpression>
|
1257
|
+
<FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
|
1258
|
+
<FRBRuri value="/za/act/1980/01/eng@"/>
|
1259
|
+
<FRBRdate date="1980-01-01" name="Generation"/>
|
1260
|
+
<FRBRauthor href="#council"/>
|
1261
|
+
<FRBRlanguage language="eng"/>
|
1262
|
+
</FRBRExpression>
|
1263
|
+
<FRBRManifestation>
|
1264
|
+
<FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
|
1265
|
+
<FRBRuri value="/za/act/1980/01/eng@"/>
|
1266
|
+
<FRBRdate date="' + today + '" name="Generation"/>
|
1267
|
+
<FRBRauthor href="#slaw"/>
|
1268
|
+
</FRBRManifestation>
|
1269
|
+
</identification>
|
1270
|
+
</meta>
|
1271
|
+
<mainBody>
|
1272
|
+
<article id="schedule1">
|
1273
|
+
<heading>Schedule Heading</heading>
|
1274
|
+
<paragraph id="paragraph-0">
|
1275
|
+
<content>
|
1276
|
+
<p>Subject to approval in terms of this By-Law, the erection:</p>
|
1277
|
+
</content>
|
1278
|
+
</paragraph>
|
1279
|
+
<section id="section-1">
|
1280
|
+
<num>1.</num>
|
1281
|
+
<heading>Foo</heading>
|
1282
|
+
</section>
|
1283
|
+
<section id="section-2">
|
1284
|
+
<num>2.</num>
|
1285
|
+
<heading>Bar</heading>
|
1286
|
+
</section>
|
1287
|
+
</article>
|
1288
|
+
</mainBody>
|
1289
|
+
</doc>
|
1290
|
+
</component>'
|
1291
|
+
end
|
1292
|
+
|
1293
|
+
it 'should handle a schedule with a title' do
|
1294
|
+
node = parse :schedules, <<EOS
|
1295
|
+
Schedule - First Schedule
|
1296
|
+
|
1297
|
+
Subject to approval in terms of this By-Law, the erection:
|
1298
|
+
1. Foo
|
1299
|
+
2. Bar
|
1300
|
+
EOS
|
1301
|
+
s = to_xml(node)
|
1302
|
+
today = Time.now.strftime('%Y-%m-%d')
|
1303
|
+
s.should == '<component id="component-firstschedule">
|
1304
|
+
<doc name="firstschedule">
|
1305
|
+
<meta>
|
1306
|
+
<identification source="#slaw">
|
1307
|
+
<FRBRWork>
|
1308
|
+
<FRBRthis value="/za/act/1980/01/firstschedule"/>
|
1309
|
+
<FRBRuri value="/za/act/1980/01"/>
|
1310
|
+
<FRBRalias value="First Schedule"/>
|
1311
|
+
<FRBRdate date="1980-01-01" name="Generation"/>
|
1312
|
+
<FRBRauthor href="#council"/>
|
1313
|
+
<FRBRcountry value="za"/>
|
1314
|
+
</FRBRWork>
|
1315
|
+
<FRBRExpression>
|
1316
|
+
<FRBRthis value="/za/act/1980/01/eng@/firstschedule"/>
|
1317
|
+
<FRBRuri value="/za/act/1980/01/eng@"/>
|
1318
|
+
<FRBRdate date="1980-01-01" name="Generation"/>
|
1319
|
+
<FRBRauthor href="#council"/>
|
1320
|
+
<FRBRlanguage language="eng"/>
|
1321
|
+
</FRBRExpression>
|
1322
|
+
<FRBRManifestation>
|
1323
|
+
<FRBRthis value="/za/act/1980/01/eng@/firstschedule"/>
|
1324
|
+
<FRBRuri value="/za/act/1980/01/eng@"/>
|
1325
|
+
<FRBRdate date="' + today + '" name="Generation"/>
|
1326
|
+
<FRBRauthor href="#slaw"/>
|
1327
|
+
</FRBRManifestation>
|
1328
|
+
</identification>
|
1329
|
+
</meta>
|
1330
|
+
<mainBody>
|
1331
|
+
<article id="firstschedule">
|
1332
|
+
<paragraph id="paragraph-0">
|
1333
|
+
<content>
|
1334
|
+
<p>Subject to approval in terms of this By-Law, the erection:</p>
|
1335
|
+
</content>
|
1336
|
+
</paragraph>
|
1337
|
+
<section id="section-1">
|
1338
|
+
<num>1.</num>
|
1339
|
+
<heading>Foo</heading>
|
1340
|
+
</section>
|
1341
|
+
<section id="section-2">
|
1342
|
+
<num>2.</num>
|
1343
|
+
<heading>Bar</heading>
|
1344
|
+
</section>
|
1345
|
+
</article>
|
1346
|
+
</mainBody>
|
1347
|
+
</doc>
|
1348
|
+
</component>'
|
1349
|
+
end
|
1350
|
+
|
1232
1351
|
it 'should serialise a single schedule without a heading' do
|
1233
1352
|
node = parse :schedules, <<EOS
|
1234
1353
|
Schedule "1"
|
1354
|
+
|
1235
1355
|
Other than as is set out hereinbelow, no signs other than locality bound signs, temporary signs including loose portable sign, estate agents signs, newspaper headline posters and posters (the erection of which must comply with the appropriate schedules pertinent thereto) shall be erected on Municipal owned land.
|
1236
1356
|
1. Foo
|
1237
1357
|
2. Bar
|
@@ -1240,7 +1360,7 @@ EOS
|
|
1240
1360
|
s = to_xml(node)
|
1241
1361
|
today = Time.now.strftime('%Y-%m-%d')
|
1242
1362
|
s.should == <<EOS
|
1243
|
-
<component id="component-
|
1363
|
+
<component id="component-schedule1">
|
1244
1364
|
<doc name="schedule1">
|
1245
1365
|
<meta>
|
1246
1366
|
<identification source="#slaw">
|
@@ -1268,7 +1388,7 @@ EOS
|
|
1268
1388
|
</identification>
|
1269
1389
|
</meta>
|
1270
1390
|
<mainBody>
|
1271
|
-
<article id="
|
1391
|
+
<article id="schedule1">
|
1272
1392
|
<paragraph id="paragraph-0">
|
1273
1393
|
<content>
|
1274
1394
|
<p>Other than as is set out hereinbelow, no signs other than locality bound signs, temporary signs including loose portable sign, estate agents signs, newspaper headline posters and posters (the erection of which must comply with the appropriate schedules pertinent thereto) shall be erected on Municipal owned land.</p>
|
@@ -1309,7 +1429,7 @@ EOS
|
|
1309
1429
|
s = to_xml(node)
|
1310
1430
|
today = Time.now.strftime('%Y-%m-%d')
|
1311
1431
|
s.should == <<EOS
|
1312
|
-
<component id="component-
|
1432
|
+
<component id="component-schedule1">
|
1313
1433
|
<doc name="schedule1">
|
1314
1434
|
<meta>
|
1315
1435
|
<identification source="#slaw">
|
@@ -1337,7 +1457,7 @@ EOS
|
|
1337
1457
|
</identification>
|
1338
1458
|
</meta>
|
1339
1459
|
<mainBody>
|
1340
|
-
<article id="
|
1460
|
+
<article id="schedule1">
|
1341
1461
|
<heading>Forms</heading>
|
1342
1462
|
<part id="part-I">
|
1343
1463
|
<num>I</num>
|
@@ -1440,7 +1560,7 @@ EOS
|
|
1440
1560
|
|
1441
1561
|
xml = to_xml(node, "")
|
1442
1562
|
today = Time.now.strftime('%Y-%m-%d')
|
1443
|
-
xml.should == '<component id="component-
|
1563
|
+
xml.should == '<component id="component-schedule1">
|
1444
1564
|
<doc name="schedule1">
|
1445
1565
|
<meta>
|
1446
1566
|
<identification source="#slaw">
|
@@ -1468,7 +1588,7 @@ EOS
|
|
1468
1588
|
</identification>
|
1469
1589
|
</meta>
|
1470
1590
|
<mainBody>
|
1471
|
-
<article id="
|
1591
|
+
<article id="schedule1">
|
1472
1592
|
<paragraph id="paragraph-0">
|
1473
1593
|
<content>
|
1474
1594
|
<p>Heres a table:</p>
|
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.8.
|
4
|
+
version: 0.8.1
|
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-09-
|
11
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|