Ruby library for generating DCAT-compliant metadata and FAIR test outputs following the FTR Vocabulary
FtrRuby provides two main classes for working with FAIR Tests in Ruby:
DCAT_Record– Creates rich DCAT metadata describing a FAIR Test (as adcat:DataService+ftr:Test)Output– Generates a standardized FAIR test execution result (as aftr:TestResultwith provenance)
The library uses the TripleEasy mixin for easy RDF triple creation and produces graphs compatible with DCAT, DQV, PROV, and the FAIR Test Registry (FTR) vocabulary.
- Full DCAT 2 metadata generation for FAIR Tests
- Standardized test result output with provenance (
prov:wasGeneratedBy,ftr:TestResult, etc.) - Automatic URL construction for test endpoints and identifiers
- Support for contact points, indicators, metrics, themes, and guidance
- JSON-LD output for easy consumption by registries and portals
- Ready for use in FAIR assessment platforms, OSTrails, and EOSC services
If published as a gem:
gem 'ftr_ruby'Or install manually:
gem install ftr_rubyFor local development:
require_relative 'lib/ftr_ruby'require 'ftr_ruby'
meta = {
testid: "ftr-rda-f1-01m",
testname: "FAIR Test F1-01M: Globally Unique Persistent Identifier",
description: "This test checks whether a digital object is identified by a globally unique persistent identifier.",
keywords: ["FAIR", "F1", "persistent identifier", "PID"],
creator: "https://orcid.org/0000-0001-2345-6789",
indicators: ["https://w3id.org/ftr/indicator/F1-01M"],
metric: "https://w3id.org/ftr/metric/F1-01M",
license: "https://creativecommons.org/licenses/by/4.0/",
testversion: "1.0.0",
protocol: "https",
host: "tests.ostrails.eu",
basePath: "api",
individuals: [{ "name" => "Mark Wilkinson", "email" => "mark.wilkinson@upm.es" }],
organizations: [{ "name" => "CBGP", "url" => "https://www.cbgp.upm.es" }]
}
record = FtrRuby::DCAT_Record.new(meta: meta)
graph = record.get_dcat
puts graph.dump(:turtle)require 'ftr_ruby'
# Meta comes from the same test definition used for DCAT_Record
meta = { ... } # same hash as above
output = FtrRuby::Output.new(
testedGUID: "https://doi.org/10.1234/example.dataset",
meta: meta
)
# Add test results and comments
output.score = "pass"
output.comments << "The resource has a valid persistent identifier."
output.comments << "Identifier resolves correctly."
# Optional: add guidance for non-passing cases
output.guidance = [
["https://example.org/fix-pid", "Register a persistent identifier"],
]
jsonld = output.createEvaluationResponse
puts jsonldCreates metadata describing the test itself.
- Builds a
dcat:DataService+ftr:Test - Automatically constructs endpoint URLs, landing pages, and identifiers
- Includes indicators, metrics, themes, license, contact points, etc.
See the class for full list of supported metadata fields.
Represents the result of executing a FAIR test against a specific resource.
- Produces a
ftr:TestResultlinked to aftr:TestExecutionActivity - Includes score, summary, log/comments, guidance suggestions, and provenance
- Outputs as JSON-LD (with configurable prefixes)
- Automatically handles assessment target (the tested GUID)
Key methods:
new(testedGUID:, meta:)– Initialize with the tested resource and test metadatacreateEvaluationResponse– Returns JSON-LD string of the full evaluation graph
- DCAT – Data Catalog Vocabulary (W3C)
- DQV – Data Quality Vocabulary
- PROV – Provenance Ontology
- FTR – FAIR Test Registry vocabulary (
https://w3id.org/ftr#) - SIO – Semanticscience Integrated Ontology
- vCard – Contact points
- Schema.org
ftr_ruby/
├── lib/
│ └── ftr_ruby.rb
├── lib/ftr_ruby/
│ ├── dcat_record.rb
│ └── output.rb
└── README.md
Bug reports and pull requests are welcome on GitHub at: https://github.com/markwilkinson/ftr_ruby
This project is licensed under the MIT License (or specify your license).
Developed in the context of the OSTrails project and the FAIR Champion initiative.
This project has received funding from the European Union’s Horizon Europe framework programme under grant agreement No. 101130187. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Executive Agency. Neither the European Union nor the European Research Executive Agency can be held responsible for them.
Made with ❤️ for the FAIR community