Class: TypstRails::Configuration
- Inherits:
-
Object
- Object
- TypstRails::Configuration
- Defined in:
- lib/typst_rails.rb
Overview
Configuration class for Typst rendering options.
This class holds configuration values that control how Typst documents are compiled and rendered. It provides validation to ensure configuration values are valid before use.
Instance Attribute Summary collapse
-
#backend ⇒ Symbol, TypstRails::Backends::Base
Which compilation backend to use.
-
#default_root_path ⇒ String?
Default root path for Typst template resolution.
-
#typst_executable_path ⇒ String
Path to the Typst executable (defaults to "typst" in PATH).
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Initializes a new Configuration with default values.
-
#validate! ⇒ true
Validates the configuration settings.
Constructor Details
#initialize ⇒ Configuration
Initializes a new Configuration with default values.
Default values:
typst_executable_path: "typst" (assumes typst is in PATH)default_root_path: nil (uses temporary directory)backend::auto(prefer thetypstgem, fall back to the CLI)
114 115 116 117 118 |
# File 'lib/typst_rails.rb', line 114 def initialize @typst_executable_path = "typst" @default_root_path = nil @backend = :auto end |
Instance Attribute Details
#backend ⇒ Symbol, TypstRails::Backends::Base
Returns Which compilation backend to use.
:auto (the default) prefers the typst gem when installed, otherwise falls
back to shelling out to the typst CLI. Set to :gem or :cli to force a
specific built-in backend, or assign a custom backend instance registered
via Backends::Registry.register.
98 99 100 |
# File 'lib/typst_rails.rb', line 98 def backend @backend end |
#default_root_path ⇒ String?
Returns Default root path for Typst template resolution.
91 92 93 |
# File 'lib/typst_rails.rb', line 91 def default_root_path @default_root_path end |
#typst_executable_path ⇒ String
Returns Path to the Typst executable (defaults to "typst" in PATH).
88 89 90 |
# File 'lib/typst_rails.rb', line 88 def typst_executable_path @typst_executable_path end |
Instance Method Details
#validate! ⇒ true
Validates the configuration settings.
Ensures that:
- typst_executable_path is a non-empty string
- default_root_path (if set) is a valid directory path
134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/typst_rails.rb', line 134 def validate! # rubocop:disable Naming/PredicateMethod -- bang method raises, doesn't predicate raise ArgumentError, "typst_executable_path must be a String" unless typst_executable_path.is_a?(String) raise ArgumentError, "typst_executable_path cannot be nil or empty" if typst_executable_path.empty? if default_root_path && !default_root_path.is_a?(String) raise ArgumentError, "default_root_path must be a String or nil" end true end |