Skip to content

Commit 71dd62c

Browse files
committed
1 parent e225a12 commit 71dd62c

File tree

1 file changed

+73
-28
lines changed

1 file changed

+73
-28
lines changed

docs/fix/Fix-functions.md

Lines changed: 73 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ nav_order: 2
88
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)
99

1010
### Functions
11-
1211
#### Script-level functions
1312

1413
##### `include`
@@ -29,6 +28,24 @@ include("<path>"[, <dynamicLocalVariables>...])
2928

3029
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+include+{")
3130

31+
##### `log`
32+
33+
Sends a message to the logs.
34+
35+
Parameters:
36+
37+
- `logMessage` (required): Message to log.
38+
39+
Options:
40+
41+
- `level`: Log level to log at (one of `DEBUG`, `INFO`, `WARN` or `ERROR`). (Default: `INFO`)
42+
43+
```perl
44+
log("<logMessage>"[, level: "<logLevel>"])
45+
```
46+
47+
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+log+{")
48+
3249
##### `nothing`
3350

3451
Does nothing. It is used for benchmarking in Catmandu.
@@ -128,8 +145,37 @@ put_vars(
128145

129146
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+put_vars+{")
130147

148+
##### `to_var`
149+
150+
Defines a single global variable that can be referenced with `$[<variableName>]` and assigns the value of the `<sourceField>`.
151+
152+
```perl
153+
to_var("<sourceField>", "<variableName>")
154+
```
155+
156+
Options:
157+
158+
- `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)
159+
160+
[Example in Playground](https://metafacture.org/playground/?example=to_var)
161+
162+
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+to_var+{")
163+
131164
#### Record-level functions
132165

166+
##### `add_array`
167+
168+
Creates a new array (with optional values).
169+
170+
```perl
171+
add_array("<targetFieldName>")
172+
add_array("<targetFieldName>", "<value_1>"[, ...])
173+
```
174+
175+
[Example in Playground](https://metafacture.org/playground/?example=add_array)
176+
177+
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_array+{")
178+
133179
##### `add_field`
134180

135181
Creates a field with a defined value.
@@ -142,6 +188,19 @@ add_field("<targetFieldName>", "<fieldValue>")
142188

143189
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_field+{")
144190

191+
##### `add_hash`
192+
193+
Creates a new hash (with optional values).
194+
195+
```perl
196+
add_hash("<targetFieldName>")
197+
add_hash("<targetFieldName>", "subfieldName": "<subfieldValue>"[, ...])
198+
```
199+
200+
[Example in Playground](https://metafacture.org/playground/?example=add_hash)
201+
202+
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_hash+{")
203+
145204
##### `array`
146205

147206
Converts a hash/object into an array.
@@ -362,39 +421,21 @@ retain("<sourceField_1>"[, ...])
362421

363422
##### `set_array`
364423

365-
Creates a new array (with optional values).
424+
_Currently alias for [`add_array`](#add_array)._
366425

367-
```perl
368-
set_array("<targetFieldName>")
369-
set_array("<targetFieldName>", "<value_1>"[, ...])
370-
```
371-
372-
[Example in Playground](https://metafacture.org/playground/?example=set_array)
373-
374-
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_array+{")
426+
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)
375427

376428
##### `set_field`
377429

378-
Creates (or replaces) a field with a defined value.
430+
_Currently alias for [`add_field`](#add_field)._
379431

380-
```perl
381-
set_field("<targetFieldName>", "<fieldValue>")
382-
```
383-
384-
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_field+{")
432+
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)
385433

386434
##### `set_hash`
387435

388-
Creates a new hash (with optional values).
436+
_Currently alias for [`add_hash`](#add_hash)._
389437

390-
```perl
391-
set_hash("<targetFieldName>")
392-
set_hash("<targetFieldName>", "subfieldName": "<subfieldValue>"[, ...])
393-
```
394-
395-
[Example in Playground](https://metafacture.org/playground/?example=set_hash)
396-
397-
[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_hash+{")
438+
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)
398439

399440
##### `timestamp`
400441

@@ -567,7 +608,7 @@ Parameters:
567608

568609
Options:
569610

570-
- `__default`: Default value to use for unknown values. (Default: Old value)
611+
- `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)
571612
- `delete`: Whether to delete unknown values. (Default: `false`)
572613
- `print_unknown`: Whether to print unknown values. (Default: `false`)
573614

@@ -609,7 +650,7 @@ put_rdfmap("path/to/file", "rdf-map", target: "<rdfProperty>")
609650
lookup("path.to.field", "rdf-map")
610651

611652
# with default value
612-
lookup("path.to.field", "map-name", __default: "NA")
653+
lookup("path.to.field", "map-name", "default": "NA")
613654

614655
# with printing unknown values to a file
615656
lookup("path.to.field", "map-name", print_unknown: "true", destination: "unknown.txt")
@@ -724,8 +765,12 @@ to_json("<sourceField>"[, pretty: "<boolean>"][, error_string: "<errorValue>"])
724765

725766
Replaces the value with its Base64 encoding.
726767

768+
Options:
769+
770+
-`url_safe`: Perform URL-safe encoding (uses Base64URL format). (Default: `false`)
771+
727772
```perl
728-
to_base64("<sourceField>")
773+
to_base64("<sourceField>"[, url_safe: "<boolean>"])
729774
```
730775

731776
[Example in Playground](https://metafacture.org/playground/?example=to_base64)

0 commit comments

Comments
 (0)