Class revisionator
The revisionator provides a standardized way of migrating configurations between revisions for instance, it will track what the currently applied revision number is, and when you tell tell it to migrate, it will apply every individual migration between the currently applied revision and the latest/current revision.
This should allow for more seamlessly moving from an older version of a package to a new one.
Info:
- Copyright: 2023
- License: MIT, see https://raw.githubusercontent.com/demonnic/MDK/main/src/scripts/LICENSE.lua
- Author: Damian Monogue
Methods
revisionator:new(options) | Creates a new revisionator |
revisionator:getAppliedPatch() | Get the currently applied revision from file |
revisionator:migrate() | go through all the patches in order and apply any which are still necessary |
revisionator:addPatch(func[, position]) | add a patch to the table of patches |
Methods
- revisionator:new(options) line 47
-
Creates a new revisionator
Parameters:
- options
table
the options to create the revisionator with.
option name description default name The name of the revisionator. This is absolutely required, as the name is used for tracking the currently applied patch level raises an error if not provided patches A table of patch functions. It is traversed using ipairs, so must be in the form of {function1, function2, function3} etc. If you do not provide it, you can add the patches by calling :addPatch for each patch in order. {}
- options
table
the options to create the revisionator with.
- revisionator:getAppliedPatch() line 65
-
Get the currently applied revision from file
Returns:
-
number
the revision number currently applied, or 0 if it can't read a current version
Or
- nil nil
- string error message
- revisionator:migrate() line 86
-
go through all the patches in order and apply any which are still necessary
Returns:
-
boolean
true if it successfully applied patches, false if it was already at the latest patch level
Or
- nil
- string error message
- revisionator:addPatch(func[, position]) line 111
-
add a patch to the table of patches
Parameters:
- func function the function to run as the patch
- position number which patch to insert it as? If not supplied, inserts it as the last patch. Which is usually what you want. (optional)