Module: Xolo::Server::Mixins::Changelog

Included in:
Title, Version
Defined in:
lib/xolo/server/mixins/changelog.rb

Overview

This is mixed in to Xolo::Server::Title and Xolo::Server::Version, for simplified access to a title's changelog

Each title has a changelog file that records changes to the title and its versions.

The changelog file is a 'jsonlines' file, which is a JSON file containing a single JSON object per line. See https://jsonlines.org/ for more info. The reason for using jsonlines is that it is easy to append to the file, rather than having to read the whole file into memory, parse it, add a new entry, and write it back.

In this case, each line is a JSON object (ruby Hash) representing a change or an action.

The keys in the hash are:

:time - the time the change was made
:admin - the admin who made the change
:host - the hostname or IP address of the admin
:version - the version number, or nil if the change is to the title
:attrib - the attribute name, or nil if the change is an action
:old - the original value, or nil if the change is an action
:new - the new value, or nil if the change is an action
:action - a description of the action, or nil if the change is to an attribute

The changelog file is stored in the title directory in a file named 'changelog.json'. The file exists for as long as the title exists. It is backed up when before every event logged to it, in the backup directory in the server's BACKUPS_DIR.

When a title is deleted, its changelog file is moved to a backup directory before the title directory is deleted, and will remain there until manually removed.

Constant Summary collapse

TITLE_CHANGELOG_FILENAME =

The change log filename

'changelog.jsonl'

Class Method Summary collapse