fragjan primitive: check that a value read from one file equals a value read from another
  • Lua 88%
  • Makefile 12%
Find a file
2026-11-20 15:34:07 +01:00
.github feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
config feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
docs feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
test feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
.fragjan feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
.gitignore feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
.merkwerk feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
.version_history chore: merkwerk auto-update 2026-11-20 15:34:07 +01:00
init.lua feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
LICENSE feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
Makefile feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
README.md feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00
VERSION feat(primitive): add valueequals primitive v0.1.0 2026-11-20 15:33:59 +01:00

daw-modul-fragjan-check-valueequals

A fragjan primitive that checks that a value read from one file equals a value read from another.

The primitive compares a value taken from a file (the first capture of a Lua pattern) with a value taken from a second file (a pattern, or the whole content). It works on the project level and only reads files.

Status: Experimental · Lua: 5.1 / 5.4 · License: ISC

❤️ Contribute and support our work

What is daw-modul-fragjan-check-valueequals?

A check primitive for fragjan, the Dragons@Work code and project checker. A rule names the primitive, two files and one or two patterns. The check passes when both values are found and are equal, and fails when a value is missing or the values differ. If one of the files cannot be read the check is skipped.

What problem does it solve?

Some values must be kept in step by hand in two places, for example the version field in init.lua and the VERSION file of a Lua library. Nothing stops them from drifting apart until a consumer reads the wrong one. A rule built on this primitive reports the difference as soon as fragjan code runs.

Status

Experimental. Errors for invalid parameters are still returned as plain text (nil, "[ERROR] ..."); the migration to daw_error/v1 follows together with fragjan. Not yet published to the module registry.

Installation

Not yet published. Until then the module can be used from a checkout, see Development and Testing.

Usage

A rule that compares the version field of init.lua with the VERSION file:

schema: fragjan_rule/v1
rule_id: init-version-matches-version-file
enabled: true
when:
  target_type: project
check:
  primitive: daw.fragjan.check.valueequals
  file: init.lua
  pattern: 'version%s*=%s*"([^"]*)"'
  other_file: VERSION
result:
  severity: error
  message: "version in init.lua differs from VERSION in {dir}"

Parameters:

Parameter Required Meaning
file yes file A, relative to the project
pattern yes Lua pattern, the first capture is the value (without a capture: the whole match)
other_file yes file B, relative to the project
other_pattern no Lua pattern for file B; without it the whole content of file B, trimmed

Result: pass (equal), error (a value not found or the values differ), skip (a file is not readable). metrics.value and metrics.other_value carry the two values.

Documentation

Development and Testing

Lua 5.1 and 5.4. The tests use the shared test helper and daw.common.fs from daw-lua-common.

make test

Contributing

Bug reports, tests, feedback and contributions are welcome.

The primary development repository is on Forgejo: Development repository.

The GitHub repository is a public mirror for discoverability. Bug reports, questions, suggestions and other feedback through GitHub Issues are welcome and are handled there. There is no need to report again in the primary Forgejo repository.

Development planning and project coordination stay in the primary Forgejo repository. Contributions and pull requests are still submitted there.

Open Knowledge Needs People

We develop ideas, share knowledge and let open-source software and tools emerge. Projects like this one do not grow on their own — they live because people ask questions, experiment, share knowledge, find bugs and help make things better.

You can contribute in different ways:

  • report bugs
  • review code
  • test on other platforms
  • improve the documentation
  • translate content
  • or, if you like, support us financially

Every contribution helps us keep developing open knowledge and open-source software for the long term.

Contribute and support our work →

License

This project is licensed under the ISC License. See LICENSE.