Skip to content

Collects the result data of a run in one table. What you put in with `Data.set` is encoded as JSON when the run ends and stored with the run log, where the server shows it as the data of that run. The table is empty (`{}`) when nothing was set. Because the table is encoded like `Json.encode`, it may only hold strings, numbers, booleans and nested tables; a value JSON cannot hold makes the encoding fail.

  • Kind Library, a global in every script
  • Category APIs & Data
  • Functions 4

Functions

  • set self Sets run data.
  • clear self Removes all run data collected so far.
  • get table Returns the data table itself (not a copy), so changes to it change the run data.
  • json string Returns the run data encoded as pretty-printed JSON, the same text that is stored when the run ends.
Data.set(luaTable: table)→selfData.set(key: any, value: any)→self

Sets run data. With one argument, the given table replaces all data collected so far; the table is used as it is, not copied, so later changes to it are part of the data. With two arguments, one key is set; setting a key to `nil` removes it. With a single argument that is not a table the call throws.

Parameters

key any
Key, normally a string
value any
Value to store: string, number, boolean or table
luaTable table
Table that becomes the run data, replacing the current one

Returns

self chainable The library itself, so calls can be chained.

Example runs in CI

Data.set("status", "ok")
Data.set("count", 3)
print(Data.json())
Data.clear()→self

Removes all run data collected so far.

Returns

self chainable The library itself, so calls can be chained.
Data.get()→table

Returns the data table itself (not a copy), so changes to it change the run data.

Returns

table The current run data
Data.json()→string

Returns the run data encoded as pretty-printed JSON, the same text that is stored when the run ends. Throws for values JSON cannot hold, as `Json.encode` does.

Returns

string The run data as JSON text