From 71dd62cece2a31a1b91a7b994d5432fa30d4a6a8 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 13 Jan 2025 11:34:05 +0100 Subject: [PATCH] Sync fix-functions.md to MF release 6.2.0 Follows https://github.com/metafacture/metafacture-core/issues/580. Appears in https://metafacture.github.io/metafacture-documentation/docs/fix/Fix-functions.html. --- docs/fix/Fix-functions.md | 101 +++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 28 deletions(-) diff --git a/docs/fix/Fix-functions.md b/docs/fix/Fix-functions.md index d88c9b9..e5c2f91 100644 --- a/docs/fix/Fix-functions.md +++ b/docs/fix/Fix-functions.md @@ -8,7 +8,6 @@ nav_order: 2 This page is a replication of the passage [Functions](https://github.com/metafacture/metafacture-fix?tab=readme-ov-file#functions) of the Fix Readme.md. Status: [Fix Release 1.1.2](https://github.com/metafacture/metafacture-fix/releases/tag/1.1.2) ### Functions - #### Script-level functions ##### `include` @@ -29,6 +28,24 @@ include(""[, ...]) [Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+include+{") +##### `log` + +Sends a message to the logs. + +Parameters: + +- `logMessage` (required): Message to log. + +Options: + +- `level`: Log level to log at (one of `DEBUG`, `INFO`, `WARN` or `ERROR`). (Default: `INFO`) + +```perl +log(""[, level: ""]) +``` + +[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+log+{") + ##### `nothing` Does nothing. It is used for benchmarking in Catmandu. @@ -128,8 +145,37 @@ put_vars( [Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+put_vars+{") +##### `to_var` + +Defines a single global variable that can be referenced with `$[]` and assigns the value of the ``. + +```perl +to_var("", "") +``` + +Options: + +- `default`: Default value if source field does not exist. The option needs to be written in quotation marks because it is a reserved word in Java. (Default: Empty string) + +[Example in Playground](https://metafacture.org/playground/?example=to_var) + +[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+to_var+{") + #### Record-level functions +##### `add_array` + +Creates a new array (with optional values). + +```perl +add_array("") +add_array("", ""[, ...]) +``` + +[Example in Playground](https://metafacture.org/playground/?example=add_array) + +[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_array+{") + ##### `add_field` Creates a field with a defined value. @@ -142,6 +188,19 @@ add_field("", "") [Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_field+{") +##### `add_hash` + +Creates a new hash (with optional values). + +```perl +add_hash("") +add_hash("", "subfieldName": ""[, ...]) +``` + +[Example in Playground](https://metafacture.org/playground/?example=add_hash) + +[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_hash+{") + ##### `array` Converts a hash/object into an array. @@ -362,39 +421,21 @@ retain(""[, ...]) ##### `set_array` -Creates a new array (with optional values). +_Currently alias for [`add_array`](#add_array)._ -```perl -set_array("") -set_array("", ""[, ...]) -``` - -[Example in Playground](https://metafacture.org/playground/?example=set_array) - -[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_array+{") +We advise you to use [`add_array`](#add_array) instead of `set_array` due to changing behaviour in an upcoming release. For more information see: [#309](https://github.com/metafacture/metafacture-fix/issues/309) ##### `set_field` -Creates (or replaces) a field with a defined value. +_Currently alias for [`add_field`](#add_field)._ -```perl -set_field("", "") -``` - -[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_field+{") +We advise you to use [`add_field`](#add_field) instead of `set_field` due to changing behaviour in an upcoming release. For more information see: [#309](https://github.com/metafacture/metafacture-fix/issues/309) ##### `set_hash` -Creates a new hash (with optional values). +_Currently alias for [`add_hash`](#add_hash)._ -```perl -set_hash("") -set_hash("", "subfieldName": ""[, ...]) -``` - -[Example in Playground](https://metafacture.org/playground/?example=set_hash) - -[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_hash+{") +We advise you to use [`add_hash`](#add_hash) instead of `set_hash` due to changing behaviour in an upcoming release. For more information see: [#309](https://github.com/metafacture/metafacture-fix/issues/309) ##### `timestamp` @@ -567,7 +608,7 @@ Parameters: Options: -- `__default`: Default value to use for unknown values. (Default: Old value) +- `default`: Default value to use for unknown values. The option needs to be written in quotation marks because it is a reserved word in Java. (Default: Old value) - `delete`: Whether to delete unknown values. (Default: `false`) - `print_unknown`: Whether to print unknown values. (Default: `false`) @@ -609,7 +650,7 @@ put_rdfmap("path/to/file", "rdf-map", target: "") lookup("path.to.field", "rdf-map") # with default value -lookup("path.to.field", "map-name", __default: "NA") +lookup("path.to.field", "map-name", "default": "NA") # with printing unknown values to a file lookup("path.to.field", "map-name", print_unknown: "true", destination: "unknown.txt") @@ -724,8 +765,12 @@ to_json(""[, pretty: ""][, error_string: ""]) Replaces the value with its Base64 encoding. +Options: + +-`url_safe`: Perform URL-safe encoding (uses Base64URL format). (Default: `false`) + ```perl -to_base64("") +to_base64(""[, url_safe: ""]) ``` [Example in Playground](https://metafacture.org/playground/?example=to_base64)