@@ -170,6 +170,8 @@ Does nothing. It is used for benchmarking in Catmandu.
170
170
nothing()
171
171
```
172
172
173
+ [ Playground-Example] ( https://metafacture.org/playground/?example=nothing )
174
+
173
175
##### ` put_filemap `
174
176
175
177
Defines an external map for [ lookup] ( #lookup ) from a file or a URL. Maps with more than 2 columns are supported but are reduced to a defined key and a value column.
@@ -178,6 +180,8 @@ Defines an external map for [lookup](#lookup) from a file or a URL. Maps with mo
178
180
put_filemap(" <sourceFile>" , " <mapName>" , sep_char: " \t " )
179
181
```
180
182
183
+ [ Playground-Example] ( https://metafacture.org/playground/?example=put_filemap )
184
+
181
185
The separator (` sep_char ` ) will vary depending on the source file, e.g.:
182
186
183
187
| Type | Separator |
@@ -207,6 +211,8 @@ put_map("<mapName>",
207
211
)
208
212
```
209
213
214
+ [ Playground-Example] ( https://metafacture.org/playground/?example=put_map )
215
+
210
216
##### ` put_rdfmap `
211
217
212
218
Defines an external RDF map for lookup from a file or an HTTP(S) resource.
@@ -218,6 +224,8 @@ put_rdfmap("<rdfResource>", "<rdfMapName>", target: "<rdfProperty>")
218
224
put_rdfmap(" <rdfResource>" , " <rdfMapName>" , target: " <rdfProperty>" , select_language: " <rdfLanguageTag>" )
219
225
```
220
226
227
+ [ Playground-Example] ( https://metafacture.org/playground/?example=put_rdfmap )
228
+
221
229
##### ` put_var `
222
230
223
231
Defines a single global variable that can be referenced with ` $[<variableName>] ` .
@@ -226,6 +234,8 @@ Defines a single global variable that can be referenced with `$[<variableName>]`
226
234
put_var(" <variableName>" , " <variableValue>" )
227
235
```
228
236
237
+ [ Playground-Example] ( https://metafacture.org/playground/?example=put_var )
238
+
229
239
##### ` put_vars `
230
240
231
241
Defines multiple global variables that can be referenced with ` $[<variableName>] ` .
@@ -237,6 +247,8 @@ put_vars(
237
247
)
238
248
```
239
249
250
+ [ Playground-Example] ( https://metafacture.org/playground/?example=put_vars )
251
+
240
252
#### Record-level functions
241
253
242
254
##### ` add_field `
@@ -247,6 +259,8 @@ Creates a field with a defined value.
247
259
add_field(" <targetFieldName>" , " <fieldValue>" )
248
260
```
249
261
262
+ [ Playground-Example] ( https://metafacture.org/playground/?example=add+field )
263
+
250
264
##### ` array `
251
265
252
266
Converts a hash/object into an array.
281
295
call_macro(" <macroName>" [, <dynamicLocalVariables>...])
282
296
```
283
297
298
+ [ Playground-Example] ( https://metafacture.org/playground/?example=call+macro )
299
+
284
300
##### ` copy_field `
285
301
286
302
Copies a field from an existing field.
@@ -289,6 +305,9 @@ Copies a field from an existing field.
289
305
copy_field(" <sourceField>" , " <targetField>" )
290
306
```
291
307
308
+ [ Playground-Example] ( https://metafacture.org/playground/?example=copy+field )
309
+
310
+
292
311
##### ` format `
293
312
294
313
Replaces the value with a formatted (` sprintf ` -like) version.
@@ -321,6 +340,9 @@ Moves a field from an existing field. Can be used to rename a field.
321
340
move_field(" <sourceField>" , " <targetField>" )
322
341
```
323
342
343
+ [ Playground-Example] ( https://metafacture.org/playground/?example=move+field )
344
+
345
+
324
346
##### ` parse_text `
325
347
326
348
Parses a text into an array or hash of values.
@@ -352,6 +374,8 @@ paste("my.string", "~Hi", "a", "~how are you?")
352
374
# "my.string": "Hi eeny how are you?"
353
375
```
354
376
377
+ [ Playground-Example] ( https://metafacture.org/playground/?example=paste )
378
+
355
379
##### ` print_record `
356
380
357
381
Prints the current record as JSON either to standard output or to a file.
@@ -401,6 +425,8 @@ Removes a field.
401
425
remove_field(" <sourceField>" )
402
426
```
403
427
428
+ [ Playground-Example] ( https://metafacture.org/playground/?example=remove+field )
429
+
404
430
##### ` rename `
405
431
406
432
Replaces a regular expression pattern in subfield names of a field. Does not change the name of the source field itself.
@@ -409,6 +435,8 @@ Replaces a regular expression pattern in subfield names of a field. Does not cha
409
435
rename (" <sourceField>" , " <regexp>" , " <replacement>" )
410
436
```
411
437
438
+ [ Playground-Example] ( https://metafacture.org/playground/?example=rename )
439
+
412
440
##### ` retain `
413
441
414
442
Deletes all fields except the ones listed (incl. subfields).
@@ -417,6 +445,8 @@ Deletes all fields except the ones listed (incl. subfields).
417
445
retain(" <sourceField_1>" [, ...])
418
446
```
419
447
448
+ [ Playground-Example] ( https://metafacture.org/playground/?example=retain )
449
+
420
450
##### ` set_array `
421
451
422
452
Creates a new array (with optional values).
@@ -426,6 +456,8 @@ set_array("<targetFieldName>")
426
456
set_array(" <targetFieldName>" , " <value_1>" [, ...])
427
457
```
428
458
459
+ [ Playground-Example] ( https://metafacture.org/playground/?example=set+array )
460
+
429
461
##### ` set_field `
430
462
431
463
Creates (or replaces) a field with a defined value.
@@ -465,6 +497,8 @@ Deletes empty fields, arrays and objects.
465
497
vacuum()
466
498
```
467
499
500
+ [ Playground-Example] ( https://metafacture.org/playground/?example=vacuum )
501
+
468
502
#### Field-level functions
469
503
470
504
##### ` append `
@@ -475,6 +509,8 @@ Adds a string at the end of a field value.
475
509
append(" <sourceField>" , " <appendString>" )
476
510
```
477
511
512
+ [ Playground-Example] ( https://metafacture.org/playground/?example=append )
513
+
478
514
##### ` capitalize `
479
515
480
516
Upcases the first character in a field value.
@@ -483,6 +519,8 @@ Upcases the first character in a field value.
483
519
capitalize(" <sourceField>" )
484
520
```
485
521
522
+ [ Playground-Example] ( https://metafacture.org/playground/?example=capitalize )
523
+
486
524
##### ` count `
487
525
488
526
Counts the number of elements in an array or a hash and replaces the field value with this number.
@@ -499,6 +537,8 @@ Downcases all characters in a field value.
499
537
downcase(" <sourceField>" )
500
538
```
501
539
540
+ [ Playground-Example] ( https://metafacture.org/playground/?example=downcase )
541
+
502
542
##### ` filter `
503
543
504
544
Only keeps field values that match the regular expression pattern. Works only with array of strings/repeated fields.
@@ -515,6 +555,8 @@ Flattens a nested array field.
515
555
flatten(" <sourceField>" )
516
556
```
517
557
558
+ [ Playground-Example] ( https://metafacture.org/playground/?example=flatten )
559
+
518
560
##### ` from_json `
519
561
520
562
Replaces the string with its JSON deserialization.
@@ -549,6 +591,8 @@ Options:
549
591
isbn(" <sourceField>" [, to: " <isbnFormat>" ][, verify_check_digit: " <boolean>" ][, error_string: " <errorValue>" ])
550
592
```
551
593
594
+ [ Playground-Example] ( https://metafacture.org/playground/?example=isbn )
595
+
552
596
##### ` join_field `
553
597
554
598
Joins an array of strings into a single string.
@@ -557,6 +601,8 @@ Joins an array of strings into a single string.
557
601
join_field(" <sourceField>" , " <separator>" )
558
602
```
559
603
604
+ [ Playground-Example] ( https://metafacture.org/playground/?example=join+field )
605
+
560
606
##### ` lookup `
561
607
562
608
Looks up matching values in a map and replaces the field value with this match. [ External files] ( #put_filemap ) , [ internal maps] ( #put_map ) as well as [ RDF resources] ( #put_rdfmap ) can be used.
@@ -624,6 +670,8 @@ Adds a string at the beginning of a field value.
624
670
prepend(" <sourceField>" , " <prependString>" )
625
671
```
626
672
673
+ [ Playground-Example] ( https://metafacture.org/playground/?example=prepend )
674
+
627
675
##### ` replace_all `
628
676
629
677
Replaces a regular expression pattern in field values with a replacement string. Regexp capturing is possible; refer to capturing groups by number (` $<number> ` ) or name (` ${<name>} ` ).
@@ -632,6 +680,8 @@ Replaces a regular expression pattern in field values with a replacement string.
632
680
replace_all(" <sourceField>" , " <regexp>" , " <replacement>" )
633
681
```
634
682
683
+ [ Playground-Example] ( https://metafacture.org/playground/?example=replace+all )
684
+
635
685
##### ` reverse `
636
686
637
687
Reverses the character order of a string or the element order of an array.
@@ -650,6 +700,8 @@ sort_field("<sourceField>", reverse: "true")
650
700
sort_field(" <sourceField>" , numeric: " true" )
651
701
```
652
702
703
+ [ Playground-Example] ( https://metafacture.org/playground/?example=sort+field )
704
+
653
705
##### ` split_field `
654
706
655
707
Splits a string into an array and replaces the field value with this array.
@@ -658,6 +710,8 @@ Splits a string into an array and replaces the field value with this array.
658
710
split_field(" <sourceField>" , " <separator>" )
659
711
```
660
712
713
+ [ Playground-Example] ( https://metafacture.org/playground/?example=split+field )
714
+
661
715
##### ` substring `
662
716
663
717
Replaces a string with its substring as defined by the start position (offset) and length.
@@ -695,6 +749,8 @@ Deletes whitespace at the beginning and the end of a field value.
695
749
trim(" <sourceField>" )
696
750
```
697
751
752
+ [ Playground-Example] ( https://metafacture.org/playground/?example=trim )
753
+
698
754
##### ` uniq `
699
755
700
756
Deletes duplicate values in an array.
@@ -703,6 +759,9 @@ Deletes duplicate values in an array.
703
759
uniq(" <sourceField>" )
704
760
```
705
761
762
+ [ Playground-Example] ( https://metafacture.org/playground/?example=uniq )
763
+
764
+
706
765
##### ` upcase `
707
766
708
767
Upcases all characters in a field value.
@@ -711,6 +770,8 @@ Upcases all characters in a field value.
711
770
upcase(" <sourceField>" )
712
771
```
713
772
773
+ [ Playground-Example] ( https://metafacture.org/playground/?example=upcase )
774
+
714
775
##### ` uri_encode `
715
776
716
777
Encodes a field value as URI. Aka percent-encoding.
@@ -742,6 +803,8 @@ if <condition>
742
803
end
743
804
```
744
805
806
+ [ Playground-Example] ( https://metafacture.org/playground/?example=reject )
807
+
745
808
### Binds
746
809
747
810
#### ` do list `
@@ -754,6 +817,8 @@ do list(path: "<sourceField>")
754
817
end
755
818
```
756
819
820
+ [ Playground-Example] ( https://metafacture.org/playground/?example=do+list )
821
+
757
822
Only the current element is accessible in this case (as the root element).
758
823
759
824
When specifying a variable name for the current element, the record remains accessible as the root element and the current element is accessible through the variable name:
@@ -764,6 +829,8 @@ do list(path: "<sourceField>", "var": "<variableName>")
764
829
end
765
830
```
766
831
832
+ [ Playground-Example] ( https://metafacture.org/playground/?example=do+list+with+var )
833
+
767
834
#### ` do list_as `
768
835
769
836
Iterates over each _ named_ element of an array (like [ ` do list ` ] ( #do-list ) with a variable name). If multiple arrays are given, iterates over the _ corresponding_ elements from each array (i.e., all elements with the same array index, skipping elements whose arrays have already been exhausted).
@@ -797,6 +864,8 @@ do once()
797
864
end
798
865
```
799
866
867
+ [ Playground-Example] ( https://metafacture.org/playground/?example=do+once )
868
+
800
869
In order to execute multiple blocks only once, tag them with unique identifiers:
801
870
802
871
``` perl
833
902
call_macro(" <macroName>" [, <dynamicLocalVariables>...])
834
903
```
835
904
905
+ [ Playground-Example] ( https://metafacture.org/playground/?example=do+pu+macro )
906
+
836
907
### Conditionals
837
908
838
909
Conditionals start with ` if ` in case of affirming the condition or ` unless ` rejecting the condition.
0 commit comments