Ruby SDK
The Ruby SDK (secretspec) is a thin client over the secretspec-ffi C ABI,
loaded via the stdlib Fiddle
(dlopen, no native gem). Resolution happens in the Rust core, so the SDK
inherits every provider with no Ruby-side logic.
Quick start
Section titled “Quick start”require "secretspec"
resolved = Secretspec::SecretSpec.builder .with_provider("keyring://") .with_profile("production") .with_reason("boot web app") .load
puts resolved.provider, resolved.profiledb = resolved.secrets["DATABASE_URL"]puts db.get # the value, or the file path for as_path secretsresolved.set_as_env! # export everything into ENVA missing required secret raises Secretspec::MissingRequiredError; any other
failure raises Secretspec::Error (with a stable #kind).
Typed access (codegen)
Section titled “Typed access (codegen)”Generate typed classes with secretspec schema plus
quicktype, then build them from resolved.fields:
secretspec schema | quicktype -s schema --top-level SecretSpec --lang ruby -o secrets_gen.rbtyped = SecretSpec.from_dynamic!(resolved.fields) # typed, generatedputs typed.database_urlLibrary discovery
Section titled “Library discovery”The native library is found via the SECRETSPEC_FFI_LIB environment variable,
or a Cargo target directory found by searching up from the working directory.